@byteplus/rtc 4.55.14 → 4.55.15

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.55.14
4
+ * version: 4.55.15
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:{};var r=function(e){return e&&e.Math==Math&&e},n=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof t&&t)||function(){return this}()||Function("return this")(),i=function(e){try{return!!e()}catch(t){return!0}},o=!i((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),a=o,s=Function.prototype,c=s.apply,u=s.call,d="object"==typeof Reflect&&Reflect.apply||(a?u.bind(c):function(){return u.apply(c,arguments)}),l=o,h=Function.prototype,p=h.call,v=l&&h.bind.bind(p,p),f=l?v:function(e){return function(){return p.apply(e,arguments)}},_=f,m=_({}.toString),y=_("".slice),g=function(e){return y(m(e),8,-1)},S=g,b=f,E=function(e){if("Function"===S(e))return b(e)},k="object"==typeof document&&document.all,T={all:k,IS_HTMLDDA:void 0===k&&void 0!==k},I=T.all,R=T.IS_HTMLDDA?function(e){return"function"==typeof e||e===I}:function(e){return"function"==typeof e},A={},w=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),C=o,x=Function.prototype.call,O=C?x.bind(x):function(){return x.apply(x,arguments)},M={},D={}.propertyIsEnumerable,P=Object.getOwnPropertyDescriptor,N=P&&!D.call({1:2},1);M.f=N?function(e){var t=P(this,e);return!!t&&t.enumerable}:D;var L,U,V=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},F=i,B=g,j=Object,H=E("".split),G=F((function(){return!j("z").propertyIsEnumerable(0)}))?function(e){return"String"==B(e)?H(e,""):j(e)}:j,z=function(e){return null==e},K=z,X=TypeError,W=function(e){if(K(e))throw X("Can't call method on "+e);return e},q=G,Y=W,J=function(e){return q(Y(e))},Q=R,Z=T.all,$=T.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:Q(e)||e===Z}:function(e){return"object"==typeof e?null!==e:Q(e)},ee={},te=ee,re=n,ne=R,ie=function(e){return ne(e)?e:void 0},oe=function(e,t){return arguments.length<2?ie(te[e])||ie(re[e]):te[e]&&te[e][t]||re[e]&&re[e][t]},ae=E({}.isPrototypeOf),se=oe("navigator","userAgent")||"",ce=n,ue=se,de=ce.process,le=ce.Deno,he=de&&de.versions||le&&le.version,pe=he&&he.v8;pe&&(U=(L=pe.split("."))[0]>0&&L[0]<4?1:+(L[0]+L[1])),!U&&ue&&(!(L=ue.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=ue.match(/Chrome\/(\d+)/))&&(U=+L[1]);var ve=U,fe=ve,_e=i,me=!!Object.getOwnPropertySymbols&&!_e((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&fe&&fe<41})),ye=me&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ge=oe,Se=R,be=ae,Ee=Object,ke=ye?function(e){return"symbol"==typeof e}:function(e){var t=ge("Symbol");return Se(t)&&be(t.prototype,Ee(e))},Te=String,Ie=function(e){try{return Te(e)}catch(t){return"Object"}},Re=R,Ae=Ie,we=TypeError,Ce=function(e){if(Re(e))return e;throw we(Ae(e)+" is not a function")},xe=Ce,Oe=z,Me=function(e,t){var r=e[t];return Oe(r)?void 0:xe(r)},De=O,Pe=R,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__",He=n[je]||Be(je,{}),Ge=He;(Ue.exports=function(e,t){return Ge[e]||(Ge[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.0",mode:"pure",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.0/LICENSE",source:"https://github.com/zloirock/core-js"});var ze=W,Ke=Object,Xe=function(e){return Ke(ze(e))},We=Xe,qe=E({}.hasOwnProperty),Ye=Object.hasOwn||function(e,t){return qe(We(e),t)},Je=E,Qe=0,Ze=Math.random(),$e=Je(1..toString),et=function(e){return"Symbol("+(void 0===e?"":e)+")_"+$e(++Qe+Ze,36)},tt=n,rt=Ue.exports,nt=Ye,it=et,ot=me,at=ye,st=rt("wks"),ct=tt.Symbol,ut=ct&&ct.for,dt=at?ct:ct&&ct.withoutSetter||it,lt=function(e){if(!nt(st,e)||!ot&&"string"!=typeof st[e]){var t="Symbol."+e;ot&&nt(ct,e)?st[e]=ct[e]:st[e]=at&&ut?ut(t):dt(t)}return st[e]},ht=O,pt=$,vt=ke,ft=Me,_t=function(e,t){var r,n;if("string"===t&&Pe(r=e.toString)&&!Ne(n=De(r,e)))return n;if(Pe(r=e.valueOf)&&!Ne(n=De(r,e)))return n;if("string"!==t&&Pe(r=e.toString)&&!Ne(n=De(r,e)))return n;throw Le("Can't convert object to primitive value")},mt=TypeError,yt=lt("toPrimitive"),gt=function(e,t){if(!pt(e)||vt(e))return e;var r,n=ft(e,yt);if(n){if(void 0===t&&(t="default"),r=ht(n,e,t),!pt(r)||vt(r))return r;throw mt("Can't convert object to primitive value")}return void 0===t&&(t="number"),_t(e,t)},St=ke,bt=function(e){var t=gt(e,"string");return St(t)?t:t+""},Et=$,kt=n.document,Tt=Et(kt)&&Et(kt.createElement),It=function(e){return Tt?kt.createElement(e):{}},Rt=It,At=!w&&!i((function(){return 7!=Object.defineProperty(Rt("div"),"a",{get:function(){return 7}}).a})),wt=w,Ct=O,xt=M,Ot=V,Mt=J,Dt=bt,Pt=Ye,Nt=At,Lt=Object.getOwnPropertyDescriptor;A.f=wt?Lt:function(e,t){if(e=Mt(e),t=Dt(t),Nt)try{return Lt(e,t)}catch(r){}if(Pt(e,t))return Ot(!Ct(xt.f,e,t),e[t])};var Ut=i,Vt=R,Ft=/#|\.prototype\./,Bt=function(e,t){var r=Ht[jt(e)];return r==zt||r!=Gt&&(Vt(t)?Ut(t):!!t)},jt=Bt.normalize=function(e){return String(e).replace(Ft,".").toLowerCase()},Ht=Bt.data={},Gt=Bt.NATIVE="N",zt=Bt.POLYFILL="P",Kt=Bt,Xt=Ce,Wt=o,qt=E(E.bind),Yt=function(e,t){return Xt(e),void 0===t?e:Wt?qt(e,t):function(){return e.apply(t,arguments)}},Jt={},Qt=w&&i((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Zt=$,$t=String,er=TypeError,tr=function(e){if(Zt(e))return e;throw er($t(e)+" is not an object")},rr=w,nr=At,ir=Qt,or=tr,ar=bt,sr=TypeError,cr=Object.defineProperty,ur=Object.getOwnPropertyDescriptor,dr="enumerable",lr="configurable",hr="writable";Jt.f=rr?ir?function(e,t,r){if(or(e),t=ar(t),or(r),"function"==typeof e&&"prototype"===t&&"value"in r&&hr in r&&!r.writable){var n=ur(e,t);n&&n.writable&&(e[t]=r.value,r={configurable:lr in r?r.configurable:n.configurable,enumerable:dr in r?r.enumerable:n.enumerable,writable:!1})}return cr(e,t,r)}:cr:function(e,t,r){if(or(e),t=ar(t),or(r),nr)try{return cr(e,t,r)}catch(n){}if("get"in r||"set"in r)throw sr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var pr=Jt,vr=V,fr=w?function(e,t,r){return pr.f(e,t,vr(1,r))}:function(e,t,r){return e[t]=r,e},_r=n,mr=d,yr=E,gr=R,Sr=A.f,br=Kt,Er=ee,kr=Yt,Tr=fr,Ir=Ye,Rr=function(e){var t=function(r,n,i){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,i)}return mr(e,this,arguments)};return t.prototype=e.prototype,t},Ar=function(e,t){var r,n,i,o,a,s,c,u,d=e.target,l=e.global,h=e.stat,p=e.proto,v=l?_r:h?_r[d]:(_r[d]||{}).prototype,f=l?Er:Er[d]||Tr(Er,d,{})[d],_=f.prototype;for(i in t)r=!br(l?i:d+(h?".":"#")+i,e.forced)&&v&&Ir(v,i),a=f[i],r&&(s=e.dontCallGetSet?(u=Sr(v,i))&&u.value:v[i]),o=r&&s?s:t[i],r&&typeof a==typeof o||(c=e.bind&&r?kr(o,_r):e.wrap&&r?Rr(o):p&&gr(o)?yr(o):o,(e.sham||o&&o.sham||a&&a.sham)&&Tr(c,"sham",!0),Tr(f,i,c),p&&(Ir(Er,n=d+"Prototype")||Tr(Er,n,{}),Tr(Er[n],i,o),e.real&&_&&!_[i]&&Tr(_,i,o)))},wr=Math.ceil,Cr=Math.floor,xr=Math.trunc||function(e){var t=+e;return(t>0?Cr:wr)(t)},Or=function(e){var t=+e;return t!=t||0===t?0:xr(t)},Mr=Or,Dr=Math.max,Pr=Math.min,Nr=function(e,t){var r=Mr(e);return r<0?Dr(r+t,0):Pr(r,t)},Lr=Or,Ur=Math.min,Vr=function(e){return e>0?Ur(Lr(e),9007199254740991):0},Fr=Vr,Br=function(e){return Fr(e.length)},jr=J,Hr=Nr,Gr=Br,zr=function(e){return function(t,r,n){var i,o=jr(t),a=Gr(o),s=Hr(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},Kr={includes:zr(!0),indexOf:zr(!1)},Xr={},Wr=Ye,qr=J,Yr=Kr.indexOf,Jr=Xr,Qr=E([].push),Zr=function(e,t){var r,n=qr(e),i=0,o=[];for(r in n)!Wr(Jr,r)&&Wr(n,r)&&Qr(o,r);for(;t.length>i;)Wr(n,r=t[i++])&&(~Yr(o,r)||Qr(o,r));return o},$r=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],en=Zr,tn=$r,rn=Object.keys||function(e){return en(e,tn)},nn=Xe,on=rn;Ar({target:"Object",stat:!0,forced:i((function(){on(1)}))},{keys:function(e){return on(nn(e))}});var an=ee.Object.keys,sn={};sn[lt("toStringTag")]="z";var cn="[object z]"===String(sn),un=cn,dn=R,ln=g,hn=lt("toStringTag"),pn=Object,vn="Arguments"==ln(function(){return arguments}()),fn=un?ln:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=pn(e),hn))?r:vn?ln(t):"Object"==(n=ln(t))&&dn(t.callee)?"Arguments":n},_n=fn,mn=String,yn=function(e){if("Symbol"===_n(e))throw TypeError("Cannot convert a Symbol value to a string");return mn(e)},gn={},Sn=w,bn=Qt,En=Jt,kn=tr,Tn=J,In=rn;gn.f=Sn&&!bn?Object.defineProperties:function(e,t){kn(e);for(var r,n=Tn(t),i=In(t),o=i.length,a=0;o>a;)En.f(e,r=i[a++],n[r]);return e};var Rn,An=oe("document","documentElement"),wn=Ue.exports,Cn=et,xn=wn("keys"),On=function(e){return xn[e]||(xn[e]=Cn(e))},Mn=tr,Dn=gn,Pn=$r,Nn=Xr,Ln=An,Un=It,Vn=On("IE_PROTO"),Fn=function(){},Bn=function(e){return"<script>"+e+"</"+"script>"},jn=function(e){e.write(Bn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Hn=function(){try{Rn=new ActiveXObject("htmlfile")}catch(n){}var e,t;Hn="undefined"!=typeof document?document.domain&&Rn?jn(Rn):((t=Un("iframe")).style.display="none",Ln.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Bn("document.F=Object")),e.close(),e.F):jn(Rn);for(var r=Pn.length;r--;)delete Hn.prototype[Pn[r]];return Hn()};Nn[Vn]=!0;var Gn=Object.create||function(e,t){var r;return null!==e?(Fn.prototype=Mn(e),r=new Fn,Fn.prototype=null,r[Vn]=e):r=Hn(),void 0===t?r:Dn.f(r,t)},zn={},Kn=Zr,Xn=$r.concat("length","prototype");zn.f=Object.getOwnPropertyNames||function(e){return Kn(e,Xn)};var Wn={},qn=bt,Yn=Jt,Jn=V,Qn=function(e,t,r){var n=qn(t);n in e?Yn.f(e,n,Jn(0,r)):e[n]=r},Zn=Nr,$n=Br,ei=Qn,ti=Array,ri=Math.max,ni=function(e,t,r){for(var n=$n(e),i=Zn(t,n),o=Zn(void 0===r?n:r,n),a=ti(ri(o-i,0)),s=0;i<o;i++,s++)ei(a,s,e[i]);return a.length=s,a},ii=g,oi=J,ai=zn.f,si=ni,ci="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Wn.f=function(e){return ci&&"Window"==ii(e)?function(e){try{return ai(e)}catch(t){return si(ci)}}(e):ai(oi(e))};var ui={};ui.f=Object.getOwnPropertySymbols;var di=fr,li=function(e,t,r,n){return n&&n.enumerable?e[t]=r:di(e,t,r),e},hi={},pi=lt;hi.f=pi;var vi,fi,_i,mi=ee,yi=Ye,gi=hi,Si=Jt.f,bi=function(e){var t=mi.Symbol||(mi.Symbol={});yi(t,e)||Si(t,e,{value:gi.f(e)})},Ei=O,ki=oe,Ti=lt,Ii=li,Ri=function(){var e=ki("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=Ti("toPrimitive");t&&!t[n]&&Ii(t,n,(function(e){return Ei(r,this)}),{arity:1})},Ai=fn,wi=cn?{}.toString:function(){return"[object "+Ai(this)+"]"},Ci=cn,xi=Jt.f,Oi=fr,Mi=Ye,Di=wi,Pi=lt("toStringTag"),Ni=function(e,t,r,n){if(e){var i=r?e:e.prototype;Mi(i,Pi)||xi(i,Pi,{configurable:!0,value:t}),n&&!Ci&&Oi(i,"toString",Di)}},Li=R,Ui=n.WeakMap,Vi=Li(Ui)&&/native code/.test(String(Ui)),Fi=Vi,Bi=n,ji=$,Hi=fr,Gi=Ye,zi=He,Ki=On,Xi=Xr,Wi="Object already initialized",qi=Bi.TypeError,Yi=Bi.WeakMap;if(Fi||zi.state){var Ji=zi.state||(zi.state=new Yi);Ji.get=Ji.get,Ji.has=Ji.has,Ji.set=Ji.set,vi=function(e,t){if(Ji.has(e))throw qi(Wi);return t.facade=e,Ji.set(e,t),t},fi=function(e){return Ji.get(e)||{}},_i=function(e){return Ji.has(e)}}else{var Qi=Ki("state");Xi[Qi]=!0,vi=function(e,t){if(Gi(e,Qi))throw qi(Wi);return t.facade=e,Hi(e,Qi,t),t},fi=function(e){return Gi(e,Qi)?e[Qi]:{}},_i=function(e){return Gi(e,Qi)}}var Zi={set:vi,get:fi,has:_i,enforce:function(e){return _i(e)?fi(e):vi(e,{})},getterFor:function(e){return function(t){var r;if(!ji(t)||(r=fi(t)).type!==e)throw qi("Incompatible receiver, "+e+" required");return r}}},$i=g,eo=Array.isArray||function(e){return"Array"==$i(e)},to=R,ro=He,no=E(Function.toString);to(ro.inspectSource)||(ro.inspectSource=function(e){return no(e)});var io=ro.inspectSource,oo=E,ao=i,so=R,co=fn,uo=io,lo=function(){},ho=[],po=oe("Reflect","construct"),vo=/^\s*(?:class|function)\b/,fo=oo(vo.exec),_o=!vo.exec(lo),mo=function(e){if(!so(e))return!1;try{return po(lo,ho,e),!0}catch(t){return!1}},yo=function(e){if(!so(e))return!1;switch(co(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return _o||!!fo(vo,uo(e))}catch(t){return!0}};yo.sham=!0;var go=!po||ao((function(){var e;return mo(mo.call)||!mo(Object)||!mo((function(){e=!0}))||e}))?yo:mo,So=eo,bo=go,Eo=$,ko=lt("species"),To=Array,Io=function(e){var t;return So(e)&&(t=e.constructor,(bo(t)&&(t===To||So(t.prototype))||Eo(t)&&null===(t=t[ko]))&&(t=void 0)),void 0===t?To:t},Ro=function(e,t){return new(Io(e))(0===t?0:t)},Ao=Yt,wo=G,Co=Xe,xo=Br,Oo=Ro,Mo=E([].push),Do=function(e){var t=1==e,r=2==e,n=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,d,l){for(var h,p,v=Co(c),f=wo(v),_=Ao(u,d),m=xo(f),y=0,g=l||Oo,S=t?g(c,m):r||a?g(c,0):void 0;m>y;y++)if((s||y in f)&&(p=_(h=f[y],y,v),e))if(t)S[y]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return y;case 2:Mo(S,h)}else switch(e){case 4:return!1;case 7:Mo(S,h)}return o?-1:n||i?i:S}},Po={forEach:Do(0),map:Do(1),filter:Do(2),some:Do(3),every:Do(4),find:Do(5),findIndex:Do(6),filterReject:Do(7)},No=Ar,Lo=n,Uo=O,Vo=E,Fo=w,Bo=me,jo=i,Ho=Ye,Go=ae,zo=tr,Ko=J,Xo=bt,Wo=yn,qo=V,Yo=Gn,Jo=rn,Qo=zn,Zo=Wn,$o=ui,ea=A,ta=Jt,ra=gn,na=M,ia=li,oa=Ue.exports,aa=Xr,sa=et,ca=lt,ua=hi,da=bi,la=Ri,ha=Ni,pa=Zi,va=Po.forEach,fa=On("hidden"),_a="Symbol",ma=pa.set,ya=pa.getterFor(_a),ga=Object.prototype,Sa=Lo.Symbol,ba=Sa&&Sa.prototype,Ea=Lo.TypeError,ka=Lo.QObject,Ta=ea.f,Ia=ta.f,Ra=Zo.f,Aa=na.f,wa=Vo([].push),Ca=oa("symbols"),xa=oa("op-symbols"),Oa=oa("wks"),Ma=!ka||!ka.prototype||!ka.prototype.findChild,Da=Fo&&jo((function(){return 7!=Yo(Ia({},"a",{get:function(){return Ia(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=Ta(ga,t);n&&delete ga[t],Ia(e,t,r),n&&e!==ga&&Ia(ga,t,n)}:Ia,Pa=function(e,t){var r=Ca[e]=Yo(ba);return ma(r,{type:_a,tag:e,description:t}),Fo||(r.description=t),r},Na=function(e,t,r){e===ga&&Na(xa,t,r),zo(e);var n=Xo(t);return zo(r),Ho(Ca,n)?(r.enumerable?(Ho(e,fa)&&e[fa][n]&&(e[fa][n]=!1),r=Yo(r,{enumerable:qo(0,!1)})):(Ho(e,fa)||Ia(e,fa,qo(1,{})),e[fa][n]=!0),Da(e,n,r)):Ia(e,n,r)},La=function(e,t){zo(e);var r=Ko(t),n=Jo(r).concat(Ba(r));return va(n,(function(t){Fo&&!Uo(Ua,r,t)||Na(e,t,r[t])})),e},Ua=function(e){var t=Xo(e),r=Uo(Aa,this,t);return!(this===ga&&Ho(Ca,t)&&!Ho(xa,t))&&(!(r||!Ho(this,t)||!Ho(Ca,t)||Ho(this,fa)&&this[fa][t])||r)},Va=function(e,t){var r=Ko(e),n=Xo(t);if(r!==ga||!Ho(Ca,n)||Ho(xa,n)){var i=Ta(r,n);return!i||!Ho(Ca,n)||Ho(r,fa)&&r[fa][n]||(i.enumerable=!0),i}},Fa=function(e){var t=Ra(Ko(e)),r=[];return va(t,(function(e){Ho(Ca,e)||Ho(aa,e)||wa(r,e)})),r},Ba=function(e){var t=e===ga,r=Ra(t?xa:Ko(e)),n=[];return va(r,(function(e){!Ho(Ca,e)||t&&!Ho(ga,e)||wa(n,Ca[e])})),n};Bo||(Sa=function(){if(Go(ba,this))throw Ea("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Wo(arguments[0]):void 0,t=sa(e),r=function(e){this===ga&&Uo(r,xa,e),Ho(this,fa)&&Ho(this[fa],t)&&(this[fa][t]=!1),Da(this,t,qo(1,e))};return Fo&&Ma&&Da(ga,t,{configurable:!0,set:r}),Pa(t,e)},ia(ba=Sa.prototype,"toString",(function(){return ya(this).tag})),ia(Sa,"withoutSetter",(function(e){return Pa(sa(e),e)})),na.f=Ua,ta.f=Na,ra.f=La,ea.f=Va,Qo.f=Zo.f=Fa,$o.f=Ba,ua.f=function(e){return Pa(ca(e),e)},Fo&&Ia(ba,"description",{configurable:!0,get:function(){return ya(this).description}})),No({global:!0,constructor:!0,wrap:!0,forced:!Bo,sham:!Bo},{Symbol:Sa}),va(Jo(Oa),(function(e){da(e)})),No({target:_a,stat:!0,forced:!Bo},{useSetter:function(){Ma=!0},useSimple:function(){Ma=!1}}),No({target:"Object",stat:!0,forced:!Bo,sham:!Fo},{create:function(e,t){return void 0===t?Yo(e):La(Yo(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,Ha=Ar,Ga=oe,za=Ye,Ka=yn,Xa=Ue.exports,Wa=ja,qa=Xa("string-to-symbol-registry"),Ya=Xa("symbol-to-string-registry");Ha({target:"Symbol",stat:!0,forced:!Wa},{for:function(e){var t=Ka(e);if(za(qa,t))return qa[t];var r=Ga("Symbol")(t);return qa[t]=r,Ya[r]=t,r}});var Ja=Ar,Qa=Ye,Za=ke,$a=Ie,es=ja,ts=(0,Ue.exports)("symbol-to-string-registry");Ja({target:"Symbol",stat:!0,forced:!es},{keyFor:function(e){if(!Za(e))throw TypeError($a(e)+" is not a symbol");if(Qa(ts,e))return ts[e]}});var rs=E([].slice),ns=Ar,is=oe,os=d,as=O,ss=E,cs=i,us=eo,ds=R,ls=$,hs=ke,ps=rs,vs=me,fs=is("JSON","stringify"),_s=ss(/./.exec),ms=ss("".charAt),ys=ss("".charCodeAt),gs=ss("".replace),Ss=ss(1..toString),bs=/[\uD800-\uDFFF]/g,Es=/^[\uD800-\uDBFF]$/,ks=/^[\uDC00-\uDFFF]$/,Ts=!vs||cs((function(){var e=is("Symbol")();return"[null]"!=fs([e])||"{}"!=fs({a:e})||"{}"!=fs(Object(e))})),Is=cs((function(){return'"\\udf06\\ud834"'!==fs("\udf06\ud834")||'"\\udead"'!==fs("\udead")})),Rs=function(e,t){var r=ps(arguments),n=t;if((ls(t)||void 0!==e)&&!hs(e))return us(t)||(t=function(e,t){if(ds(n)&&(t=as(n,this,e,t)),!hs(t))return t}),r[1]=t,os(fs,null,r)},As=function(e,t,r){var n=ms(r,t-1),i=ms(r,t+1);return _s(Es,e)&&!_s(ks,i)||_s(ks,e)&&!_s(Es,n)?"\\u"+Ss(ys(e,0),16):e};fs&&ns({target:"JSON",stat:!0,arity:3,forced:Ts||Is},{stringify:function(e,t,r){var n=ps(arguments),i=os(Ts?Rs:fs,null,n);return Is&&"string"==typeof i?gs(i,bs,As):i}});var ws=ui,Cs=Xe;Ar({target:"Object",stat:!0,forced:!me||i((function(){ws.f(1)}))},{getOwnPropertySymbols:function(e){var t=ws.f;return t?t(Cs(e)):[]}});var xs=ee.Object.getOwnPropertySymbols,Os=i,Ms=ve,Ds=lt("species"),Ps=function(e){return Ms>=51||!Os((function(){var t=[];return(t.constructor={})[Ds]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Ns=Po.filter;Ar({target:"Array",proto:!0,forced:!Ps("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,Hs=function(e){var t=e.filter;return e===js||Fs(js,e)&&t===js.filter?Bs:t},Gs={exports:{}},zs=Ar,Ks=i,Xs=J,Ws=A.f,qs=w,Ys=Ks((function(){Ws(1)}));zs({target:"Object",stat:!0,forced:!qs||Ys,sham:!qs},{getOwnPropertyDescriptor:function(e,t){return Ws(Xs(e),t)}});var Js=ee.Object,Qs=Gs.exports=function(e,t){return Js.getOwnPropertyDescriptor(e,t)};Js.getOwnPropertyDescriptor.sham&&(Qs.sham=!0);var Zs,$s,ec,tc=Gs.exports,rc={},nc=w,ic=Ye,oc=Function.prototype,ac=nc&&Object.getOwnPropertyDescriptor,sc=ic(oc,"name"),cc={EXISTS:sc,PROPER:sc&&"something"===function(){}.name,CONFIGURABLE:sc&&(!nc||nc&&ac(oc,"name").configurable)},uc=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),dc=Ye,lc=R,hc=Xe,pc=uc,vc=On("IE_PROTO"),fc=Object,_c=fc.prototype,mc=pc?fc.getPrototypeOf:function(e){var t=hc(e);if(dc(t,vc))return t[vc];var r=t.constructor;return lc(r)&&t instanceof r?r.prototype:t instanceof fc?_c:null},yc=i,gc=R,Sc=$,bc=Gn,Ec=mc,kc=li,Tc=lt("iterator"),Ic=!1;[].keys&&("next"in(ec=[].keys())?($s=Ec(Ec(ec)))!==Object.prototype&&(Zs=$s):Ic=!0);var Rc=!Sc(Zs)||yc((function(){var e={};return Zs[Tc].call(e)!==e}));gc((Zs=Rc?{}:bc(Zs))[Tc])||kc(Zs,Tc,(function(){return this}));var Ac={IteratorPrototype:Zs,BUGGY_SAFARI_ITERATORS:Ic},wc=Ac.IteratorPrototype,Cc=Gn,xc=V,Oc=Ni,Mc=rc,Dc=function(){return this},Pc=function(e,t,r,n){var i=t+" Iterator";return e.prototype=Cc(wc,{next:xc(+!n,r)}),Oc(e,i,!1,!0),Mc[i]=Dc,e},Nc=R,Lc=String,Uc=TypeError,Vc=E,Fc=tr,Bc=function(e){if("object"==typeof e||Nc(e))return e;throw Uc("Can't set "+Lc(e)+" as a prototype")},jc=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Vc(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return Fc(r),Bc(n),t?e(r,n):r.__proto__=n,r}}():void 0),Hc=Ar,Gc=O,zc=cc,Kc=Pc,Xc=mc,Wc=Ni,qc=li,Yc=rc,Jc=Ac,Qc=zc.PROPER,Zc=Jc.BUGGY_SAFARI_ITERATORS,$c=lt("iterator"),eu="keys",tu="values",ru="entries",nu=function(){return this},iu=function(e,t,r,n,i,o,a){Kc(r,t,n);var s,c,u,d=function(e){if(e===i&&f)return f;if(!Zc&&e in p)return p[e];switch(e){case eu:case tu:case ru:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,p=e.prototype,v=p[$c]||p["@@iterator"]||i&&p[i],f=!Zc&&v||d(i),_="Array"==t&&p.entries||v;if(_&&(s=Xc(_.call(new e)))!==Object.prototype&&s.next&&(Wc(s,l,!0,!0),Yc[l]=nu),Qc&&i==tu&&v&&v.name!==tu&&(h=!0,f=function(){return Gc(v,this)}),i)if(c={values:d(tu),keys:o?f:d(eu),entries:d(ru)},a)for(u in c)(Zc||h||!(u in p))&&qc(p,u,c[u]);else Hc({target:t,proto:!0,forced:Zc||h},c);return a&&p[$c]!==f&&qc(p,$c,f,{name:i}),Yc[t]=f,c},ou=function(e,t){return{value:e,done:t}},au=J,su=function(){},cu=rc,uu=Zi,du=(Jt.f,iu),lu=ou,hu="Array Iterator",pu=uu.set,vu=uu.getterFor(hu);du(Array,"Array",(function(e,t){pu(this,{type:hu,target:au(e),index:0,kind:t})}),(function(){var e=vu(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,lu(void 0,!0)):lu("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values");cu.Arguments=cu.Array;su(),su(),su();var fu={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},_u=n,mu=fn,yu=fr,gu=rc,Su=lt("toStringTag");for(var bu in fu){var Eu=_u[bu],ku=Eu&&Eu.prototype;ku&&mu(ku)!==Su&&yu(ku,Su,bu),gu[bu]=gu.Array}var Tu=i,Iu=function(e,t){var r=[][e];return!!r&&Tu((function(){r.call(null,t||function(){return 1},1)}))},Ru=Po.forEach,Au=Iu("forEach")?[].forEach:function(e){return Ru(this,e,arguments.length>1?arguments[1]:void 0)};Ar({target:"Array",proto:!0,forced:[].forEach!=Au},{forEach:Au});var wu=Us("Array").forEach,Cu=fn,xu=Ye,Ou=ae,Mu=wu,Du=Array.prototype,Pu={DOMTokenList:!0,NodeList:!0},Nu=function(e){var t=e.forEach;return e===Du||Ou(Du,e)&&t===Du.forEach||xu(Pu,Cu(e))?Mu:t},Lu=oe,Uu=zn,Vu=ui,Fu=tr,Bu=E([].concat),ju=Lu("Reflect","ownKeys")||function(e){var t=Uu.f(Fu(e)),r=Vu.f;return r?Bu(t,r(e)):t},Hu=ju,Gu=J,zu=A,Ku=Qn;Ar({target:"Object",stat:!0,sham:!w},{getOwnPropertyDescriptors:function(e){for(var t,r,n=Gu(e),i=zu.f,o=Hu(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&Ku(a,t,r);return a}});var Xu=ee.Object.getOwnPropertyDescriptors,Wu={exports:{}},qu=Ar,Yu=w,Ju=gn.f;qu({target:"Object",stat:!0,forced:Object.defineProperties!==Ju,sham:!Yu},{defineProperties:Ju});var Qu=ee.Object,Zu=Wu.exports=function(e,t){return Qu.defineProperties(e,t)};Qu.defineProperties.sham&&(Zu.sham=!0);var $u=Wu.exports,ed={exports:{}},td=Ar,rd=w,nd=Jt.f;td({target:"Object",stat:!0,forced:Object.defineProperty!==nd,sham:!rd},{defineProperty:nd});var id=ee.Object,od=ed.exports=function(e,t,r){return id.defineProperty(e,t,r)};id.defineProperty.sham&&(od.sham=!0);var ad=ed.exports,sd=TypeError,cd=function(e){if(e>9007199254740991)throw sd("Maximum allowed index exceeded");return e},ud=Ar,dd=i,ld=eo,hd=$,pd=Xe,vd=Br,fd=cd,_d=Qn,md=Ro,yd=Ps,gd=ve,Sd=lt("isConcatSpreadable"),bd=gd>=51||!dd((function(){var e=[];return e[Sd]=!1,e.concat()[0]!==e})),Ed=yd("concat"),kd=function(e){if(!hd(e))return!1;var t=e[Sd];return void 0!==t?!!t:ld(e)};ud({target:"Array",proto:!0,arity:1,forced:!bd||!Ed},{concat:function(e){var t,r,n,i,o,a=pd(this),s=md(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(kd(o=-1===t?a:arguments[t]))for(i=vd(o),fd(c+i),r=0;r<i;r++,c++)r in o&&_d(s,c,o[r]);else fd(c+1),_d(s,c++,o);return s.length=c,s}}),bi("asyncIterator"),bi("hasInstance"),bi("isConcatSpreadable"),bi("iterator"),bi("match"),bi("matchAll"),bi("replace"),bi("search"),bi("species"),bi("split");var Td=Ri;bi("toPrimitive"),Td();var Id=oe,Rd=Ni;bi("toStringTag"),Rd(Id("Symbol"),"Symbol"),bi("unscopables"),Ni(n.JSON,"JSON",!0);var Ad=ee.Symbol;bi("asyncDispose"),bi("dispose"),bi("matcher"),bi("metadataKey"),bi("observable"),bi("metadata"),bi("patternMatch"),bi("replaceAll");var wd=Ad,Cd=E,xd=Or,Od=yn,Md=W,Dd=Cd("".charAt),Pd=Cd("".charCodeAt),Nd=Cd("".slice),Ld=function(e){return function(t,r){var n,i,o=Od(Md(t)),a=xd(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Pd(o,a))<55296||n>56319||a+1===s||(i=Pd(o,a+1))<56320||i>57343?e?Dd(o,a):n:e?Nd(o,a,a+2):i-56320+(n-55296<<10)+65536}},Ud={codeAt:Ld(!1),charAt:Ld(!0)},Vd=Ud.charAt,Fd=yn,Bd=Zi,jd=iu,Hd=ou,Gd="String Iterator",zd=Bd.set,Kd=Bd.getterFor(Gd);jd(String,"String",(function(e){zd(this,{type:Gd,string:Fd(e),index:0})}),(function(){var e,t=Kd(this),r=t.string,n=t.index;return n>=r.length?Hd(void 0,!0):(e=Vd(r,n),t.index+=e.length,Hd(e,!1))}));var Xd=hi.f("iterator");function Wd(e){return(Wd="function"==typeof wd&&"symbol"==typeof Xd?function(e){return typeof e}:function(e){return e&&"function"==typeof wd&&e.constructor===wd&&e!==wd.prototype?"symbol":typeof e})(e)}var qd=hi.f("toPrimitive");function Yd(e){var t=function(e,t){if("object"!==Wd(e)||null===e)return e;var r=e[qd];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==Wd(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Wd(t)?t:String(t)}function Jd(e,t,r){return(t=Yd(t))in e?ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Qd(e,t){var r=an(e);if(xs){var n=xs(e);t&&(n=Hs(n).call(n,(function(t){return tc(e,t).enumerable}))),r.push.apply(r,n)}return r}function Zd(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?Nu(r=Qd(Object(i),!0)).call(r,(function(t){Jd(e,t,i[t])})):Xu?$u(e,Xu(i)):Nu(n=Qd(Object(i))).call(n,(function(t){ad(e,t,tc(i,t))}))}return e}var $d=function(e){return e[e.VIDEO_SOURCE_TYPE_EXTERNAL=0]="VIDEO_SOURCE_TYPE_EXTERNAL",e[e.VIDEO_SOURCE_TYPE_INTERNAL=1]="VIDEO_SOURCE_TYPE_INTERNAL",e}($d||{}),el=function(e){return e[e.AUDIO_SOURCE_TYPE_EXTERNAL=0]="AUDIO_SOURCE_TYPE_EXTERNAL",e[e.AUDIO_SOURCE_TYPE_INTERNAL=1]="AUDIO_SOURCE_TYPE_INTERNAL",e}(el||{}),tl=function(e){return e[e.QUIT=0]="QUIT",e[e.DROPPED=1]="DROPPED",e[e.SWITCH_TO_INVISIBLE=2]="SWITCH_TO_INVISIBLE",e[e.KICKED_BY_ADMIN=3]="KICKED_BY_ADMIN",e}(tl||{}),rl=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(rl||{}),nl=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(nl||{}),il=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(il||{}),ol=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(ol||{}),al=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(al||{}),sl=function(e){return e[e.RENDER_MODE_HIDDEN=0]="RENDER_MODE_HIDDEN",e[e.RENDER_MODE_FIT=1]="RENDER_MODE_FIT",e[e.RENDER_MODE_FILL=2]="RENDER_MODE_FILL",e}(sl||{}),cl=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(cl||{}),ul=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(ul||{}),dl=function(e){return e[e.STREAM_REMOVE_REASON_UNPUBLISH=0]="STREAM_REMOVE_REASON_UNPUBLISH",e[e.STREAM_REMOVE_REASON_PUBLISH_FAILED=1]="STREAM_REMOVE_REASON_PUBLISH_FAILED",e[e.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED=2]="STREAM_REMOVE_REASON_KEEP_LIVE_FAILED",e[e.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED=3]="STREAM_REMOVE_REASON_CLIENT_DISCONNECTED",e[e.STREAM_REMOVE_REASON_REPUBLISH=4]="STREAM_REMOVE_REASON_REPUBLISH",e[e.STREAM_REMOVE_REASON_OTHER=5]="STREAM_REMOVE_REASON_OTHER",e}(dl||{}),ll=function(e){return e[e.CONNECTION_START=0]="CONNECTION_START",e[e.CONNECTION_STATE_DISCONNECTED=1]="CONNECTION_STATE_DISCONNECTED",e[e.CONNECTION_STATE_CONNECTING=2]="CONNECTION_STATE_CONNECTING",e[e.CONNECTION_STATE_CONNECTED=3]="CONNECTION_STATE_CONNECTED",e[e.CONNECTION_STATE_RECONNECTING=4]="CONNECTION_STATE_RECONNECTING",e[e.CONNECTION_STATE_RECONNECTED=5]="CONNECTION_STATE_RECONNECTED",e[e.CONNECTION_STATE_LOST=6]="CONNECTION_STATE_LOST",e}(ll||{}),hl=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(hl||{}),pl=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(pl||{}),vl=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(vl||{}),fl=function(e){return e[e.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",e[e.AUDIO_ONLY=1]="AUDIO_ONLY",e[e.VIDEO_ONLY=2]="VIDEO_ONLY",e}(fl||{}),_l=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(_l||{}),ml=function(e){return e[e.DISABLE=0]="DISABLE",e[e.VIDEO_STREAM_LOW=1]="VIDEO_STREAM_LOW",e[e.AUDIO_ONLY=2]="AUDIO_ONLY",e}(ml||{}),yl=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(yl||{}),gl=function(e){return e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VBAD=5]="VBAD",e[e.DOWN=6]="DOWN",e}(gl||{}),Sl=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(Sl||{}),bl=function(e){return e[e.communication=0]="communication",e[e.chat=5]="chat",e[e.chatRoom=6]="chatRoom",e[e.coHost=9]="coHost",e[e.meeting=16]="meeting",e[e.classRoom=18]="classRoom",e}(bl||{}),El=function(e){return e[e.default=0]="default",e[e.fluent=1]="fluent",e[e.standard=2]="standard",e[e.hd=3]="hd",e[e.standardStereo=4]="standardStereo",e[e.hdMono=5]="hdMono",e}(El||{}),kl=function(e){return e[e.AUTO_PLAY=0]="AUTO_PLAY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.PLAY_MANUALLY=2]="PLAY_MANUALLY",e}(kl||{}),Tl=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(Tl||{}),Il=function(e){return e.H264="H264",e.H265="H265",e}(Il||{}),Rl=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(Rl||{}),Al=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(Al||{}),wl=function(e){return e[e.FORWARD_STREAM_STATE_SUCCESS=0]="FORWARD_STREAM_STATE_SUCCESS",e[e.FORWARD_STREAM_STATE_FAILURE=1]="FORWARD_STREAM_STATE_FAILURE",e}(wl||{}),Cl=function(e){return e[e.FORWARD_STREAM_ERROR_OK=0]="FORWARD_STREAM_ERROR_OK",e[e.FORWARD_STREAM_ERROR_INVALID_TOKEN=1202]="FORWARD_STREAM_ERROR_INVALID_TOKEN",e[e.FORWARD_STREAM_ERROR_RESPONSE=1203]="FORWARD_STREAM_ERROR_RESPONSE",e[e.FORWARD_STREAM_ERROR_REMOTE_KICKED=1204]="FORWARD_STREAM_ERROR_REMOTE_KICKED",e[e.FORWARD_STREAM_ERROR_NOT_SUPPORT=1205]="FORWARD_STREAM_ERROR_NOT_SUPPORT",e}(Cl||{}),xl=Object.freeze(Object.defineProperty({__proto__:null,VideoSourceType:$d,AudioSourceType:el,UserOfflineReason:tl,ChannelProfile:rl,SubscribeMode:nl,SubscribeState:il,PublishState:ol,MirrorMode:al,VideoRenderMode:sl,StreamIndex:cl,MediaType:ul,StreamRemoveReason:dl,ConnectionState:ll,MirrorType:hl,LogChannel:pl,USER_ONLINE_STATUS:vl,PublicStreamType:fl,PublicInterpolationMode:_l,SubscribeFallbackOption:ml,RemoteUserPriority:yl,NetworkQuality:gl,FallbackOrRecoverReason:Sl,RoomProfileType:bl,AudioProfileType:El,RTCAutoPlayPolicy:kl,AAC_PROFILE:Tl,TRANSCODING_VIDEO_CODEC:Il,SUBTITLE_MODE:Rl,SubtitleEventType:Al,ForwardStreamState:wl,ForwardStreamError:Cl},Symbol.toStringTag,{value:"Module"})),Ol=function(e){return e[e.AUTO=0]="AUTO",e[e.MODE_L=1]="MODE_L",e[e.MODE_R=2]="MODE_R",e[e.MODE_MIX=3]="MODE_MIX",e}(Ol||{}),Ml=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(Ml||{}),Dl=function(e){return e[e.AUDIO_MIXING_STATE_PRELOADED=0]="AUDIO_MIXING_STATE_PRELOADED",e[e.AUDIO_MIXING_STATE_PLAYING=1]="AUDIO_MIXING_STATE_PLAYING",e[e.AUDIO_MIXING_STATE_PAUSED=2]="AUDIO_MIXING_STATE_PAUSED",e[e.AUDIO_MIXING_STATE_STOPPED=3]="AUDIO_MIXING_STATE_STOPPED",e[e.AUDIO_MIXING_STATE_FAILED=4]="AUDIO_MIXING_STATE_FAILED",e[e.AUDIO_MIXING_STATE_FINISHED=5]="AUDIO_MIXING_STATE_FINISHED",e[e.AUDIO_MIXING_STATE_PCM_ENABLED=6]="AUDIO_MIXING_STATE_PCM_ENABLED",e[e.AUDIO_MIXING_STATE_PCM_DISABLED=7]="AUDIO_MIXING_STATE_PCM_DISABLED",e}(Dl||{}),Pl=Object.freeze(Object.defineProperty({__proto__:null,AudioMixingDualMonoMode:Ol,AudioMixingType:Ml,AudioMixingState:Dl},Symbol.toStringTag,{value:"Module"})),Nl=function(e){return e.onTrackEnded="onTrackEnded",e.onTrackMute="onTrackMute",e.onTrackUnmute="onTrackUnmute",e.onPlayerEvent="onPlayerEvent",e.onAutoplayFailed="onAutoplayFailed",e.onUserJoined="onUserJoined",e.onUserLeave="onUserLeave",e.onConnectionStateChanged="onConnectionStateChanged",e.onUserPublishStream="onUserPublishStream",e.onUserUnpublishStream="onUserUnpublishStream",e.onUserPublishScreen="onUserPublishScreen",e.onUserUnpublishScreen="onUserUnpublishScreen",e.onRoomMessageReceived="onRoomMessageReceived",e.onRoomBinaryMessageReceived="onRoomBinaryMessageReceived",e.onUserMessageReceived="onUserMessageReceived",e.onUserBinaryMessageReceived="onUserBinaryMessageReceived",e.onVideoFirstFrameRendered="onVideoFirstFrameRendered",e.onVideoFirstFrameDecoded="onVideoFirstFrameDecoded",e.onRemoteVideoFirstFrame="onRemoteVideoFirstFrame",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onRemoteAudioFirstFrame="onRemoteAudioFirstFrame",e.onFirstPublicStreamVideoFrameRendered="onFirstPublicStreamVideoFrameRendered",e.onFirstPublicStreamVideoFrameDecoded="onFirstPublicStreamVideoFrameDecoded",e.onFirstPublicStreamAudioFrameDecoded="onFirstPublicStreamAudioFrameDecoded",e.onVideoDeviceStateChanged="onVideoDeviceStateChanged",e.onAudioDeviceStateChanged="onAudioDeviceStateChanged",e.onRemoteStreamStats="onRemoteStreamStats",e.onPublicStreamStats="onPublicStreamStats",e.onLocalStreamStats="onLocalStreamStats",e.onAudioVolumeIndication="onAudioVolumeIndication",e.onLocalAudioPropertiesReport="onLocalAudioPropertiesReport",e.onRemoteAudioPropertiesReport="onRemoteAudioPropertiesReport",e.onActiveSpeaker="onActiveSpeaker",e.onAudioPlaybackDeviceChanged="onAudioPlaybackDeviceChanged",e.onUserStartVideoCapture="onUserStartVideoCapture",e.onUserStopVideoCapture="onUserStopVideoCapture",e.onUserStartAudioCapture="onUserStartAudioCapture",e.onUserStopAudioCapture="onUserStopAudioCapture",e.onAutoPublishResult="onAutoPublishResult",e.onAutoSubscribeResult="onAutoSubscribeResult",e.onLiveTranscodingResult="onLiveTranscodingResult",e.onStreamMixingEvent="onStreamMixingEvent",e.onAudioPlaybackDeviceTestVolume="onAudioPlaybackDeviceTestVolume",e.onSEIMessageReceived="onSEIMessageReceived",e.onError="onError",e.onAudioMixingStateChanged="onAudioMixingStateChanged",e.onUserMessageReceivedOutsideRoom="onUserMessageReceivedOutsideRoom",e.onUserBinaryMessageReceivedOutsideRoom="onUserBinaryMessageReceivedOutsideRoom",e.onTokenWillExpire="onTokenWillExpire",e.onCloudProxyConnected="onCloudProxyConnected",e.onPushPublicStreamResult="onPushPublicStreamResult",e.onPublicStreamSEIMessageReceived="onPublicStreamSEIMessageReceived",e.onNetworkQuality="onNetworkQuality",e.onSimulcastSubscribeFallback="onSimulcastSubscribeFallback",e.onRemoteVideoSizeChanged="onRemoteVideoSizeChanged",e.onVideoStreamBanned="onVideoStreamBanned",e.onAudioStreamBanned="onAudioStreamBanned",e.onLocalVideoSizeChanged="onLocalVideoSizeChanged",e.onSubtitleStateChanged="onSubtitleStateChanged",e.onSubtitleMessageReceived="onSubtitleMessageReceived",e.onServerParamsSetResult="onServerParamsSetResult",e.onLocalStreamTrackChangedByExtension="onLocalStreamTrackChangedByExtension",e.onVendorConnectionStateChanged="onVendorConnectionStateChanged",e.onForwardStreamError="onForwardStreamError",e.onRejoinWithTcp="onRejoinWithTcp",e.onIceConnectWithTcp="onIceConnectWithTcp",e}(Nl||{});function Ll(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),ad(e,Yd(n.key),n)}}function Ul(e,t,r){return t&&Ll(e.prototype,t),r&&Ll(e,r),ad(e,"prototype",{writable:!1}),e}function Vl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Ar({target:"Object",stat:!0,sham:!w},{create:Gn});var Fl=ee.Object,Bl=function(e,t){return Fl.create(e,t)},jl=Xe,Hl=mc,Gl=uc;Ar({target:"Object",stat:!0,forced:i((function(){Hl(1)})),sham:!Gl},{getPrototypeOf:function(e){return Hl(jl(e))}});var zl=ee.Object.getPrototypeOf;Ar({target:"Object",stat:!0},{setPrototypeOf:jc});var Kl=ee.Object.setPrototypeOf,Xl=Ye,Wl=ju,ql=A,Yl=Jt,Jl=Error,Ql=E("".replace),Zl=String(Jl("zxcasd").stack),$l=/\n\s*at [^:]*:[^\n]*/,eh=$l.test(Zl),th=$,rh=fr,nh=rc,ih=lt("iterator"),oh=Array.prototype,ah=function(e){return void 0!==e&&(nh.Array===e||oh[ih]===e)},sh=fn,ch=Me,uh=z,dh=rc,lh=lt("iterator"),hh=function(e){if(!uh(e))return ch(e,lh)||ch(e,"@@iterator")||dh[sh(e)]},ph=O,vh=Ce,fh=tr,_h=Ie,mh=hh,yh=TypeError,gh=function(e,t){var r=arguments.length<2?mh(e):t;if(vh(r))return fh(ph(r,e));throw yh(_h(e)+" is not iterable")},Sh=O,bh=tr,Eh=Me,kh=function(e,t,r){var n,i;bh(e);try{if(!(n=Eh(e,"return"))){if("throw"===t)throw r;return r}n=Sh(n,e)}catch(o){i=!0,n=o}if("throw"===t)throw r;if(i)throw n;return bh(n),r},Th=Yt,Ih=O,Rh=tr,Ah=Ie,wh=ah,Ch=Br,xh=ae,Oh=gh,Mh=hh,Dh=kh,Ph=TypeError,Nh=function(e,t){this.stopped=e,this.result=t},Lh=Nh.prototype,Uh=function(e,t,r){var n,i,o,a,s,c,u,d=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),v=!(!r||!r.INTERRUPTED),f=Th(t,d),_=function(e){return n&&Dh(n,"normal",e),new Nh(!0,e)},m=function(e){return l?(Rh(e),v?f(e[0],e[1],_):f(e[0],e[1])):v?f(e,_):f(e)};if(h)n=e.iterator;else if(p)n=e;else{if(!(i=Mh(e)))throw Ph(Ah(e)+" is not iterable");if(wh(i)){for(o=0,a=Ch(e);a>o;o++)if((s=m(e[o]))&&xh(Lh,s))return s;return new Nh(!1)}n=Oh(e,i)}for(c=h?e.next:n.next;!(u=Ih(c,n)).done;){try{s=m(u.value)}catch(y){Dh(n,"throw",y)}if("object"==typeof s&&s&&xh(Lh,s))return s}return new Nh(!1)},Vh=yn,Fh=V,Bh=!i((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Fh(1,7)),7!==e.stack)})),jh=Ar,Hh=ae,Gh=mc,zh=jc,Kh=function(e,t,r){for(var n=Wl(t),i=Yl.f,o=ql.f,a=0;a<n.length;a++){var s=n[a];Xl(e,s)||r&&Xl(r,s)||i(e,s,o(t,s))}},Xh=Gn,Wh=fr,qh=V,Yh=function(e,t){if(eh&&"string"==typeof e&&!Jl.prepareStackTrace)for(;t--;)e=Ql(e,$l,"");return e},Jh=function(e,t){th(t)&&"cause"in t&&rh(e,"cause",t.cause)},Qh=Uh,Zh=function(e,t){return void 0===e?arguments.length<2?"":t:Vh(e)},$h=Bh,ep=lt("toStringTag"),tp=Error,rp=[].push,np=function(e,t){var r,n=arguments.length>2?arguments[2]:void 0,i=Hh(ip,this);zh?r=zh(tp(),i?Gh(this):ip):(r=i?this:Xh(ip),Wh(r,ep,"Error")),void 0!==t&&Wh(r,"message",Zh(t)),$h&&Wh(r,"stack",Yh(r.stack,1)),Jh(r,n);var o=[];return Qh(e,rp,{that:o}),Wh(r,"errors",o),r};zh?zh(np,tp):Kh(np,tp,{name:!0});var ip=np.prototype=Xh(tp.prototype,{constructor:qh(1,np),message:qh(1,""),name:qh(1,"AggregateError")});jh({global:!0,constructor:!0,arity:2},{AggregateError:np});var op,ap,sp,cp,up="process"==g(n.process),dp=oe,lp=Jt,hp=w,pp=lt("species"),vp=function(e){var t=dp(e),r=lp.f;hp&&t&&!t[pp]&&r(t,pp,{configurable:!0,get:function(){return this}})},fp=ae,_p=TypeError,mp=function(e,t){if(fp(t,e))return e;throw _p("Incorrect invocation")},yp=go,gp=Ie,Sp=TypeError,bp=function(e){if(yp(e))return e;throw Sp(gp(e)+" is not a constructor")},Ep=tr,kp=bp,Tp=z,Ip=lt("species"),Rp=function(e,t){var r,n=Ep(e).constructor;return void 0===n||Tp(r=Ep(n)[Ip])?t:kp(r)},Ap=TypeError,wp=function(e,t){if(e<t)throw Ap("Not enough arguments");return e},Cp=/(?:ipad|iphone|ipod).*applewebkit/i.test(se),xp=n,Op=d,Mp=Yt,Dp=R,Pp=Ye,Np=i,Lp=An,Up=rs,Vp=It,Fp=wp,Bp=Cp,jp=up,Hp=xp.setImmediate,Gp=xp.clearImmediate,zp=xp.process,Kp=xp.Dispatch,Xp=xp.Function,Wp=xp.MessageChannel,qp=xp.String,Yp=0,Jp={},Qp="onreadystatechange";try{op=xp.location}catch(cq){}var Zp=function(e){if(Pp(Jp,e)){var t=Jp[e];delete Jp[e],t()}},$p=function(e){return function(){Zp(e)}},ev=function(e){Zp(e.data)},tv=function(e){xp.postMessage(qp(e),op.protocol+"//"+op.host)};Hp&&Gp||(Hp=function(e){Fp(arguments.length,1);var t=Dp(e)?e:Xp(e),r=Up(arguments,1);return Jp[++Yp]=function(){Op(t,void 0,r)},ap(Yp),Yp},Gp=function(e){delete Jp[e]},jp?ap=function(e){zp.nextTick($p(e))}:Kp&&Kp.now?ap=function(e){Kp.now($p(e))}:Wp&&!Bp?(cp=(sp=new Wp).port2,sp.port1.onmessage=ev,ap=Mp(cp.postMessage,cp)):xp.addEventListener&&Dp(xp.postMessage)&&!xp.importScripts&&op&&"file:"!==op.protocol&&!Np(tv)?(ap=tv,xp.addEventListener("message",ev,!1)):ap=Qp in Vp("script")?function(e){Lp.appendChild(Vp("script")).onreadystatechange=function(){Lp.removeChild(this),Zp(e)}}:function(e){setTimeout($p(e),0)});var rv,nv,iv,ov,av,sv,cv,uv,dv={set:Hp,clear:Gp},lv=n,hv=/ipad|iphone|ipod/i.test(se)&&void 0!==lv.Pebble,pv=/web0s(?!.*chrome)/i.test(se),vv=n,fv=Yt,_v=A.f,mv=dv.set,yv=Cp,gv=hv,Sv=pv,bv=up,Ev=vv.MutationObserver||vv.WebKitMutationObserver,kv=vv.document,Tv=vv.process,Iv=vv.Promise,Rv=_v(vv,"queueMicrotask"),Av=Rv&&Rv.value;Av||(rv=function(){var e,t;for(bv&&(e=Tv.domain)&&e.exit();nv;){t=nv.fn,nv=nv.next;try{t()}catch(cq){throw nv?ov():iv=void 0,cq}}iv=void 0,e&&e.enter()},yv||bv||Sv||!Ev||!kv?!gv&&Iv&&Iv.resolve?((cv=Iv.resolve(void 0)).constructor=Iv,uv=fv(cv.then,cv),ov=function(){uv(rv)}):bv?ov=function(){Tv.nextTick(rv)}:(mv=fv(mv,vv),ov=function(){mv(rv)}):(av=!0,sv=kv.createTextNode(""),new Ev(rv).observe(sv,{characterData:!0}),ov=function(){sv.data=av=!av}));var wv=Av||function(e){var t={fn:e,next:void 0};iv&&(iv.next=t),nv||(nv=t,ov()),iv=t},Cv=n,xv=function(e){try{return{error:!1,value:e()}}catch(cq){return{error:!0,value:cq}}},Ov=function(){this.head=null,this.tail=null};Ov.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var Mv=Ov,Dv=n.Promise,Pv="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Nv=!Pv&&!up&&"object"==typeof window&&"object"==typeof document,Lv=n,Uv=Dv,Vv=R,Fv=Kt,Bv=io,jv=lt,Hv=Nv,Gv=Pv,zv=ve,Kv=Uv&&Uv.prototype,Xv=jv("species"),Wv=!1,qv=Vv(Lv.PromiseRejectionEvent),Yv={CONSTRUCTOR:Fv("Promise",(function(){var e=Bv(Uv),t=e!==String(Uv);if(!t&&66===zv)return!0;if(!Kv.catch||!Kv.finally)return!0;if(!zv||zv<51||!/native code/.test(e)){var r=new Uv((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[Xv]=n,!(Wv=r.then((function(){}))instanceof n))return!0}return!t&&(Hv||Gv)&&!qv})),REJECTION_EVENT:qv,SUBCLASSING:Wv},Jv={},Qv=Ce,Zv=TypeError,$v=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw Zv("Bad Promise constructor");t=e,r=n})),this.resolve=Qv(t),this.reject=Qv(r)};Jv.f=function(e){return new $v(e)};var ef,tf,rf=Ar,nf=up,of=n,af=O,sf=li,cf=Ni,uf=vp,df=Ce,lf=R,hf=$,pf=mp,vf=Rp,ff=dv.set,_f=wv,mf=function(e,t){var r=Cv.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},yf=xv,gf=Mv,Sf=Zi,bf=Dv,Ef=Yv,kf=Jv,Tf="Promise",If=Ef.CONSTRUCTOR,Rf=Ef.REJECTION_EVENT,Af=Sf.getterFor(Tf),wf=Sf.set,Cf=bf&&bf.prototype,xf=bf,Of=Cf,Mf=of.TypeError,Df=of.document,Pf=of.process,Nf=kf.f,Lf=Nf,Uf=!!(Df&&Df.createEvent&&of.dispatchEvent),Vf="unhandledrejection",Ff=function(e){var t;return!(!hf(e)||!lf(t=e.then))&&t},Bf=function(e,t){var r,n,i,o=t.value,a=1==t.state,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&Kf(t),t.rejection=1),!0===s?r=o:(d&&d.enter(),r=s(o),d&&(d.exit(),i=!0)),r===e.promise?u(Mf("Promise-chain cycle")):(n=Ff(r))?af(n,r,c,u):c(r)):u(o)}catch(cq){d&&!i&&d.exit(),u(cq)}},jf=function(e,t){e.notified||(e.notified=!0,_f((function(){for(var r,n=e.reactions;r=n.get();)Bf(r,e);e.notified=!1,t&&!e.rejection&&Gf(e)})))},Hf=function(e,t,r){var n,i;Uf?((n=Df.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),of.dispatchEvent(n)):n={promise:t,reason:r},!Rf&&(i=of["on"+e])?i(n):e===Vf&&mf("Unhandled promise rejection",r)},Gf=function(e){af(ff,of,(function(){var t,r=e.facade,n=e.value;if(zf(e)&&(t=yf((function(){nf?Pf.emit("unhandledRejection",n,r):Hf(Vf,r,n)})),e.rejection=nf||zf(e)?2:1,t.error))throw t.value}))},zf=function(e){return 1!==e.rejection&&!e.parent},Kf=function(e){af(ff,of,(function(){var t=e.facade;nf?Pf.emit("rejectionHandled",t):Hf("rejectionhandled",t,e.value)}))},Xf=function(e,t,r){return function(n){e(t,n,r)}},Wf=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,jf(e,!0))},qf=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw Mf("Promise can't be resolved itself");var n=Ff(t);n?_f((function(){var r={done:!1};try{af(n,t,Xf(qf,r,e),Xf(Wf,r,e))}catch(cq){Wf(r,cq,e)}})):(e.value=t,e.state=1,jf(e,!1))}catch(cq){Wf({done:!1},cq,e)}}};If&&(Of=(xf=function(e){pf(this,Of),df(e),af(ef,this);var t=Af(this);try{e(Xf(qf,t),Xf(Wf,t))}catch(cq){Wf(t,cq)}}).prototype,(ef=function(e){wf(this,{type:Tf,done:!1,notified:!1,parent:!1,reactions:new gf,rejection:!1,state:0,value:void 0})}).prototype=sf(Of,"then",(function(e,t){var r=Af(this),n=Nf(vf(this,xf));return r.parent=!0,n.ok=!lf(e)||e,n.fail=lf(t)&&t,n.domain=nf?Pf.domain:void 0,0==r.state?r.reactions.add(n):_f((function(){Bf(n,r)})),n.promise})),tf=function(){var e=new ef,t=Af(e);this.promise=e,this.resolve=Xf(qf,t),this.reject=Xf(Wf,t)},kf.f=Nf=function(e){return e===xf||undefined===e?new tf(e):Lf(e)}),rf({global:!0,constructor:!0,wrap:!0,forced:If},{Promise:xf}),cf(xf,Tf,!1,!0),uf(Tf);var Yf=lt("iterator"),Jf=!1;try{var Qf=0,Zf={next:function(){return{done:!!Qf++}},return:function(){Jf=!0}};Zf[Yf]=function(){return this},Array.from(Zf,(function(){throw 2}))}catch(cq){}var $f=function(e,t){if(!t&&!Jf)return!1;var r=!1;try{var n={};n[Yf]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(cq){}return r},e_=Dv,t_=Yv.CONSTRUCTOR||!$f((function(e){e_.all(e).then(void 0,(function(){}))})),r_=O,n_=Ce,i_=Jv,o_=xv,a_=Uh;Ar({target:"Promise",stat:!0,forced:t_},{all:function(e){var t=this,r=i_.f(t),n=r.resolve,i=r.reject,o=o_((function(){var r=n_(t.resolve),o=[],a=0,s=1;a_(e,(function(e){var c=a++,u=!1;s++,r_(r,t,e).then((function(e){u||(u=!0,o[c]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var s_=Ar,c_=Yv.CONSTRUCTOR;Dv&&Dv.prototype,s_({target:"Promise",proto:!0,forced:c_,real:!0},{catch:function(e){return this.then(void 0,e)}});var u_=O,d_=Ce,l_=Jv,h_=xv,p_=Uh;Ar({target:"Promise",stat:!0,forced:t_},{race:function(e){var t=this,r=l_.f(t),n=r.reject,i=h_((function(){var i=d_(t.resolve);p_(e,(function(e){u_(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var v_=O,f_=Jv;Ar({target:"Promise",stat:!0,forced:Yv.CONSTRUCTOR},{reject:function(e){var t=f_.f(this);return v_(t.reject,void 0,e),t.promise}});var __=tr,m_=$,y_=Jv,g_=function(e,t){if(__(e),m_(t)&&t.constructor===e)return t;var r=y_.f(e);return(0,r.resolve)(t),r.promise},S_=Ar,b_=Dv,E_=Yv.CONSTRUCTOR,k_=g_,T_=oe("Promise"),I_=!E_;S_({target:"Promise",stat:!0,forced:true},{resolve:function(e){return k_(I_&&this===T_?b_:this,e)}});var R_=O,A_=Ce,w_=Jv,C_=xv,x_=Uh;Ar({target:"Promise",stat:!0},{allSettled:function(e){var t=this,r=w_.f(t),n=r.resolve,i=r.reject,o=C_((function(){var r=A_(t.resolve),i=[],o=0,a=1;x_(e,(function(e){var s=o++,c=!1;a++,R_(r,t,e).then((function(e){c||(c=!0,i[s]={status:"fulfilled",value:e},--a||n(i))}),(function(e){c||(c=!0,i[s]={status:"rejected",reason:e},--a||n(i))}))})),--a||n(i)}));return o.error&&i(o.value),r.promise}});var O_=O,M_=Ce,D_=oe,P_=Jv,N_=xv,L_=Uh,U_="No one promise resolved";Ar({target:"Promise",stat:!0},{any:function(e){var t=this,r=D_("AggregateError"),n=P_.f(t),i=n.resolve,o=n.reject,a=N_((function(){var n=M_(t.resolve),a=[],s=0,c=1,u=!1;L_(e,(function(e){var d=s++,l=!1;c++,O_(n,t,e).then((function(e){l||u||(u=!0,i(e))}),(function(e){l||u||(l=!0,a[d]=e,--c||o(new r(a,U_)))}))})),--c||o(new r(a,U_))}));return a.error&&o(a.value),n.promise}});var V_=Ar,F_=Dv,B_=i,j_=oe,H_=R,G_=Rp,z_=g_,K_=F_&&F_.prototype;V_({target:"Promise",proto:!0,real:!0,forced:!!F_&&B_((function(){K_.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=G_(this,j_("Promise")),r=H_(e);return this.then(r?function(r){return z_(t,e()).then((function(){return r}))}:e,r?function(r){return z_(t,e()).then((function(){throw r}))}:e)}});var X_=ee.Promise,W_=Jv,q_=xv;Ar({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=W_.f(this),r=q_(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var Y_=X_,J_=Ar,Q_=eo,Z_=E([].reverse),$_=[1,2];J_({target:"Array",proto:!0,forced:String($_)===String($_.reverse())},{reverse:function(){return Q_(this)&&(this.length=this.length),Z_(this)}});var em=Us("Array").reverse,tm=ae,rm=em,nm=Array.prototype,im=function(e){var t=e.reverse;return e===nm||tm(nm,e)&&t===nm.reverse?rm:t},om=Ar,am=eo,sm=go,cm=$,um=Nr,dm=Br,lm=J,hm=Qn,pm=lt,vm=rs,fm=Ps("slice"),_m=pm("species"),mm=Array,ym=Math.max;om({target:"Array",proto:!0,forced:!fm},{slice:function(e,t){var r,n,i,o=lm(this),a=dm(o),s=um(e,a),c=um(void 0===t?a:t,a);if(am(o)&&(r=o.constructor,(sm(r)&&(r===mm||am(r.prototype))||cm(r)&&null===(r=r[_m]))&&(r=void 0),r===mm||void 0===r))return vm(o,s,c);for(n=new(void 0===r?mm:r)(ym(c-s,0)),i=0;s<c;s++,i++)s in o&&hm(n,i,o[s]);return n.length=i,n}});var gm=Us("Array").slice,Sm=ae,bm=gm,Em=Array.prototype,km=function(e){var t=e.slice;return e===Em||Sm(Em,e)&&t===Em.slice?bm:t};function Tm(){Tm=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=ad||function(e,t,r){e[t]=r.value},i="function"==typeof wd?wd:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,r){return ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(A){c=function(e,t,r){return e[t]=r}}function u(e,t,r,i){var o=t&&t.prototype instanceof h?t:h,a=Bl(o.prototype),s=new T(i||[]);return n(a,"_invoke",{value:S(e,r,s)}),a}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(A){return{type:"throw",arg:A}}}e.wrap=u;var l={};function h(){}function p(){}function v(){}var f={};c(f,o,(function(){return this}));var _=zl&&zl(zl(I([])));_&&_!==t&&r.call(_,o)&&(f=_);var m=v.prototype=h.prototype=Bl(f);function y(e){var t;Nu(t=["next","throw","return"]).call(t,(function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){function i(n,o,a,s){var c=d(e[n],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Wd(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return i("throw",e,a,s)}))}s(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function S(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=b(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=d(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function b(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),l;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,l;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],Nu(e).call(e,E,this),this.reset(!0)}function I(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:R}}function R(){return{value:void 0,done:!0}}return p.prototype=v,n(m,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:p,configurable:!0}),p.displayName=c(v,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Kl?Kl(e,v):(e.__proto__=v,c(e,s,"GeneratorFunction")),e.prototype=Bl(m),e},e.awrap=function(e){return{__await:e}},y(g.prototype),c(g.prototype,a,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Y_);var a=new g(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},y(m),c(m,s,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return im(r).call(r),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,T.prototype={constructor:T,reset:function(e){var t;if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,Nu(t=this.tryEntries).call(t,k),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+km(n).call(n,1))&&(this[n]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;k(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function Im(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(cq){return void r(cq)}s.done?t(c):Y_.resolve(c).then(n,i)}function Rm(e){return function(){var t=this,r=arguments;return new Y_((function(n,i){var o=e.apply(t,r);function a(e){Im(o,n,i,a,s,"next",e)}function s(e){Im(o,n,i,a,s,"throw",e)}a(void 0)}))}}var Am=Us("Array").concat,wm=ae,Cm=Am,xm=Array.prototype,Om=function(e){var t=e.concat;return e===xm||wm(xm,e)&&t===xm.concat?Cm:t},Mm=ee,Dm=d;Mm.JSON||(Mm.JSON={stringify:JSON.stringify});var Pm=function(e,t,r){return Dm(Mm.JSON.stringify,null,arguments)},Nm=Pm,Lm=Po.map;Ar({target:"Array",proto:!0,forced:!Ps("map")},{map:function(e){return Lm(this,e,arguments.length>1?arguments[1]:void 0)}});var Um=Us("Array").map,Vm=ae,Fm=Um,Bm=Array.prototype,jm=function(e){var t=e.map;return e===Bm||Vm(Bm,e)&&t===Bm.map?Fm:t},Hm="\t\n\v\f\r                 \u2028\u2029\ufeff",Gm=W,zm=yn,Km=E("".replace),Xm="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Wm=RegExp("^"+Xm+Xm+"*"),qm=RegExp(Xm+Xm+"*$"),Ym=function(e){return function(t){var r=zm(Gm(t));return 1&e&&(r=Km(r,Wm,"")),2&e&&(r=Km(r,qm,"")),r}},Jm={start:Ym(1),end:Ym(2),trim:Ym(3)},Qm=n,Zm=i,$m=E,ey=yn,ty=Jm.trim,ry=Hm,ny=Qm.parseInt,iy=Qm.Symbol,oy=iy&&iy.iterator,ay=/^[+-]?0x/i,sy=$m(ay.exec),cy=8!==ny(ry+"08")||22!==ny(ry+"0x16")||oy&&!Zm((function(){ny(Object(oy))}))?function(e,t){var r=ty(ey(e));return ny(r,t>>>0||(sy(ay,r)?16:10))}:ny;Ar({global:!0,forced:parseInt!=cy},{parseInt:cy});var uy=ee.parseInt,dy={exports:{}},ly=i((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),hy=i,py=$,vy=g,fy=ly,_y=Object.isExtensible,my=hy((function(){_y(1)}))||fy?function(e){return!!py(e)&&((!fy||"ArrayBuffer"!=vy(e))&&(!_y||_y(e)))}:_y,yy=!i((function(){return Object.isExtensible(Object.preventExtensions({}))})),gy=Ar,Sy=E,by=Xr,Ey=$,ky=Ye,Ty=Jt.f,Iy=zn,Ry=Wn,Ay=my,wy=yy,Cy=!1,xy=et("meta"),Oy=0,My=function(e){Ty(e,xy,{value:{objectID:"O"+Oy++,weakData:{}}})},Dy=dy.exports={enable:function(){Dy.enable=function(){},Cy=!0;var e=Iy.f,t=Sy([].splice),r={};r[xy]=1,e(r).length&&(Iy.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===xy){t(n,i,1);break}return n},gy({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Ry.f}))},fastKey:function(e,t){if(!Ey(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!ky(e,xy)){if(!Ay(e))return"F";if(!t)return"E";My(e)}return e[xy].objectID},getWeakData:function(e,t){if(!ky(e,xy)){if(!Ay(e))return!0;if(!t)return!1;My(e)}return e[xy].weakData},onFreeze:function(e){return wy&&Cy&&Ay(e)&&!ky(e,xy)&&My(e),e}};by[xy]=!0;var Py=Ar,Ny=n,Ly=dy.exports,Uy=i,Vy=fr,Fy=Uh,By=mp,jy=R,Hy=$,Gy=Ni,zy=Jt.f,Ky=Po.forEach,Xy=w,Wy=Zi.set,qy=Zi.getterFor,Yy=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=Ny[e],c=s&&s.prototype,u={};if(Xy&&jy(s)&&(o||c.forEach&&!Uy((function(){(new s).entries().next()})))){var d=(n=t((function(t,r){Wy(By(t,d),{type:e,collection:new s}),null!=r&&Fy(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,l=qy(e);Ky(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in c)||o&&"clear"==e||Vy(d,e,(function(r,n){var i=l(this).collection;if(!t&&o&&!Hy(r))return"get"==e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||zy(d,"size",{configurable:!0,get:function(){return l(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Ly.enable();return Gy(n,e,!1,!0),u[e]=n,Py({global:!0,forced:!0},u),o||r.setStrong(n,e,i),n},Jy=li,Qy=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:Jy(e,n,t[n],r);return e},Zy=Jt.f,$y=Gn,eg=Qy,tg=Yt,rg=mp,ng=z,ig=Uh,og=iu,ag=ou,sg=vp,cg=w,ug=dy.exports.fastKey,dg=Zi.set,lg=Zi.getterFor,hg={getConstructor:function(e,t,r,n){var i=e((function(e,i){rg(e,o),dg(e,{type:t,index:$y(null),first:void 0,last:void 0,size:0}),cg||(e.size=0),ng(i)||ig(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=lg(t),s=function(e,t,r){var n,i,o=a(e),s=c(e,t);return s?s.value=r:(o.last=s={index:i=ug(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),cg?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=ug(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return eg(o,{clear:function(){for(var e=a(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,cg?e.size=0:this.size=0},delete:function(e){var t=this,r=a(t),n=c(t,e);if(n){var i=n.next,o=n.previous;delete r.index[n.index],n.removed=!0,o&&(o.next=i),i&&(i.previous=o),r.first==n&&(r.first=i),r.last==n&&(r.last=o),cg?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=tg(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),eg(o,r?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),cg&&Zy(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=lg(t),o=lg(n);og(e,t,(function(e,t){dg(this,{type:n,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?ag("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,ag(void 0,!0))}),r?"entries":"values",!r,!0),sg(t)}};Yy("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hg);var pg=ee.Map,vg=Yt,fg=O,_g=Ce,mg=bp,yg=z,gg=Uh,Sg=[].push,bg=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return mg(this),(t=void 0!==a)&&_g(a),yg(e)?new this:(r=[],t?(n=0,i=vg(a,o>2?arguments[2]:void 0),gg(e,(function(e){fg(Sg,r,i(e,n++))}))):gg(e,Sg,{that:r}),new this(r))};Ar({target:"Map",stat:!0,forced:!0},{from:bg});var Eg=rs,kg=function(){return new this(Eg(arguments))};Ar({target:"Map",stat:!0,forced:!0},{of:kg});var Tg=O,Ig=Ce,Rg=tr,Ag=function(){for(var e,t=Rg(this),r=Ig(t.delete),n=!0,i=0,o=arguments.length;i<o;i++)e=Tg(r,t,arguments[i]),n=n&&e;return!!n};Ar({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:Ag});var wg=O,Cg=Ce,xg=tr,Og=function(e,t){var r,n,i=xg(this),o=Cg(i.get),a=Cg(i.has),s=Cg(i.set);return wg(a,i,e)?(r=wg(o,i,e),"update"in t&&(r=t.update(r,e,i),wg(s,i,e,r)),r):(n=t.insert(e,i),wg(s,i,e,n),n)};Ar({target:"Map",proto:!0,real:!0,forced:!0},{emplace:Og});var Mg=gh,Dg=tr,Pg=Yt,Ng=Mg,Lg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=Dg(this),r=Ng(t),n=Pg(e,arguments.length>1?arguments[1]:void 0);return!Lg(r,(function(e,r,i){if(!n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var Ug=oe,Vg=Yt,Fg=O,Bg=Ce,jg=tr,Hg=Rp,Gg=Mg,zg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=jg(this),r=Gg(t),n=Vg(e,arguments.length>1?arguments[1]:void 0),i=new(Hg(t,Ug("Map"))),o=Bg(i.set);return zg(r,(function(e,r){n(r,e,t)&&Fg(o,i,e,r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var Kg=tr,Xg=Yt,Wg=Mg,qg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=Kg(this),r=Wg(t),n=Xg(e,arguments.length>1?arguments[1]:void 0);return qg(r,(function(e,r,i){if(n(r,e,t))return i(r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var Yg=tr,Jg=Yt,Qg=Mg,Zg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=Yg(this),r=Qg(t),n=Jg(e,arguments.length>1?arguments[1]:void 0);return Zg(r,(function(e,r,i){if(n(r,e,t))return i(e)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $g=Ar,eS=O,tS=Ce,rS=gh,nS=Uh,iS=E([].push);$g({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){tS(t);var r=rS(e),n=new this,i=tS(n.has),o=tS(n.get),a=tS(n.set);return nS(r,(function(e){var r=t(e);eS(i,n,r)?iS(eS(o,n,r),e):eS(a,n,r,[e])}),{IS_ITERATOR:!0}),n}});var oS=tr,aS=Mg,sS=function(e,t){return e===t||e!=e&&t!=t},cS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return cS(aS(oS(this)),(function(t,r,n){if(sS(r,e))return n()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var uS=O,dS=Uh,lS=Ce;Ar({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new this;lS(t);var n=lS(r.set);return dS(e,(function(e){uS(n,r,t(e),e)})),r}});var hS=tr,pS=Mg,vS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){return vS(pS(hS(this)),(function(t,r,n){if(r===e)return n(t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var fS=oe,_S=Yt,mS=O,yS=Ce,gS=tr,SS=Rp,bS=Mg,ES=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=gS(this),r=bS(t),n=_S(e,arguments.length>1?arguments[1]:void 0),i=new(SS(t,fS("Map"))),o=yS(i.set);return ES(r,(function(e,r){mS(o,i,n(r,e,t),r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var kS=oe,TS=Yt,IS=O,RS=Ce,AS=tr,wS=Rp,CS=Mg,xS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=AS(this),r=CS(t),n=TS(e,arguments.length>1?arguments[1]:void 0),i=new(wS(t,kS("Map"))),o=RS(i.set);return xS(r,(function(e,r){IS(o,i,e,n(r,e,t))}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var OS=Ce,MS=tr,DS=Uh;Ar({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=MS(this),r=OS(t.set),n=arguments.length,i=0;i<n;)DS(arguments[i++],r,{that:t,AS_ENTRIES:!0});return t}});var PS=tr,NS=Ce,LS=Mg,US=Uh,VS=TypeError;Ar({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=PS(this),r=LS(t),n=arguments.length<2,i=n?void 0:arguments[1];if(NS(e),US(r,(function(r,o){n?(n=!1,i=o):i=e(i,o,r,t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),n)throw VS("Reduce of empty map with no initial value");return i}});var FS=tr,BS=Yt,jS=Mg,HS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=FS(this),r=jS(t),n=BS(e,arguments.length>1?arguments[1]:void 0);return HS(r,(function(e,r,i){if(n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var GS=O,zS=tr,KS=Ce,XS=TypeError;Ar({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=zS(this),n=KS(r.get),i=KS(r.has),o=KS(r.set),a=arguments.length;KS(t);var s=GS(i,r,e);if(!s&&a<3)throw XS("Updating absent value");var c=s?GS(n,r,e):KS(a>2?arguments[2]:void 0)(e,r);return GS(o,r,e,t(c,e,r)),r}});var WS=O,qS=Ce,YS=R,JS=tr,QS=TypeError,ZS=function(e,t){var r,n=JS(this),i=qS(n.get),o=qS(n.has),a=qS(n.set),s=arguments.length>2?arguments[2]:void 0;if(!YS(t)&&!YS(s))throw QS("At least one callback required");return WS(o,n,e)?(r=WS(i,n,e),YS(t)&&(r=t(r),WS(a,n,e,r))):YS(s)&&(r=s(),WS(a,n,e,r)),r};Ar({target:"Map",proto:!0,real:!0,forced:!0},{upsert:ZS}),Ar({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:ZS});var $S=pg,eb=Ce,tb=Xe,rb=G,nb=Br,ib=TypeError,ob=function(e){return function(t,r,n,i){eb(r);var o=tb(t),a=rb(o),s=nb(o),c=e?s-1:0,u=e?-1:1;if(n<2)for(;;){if(c in a){i=a[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw ib("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in a&&(i=r(i,a[c],c,o));return i}},ab={left:ob(!1),right:ob(!0)}.left,sb=ve,cb=up;Ar({target:"Array",proto:!0,forced:!Iu("reduce")||!cb&&sb>79&&sb<83},{reduce:function(e){var t=arguments.length;return ab(this,e,t,t>1?arguments[1]:void 0)}});var ub=Us("Array").reduce,db=ae,lb=ub,hb=Array.prototype,pb=function(e){var t=e.reduce;return e===hb||db(hb,e)&&t===hb.reduce?lb:t},vb=w,fb=E,_b=O,mb=i,yb=rn,gb=ui,Sb=M,bb=Xe,Eb=G,kb=Object.assign,Tb=Object.defineProperty,Ib=fb([].concat),Rb=!kb||mb((function(){if(vb&&1!==kb({b:1},kb(Tb({},"a",{enumerable:!0,get:function(){Tb(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=kb({},e)[r]||yb(kb({},t)).join("")!=n}))?function(e,t){for(var r=bb(e),n=arguments.length,i=1,o=gb.f,a=Sb.f;n>i;)for(var s,c=Eb(arguments[i++]),u=o?Ib(yb(c),o(c)):yb(c),d=u.length,l=0;d>l;)s=u[l++],vb&&!_b(a,c,s)||(r[s]=c[s]);return r}:kb,Ab=Rb;Ar({target:"Object",stat:!0,arity:2,forced:Object.assign!==Ab},{assign:Ab});var wb=ee.Object.assign,Cb=$,xb=g,Ob=lt("match"),Mb=function(e){var t;return Cb(e)&&(void 0!==(t=e[Ob])?!!t:"RegExp"==xb(e))},Db=TypeError,Pb=function(e){if(Mb(e))throw Db("The method doesn't accept regular expressions");return e},Nb=lt("match"),Lb=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Nb]=!1,"/./"[e](t)}catch(n){}}return!1},Ub=Ar,Vb=E;A.f;var Fb=Vr,Bb=yn,jb=Pb,Hb=W,Gb=Lb,zb=Vb("".endsWith),Kb=Vb("".slice),Xb=Math.min;Ub({target:"String",proto:!0,forced:!Gb("endsWith")},{endsWith:function(e){var t=Bb(Hb(this));jb(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:Xb(Fb(r),n),o=Bb(e);return zb?zb(t,o,i):Kb(t,i-o.length,i)===o}});var Wb=Us("String").endsWith,qb=ae,Yb=Wb,Jb=String.prototype,Qb=function(e){var t=e.endsWith;return"string"==typeof e||e===Jb||qb(Jb,e)&&t===Jb.endsWith?Yb:t},Zb=!0,$b=!0;function eE(e,t,r){var n=e.match(t);return n&&n.length>=r&&uy(n[r],10)}function tE(e,t,r){if(e.RTCPeerConnection){var n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);var o=function(e){var t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new $S),this._eventMap[t].set(n,o),i.apply(this,[e,o])};var o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);var n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===an(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},ad(n,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}}function rE(e){return"boolean"!=typeof e?new Error("Argument type: "+Wd(e)+". Please use a boolean."):(Zb=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function nE(e){return"boolean"!=typeof e?new Error("Argument type: "+Wd(e)+". Please use a boolean."):($b=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function iE(){if("object"===("undefined"==typeof window?"undefined":Wd(window))){if(Zb)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function oE(e,t){$b&&console.warn(e+" is deprecated, please use "+t+" instead.")}function aE(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var r=e.navigator;if(r.mozGetUserMedia)t.browser="firefox",t.version=eE(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=eE(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=eE(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function sE(e){return"[object Object]"===Object.prototype.toString.call(e)}function cE(e){var t;return sE(e)?pb(t=an(e)).call(t,(function(t,r){var n=sE(e[r]),i=n?cE(e[r]):e[r],o=n&&!an(i).length;return void 0===i||o?t:wb(t,Jd({},r,i))}),{}):e}function uE(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),an(t).forEach((function(n){Qb(n).call(n,"Id")?uE(e,e.get(t[n]),r):Qb(n).call(n,"Ids")&&t[n].forEach((function(t){uE(e,e.get(t),r)}))})))}function dE(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new $S;if(null===t)return i;var o=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((function(t){e.forEach((function(r){r.type===n&&r.trackId===t.id&&uE(e,r,i)}))})),i}var lE=Ar,hE=Po.find,pE="find",vE=!0;pE in[]&&Array(1).find((function(){vE=!1})),lE({target:"Array",proto:!0,forced:vE},{find:function(e){return hE(this,e,arguments.length>1?arguments[1]:void 0)}});var fE=Us("Array").find,_E=ae,mE=fE,yE=Array.prototype,gE=function(e){var t=e.find;return e===yE||_E(yE,e)&&t===yE.find?mE:t},SE=Ar,bE=Kr.indexOf,EE=Iu,kE=E([].indexOf),TE=!!kE&&1/kE([1],1,-0)<0,IE=EE("indexOf");SE({target:"Array",proto:!0,forced:TE||!IE},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return TE?kE(this,e,t)||0:bE(this,e,t)}});var RE=Us("Array").indexOf,AE=ae,wE=RE,CE=Array.prototype,xE=function(e){var t=e.indexOf;return e===CE||AE(CE,e)&&t===CE.indexOf?wE:t},OE=w,ME=eo,DE=TypeError,PE=Object.getOwnPropertyDescriptor,NE=OE&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(cq){return cq instanceof TypeError}}(),LE=Ie,UE=TypeError,VE=function(e,t){if(!delete e[t])throw UE("Cannot delete property "+LE(t)+" of "+LE(e))},FE=Ar,BE=Xe,jE=Nr,HE=Or,GE=Br,zE=NE?function(e,t){if(ME(e)&&!PE(e,"length").writable)throw DE("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},KE=cd,XE=Ro,WE=Qn,qE=VE,YE=Ps("splice"),JE=Math.max,QE=Math.min;FE({target:"Array",proto:!0,forced:!YE},{splice:function(e,t){var r,n,i,o,a,s,c=BE(this),u=GE(c),d=jE(e,u),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=u-d):(r=l-2,n=QE(JE(HE(t),0),u-d)),KE(u+r-n),i=XE(c,n),o=0;o<n;o++)(a=d+o)in c&&WE(i,o,c[a]);if(i.length=n,r<n){for(o=d;o<u-n;o++)s=o+r,(a=o+n)in c?c[s]=c[a]:qE(c,s);for(o=u;o>u-n+r;o--)qE(c,o-1)}else if(r>n)for(o=u-n;o>d;o--)s=o+r-1,(a=o+n-1)in c?c[s]=c[a]:qE(c,s);for(o=0;o<r;o++)c[o+d]=arguments[o+2];return zE(c,u-n+r),i}});var ZE=Us("Array").splice,$E=ae,ek=ZE,tk=Array.prototype,rk=function(e){var t=e.splice;return e===tk||$E(tk,e)&&t===tk.splice?ek:t},nk=Kr.includes;Ar({target:"Array",proto:!0,forced:i((function(){return!Array(1).includes()}))},{includes:function(e){return nk(this,e,arguments.length>1?arguments[1]:void 0)}});var ik=Us("Array").includes,ok=Ar,ak=Pb,sk=W,ck=yn,uk=Lb,dk=E("".indexOf);ok({target:"String",proto:!0,forced:!uk("includes")},{includes:function(e){return!!~dk(ck(sk(this)),ck(ak(e)),arguments.length>1?arguments[1]:void 0)}});var lk=Us("String").includes,hk=ae,pk=ik,vk=lk,fk=Array.prototype,_k=String.prototype,mk=function(e){var t=e.includes;return e===fk||hk(fk,e)&&t===fk.includes?pk:"string"==typeof e||e===_k||hk(_k,e)&&t===_k.includes?vk:t},yk=iE;function gk(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==Wd(e)||e.mandatory||e.optional)return e;var t,r={};(an(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===Wd(e[t])?e[t]:{ideal:e[t]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+km(t).call(t,1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){r.optional=r.optional||[];var o={};"number"==typeof n.ideal?(o[i("min",t)]=n.ideal,r.optional.push(o),(o={})[i("max",t)]=n.ideal,r.optional.push(o)):(o[i("",t)]=n.ideal,r.optional.push(o))}void 0!==n.exact&&"number"!=typeof n.exact?(r.mandatory=r.mandatory||{},r.mandatory[i("",t)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(r.mandatory=r.mandatory||{},r.mandatory[i(e,t)]=n[e])}))}})),e.advanced)&&(r.optional=Om(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(Nm(e)))&&"object"===Wd(e.audio)){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};o((e=JSON.parse(Nm(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===Wd(e.video)){var a=e.video.facingMode;a=a&&("object"===Wd(a)?a:{ideal:a});var s,c=t.version<66;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||c))if(delete e.video.facingMode,"environment"===a.exact||"environment"===a.ideal?s=["back","rear"]:"user"!==a.exact&&"user"!==a.ideal||(s=["front"]),s)return r.mediaDevices.enumerateDevices().then((function(t){t=Hs(t).call(t,(function(e){return"videoinput"===e.kind}));var r=gE(t).call(t,(function(e){return s.some((function(t){var r;return mk(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&mk(s).call(s,"back")&&(r=t[t.length-1]),r&&(e.video.deviceId=a.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=n(e.video),yk("chrome: "+Nm(e)),i(e)}));e.video=n(e.video)}return yk("chrome: "+Nm(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};if(r.getUserMedia=function(e,t,n){i(e,(function(e){r.webkitGetUserMedia(e,t,(function(e){n&&n(o(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){var a=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return a(e).then((function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach((function(e){e.stop()})),new DOMException("","NotFoundError");return t}),(function(e){return Y_.reject(o(e))}))}))}}}}function Sk(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function bk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){ad(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",(function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=gE(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.track.id})):i={track:n.track};var a=new Event("track");a.track=n.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)})),t.stream.getTracks().forEach((function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=gE(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.id})):i={track:n};var a=new Event("track");a.track=n,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else tE(e,"track",(function(e){return e.transceiver||ad(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function Ek(e){if("object"===Wd(e)&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){var e;return this._senders=this._senders||[],km(e=this._senders).call(e)};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t;n.apply(this,arguments);var r,i=xE(t=this._senders).call(t,e);-1!==i&&rk(r=this._senders).call(r,i,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((function(e){r._senders.push(t(r,e))}))};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach((function(e){var r,n,i,o=gE(r=t._senders).call(r,(function(t){return t.track===e}));o&&rk(n=t._senders).call(n,xE(i=t._senders).call(i,o),1)}))}}else if("object"===Wd(e)&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},ad(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function kk(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=km(Array.prototype).call(arguments),n=r[0],i=r[1],o=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var a=function(e){var t={};return e.result().forEach((function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){r[t]=e.stat(t)})),t[r.id]=r})),t},s=function(e){var t;return new $S(jm(t=an(e)).call(t,(function(t){return[t,e[t]]})))};if(arguments.length>=2){var c=function(e){i(s(a(e)))};return t.apply(this,[c,n])}return new Y_((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function Tk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return dE(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=n.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),tE(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return dE(t,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t,r,n,o=arguments[0];return this.getSenders().forEach((function(e){e.track===o&&(t?n=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===o&&(r?n=!0:r=e),e.track===o})),n||t&&r?Y_.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Y_.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function Ik(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},jm(e=an(this._shimmedLocalStreams)).call(e,(function(e){return t._shimmedLocalStreams[e][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var n;if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var i=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===xE(n=this._shimmedLocalStreams[r.id]).call(n,i)&&this._shimmedLocalStreams[r.id].push(i):this._shimmedLocalStreams[r.id]=[r,i],i};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t,n,i=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){var t;if(gE(t=i.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var o=this.getSenders();r.apply(this,arguments);var a=Hs(t=this.getSenders()).call(t,(function(e){return-1===xE(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Om(n=[e]).call(n,a)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&an(this._shimmedLocalStreams).forEach((function(r){var n,i,o=xE(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&rk(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function Rk(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Ik(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},jm(t).call(t,(function(t){return e._reverseStreams[t.id]}))};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){var t;if(gE(t=r.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,r){var n,i,o,a=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var s=km([]).call(arguments,1);if(1!==s.length||!gE(n=s[0].getTracks()).call(n,(function(e){return e===t})))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var c=gE(i=this.getSenders()).call(i,(function(e){return e.track===t}));if(c)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var u=this._streams[r.id];if(u)u.addTrack(t),Y_.resolve().then((function(){a.dispatchEvent(new Event("negotiationneeded"))}));else{var d=new e.MediaStream([t]);this._streams[r.id]=d,this._reverseStreams[d.id]=r,this.addStream(d)}return gE(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=s(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then((function(t){return s(e,t)}))}));e.RTCPeerConnection.prototype[t]=n[t]}));var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=c(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var a=tc(e.RTCPeerConnection.prototype,"localDescription");ad(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,r=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{},an(this._streams).forEach((function(n){var i;gE(i=r._streams[n].getTracks()).call(i,(function(t){return e.track===t}))&&(t=r._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function s(e,t){var r=t.sdp;return an(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}function c(e,t){var r=t.sdp;return an(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}}function Ak(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}))}function wk(e,t){tE(e,"negotiationneeded",(function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var Ck=Object.freeze(Object.defineProperty({__proto__:null,shimMediaStream:Sk,shimOnTrack:bk,shimGetSendersWithDtmf:Ek,shimGetStats:kk,shimSenderReceiverGetStats:Tk,shimAddTrackRemoveTrackWithNative:Ik,shimAddTrackRemoveTrack:Rk,shimPeerConnection:Ak,fixNegotiationNeeded:wk,shimGetUserMedia:gk,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then((function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}},Symbol.toStringTag,{value:"Module"}));Ar({target:"Array",stat:!0},{isArray:eo});var xk=ee.Array.isArray;function Ok(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Mk=hh,Dk=tr,Pk=kh,Nk=Yt,Lk=O,Uk=Xe,Vk=function(e,t,r,n){try{return n?t(Dk(r)[0],r[1]):t(r)}catch(cq){Pk(e,"throw",cq)}},Fk=ah,Bk=go,jk=Br,Hk=Qn,Gk=gh,zk=hh,Kk=Array,Xk=function(e){var t=Uk(e),r=Bk(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=Nk(i,n>2?arguments[2]:void 0));var a,s,c,u,d,l,h=zk(t),p=0;if(!h||this===Kk&&Fk(h))for(a=jk(t),s=r?new this(a):Kk(a);a>p;p++)l=o?i(t[p],p):t[p],Hk(s,p,l);else for(d=(u=Gk(t,h)).next,s=r?new this:[];!(c=Lk(d,u)).done;p++)l=o?Vk(u,i,[c.value,p],!0):c.value,Hk(s,p,l);return s.length=p,s},Wk=Xk;Ar({target:"Array",stat:!0,forced:!$f((function(e){Array.from(e)}))},{from:Wk});var qk=ee.Array.from;function Yk(e,t){var r;if(e){if("string"==typeof e)return Ok(e,t);var n=km(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?qk(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ok(e,t):void 0}}function Jk(e){return function(e){if(xk(e))return Ok(e)}(e)||function(e){if(void 0!==wd&&null!=Mk(e)||null!=e["@@iterator"])return qk(e)}(e)||Yk(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Qk=n,Zk=i,$k=yn,eT=Jm.trim,tT=E("".charAt),rT=Qk.parseFloat,nT=Qk.Symbol,iT=nT&&nT.iterator,oT=1/rT("\t\n\v\f\r                 \u2028\u2029\ufeff-0")!=-1/0||iT&&!Zk((function(){rT(Object(iT))}))?function(e){var t=eT($k(e)),r=rT(t);return 0===r&&"-"==tT(t,0)?-0:r}:rT;Ar({global:!0,forced:parseFloat!=oT},{parseFloat:oT});var aT=ee.parseFloat;function sT(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){oE("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},o=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===Wd(e)&&"object"===Wd(e.audio)&&(e=JSON.parse(Nm(e)),i(e.audio,"autoGainControl","mozAutoGainControl"),i(e.audio,"noiseSuppression","mozNoiseSuppression")),o(e)},n&&n.prototype.getSettings){var a=n.prototype.getSettings;n.prototype.getSettings=function(){var e=a.apply(this,arguments);return i(e,"mozAutoGainControl","autoGainControl"),i(e,"mozNoiseSuppression","noiseSuppression"),e}}if(n&&n.prototype.applyConstraints){var s=n.prototype.applyConstraints;n.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===Wd(e)&&(e=JSON.parse(Nm(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function cT(e){"object"===Wd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&ad(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function uT(e,t){if("object"===Wd(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}));var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=km(Array.prototype).call(arguments),i=e[0],o=e[1],a=e[2];return n.apply(this,[i||null]).then((function(e){if(t.version<53&&!o)try{e.forEach((function(e){e.type=r[e.type]||e.type}))}catch(n){if("TypeError"!==n.name)throw n;e.forEach((function(t,n){e.set(n,wb({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function dT(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Y_.resolve(new $S)}}}function lT(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r}),tE(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function hT(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;oE("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&mk(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function pT(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function vT(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]);var r=(e=Jk(e)).length>0;r&&e.forEach((function(e){if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(aT(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(aT(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));var n=t.apply(this,arguments);if(r){var i=n.sender,o=i.getParameters();(!("encodings"in o)||1===o.encodings.length&&0===an(o.encodings[0]).length)&&(o.encodings=e,i.sendEncodings=e,this.setParametersPromises.push(i.setParameters(o).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return n})}}function fT(e){if("object"===Wd(e)&&e.RTCRtpSender){var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e,r=t.apply(this,arguments);"encodings"in r||(r.encodings=Om(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function _T(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Y_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function mT(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Y_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var yT=Object.freeze(Object.defineProperty({__proto__:null,shimOnTrack:cT,shimPeerConnection:uT,shimSenderGetStats:dT,shimReceiverGetStats:lT,shimRemoveStream:hT,shimRTCDataChannel:pT,shimAddTransceiver:vT,shimGetParameters:fT,shimCreateOffer:_T,shimCreateAnswer:mT,shimGetUserMedia:sT,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Y_.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}},Symbol.toStringTag,{value:"Module"}));function gT(e){if("object"===Wd(e)&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r,n=this;this._localStreams||(this._localStreams=[]),mk(r=this._localStreams).call(r,e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(r){return t.call(n,r,e)})),e.getVideoTracks().forEach((function(r){return t.call(n,r,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i&&i.forEach((function(e){var t;r._localStreams?mk(t=r._localStreams).call(t,e)||r._localStreams.push(e):r._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t,r,n=this;this._localStreams||(this._localStreams=[]);var i=xE(t=this._localStreams).call(t,e);if(-1!==i){rk(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){mk(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function ST(e){if("object"===Wd(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){ad(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var t=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach((function(e){var r;if(t._remoteStreams||(t._remoteStreams=[]),!mk(r=t._remoteStreams).call(r,e)){t._remoteStreams.push(e);var n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}}))})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((function(t){var r;if(e._remoteStreams||(e._remoteStreams=[]),!(xE(r=e._remoteStreams).call(r,t)>=0)){e._remoteStreams.push(t);var n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}}))}),t.apply(e,arguments)}}}function bT(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Y_.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Y_.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),Y_.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Y_.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Y_.resolve()):n},t.addIceCandidate=s}}function ET(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(kT(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function kT(e){return e&&void 0!==e.video?wb({},e,{video:cE(e.video)}):e}function TT(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],i=0;i<e.iceServers.length;i++){var o=e.iceServers[i];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(oE("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(Nm(o))).urls=o.url,delete o.url,n.push(o)):n.push(e.iceServers[i])}e.iceServers=n}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&ad(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function IT(e){"object"===Wd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&ad(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function RT(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){var r,n;void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var i=gE(r=this.getTransceivers()).call(r,(function(e){return"audio"===e.receiver.track.kind}));!1===e.offerToReceiveAudio&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveAudio||i||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var o=gE(n=this.getTransceivers()).call(n,(function(e){return"video"===e.receiver.track.kind}));!1===e.offerToReceiveVideo&&o?"sendrecv"===o.direction?o.setDirection?o.setDirection("sendonly"):o.direction="sendonly":"recvonly"===o.direction&&(o.setDirection?o.setDirection("inactive"):o.direction="inactive"):!0!==e.offerToReceiveVideo||o||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function AT(e){"object"!==Wd(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var wT=Object.freeze(Object.defineProperty({__proto__:null,shimLocalStreamsAPI:gT,shimRemoteStreamsAPI:ST,shimCallbacksAPI:bT,shimGetUserMedia:ET,shimConstraints:kT,shimRTCIceServerUrls:TT,shimTrackEventTransceiver:IT,shimCreateOfferLegacy:RT,shimAudioContext:AT},Symbol.toStringTag,{value:"Module"})),CT=cc.PROPER,xT=i,OT=Hm,MT=Jm.trim;Ar({target:"String",proto:!0,forced:function(e){return xT((function(){return!!OT[e]()||"​…᠎"!=="​…᠎"[e]()||CT&&OT[e].name!==e}))}("trim")},{trim:function(){return MT(this)}});var DT,PT,NT=Us("String").trim,LT=ae,UT=NT,VT=String.prototype,FT=function(e){var t=e.trim;return"string"==typeof e||e===VT||LT(VT,e)&&t===VT.trim?UT:t},BT={exports:{}};DT=BT,(PT={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=PT.generateIdentifier(),PT.splitLines=function(e){var t;return jm(t=FT(e).call(e).split("\n")).call(t,(function(e){return FT(e).call(e)}))},PT.splitSections=function(e){var t=e.split("\nm=");return jm(t).call(t,(function(e,t){var r;return FT(r=t>0?"m="+e:e).call(r)+"\r\n"}))},PT.getDescription=function(e){var t=PT.splitSections(e);return t&&t[0]},PT.getMediaSections=function(e){var t=PT.splitSections(e);return t.shift(),t},PT.matchPrefix=function(e,t){var r;return Hs(r=PT.splitLines(e)).call(r,(function(e){return 0===xE(e).call(e,t)}))},PT.parseCandidate=function(e){for(var t,r={foundation:(t=0===xE(e).call(e,"a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:uy(t[3],10),ip:t[4],address:t[4],port:uy(t[5],10),type:t[7]},n=8;n<t.length;n+=2)switch(t[n]){case"raddr":r.relatedAddress=t[n+1];break;case"rport":r.relatedPort=uy(t[n+1],10);break;case"tcptype":r.tcpType=t[n+1];break;case"ufrag":r.ufrag=t[n+1],r.usernameFragment=t[n+1];break;default:void 0===r[t[n]]&&(r[t[n]]=t[n+1])}return r},PT.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(" ")},PT.parseIceOptions=function(e){return e.substr(14).split(" ")},PT.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:uy(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=uy(t[1],10),r.channels=3===t.length?uy(t[2],10):1,r.numChannels=r.channels,r},PT.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"},PT.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:uy(r[0],10),direction:xE(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},PT.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},PT.parseFmtp=function(e){for(var t,r={},n=e.substr(xE(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=FT(o=n[i]).call(o).split("="),r[FT(a=t[0]).call(a)]=t[1]}return r},PT.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},PT.parseRtcpFb=function(e){var t=e.substr(xE(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},PT.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},PT.parseSsrcMedia=function(e){var t=xE(e).call(e," "),r={ssrc:uy(e.substr(7,t-7),10)},n=xE(e).call(e,":",t);return n>-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},PT.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:jm(t).call(t,(function(e){return uy(e,10)}))}},PT.getMid=function(e){var t=PT.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},PT.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},PT.getDtlsParameters=function(e,t){var r=PT.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:jm(r).call(r,PT.parseFingerprint)}},PT.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},PT.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:uy(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:km(t).call(t,3)}},PT.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===Wd(e.keyParams)?PT.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},PT.parseCryptoKeyParams=function(e){if(0!==xE(e).call(e,"inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},PT.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},PT.getCryptoParameters=function(e,t){var r=PT.matchPrefix(e+t,"a=crypto:");return jm(r).call(r,PT.parseCryptoLine)},PT.getIceParameters=function(e,t){var r=PT.matchPrefix(e+t,"a=ice-ufrag:")[0],n=PT.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},PT.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},PT.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=PT.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=PT.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=PT.parseRtpMap(o),c=PT.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=c.length?PT.parseFmtp(c[0]):{},s.rtcpFeedback=jm(a=PT.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,PT.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return PT.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(PT.parseExtmap(e))})),t},PT.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=jm(r=t.codecs).call(r,(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach((function(e){n+=PT.writeRtpMap(e),n+=PT.writeFmtp(e),n+=PT.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+=PT.writeExtmap(e)})),n},PT.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],c=PT.parseRtpParameters(e),u=-1!==xE(t=c.fecMechanisms).call(t,"RED"),d=-1!==xE(r=c.fecMechanisms).call(r,"ULPFEC"),l=Hs(n=jm(i=PT.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return PT.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=l.length>0&&l[0].ssrc,p=jm(o=PT.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return jm(t).call(t,(function(e){return uy(e,10)}))}));p.length>0&&p[0].length>1&&p[0][0]===h&&(a=p[0][1]),c.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:h,codecPayloadType:uy(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),u&&((t=JSON.parse(Nm(t))).fec={ssrc:h,mechanism:d?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var v,f,_=PT.matchPrefix(e,"b=");return _.length&&(_=0===xE(v=_[0]).call(v,"b=TIAS:")?uy(_[0].substr(7),10):0===xE(f=_[0]).call(f,"b=AS:")?1e3*uy(_[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=_}))),s},PT.parseRtcpParameters=function(e){var t,r,n={},i=Hs(t=jm(r=PT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return PT.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=PT.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=PT.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},PT.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},PT.parseMsid=function(e){var t,r,n,i=PT.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=Hs(t=jm(r=PT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return PT.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},PT.parseSctpDescription=function(e){var t,r=PT.parseMLine(e),n=PT.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=uy(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=PT.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:uy(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=PT.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:uy(a[0],10),protocol:a[1],maxMessageSize:t}}},PT.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("")},PT.generateSessionId=function(){return Math.random().toString().substr(2,21)},PT.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||PT.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},PT.getDirection=function(e,t){for(var r=PT.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?PT.getDirection(t):"sendrecv"},PT.getKind=function(e){return PT.splitLines(e)[0].split(" ")[0].substr(2)},PT.isRejected=function(e){return"0"===e.split(" ",2)[1]},PT.parseMLine=function(e){var t=PT.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:uy(t[1],10),protocol:t[2],fmt:km(t).call(t,3).join(" ")}},PT.parseOLine=function(e){var t=PT.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:uy(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},PT.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=PT.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},DT.exports=PT;var jT=BT.exports,HT=e({__proto__:null,default:jT},[BT.exports]);function GT(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===Wd(e)&&e.candidate&&0===xE(r=e.candidate).call(r,"a=")&&((e=JSON.parse(Nm(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=jT.parseCandidate(e.candidate),o=wb(n,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,tE(e,"icecandidate",(function(t){return t.candidate&&ad(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function zT(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||tE(e,"icecandidate",(function(e){if(e.candidate){var t=jT.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function KT(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||ad(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=function(e){if(!e||!e.sdp)return!1;var t=jT.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=jT.parseMLine(e);return r&&"application"===r.kind&&-1!==xE(t=r.protocol).call(t,"SCTP")}))},n=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=uy(t[1],10);return r!=r?-1:r},i=function(e){var r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},o=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=jT.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=uy(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),s=e.sdpSemantics;"plan-b"===s&&ad(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){var c,u=n(arguments[0]),d=i(u),l=o(arguments[0],u);c=0===d&&0===l?Number.POSITIVE_INFINITY:0===d||0===l?Math.max(d,l):Math.min(d,l);var h={};ad(h,"maxMessageSize",{get:function(){return c}}),this._sctp=h}return a.apply(this,arguments)}}}function XT(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return r(e),e},tE(e,"datachannel",(function(e){return r(e.channel,e.target),e}))}function r(e,t){var r=e.send;e.send=function(){return r.apply(e,arguments)}}}function WT(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;ad(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),ad(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((function(e){var r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}}))}}function qT(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71||"safari"===t.browser&&t.version>=605)){var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){var n;if(t&&t.sdp&&-1!==xE(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=Hs(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==FT(e).call(e)})).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:o}):t.sdp=o}return r.apply(this,arguments)}}}function YT(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Y_.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Y_.resolve())})}}function JT(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.setLocalDescription;r&&0!==r.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this,t=arguments[0]||{};if("object"!==Wd(t)||t.type&&t.sdp)return r.apply(this,arguments);if(!(t={type:t.type,sdp:t.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":t.type="offer";break;default:t.type="answer"}if(t.sdp||"offer"!==t.type&&"answer"!==t.type)return r.apply(this,[t]);var n="offer"===t.type?this.createOffer:this.createAnswer;return n.apply(this).then((function(t){return r.apply(e,[t])}))})}}var QT=Object.freeze(Object.defineProperty({__proto__:null,shimRTCIceCandidate:GT,shimRTCIceCandidateRelayProtocol:zT,shimMaxMessageSize:KT,shimSendThrowTypeError:XT,shimConnectionState:WT,removeExtmapAllowMixed:qT,shimAddIceCandidateNullOrEmpty:YT,shimParameterlessSetLocalDescription:JT},Symbol.toStringTag,{value:"Module"}));if(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.window,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=iE,i=aE(t),o={browserDetails:i,commonShim:QT,extractVersion:eE,disableLog:rE,disableWarnings:nE,sdp:HT};switch(i.browser){case"chrome":if(!Ck||!Ak||!r.shimChrome)return n("Chrome shim is not included in this adapter release."),o;if(null===i.version)return n("Chrome shim can not determine version, not shimming."),o;n("adapter.js shimming chrome."),o.browserShim=Ck,YT(t,i),JT(t),gk(t,i),Sk(t),Ak(t,i),bk(t),Rk(t,i),Ek(t),kk(t),Tk(t),wk(t,i),GT(t),zT(t),WT(t),KT(t,i),XT(t),qT(t,i);break;case"firefox":if(!yT||!uT||!r.shimFirefox)return n("Firefox shim is not included in this adapter release."),o;n("adapter.js shimming firefox."),o.browserShim=yT,YT(t,i),JT(t),sT(t,i),uT(t,i),cT(t),hT(t),dT(t),lT(t),pT(t),vT(t),fT(t),_T(t),mT(t),GT(t),WT(t),KT(t,i),XT(t);break;case"safari":if(!wT||!r.shimSafari)return n("Safari shim is not included in this adapter release."),o;n("adapter.js shimming safari."),o.browserShim=wT,YT(t,i),JT(t),TT(t),RT(t),bT(t),gT(t),ST(t),IT(t),ET(t),AT(t),GT(t),zT(t),KT(t,i),XT(t),qT(t,i);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var ZT=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=ZT.call(this);return e.width&&(e.width=Math.floor(e.width)),e.height&&(e.height=Math.floor(e.height)),e.frameRate&&(e.frameRate=Math.floor(e.frameRate)),e}}function $T(e,t){var r=void 0!==wd&&Mk(e)||e["@@iterator"];if(!r){if(xk(e)||(r=Yk(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function eI(e,t){return function(e){if(xk(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==wd&&Mk(e)||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(d){u=!0,i=d}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||Yk(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tI(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var rI=Ye,nI=function(e){return void 0!==e&&(rI(e,"value")||rI(e,"writable"))},iI=O,oI=$,aI=tr,sI=nI,cI=A,uI=mc;Ar({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return aI(t)===o?t[r]:(n=cI.f(t,r))?sI(n)?n.value:void 0===n.get?void 0:iI(n.get,o):oI(i=uI(t))?e(i,r,o):void 0}});var dI=ee.Reflect.get,lI=E,hI=Ce,pI=$,vI=Ye,fI=rs,_I=o,mI=Function,yI=lI([].concat),gI=lI([].join),SI={},bI=function(e,t,r){if(!vI(SI,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";SI[t]=mI("C,a","return new C("+gI(n,",")+")")}return SI[t](e,r)},EI=_I?mI.bind:function(e){var t=hI(this),r=t.prototype,n=fI(arguments,1),i=function(){var r=yI(n,fI(arguments));return this instanceof i?bI(t,r.length,r):t.apply(e,r)};return pI(r)&&(i.prototype=r),i},kI=EI;Ar({target:"Function",proto:!0,forced:Function.bind!==kI},{bind:kI});var TI=Us("Function").bind,II=ae,RI=TI,AI=Function.prototype,wI=function(e){var t=e.bind;return e===AI||II(AI,e)&&t===AI.bind?RI:t};function CI(e){var t;return(CI=Kl?wI(t=zl).call(t):function(e){return e.__proto__||zl(e)})(e)}function xI(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=CI(e)););return e}function OI(){var e;"undefined"!=typeof Reflect&&dI?OI=wI(e=dI).call(e):OI=function(e,t,r){var n=xI(e,t);if(n){var i=tc(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return OI.apply(this,arguments)}function MI(e,t){var r;return(MI=Kl?wI(r=Kl).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function DI(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Bl(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),ad(e,"prototype",{writable:!1}),t&&MI(e,t)}var PI=Ar,NI=d,LI=EI,UI=bp,VI=tr,FI=$,BI=Gn,jI=i,HI=oe("Reflect","construct"),GI=Object.prototype,zI=[].push,KI=jI((function(){function e(){}return!(HI((function(){}),[],e)instanceof e)})),XI=!jI((function(){HI((function(){}))})),WI=KI||XI;PI({target:"Reflect",stat:!0,forced:WI,sham:WI},{construct:function(e,t){UI(e),VI(t);var r=arguments.length<3?e:UI(arguments[2]);if(XI&&!KI)return HI(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 NI(zI,n,t),new(NI(LI,e,n))}var i=r.prototype,o=BI(FI(i)?i:GI),a=NI(e,o,t);return FI(a)?a:o}});var qI=ee.Reflect.construct;function YI(){if("undefined"==typeof Reflect||!qI)return!1;if(qI.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(qI(Boolean,[],(function(){}))),!0}catch(e){return!1}}function JI(e,t){if(t&&("object"===Wd(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return tI(e)}function QI(e){var t=YI();return function(){var r,n=CI(e);if(t){var i=CI(this).constructor;r=qI(n,arguments,i)}else r=n.apply(this,arguments);return JI(this,r)}}var ZI=Us("Array").values,$I=fn,eR=Ye,tR=ae,rR=ZI,nR=Array.prototype,iR={DOMTokenList:!0,NodeList:!0},oR=function(e){var t=e.values;return e===nR||tR(nR,e)&&t===nR.values||eR(iR,$I(e))?rR:t},aR=ni,sR=Math.floor,cR=function(e,t){var r=e.length,n=sR(r/2);return r<8?uR(e,t):dR(e,cR(aR(e,0,n),t),cR(aR(e,n),t),t)},uR=function(e,t){for(var r,n,i=e.length,o=1;o<i;){for(n=o,r=e[o];n&&t(e[n-1],r)>0;)e[n]=e[--n];n!==o++&&(e[n]=r)}return e},dR=function(e,t,r,n){for(var i=t.length,o=r.length,a=0,s=0;a<i||s<o;)e[a+s]=a<i&&s<o?n(t[a],r[s])<=0?t[a++]:r[s++]:a<i?t[a++]:r[s++];return e},lR=cR,hR=se.match(/firefox\/(\d+)/i),pR=!!hR&&+hR[1],vR=/MSIE|Trident/.test(se),fR=se.match(/AppleWebKit\/(\d+)\./),_R=!!fR&&+fR[1],mR=Ar,yR=E,gR=Ce,SR=Xe,bR=Br,ER=VE,kR=yn,TR=i,IR=lR,RR=Iu,AR=pR,wR=vR,CR=ve,xR=_R,OR=[],MR=yR(OR.sort),DR=yR(OR.push),PR=TR((function(){OR.sort(void 0)})),NR=TR((function(){OR.sort(null)})),LR=RR("sort"),UR=!TR((function(){if(CR)return CR<70;if(!(AR&&AR>3)){if(wR)return!0;if(xR)return xR<603;var e,t,r,n,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(n=0;n<47;n++)OR.push({k:t+n,v:r})}for(OR.sort((function(e,t){return t.v-e.v})),n=0;n<OR.length;n++)t=OR[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));mR({target:"Array",proto:!0,forced:PR||!NR||!LR||!UR},{sort:function(e){void 0!==e&&gR(e);var t=SR(this);if(UR)return void 0===e?MR(t):MR(t,e);var r,n,i=[],o=bR(t);for(n=0;n<o;n++)n in t&&DR(i,t[n]);for(IR(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:kR(t)>kR(r)?1:-1}}(e)),r=bR(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)ER(t,n++);return t}});var VR=Us("Array").sort,FR=ae,BR=VR,jR=Array.prototype,HR=function(e){var t=e.sort;return e===jR||FR(jR,e)&&t===jR.sort?BR:t},GR=Ar,zR=Po.findIndex,KR="findIndex",XR=!0;KR in[]&&Array(1).findIndex((function(){XR=!1})),GR({target:"Array",proto:!0,forced:XR},{findIndex:function(e){return zR(this,e,arguments.length>1?arguments[1]:void 0)}});var WR=Us("Array").findIndex,qR=ae,YR=WR,JR=Array.prototype,QR=function(e){var t=e.findIndex;return e===JR||qR(JR,e)&&t===JR.findIndex?YR:t},ZR=Ar,$R=E;A.f;var eA=Vr,tA=yn,rA=Pb,nA=W,iA=Lb,oA=$R("".startsWith),aA=$R("".slice),sA=Math.min;ZR({target:"String",proto:!0,forced:!iA("startsWith")},{startsWith:function(e){var t=tA(nA(this));rA(e);var r=eA(sA(arguments.length>1?arguments[1]:void 0,t.length)),n=tA(e);return oA?oA(t,n,r):aA(t,r,r+n.length)===n}});var cA=Us("String").startsWith,uA=ae,dA=cA,lA=String.prototype,hA=function(e){var t=e.startsWith;return"string"==typeof e||e===lA||uA(lA,e)&&t===lA.startsWith?dA:t},pA=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.EXPIRED_TOKEN="EXPIRED_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_EXCEED_QPS="USER_MESSAGE_EXCEED_QPS",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e.SUBTITLE_ALREADY_ON="SUBTITLE_ALREADY_ON",e.SUBTITLE_NOT_TURNED_ON="SUBTITLE_NOT_TURNED_ON",e.SUBTITLE_ERR_POSTPROCESS="SUBTITLE_ERR_POSTPROCESS",e.SUBTITLE_ERR_CONNECTION_ERROR="SUBTITLE_ERR_CONNECTION_ERROR",e.SUBTITLE_ERR_PROCESS_ERROR="SUBTITLE_ERR_PROCESS_ERROR",e.SUBTITLE_ERR_UNKNOWN="SUBTITLE_ERR_UNKNOWN",e.UNEXPECTED_INVOKE_FORWARD_STREAM="UNEXPECTED_INVOKE_FORWARD_STREAM",e}(pA||{}),vA=function(e){return e[e.AUDIO_MIXING_ERROR_OK=0]="AUDIO_MIXING_ERROR_OK",e[e.AUDIO_MIXING_ERROR_PRELOAD_FAILED=1]="AUDIO_MIXING_ERROR_PRELOAD_FAILED",e[e.AUDIO_MIXING_ERROR_START_FAILED=2]="AUDIO_MIXING_ERROR_START_FAILED",e[e.AUDIO_MIXING_ERROR_ID_NOT_FOUND=3]="AUDIO_MIXING_ERROR_ID_NOT_FOUND",e[e.AUDIO_MIXING_ERROR_SET_POSITION_FAILED=4]="AUDIO_MIXING_ERROR_SET_POSITION_FAILED",e[e.AUDIO_MIXING_ERROR_INVALID_VOLUME=5]="AUDIO_MIXING_ERROR_INVALID_VOLUME",e[e.AUDIO_MIXING_ERROR_LOAD_CONFLICT=6]="AUDIO_MIXING_ERROR_LOAD_CONFLICT",e[e.AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH=7]="AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH",e[e.AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH=8]="AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH",e[e.AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK=9]="AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK",e}(vA||{});function fA(e,t,r){var n;YI()?fA=wI(n=qI).call(n):fA=function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(wI(Function).apply(e,n));return r&&MI(i,r.prototype),i};return fA.apply(null,arguments)}function _A(e){var t="function"==typeof $S?new $S:void 0;return _A=function(e){if(null===e||(r=e,-1===xE(n=Function.toString.call(r)).call(n,"[native code]")))return e;var r,n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return fA(e,arguments,CI(this).constructor)}return i.prototype=Bl(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),MI(i,e)},_A(e)}var mA=function(e){DI(r,e);var t=QI(r);function r(e,n,i){var o;return Vl(this,r),Jd(tI(o=t.call(this,n)),"code",void 0),Jd(tI(o),"message",void 0),Jd(tI(o),"error",void 0),o.code=e,o.message=n,o.error=i,Kl(tI(o),r.prototype),o}return Ul(r,[{key:"toString",value:function(){var e;return Om(e="SDKError: ".concat(this.code," ")).call(e,this.message)}}]),r}(_A(Error)),yA=w,gA=E,SA=rn,bA=J,EA=gA(M.f),kA=gA([].push),TA=function(e){return function(t){for(var r,n=bA(t),i=SA(n),o=i.length,a=0,s=[];o>a;)r=i[a++],yA&&!EA(n,r)||kA(s,e?[r,n[r]]:n[r]);return s}},IA={entries:TA(!0),values:TA(!1)}.entries;Ar({target:"Object",stat:!0},{entries:function(e){return IA(e)}});var RA=ee.Object.entries,AA=Or,wA=yn,CA=W,xA=RangeError,OA=E,MA=Vr,DA=yn,PA=function(e){var t=wA(CA(this)),r="",n=AA(e);if(n<0||n==1/0)throw xA("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},NA=W,LA=OA(PA),UA=OA("".slice),VA=Math.ceil,FA=function(e){return function(t,r,n){var i,o,a=DA(NA(t)),s=MA(r),c=a.length,u=void 0===n?" ":DA(n);return s<=c||""==u?a:((o=LA(u,VA((i=s-c)/u.length))).length>i&&(o=UA(o,0,i)),e?a+o:o+a)}},BA={start:FA(!1),end:FA(!0)},jA=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(se),HA=BA.end;Ar({target:"String",proto:!0,forced:jA},{padEnd:function(e){return HA(this,e,arguments.length>1?arguments[1]:void 0)}});var GA=Us("String").padEnd,zA=ae,KA=GA,XA=String.prototype,WA=function(e){var t=e.padEnd;return"string"==typeof e||e===XA||zA(XA,e)&&t===XA.padEnd?KA:t},qA=cy;Ar({target:"Number",stat:!0,forced:Number.parseInt!=qA},{parseInt:qA});var YA=ee.Number.parseInt,JA=Math.log,QA=Math.LOG10E;Ar({target:"Math",stat:!0},{log10:Math.log10||function(e){return JA(e)*QA}});var ZA,$A=ee.Math.log10,ew=Us("Array").keys,tw=fn,rw=Ye,nw=ae,iw=ew,ow=Array.prototype,aw={DOMTokenList:!0,NodeList:!0},sw=function(e){var t=e.keys;return e===ow||nw(ow,e)&&t===ow.keys||rw(aw,tw(e))?iw:t},cw=new Uint8Array(16);function uw(){if(!ZA&&!(ZA="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ZA(cw)}var dw=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function lw(e){return"string"==typeof e&&dw.test(e)}for(var hw=[],pw=0;pw<256;++pw)hw.push((pw+256).toString(16).substr(1));function vw(e,t,r){var n=(e=e||{}).random||(e.rng||uw)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(hw[e[t+0]]+hw[e[t+1]]+hw[e[t+2]]+hw[e[t+3]]+"-"+hw[e[t+4]]+hw[e[t+5]]+"-"+hw[e[t+6]]+hw[e[t+7]]+"-"+hw[e[t+8]]+hw[e[t+9]]+"-"+hw[e[t+10]]+hw[e[t+11]]+hw[e[t+12]]+hw[e[t+13]]+hw[e[t+14]]+hw[e[t+15]]).toLowerCase();if(!lw(r))throw TypeError("Stringified UUID is invalid");return r}(n)}var fw=function(){return"undefined"==typeof window},_w=function(){return vw()},mw=function(e){return"number"==typeof e},yw=function(e){var t;return mk(t=Function.prototype.toString.call(e)).call(t,"[native code]")},gw="@byted/ve-rtc",Sw="@byted/ve-rtc-cache-size",bw=function(){function e(){Vl(this,e),Jd(this,"storeKey",void 0),Jd(this,"logLevel",void 0),Jd(this,"LogfileSize",void 0),Jd(this,"db",void 0),Jd(this,"logId",void 0),Jd(this,"cacheLog",void 0),Jd(this,"cachedSize",void 0),Jd(this,"preCacheTime",void 0),Jd(this,"timer",void 0),Jd(this,"_getSize",(function(e){return new Blob(e).size/1048576})),this.storeKey="",this.logId=1,this.cacheLog="",this.logLevel="none",this.LogfileSize=100,this._createStore()}return Ul(e,[{key:"_createStore",value:function(){var e=this;if(!fw()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(gw);try{localStorage.removeItem(Sw)}catch(cq){}},t.onerror=function(e){},t.onsuccess=function(){e.db=t.result,e._getCachedSize()}}}},{key:"_getCachedSize",value:function(){var e=this;try{var t=localStorage.getItem(Sw);if(t)this.cachedSize=Number(t);else oR(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(cq){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(Sw,"".concat(this.cachedSize))}catch(cq){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(gw,e).objectStore(gw)}},{key:"set",value:function(e){var t=this;return new Y_((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Om(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,t.timer||(t.timer=setTimeout((function(){t.set("")}),1e3-(t.preCacheTime-Date.now()))),r();clearTimeout(t.timer),t.timer=null;var o=t._getStore("readwrite");if(!o)return n("get store fail");t.cachedSize&&t.cachedSize>t.LogfileSize&&t.keyEarliest().then((function(e){t.get(e).then((function(r){t.del(e).then((function(){t.cachedSize=t.cachedSize-t._getSize(["".concat(r)]),t._setCachedSize()}))}))}));var a=o.get(t.storeKey);a.onsuccess=function(){try{var i,s,c,u,d,l=Om(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Om(s=Om(c="".concat(l?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(Om(u="".concat(l)).call(u,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Om(d="".concat(t.cacheLog)).call(d,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(v){var p;if(!e)return n(v);t.cacheLog+=Om(p="\n\n".concat(t.logId,": ")).call(p,e),t.logId++,n(v)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Om(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new Y_((function(r,n){var i=t._getStore("readonly");if(!i)return n();var o=i.get(e);o.onsuccess=function(){r(o.result)},o.onerror=function(e){n(e)}}))}},{key:"del",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.storeKey;return new Y_((function(r,n){var i=e._getStore("readwrite");if(!i)return n();var o=i.delete(t);o.onsuccess=function(){return r(o.result)},o.onerror=function(e){return n(e)}}))}},{key:"keyEarliest",value:function(){return sw(this).call(this).then((function(e){var t,r=Date.now();return e.forEach((function(e){if(e&&e.length){var n=e.split("-")[0];Number(n)<r&&(r=Number(n),t=e)}})),t}))}},{key:"keys",value:function(){var e=this;return new Y_((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAllKeys){var i=n.getAllKeys();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.key),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"values",value:function(){var e=this;return new Y_((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAll){var i=n.getAll();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.value),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"download",value:function(e){e=e||this.storeKey,this.get(e).then((function(t){var r=document.createElement("a");r.download="".concat(e,".txt"),r.href="data:text/paint;utf-8,".concat(t||""),r.click()}))}}]),e}(),Ew=new bw,kw=BA.start;Ar({target:"String",proto:!0,forced:jA},{padStart:function(e){return kw(this,e,arguments.length>1?arguments[1]:void 0)}});var Tw,Iw,Rw=Us("String").padStart,Aw=ae,ww=Rw,Cw=String.prototype,xw=function(e){var t=e.padStart;return"string"==typeof e||e===Cw||Aw(Cw,e)&&t===Cw.padStart?ww:t},Ow="[VERTC]",Mw="#0050b3",Dw=(Jd(Tw={},"DEBUG","rgba(0, 0, 0, 0)"),Jd(Tw," INFO","rgba(93, 173, 226, 0)"),Jd(Tw," WARN","rgba(255, 119, 0, 0.3)"),Jd(Tw,"ERROR","rgba(255, 0, 0, 0.3)"),Jd(Tw," SUCC","rgba(0, 119, 0, 0.3)"),Tw),Pw="undefined"!=typeof window&&mk(Iw=window.location.search).call(Iw,"_rtc_debug_"),Nw=function(){function e(t,r){Vl(this,e),Jd(this,"indent",void 0),Jd(this,"module",void 0),this.module=t,this.indent=r}return Ul(e,[{key:"log",value:function(e,t){for(var r,n,i,o,a,s,c,u,d=arguments.length,l=new Array(d>2?d-2:0),h=2;h<d;h++)l[h-2]=arguments[h];var p=l.shift();try{var v,f,_,m,y=Om(v=[]).call(v,l),g="".concat(p).replace(/%o/gi,(function(){var e=y.shift();return Nm(e)}));Ew.set(Om(f=Om(_=Om(m="".concat(Ow,"[").concat(this.module,".")).call(m,t,"] ")).call(_,g," ")).call(f,jm(y).call(y,(function(e){return Nm(e)})).join(", ")))}catch(cq){}if(Pw){for(var S="",b=0;b<this.indent;b++)S+=" ";(r=console).log.apply(r,Om(n=[Om(i=Om(o=Om(a=Om(s=Om(c=Om(u="%c".concat(Lw(),"-")).call(u,Ow,"%c[")).call(c,e,"]%c")).call(s,S,"[")).call(a,this.module,".")).call(o,t,"] ")).call(i,p),"color:".concat(Mw,";"),"background-color:".concat(Dw[e],";"),"color:".concat(Mw,";")]).call(n,l))}}},{key:"print",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" INFO",e]).call(t,n))}},{key:"debug",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=["DEBUG",e]).call(t,n))}},{key:"info",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" INFO",e]).call(t,n))}},{key:"warn",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" WARN",e]).call(t,n))}},{key:"error",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=["ERROR",e]).call(t,n))}},{key:"success",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" SUCC",e]).call(t,n))}}]),e}(),Lw=function(){var e,t,r=new Date;return Om(e="".concat(r.toTimeString().split(" ")[0],":")).call(e,xw(t=r.getMilliseconds().toString()).call(t,3,"0"))},Uw={};!function(e){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=km(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==Wd(n))throw new TypeError(n+"must be non-object");for(var i in n)r(n,i)&&(e[i]=n[i])}}return e},e.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){var t,r,n,i,o,a;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),i=0,t=0,r=e.length;t<r;t++)o=e[t],a.set(o,i),i+=o.length;return a}},i={arraySet:function(e,t,r,n,i){for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){return Om([]).apply([],e)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,n)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,i))},e.setTyped(t)}(Uw);var Vw={},Fw={},Bw={},jw=Uw;function Hw(e){for(var t=e.length;--t>=0;)e[t]=0}var Gw=256,zw=286,Kw=30,Xw=15,Ww=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],qw=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Yw=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Jw=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Qw=new Array(576);Hw(Qw);var Zw=new Array(60);Hw(Zw);var $w=new Array(512);Hw($w);var eC=new Array(256);Hw(eC);var tC=new Array(29);Hw(tC);var rC,nC,iC,oC=new Array(Kw);function aC(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function sC(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function cC(e){return e<256?$w[e]:$w[256+(e>>>7)]}function uC(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function dC(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,uC(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function lC(e,t,r){dC(e,r[2*t],r[2*t+1])}function hC(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function pC(e,t,r){var n,i,o=new Array(16),a=0;for(n=1;n<=Xw;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=hC(o[s]++,s))}}function vC(e){var t;for(t=0;t<zw;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Kw;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function fC(e){e.bi_valid>8?uC(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function _C(e,t,r,n){var i=2*t,o=2*r;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]}function mC(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&_C(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!_C(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function yC(e,t,r){var n,i,o,a,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?lC(e,i,t):(lC(e,(o=eC[i])+Gw+1,t),0!==(a=Ww[o])&&dC(e,i-=tC[o],a),lC(e,o=cC(--n),r),0!==(a=qw[o])&&dC(e,n-=oC[o],a))}while(s<e.last_lit);lC(e,256,t)}function gC(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<c;r++)0!==o[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)mC(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],mC(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,mC(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,a,s,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,v=t.stat_desc.max_length,f=0;for(o=0;o<=Xw;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>v&&(o=v,f++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),s=c[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(d[2*n+1]+a)));if(0!==f){do{for(o=v-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[v]--,f-=2}while(f>0);for(o=v;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}}(e,t),pC(o,u,e.bl_count)}function SC(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<c&&i===a||(s<u?e.bl_tree[2*i]+=s:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function bC(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<c&&i===a)){if(s<u)do{lC(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(lC(e,i,e.bl_tree),s--),lC(e,16,e.bl_tree),dC(e,s-3,2)):s<=10?(lC(e,17,e.bl_tree),dC(e,s-3,3)):(lC(e,18,e.bl_tree),dC(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}Hw(oC);var EC=!1;function kC(e,t,r,n){dC(e,0+(n?1:0),3),function(e,t,r,n){fC(e),n&&(uC(e,r),uC(e,~r)),jw.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}Bw._tr_init=function(e){EC||(!function(){var e,t,r,n,i,o=new Array(16);for(r=0,n=0;n<28;n++)for(tC[n]=r,e=0;e<1<<Ww[n];e++)eC[r++]=n;for(eC[r-1]=n,i=0,n=0;n<16;n++)for(oC[n]=i,e=0;e<1<<qw[n];e++)$w[i++]=n;for(i>>=7;n<Kw;n++)for(oC[n]=i<<7,e=0;e<1<<qw[n]-7;e++)$w[256+i++]=n;for(t=0;t<=Xw;t++)o[t]=0;for(e=0;e<=143;)Qw[2*e+1]=8,e++,o[8]++;for(;e<=255;)Qw[2*e+1]=9,e++,o[9]++;for(;e<=279;)Qw[2*e+1]=7,e++,o[7]++;for(;e<=287;)Qw[2*e+1]=8,e++,o[8]++;for(pC(Qw,287,o),e=0;e<Kw;e++)Zw[2*e+1]=5,Zw[2*e]=hC(e,5);rC=new aC(Qw,Ww,257,zw,Xw),nC=new aC(Zw,qw,0,Kw,Xw),iC=new aC(new Array(0),Yw,0,19,7)}(),EC=!0),e.l_desc=new sC(e.dyn_ltree,rC),e.d_desc=new sC(e.dyn_dtree,nC),e.bl_desc=new sC(e.bl_tree,iC),e.bi_buf=0,e.bi_valid=0,vC(e)},Bw._tr_stored_block=kC,Bw._tr_flush_block=function(e,t,r,n){var i,o,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<Gw;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),gC(e,e.l_desc),gC(e,e.d_desc),a=function(e){var t;for(SC(e,e.dyn_ltree,e.l_desc.max_code),SC(e,e.dyn_dtree,e.d_desc.max_code),gC(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Jw[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?kC(e,t,r,n):4===e.strategy||o===i?(dC(e,2+(n?1:0),3),yC(e,Qw,Zw)):(dC(e,4+(n?1:0),3),function(e,t,r,n){var i;for(dC(e,t-257,5),dC(e,r-1,5),dC(e,n-4,4),i=0;i<n;i++)dC(e,e.bl_tree[2*Jw[i]+1],3);bC(e,e.dyn_ltree,t-1),bC(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),yC(e,e.dyn_ltree,e.dyn_dtree)),vC(e),n&&fC(e)},Bw._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(eC[r]+Gw+1)]++,e.dyn_dtree[2*cC(t)]++),e.last_lit===e.lit_bufsize-1},Bw._tr_align=function(e){dC(e,2,3),lC(e,256,Qw),function(e){16===e.bi_valid?(uC(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)};var TC=function(e,t,r,n){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16|0};var IC=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();var RC,AC=function(e,t,r,n){var i=IC,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},wC={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},CC=Uw,xC=Bw,OC=TC,MC=AC,DC=wC,PC=-2,NC=258,LC=262,UC=103,VC=113,FC=666;function BC(e,t){return e.msg=DC[t],t}function jC(e){return(e<<1)-(e>4?9:0)}function HC(e){for(var t=e.length;--t>=0;)e[t]=0}function GC(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(CC.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function zC(e,t){xC._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,GC(e.strm)}function KC(e,t){e.pending_buf[e.pending++]=t}function XC(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function WC(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-LC?e.strstart-(e.w_size-LC):0,u=e.window,d=e.w_mask,l=e.prev,h=e.strstart+NC,p=u[o+a-1],v=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===v&&u[r+a-1]===p&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<h);if(n=NC-(h-o),o=h-NC,n>a){if(e.match_start=t,a=n,n>=s)break;p=u[o+a-1],v=u[o+a]}}}while((t=l[t&d])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function qC(e){var t,r,n,i,o,a,s,c,u,d,l=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=l+(l-LC)){CC.arraySet(e.window,e.window,l,l,0),e.match_start-=l,e.strstart-=l,e.block_start-=l,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=l?n-l:0}while(--r);t=r=l;do{n=e.prev[--t],e.prev[t]=n>=l?n-l:0}while(--r);i+=l}if(0===e.strm.avail_in)break;if(a=e.strm,s=e.window,c=e.strstart+e.lookahead,u=i,d=void 0,(d=a.avail_in)>u&&(d=u),r=0===d?0:(a.avail_in-=d,CC.arraySet(s,a.input,a.next_in,d,c),1===a.state.wrap?a.adler=OC(a.adler,s,d,c):2===a.state.wrap&&(a.adler=MC(a.adler,s,d,c)),a.next_in+=d,a.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+3-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<LC&&0!==e.strm.avail_in)}function YC(e,t){for(var r,n;;){if(e.lookahead<LC){if(qC(e),e.lookahead<LC&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-LC&&(e.match_length=WC(e,r)),e.match_length>=3)if(n=xC._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=xC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}function JC(e,t){for(var r,n,i;;){if(e.lookahead<LC){if(qC(e),e.lookahead<LC&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-LC&&(e.match_length=WC(e,r),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=xC._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(zC(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=xC._tr_tally(e,0,e.window[e.strstart-1]))&&zC(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=xC._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}function QC(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function ZC(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new CC.Buf16(1146),this.dyn_dtree=new CC.Buf16(122),this.bl_tree=new CC.Buf16(78),HC(this.dyn_ltree),HC(this.dyn_dtree),HC(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new CC.Buf16(16),this.heap=new CC.Buf16(573),HC(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new CC.Buf16(573),HC(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function $C(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:VC,e.adler=2===t.wrap?0:1,t.last_flush=0,xC._tr_init(t),0):BC(e,PC)}function ex(e){var t,r=$C(e);return 0===r&&((t=e.state).window_size=2*t.w_size,HC(t.head),t.max_lazy_match=RC[t.level].max_lazy,t.good_match=RC[t.level].good_length,t.nice_match=RC[t.level].nice_length,t.max_chain_length=RC[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),r}function tx(e,t,r,n,i,o){if(!e)return PC;var a=1;if(-1===t&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>9||8!==r||n<8||n>15||t<0||t>9||o<0||o>4)return BC(e,PC);8===n&&(n=9);var s=new ZC;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+3-1)/3),s.window=new CC.Buf8(2*s.w_size),s.head=new CC.Buf16(s.hash_size),s.prev=new CC.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new CC.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=r,ex(e)}RC=[new QC(0,0,0,0,(function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(qC(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,zC(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-LC&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(zC(e,!1),e.strm.avail_out),1)})),new QC(4,4,8,4,YC),new QC(4,5,16,8,YC),new QC(4,6,32,32,YC),new QC(4,4,16,16,JC),new QC(8,16,32,32,JC),new QC(8,16,128,128,JC),new QC(8,32,128,256,JC),new QC(32,128,258,1024,JC),new QC(32,258,258,4096,JC)],Fw.deflateInit=function(e,t){return tx(e,t,8,15,8,0)},Fw.deflateInit2=tx,Fw.deflateReset=ex,Fw.deflateResetKeep=$C,Fw.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?PC:(e.state.gzhead=t,0):PC},Fw.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?BC(e,PC):PC;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===FC&&4!==t)return BC(e,0===e.avail_out?-5:PC);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,KC(n,31),KC(n,139),KC(n,8),n.gzhead?(KC(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),KC(n,255&n.gzhead.time),KC(n,n.gzhead.time>>8&255),KC(n,n.gzhead.time>>16&255),KC(n,n.gzhead.time>>24&255),KC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),KC(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(KC(n,255&n.gzhead.extra.length),KC(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=MC(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(KC(n,0),KC(n,0),KC(n,0),KC(n,0),KC(n,0),KC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),KC(n,3),n.status=VC);else{var a=8+(n.w_bits-8<<4)<<8;a|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=VC,XC(n,a),0!==n.strstart&&(XC(n,e.adler>>>16),XC(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=MC(e.adler,n.pending_buf,n.pending-i,i)),GC(e),i=n.pending,n.pending!==n.pending_buf_size));)KC(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=MC(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=MC(e.adler,n.pending_buf,n.pending-i,i)),GC(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,KC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=MC(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=MC(e.adler,n.pending_buf,n.pending-i,i)),GC(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,KC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=MC(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=UC)}else n.status=UC;if(n.status===UC&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&GC(e),n.pending+2<=n.pending_buf_size&&(KC(n,255&e.adler),KC(n,e.adler>>8&255),e.adler=0,n.status=VC)):n.status=VC),0!==n.pending){if(GC(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&jC(t)<=jC(r)&&4!==t)return BC(e,-5);if(n.status===FC&&0!==e.avail_in)return BC(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==FC){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(qC(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=xC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=NC){if(qC(e),e.lookahead<=NC&&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+NC;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=NC-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=xC._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=xC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}(n,t):RC[n.level].func(n,t);if(3!==s&&4!==s||(n.status=FC),1===s||3===s)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===s&&(1===t?xC._tr_align(n):5!==t&&(xC._tr_stored_block(n,0,0,!1),3===t&&(HC(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),GC(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(KC(n,255&e.adler),KC(n,e.adler>>8&255),KC(n,e.adler>>16&255),KC(n,e.adler>>24&255),KC(n,255&e.total_in),KC(n,e.total_in>>8&255),KC(n,e.total_in>>16&255),KC(n,e.total_in>>24&255)):(XC(n,e.adler>>>16),XC(n,65535&e.adler)),GC(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},Fw.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==UC&&t!==VC&&t!==FC?BC(e,PC):(e.state=null,t===VC?BC(e,-3):0):PC},Fw.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,d=t.length;if(!e||!e.state)return PC;if(2===(o=(r=e.state).wrap)||1===o&&42!==r.status||r.lookahead)return PC;for(1===o&&(e.adler=OC(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(HC(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new CC.Buf8(r.w_size),CC.arraySet(u,t,d-r.w_size,r.w_size,0),t=u,d=r.w_size),a=e.avail_in,s=e.next_in,c=e.input,e.avail_in=d,e.next_in=0,e.input=t,qC(r);r.lookahead>=3;){n=r.strstart,i=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--i);r.strstart=n,r.lookahead=2,qC(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,0},Fw.deflateInfo="pako deflate (from Nodeca project)";var rx={},nx=Uw,ix=!0,ox=!0;try{String.fromCharCode.apply(null,[0])}catch(uq){ix=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(uq){ox=!1}for(var ax=new nx.Buf8(256),sx=0;sx<256;sx++)ax[sx]=sx>=252?6:sx>=248?5:sx>=240?4:sx>=224?3:sx>=192?2:1;function cx(e,t){if(t<65534&&(e.subarray&&ox||!e.subarray&&ix))return String.fromCharCode.apply(null,nx.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}ax[254]=ax[254]=1,rx.string2buf=function(e){var t,r,n,i,o,a=e.length,s=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new nx.Buf8(s),o=0,i=0;o<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},rx.buf2binstring=function(e){return cx(e,e.length)},rx.binstring2buf=function(e){for(var t=new nx.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},rx.buf2string=function(e,t){var r,n,i,o,a=t||e.length,s=new Array(2*a);for(n=0,r=0;r<a;)if((i=e[r++])<128)s[n++]=i;else if((o=ax[i])>4)s[n++]=65533,r+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&r<a;)i=i<<6|63&e[r++],o--;o>1?s[n++]=65533:i<65536?s[n++]=i:(i-=65536,s[n++]=55296|i>>10&1023,s[n++]=56320|1023&i)}return cx(s,n)},rx.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+ax[e[r]]>t?r:t};var ux=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},dx=Fw,lx=Uw,hx=rx,px=wC,vx=ux,fx=Object.prototype.toString;function _x(e){if(!(this instanceof _x))return new _x(e);this.options=lx.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new vx,this.strm.avail_out=0;var r=dx.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==r)throw new Error(px[r]);if(t.header&&dx.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?hx.string2buf(t.dictionary):"[object ArrayBuffer]"===fx.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=dx.deflateSetDictionary(this.strm,n)))throw new Error(px[r]);this._dict_set=!0}}function mx(e,t){var r=new _x(t);if(r.push(e,!0),r.err)throw r.msg||px[r.err];return r.result}_x.prototype.push=function(e,t){var r,n,i=this.strm,o=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=hx.string2buf(e):"[object ArrayBuffer]"===fx.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new lx.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=dx.deflate(i,n))&&0!==r)return this.onEnd(r),this.ended=!0,!1;0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(hx.buf2binstring(lx.shrinkBuf(i.output,i.next_out))):this.onData(lx.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=dx.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==n||(this.onEnd(0),i.avail_out=0,!0)},_x.prototype.onData=function(e){this.chunks.push(e)},_x.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=lx.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},Vw.Deflate=_x,Vw.deflate=mx,Vw.deflateRaw=function(e,t){return(t=t||{}).raw=!0,mx(e,t)},Vw.gzip=function(e,t){return(t=t||{}).gzip=!0,mx(e,t)};var yx={},gx=tr,Sx=O,bx=Ye,Ex=ae,kx=function(){var e=gx(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Tx=RegExp.prototype,Ix=ae,Rx=function(e){var t=e.flags;return void 0!==t||"flags"in Tx||bx(e,"flags")||!Ex(Tx,e)?t:Sx(kx,e)},Ax=RegExp.prototype,wx=function(e){return e===Ax||Ix(Ax,e)?Rx(e):e.flags},Cx={},xx=Uw,Ox=15,Mx=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Dx=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Px=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],Nx=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],Lx=Uw,Ux=TC,Vx=AC,Fx=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,R=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,u=r.wsize,d=r.whave,l=r.wnext,h=r.window,p=r.hold,v=r.bits,f=r.lencode,_=r.distcode,m=(1<<r.lenbits)-1,y=(1<<r.distbits)-1;e:do{v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),g=f[p&m];t:for(;;){if(p>>>=S=g>>>24,v-=S,0===(S=g>>>16&255))R[o++]=65535&g;else{if(!(16&S)){if(0==(64&S)){g=f[(65535&g)+(p&(1<<S)-1)];continue t}if(32&S){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=65535&g,(S&=15)&&(v<S&&(p+=I[n++]<<v,v+=8),b+=p&(1<<S)-1,p>>>=S,v-=S),v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),g=_[p&y];r:for(;;){if(p>>>=S=g>>>24,v-=S,!(16&(S=g>>>16&255))){if(0==(64&S)){g=_[(65535&g)+(p&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(E=65535&g,v<(S&=15)&&(p+=I[n++]<<v,(v+=8)<S&&(p+=I[n++]<<v,v+=8)),(E+=p&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(p>>>=S,v-=S,E>(S=o-a)){if((S=E-S)>d&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(k=0,T=h,0===l){if(k+=u-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}else if(l<S){if(k+=u+l-S,(S-=l)<b){b-=S;do{R[o++]=h[k++]}while(--S);if(k=0,l<b){b-=S=l;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}}else if(k+=l-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}for(;b>2;)R[o++]=T[k++],R[o++]=T[k++],R[o++]=T[k++],b-=3;b&&(R[o++]=T[k++],b>1&&(R[o++]=T[k++]))}else{k=o-E;do{R[o++]=R[k++],R[o++]=R[k++],R[o++]=R[k++],b-=3}while(b>2);b&&(R[o++]=R[k++],b>1&&(R[o++]=R[k++]))}break}}break}}while(n<i&&o<s);n-=b=v>>3,p&=(1<<(v-=b<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<s?s-o+257:257-(o-s),r.hold=p,r.bits=v},Bx=function(e,t,r,n,i,o,a,s){var c,u,d,l,h,p,v,f,_,m=s.bits,y=0,g=0,S=0,b=0,E=0,k=0,T=0,I=0,R=0,A=0,w=null,C=0,x=new xx.Buf16(16),O=new xx.Buf16(16),M=null,D=0;for(y=0;y<=Ox;y++)x[y]=0;for(g=0;g<n;g++)x[t[r+g]]++;for(E=m,b=Ox;b>=1&&0===x[b];b--);if(E>b&&(E=b),0===b)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<b&&0===x[S];S++);for(E<S&&(E=S),I=1,y=1;y<=Ox;y++)if(I<<=1,(I-=x[y])<0)return-1;if(I>0&&(0===e||1!==b))return-1;for(O[1]=0,y=1;y<Ox;y++)O[y+1]=O[y]+x[y];for(g=0;g<n;g++)0!==t[r+g]&&(a[O[t[r+g]]++]=g);if(0===e?(w=M=a,p=19):1===e?(w=Mx,C-=257,M=Dx,D-=257,p=256):(w=Px,M=Nx,p=-1),A=0,g=0,y=S,h=o,k=E,T=0,d=-1,l=(R=1<<E)-1,1===e&&R>852||2===e&&R>592)return 1;for(;;){v=y-T,a[g]<p?(f=0,_=a[g]):a[g]>p?(f=M[D+a[g]],_=w[C+a[g]]):(f=96,_=0),c=1<<y-T,S=u=1<<k;do{i[h+(A>>T)+(u-=c)]=v<<24|f<<16|_|0}while(0!==u);for(c=1<<y-1;A&c;)c>>=1;if(0!==c?(A&=c-1,A+=c):A=0,g++,0==--x[y]){if(y===b)break;y=t[r+a[g]]}if(y>E&&(A&l)!==d){for(0===T&&(T=E),h+=S,I=1<<(k=y-T);k+T<b&&!((I-=x[k+T])<=0);)k++,I<<=1;if(R+=1<<k,1===e&&R>852||2===e&&R>592)return 1;i[d=A&l]=E<<24|k<<16|h-o|0}}return 0!==A&&(i[h+A]=y-T<<24|64<<16|0),s.bits=E,0},jx=-2,Hx=12,Gx=30;function zx(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function Kx(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Lx.Buf16(320),this.work=new Lx.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Xx(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Lx.Buf32(852),t.distcode=t.distdyn=new Lx.Buf32(592),t.sane=1,t.back=-1,0):jx}function Wx(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,Xx(e)):jx}function qx(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?jx:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,Wx(e))):jx}function Yx(e,t){var r,n;return e?(n=new Kx,e.state=n,n.window=null,0!==(r=qx(e,t))&&(e.state=null),r):jx}var Jx,Qx,Zx=!0;function $x(e){if(Zx){var t;for(Jx=new Lx.Buf32(512),Qx=new Lx.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Bx(1,e.lens,0,288,Jx,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Bx(2,e.lens,0,32,Qx,0,e.work,{bits:5}),Zx=!1}e.lencode=Jx,e.lenbits=9,e.distcode=Qx,e.distbits=5}function eO(e,t,r,n){var i,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Lx.Buf8(o.wsize)),n>=o.wsize?(Lx.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((i=o.wsize-o.wnext)>n&&(i=n),Lx.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(Lx.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0}Cx.inflateReset=Wx,Cx.inflateReset2=qx,Cx.inflateResetKeep=Xx,Cx.inflateInit=function(e){return Yx(e,15)},Cx.inflateInit2=Yx,Cx.inflate=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R=0,A=new Lx.Buf8(4),w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return jx;(r=e.state).mode===Hx&&(r.mode=13),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,l=s,h=c,k=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(2&r.wrap&&35615===u){r.check=0,A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0),u=0,d=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=Gx;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=Gx;break}if(d-=4,E=8+(15&(u>>>=4)),0===r.wbits)r.wbits=E;else if(E>r.wbits){e.msg="invalid window size",r.mode=Gx;break}r.dmax=1<<E,e.adler=r.check=1,r.mode=512&u?10:Hx,u=0,d=0;break;case 2:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.flags=u,8!=(255&wx(r))){e.msg="unknown compression method",r.mode=Gx;break}if(57344&wx(r)){e.msg="unknown header flags set",r.mode=Gx;break}r.head&&(r.head.text=u>>8&1),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0)),u=0,d=0,r.mode=3;case 3:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.time=u),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=Vx(r.check,A,4,0)),u=0,d=0,r.mode=4;case 4:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0)),u=0,d=0,r.mode=5;case 5:if(1024&wx(r)){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length=u,r.head&&(r.head.extra_len=u),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&wx(r)&&((p=r.length)>s&&(p=s),p&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),Lx.arraySet(r.head.extra,n,o,p,E)),512&wx(r)&&(r.check=Vx(r.check,n,p,o)),s-=p,o+=p,r.length-=p),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&wx(r)){if(0===s)break e;p=0;do{E=n[o+p++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&p<s);if(512&wx(r)&&(r.check=Vx(r.check,n,p,o)),s-=p,o+=p,E)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&wx(r)){if(0===s)break e;p=0;do{E=n[o+p++],r.head&&E&&r.length<65536&&(r.head.comment+=String.fromCharCode(E))}while(E&&p<s);if(512&wx(r)&&(r.check=Vx(r.check,n,p,o)),s-=p,o+=p,E)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&wx(r)){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=Gx;break}u=0,d=0}r.head&&(r.head.hcrc=wx(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Hx;break;case 10:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}e.adler=r.check=zx(u),u=0,d=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,2;e.adler=r.check=1,r.mode=Hx;case Hx:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&d,d-=7&d,r.mode=27;break}for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}switch(r.last=1&u,d-=1,3&(u>>>=1)){case 0:r.mode=14;break;case 1:if($x(r),r.mode=20,6===t){u>>>=2,d-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=Gx}u>>>=2,d-=2;break;case 14:for(u>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Gx;break}if(r.length=65535&u,u=0,d=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(p=r.length){if(p>s&&(p=s),p>c&&(p=c),0===p)break e;Lx.arraySet(i,n,o,p,a),s-=p,o+=p,c-=p,a+=p,r.length-=p;break}r.mode=Hx;break;case 17:for(;d<14;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.nlen=257+(31&u),u>>>=5,d-=5,r.ndist=1+(31&u),u>>>=5,d-=5,r.ncode=4+(15&u),u>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Gx;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.lens[w[r.have++]]=7&u,u>>>=3,d-=3}for(;r.have<19;)r.lens[w[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,T={bits:r.lenbits},k=Bx(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid code lengths set",r.mode=Gx;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&R,!((_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(y<16)u>>>=_,d-=_,r.lens[r.have++]=y;else{if(16===y){for(I=_+2;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u>>>=_,d-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=Gx;break}E=r.lens[r.have-1],p=3+(3&u),u>>>=2,d-=2}else if(17===y){for(I=_+3;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,E=0,p=3+(7&(u>>>=_)),u>>>=3,d-=3}else{for(I=_+7;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,E=0,p=11+(127&(u>>>=_)),u>>>=7,d-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Gx;break}for(;p--;)r.lens[r.have++]=E}}if(r.mode===Gx)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=Gx;break}if(r.lenbits=9,T={bits:r.lenbits},k=Bx(1,r.lens,0,r.nlen,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid literal/lengths set",r.mode=Gx;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},k=Bx(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,T),r.distbits=T.bits,k){e.msg="invalid distances set",r.mode=Gx;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,Fx(e,h),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,r.mode===Hx&&(r.back=-1);break}for(r.back=0;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&R,!((_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(m&&0==(240&m)){for(g=_,S=m,b=y;m=(R=r.lencode[b+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&R,!(g+(_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=_,d-=_,r.back+=_,r.length=y,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=Hx;break}if(64&m){e.msg="invalid literal/length code",r.mode=Gx;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(R=r.distcode[u&(1<<r.distbits)-1])>>>16&255,y=65535&R,!((_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(0==(240&m)){for(g=_,S=m,b=y;m=(R=r.distcode[b+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&R,!(g+(_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=_,d-=_,r.back+=_,64&m){e.msg="invalid distance code",r.mode=Gx;break}r.offset=y,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Gx;break}r.mode=25;case 25:if(0===c)break e;if(p=h-c,r.offset>p){if((p=r.offset-p)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Gx;break}p>r.wnext?(p-=r.wnext,v=r.wsize-p):v=r.wnext-p,p>r.length&&(p=r.length),f=r.window}else f=i,v=a-r.offset,p=r.length;p>c&&(p=c),c-=p,r.length-=p;do{i[a++]=f[v++]}while(--p);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===s)break e;s--,u|=n[o++]<<d,d+=8}if(h-=c,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=wx(r)?Vx(r.check,i,h,a-h):Ux(r.check,i,h,a-h)),h=c,(wx(r)?u:zx(u))!==r.check){e.msg="incorrect data check",r.mode=Gx;break}u=0,d=0}r.mode=28;case 28:if(r.wrap&&wx(r)){for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=Gx;break}u=0,d=0}r.mode=29;case 29:k=1;break e;case Gx:k=-3;break e;case 31:return-4;default:return jx}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,(r.wsize||h!==e.avail_out&&r.mode<Gx&&(r.mode<27||4!==t))&&eO(e,e.output,e.next_out,h-e.avail_out),l-=e.avail_in,h-=e.avail_out,e.total_in+=l,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=wx(r)?Vx(r.check,i,h,e.next_out-h):Ux(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===Hx?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&0===k&&(k=-5),k},Cx.inflateEnd=function(e){if(!e||!e.state)return jx;var t=e.state;return t.window&&(t.window=null),e.state=null,0},Cx.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?jx:(r.head=t,t.done=!1,0):jx},Cx.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?jx:11===r.mode&&Ux(1,t,n,0)!==r.check?-3:eO(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,0):jx},Cx.inflateInfo="pako inflate (from Nodeca project)";var tO={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};var rO=Cx,nO=Uw,iO=rx,oO=tO,aO=wC,sO=ux,cO=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},uO=Object.prototype.toString;function dO(e){if(!(this instanceof dO))return new dO(e);this.options=nO.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new sO,this.strm.avail_out=0;var r=rO.inflateInit2(this.strm,t.windowBits);if(r!==oO.Z_OK)throw new Error(aO[r]);if(this.header=new cO,rO.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=iO.string2buf(t.dictionary):"[object ArrayBuffer]"===uO.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=rO.inflateSetDictionary(this.strm,t.dictionary))!==oO.Z_OK))throw new Error(aO[r])}function lO(e,t){var r=new dO(t);if(r.push(e,!0),r.err)throw r.msg||aO[r.err];return r.result}dO.prototype.push=function(e,t){var r,n,i,o,a,s=this.strm,c=this.options.chunkSize,u=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?oO.Z_FINISH:oO.Z_NO_FLUSH,"string"==typeof e?s.input=iO.binstring2buf(e):"[object ArrayBuffer]"===uO.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new nO.Buf8(c),s.next_out=0,s.avail_out=c),(r=rO.inflate(s,oO.Z_NO_FLUSH))===oO.Z_NEED_DICT&&u&&(r=rO.inflateSetDictionary(this.strm,u)),r===oO.Z_BUF_ERROR&&!0===d&&(r=oO.Z_OK,d=!1),r!==oO.Z_STREAM_END&&r!==oO.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==oO.Z_STREAM_END&&(0!==s.avail_in||n!==oO.Z_FINISH&&n!==oO.Z_SYNC_FLUSH)||("string"===this.options.to?(i=iO.utf8border(s.output,s.next_out),o=s.next_out-i,a=iO.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&nO.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(nO.shrinkBuf(s.output,s.next_out)))),0===s.avail_in&&0===s.avail_out&&(d=!0)}while((s.avail_in>0||0===s.avail_out)&&r!==oO.Z_STREAM_END);return r===oO.Z_STREAM_END&&(n=oO.Z_FINISH),n===oO.Z_FINISH?(r=rO.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===oO.Z_OK):n!==oO.Z_SYNC_FLUSH||(this.onEnd(oO.Z_OK),s.avail_out=0,!0)},dO.prototype.onData=function(e){this.chunks.push(e)},dO.prototype.onEnd=function(e){e===oO.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=nO.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},yx.Inflate=dO,yx.inflate=lO,yx.inflateRaw=function(e,t){return(t=t||{}).raw=!0,lO(e,t)},yx.ungzip=lO;var hO={};(0,Uw.assign)(hO,Vw,yx,tO);var pO,vO=hO,fO="BytePlusRTC",_O=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},mO=function(){function e(t){Vl(this,e),Jd(this,"storeName",void 0),Jd(this,"pendingList",[]),this.storeName=t,!fw()&&_O()&&this._checkAndCreateStore(t)}var t,r;return Ul(e,[{key:"_checkAndCreateStore",value:function(t,r){var n=this;e.db&&e.db.close();var i=r?_O().open(fO,r):_O().open(fO);i.onupgradeneeded=function(){i.result.createObjectStore(t)},i.onerror=function(e){console.error("IndexedDBInterface error",i.error)},i.onsuccess=function(){var r=i.result;e.db=r;try{e.db.transaction(n.storeName,"readonly"),n.pendingList.forEach(function(){var e=Rm(Tm().mark((function e(t){var r,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.txMode,i=t.resolve,o=t.reject,e.prev=1,e.next=4,n._getStore(r);case 4:a=e.sent,i(a),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o();case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}())}catch(o){n._checkAndCreateStore(t,r.version+1)}}}},{key:"_getStore",value:function(t){var r=this;return new Y_((function(n,i){e.db?n(e.db.transaction(r.storeName,t).objectStore(r.storeName)):r.pendingList.push({txMode:t,resolve:n,reject:i})}))}},{key:"put",value:(r=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readwrite");case 2:return n=e.sent,e.abrupt("return",new Y_((function(e,i){var o=n.put(t,r);o.onsuccess=function(){e()},o.onerror=function(e){i(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"get",value:(t=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readonly");case 2:return r=e.sent,e.abrupt("return",new Y_((function(e,n){var i=r.get(t);i.onsuccess=function(){e(i.result)},i.onerror=function(e){n(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();Jd(mO,"db",void 0),Jd(mO,"state","init");var yO={product_line:"rtc",report_version:"5",os:"web",user_agent:fw()?"":null===(pO=navigator)||void 0===pO?void 0:pO.userAgent,platform:"web",product:"webrtc",app_state:"active"},gO="ReportErrorBuffer",SO=function(){function e(){Vl(this,e),Jd(this,"_buffer",new mO(gO))}var t,r;return Ul(e,[{key:"set",value:(r=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put(t,gO);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"get",value:(t=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.prev=1,e.next=4,this._buffer.get(gO);case 4:t=e.sent,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(1);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(){return t.apply(this,arguments)})}]),e}(),bO=function(){function e(){var t=this;Vl(this,e),Jd(this,"reportCommon",yO),Jd(this,"dataBuffer",[]),Jd(this,"logBuffer",[]),Jd(this,"posting",!1),Jd(this,"sucSendTimer",void 0),Jd(this,"preSucTime",0),Jd(this,"errSendTimer",void 0),Jd(this,"errSendDelay",100),Jd(this,"errSendBuffer",void 0),Jd(this,"_logServerUrl",void 0),Jd(this,"_retryCount",0),fw()||(window.addEventListener("beforeunload",(function(){clearTimeout(t.errSendTimer),clearTimeout(t.sucSendTimer),t.send(void 0,!0)})),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState?t.setCommonStats({app_state:"active"}):"hidden"===document.visibilityState&&t.setCommonStats({app_state:"background"})})))}var t;return Ul(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.reportCommon=wb(this.reportCommon,e)}},{key:"enableErrorBuffer",value:function(){this.errSendBuffer=new SO,this.loadErrorBuffer()}},{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?this.send(e):(this.dataBuffer.push(e),!this.posting&&!this.errSendTimer&&Date.now()-this.preSucTime>2e3&&(clearTimeout(this.sucSendTimer),this.send()))}},{key:"unshift",value:function(e){this.dataBuffer=Om(e).call(e,this.dataBuffer)}},{key:"send",value:function(e,t){var r,n,i=this;if((e||this.dataBuffer.length)&&this._logServerUrl){var o={data:e||rk(r=this.dataBuffer).call(r,0,EO(this.dataBuffer,5e5)),header:Zd(Zd({},this.reportCommon),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},a=new XMLHttpRequest;if(a.timeout=1e4,a.onreadystatechange=function(){if(4===a.readyState){var r,n,s,c;if(e||(i.posting=!1),200===a.status||304===a.status)try{r=JSON.parse(a.responseText)}catch(cq){n=cq}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;NO(Om(e="reportor error, res:".concat(null===(t=r)||void 0===t?void 0:t.toString()," err:")).call(e,n),a.status,n)}),0),e)i.send(e);else i.unshift(o.data),null===(c=i.errSendBuffer)||void 0===c||c.set(Jk(i.dataBuffer)),t?i.send():i.errSend()}},a.open("POST",this._logServerUrl,!0),e||(this.posting=!0),!fw()&&mk(n=location.search).call(n,"_rtc_debug_"))a.send(Nm(o));else{var s=vO.gzip(Nm(o));a.setRequestHeader("Content-Encoding","gzip"),a.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),a.send(s)}}}},{key:"sucSend",value:function(){this.errSendDelay=100,this._retryCount=0,this.preSucTime=Date.now(),this.sucSendTimer=window.setTimeout(this.send.bind(this),2e3)}},{key:"errSend",value:function(){var e=this;this.errSendTimer=window.setTimeout((function(){e.send(),delete e.errSendTimer}),this.errSendDelay),this.errSendDelay*=2,this._retryCount++}},{key:"loadErrorBuffer",value:(t=Rm(Tm().mark((function e(){var t,r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this.errSendBuffer)||void 0===r?void 0:r.get();case 2:if(e.t1=t=e.sent,e.t0=null!==e.t1,!e.t0){e.next=6;break}e.t0=void 0!==t;case 6:if(!e.t0){e.next=10;break}e.t2=t,e.next=11;break;case 10:e.t2=[];case 11:e.t2.forEach((function(e){n.push(e)}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();function EO(e,t){for(var r=0,n=0;n<e.length;n++)if((r+=Nm(e[n]).length)>t)return n-1;return e.length}var kO=new bO,TO=function(){function e(t){Vl(this,e),Jd(this,"report_id",0),Jd(this,"modify_ids",{}),this.id=t}return Ul(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=Zd(Zd(Zd({event_key:e,report_id:this.report_id++,rtc_timestamp:Date.now()},this.modify_ids),t),{},{common_extra_info:Nm(i)});(kO.push(o),fw())||(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.id,o))}},{key:"set",value:function(e){this.modify_ids=wb(this.modify_ids,e)}},{key:"destroy",value:function(){}}]),e}(),IO=new Nw("MessageReportor",1),RO=function(){function e(t){Vl(this,e),Jd(this,"_preTime",Date.now()),Jd(this,"_one2oneNum",0),Jd(this,"_one2manyNum",0),Jd(this,"_one2oneMsgCache",new $S),Jd(this,"_one2manyMsgCache",new $S),Jd(this,"roomId",""),Jd(this,"userId",""),Jd(this,"rtsSessionId",""),this.id=t}return Ul(e,[{key:"needReport",value:function(t){return!!e.config&&(Date.now()-this._preTime>=36e5&&(this._preTime=Date.now(),this._one2oneNum=0,this._one2manyNum=0),"one2one"===t&&this._one2oneNum<e.config.max_one2one_fpt_per_hour&&Math.random()<=e.config.one2one_fpt_ratio/100||"one2many"===t&&this._one2manyNum<e.config.max_one2many_fpt_per_hour&&Math.random()<=e.config.one2many_fpt_ratio/100)}},{key:"cacheP2PMsg",value:function(t){var r;this._one2oneMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateP2PMsg",value:function(e,t){var r=this._one2oneMsgCache.get(e);r&&this._one2oneMsgCache.set(e,Zd(Zd({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateOne2ManyMsg",value:function(e,t){var r=this._one2manyMsgCache.get(e);r&&this._one2manyMsgCache.set(e,Zd(Zd({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(IO.info("reportP2PMsg",r.type,Nm(r)),null===(t=VO(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(IO.info("reportOne2ManyMsg",r.type,Nm(r)),null===(t=VO(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportMsgRecv",value:function(t){var r,n;t.config_version=(null===(r=e.config)||void 0===r?void 0:r.version)||"",IO.info("reportMsgRecv",t.type,Nm(t)),null===(n=VO(this.id))||void 0===n||n.report("rts_message",t)}},{key:"destroy",value:function(){this._one2manyNum=0,this._one2oneNum=0,this._one2manyMsgCache.clear(),this._one2oneMsgCache.clear(),this._preTime=Date.now(),this.roomId="",this.userId="",this.rtsSessionId=""}}]),e}();Jd(RO,"config",void 0);var AO=new $S,wO={_cache:AO,setConfig:function(e){IO.info("setConfig","get config: ".concat(Nm(e))),RO.config=e},setRtsSessionId:function(e,t){var r=AO.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=AO.get(e)||new RO(e);return AO.set(e,t),t},destroyRTSMsgReportor:function(e){var t=AO.get(e);t&&(t.destroy(),AO.delete(e))},setRoomId:function(e,t){var r=AO.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=AO.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=AO.get(e);if(null!=r&&r.needReport("one2one")){var n,i=Om(n="".concat(t.from)).call(n,t.id),o=t.to?"one2one":"one2server";t.enable_report=!0,t.report_msg_id=t.id,r.cacheP2PMsg({rts_session_id:r.rtsSessionId,msg_id:i,node_role:"src_sdk",from:t.from,to:t.to||"server",type:o,rts_room_id:t.room,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""})}return t},updateP2PMsgReq:function(e,t,r){var n,i;t.enable_report&&mw(t.report_msg_id)&&(null===(n=AO.get(e))||void 0===n||n.updateP2PMsg(Om(i="".concat(t.from)).call(i,t.report_msg_id),{send_ts:Date.now(),msg_size:r}))},updateP2PMsgAck:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i,o=AO.get(e);null==o||o.updateP2PMsg(Om(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(Om(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n,i=AO.get(e);null!=i&&i.needReport("one2many")&&(r.enable_report=!0,r.report_msg_id=t,i.cacheCustomMsg({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(r.clientId)).call(n,t),node_role:"src_sdk",from:r.clientId,to:i.roomId,type:"one2many",rts_room_id:i.roomId,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""}));return r},reportP2PMsgRecv:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i=AO.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(t.from)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:o,rts_room_id:t.room,from:t.from,to:t.to||t.room,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:t.to?"":i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},updateOne2ManyMsgAck:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i,o=AO.get(e);if(o)null==o||o.updateOne2ManyMsg(Om(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(Om(i="".concat(t.clientId)).call(i,t.report_msg_id))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i=AO.get(e);if(i)i.updateOne2ManyMsg(Om(n="".concat(t.clientId)).call(n,t.report_msg_id),{send_ts:Date.now(),msg_size:r})}},reportOne2ManyMsgRecv:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i=AO.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(t.clientId)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:"one2many",rts_room_id:t.roomId,from:t.clientId,to:t.roomId,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}}},CO=function(){function e(t){Vl(this,e),Jd(this,"_timer",void 0),Jd(this,"userMessage",{}),Jd(this,"roomMessage",{}),this.id=t,this._setTimer()}return Ul(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(an(this.userMessage).length||an(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e,t,r,n=this;null===(e=VO(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:jm(t=an(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:jm(r=an(this.roomMessage)).call(r,(function(e){return n.roomMessage[e]})),media_server_ip:""})}},{key:"_reset",value:function(){this.userMessage={},this.roomMessage={}}},{key:"_checkInitUserMessage",value:function(e,t){var r,n;this.userMessage[Om(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Om(n="".concat(t,"-")).call(n,e)]={dc_peer_user_id:e,dc_send_total:0,dc_recv_total:0,dc_send_ack:0,dc_send_fail:0,dc_fail_timeout:0,dc_fail_no_receiver:0,dc_fail_no_relay_path:0,dc_cost_time:0,dc_cost_e2s:0,dc_cost_s2s:0,dc_least_time:Number(1/0),dc_most_time:0,dc_cost_peer_s2e:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_message_type:t,dc_send_binary:0})}},{key:"_sendUserMessage",value:function(e,t,r){var n,i;(this._checkInitUserMessage(e,t),this.userMessage[Om(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Om(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Om(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Om(n="".concat(t,"-")).call(n,e)];i&&(i.dc_send_fail++,this._handleUserFail(i,r))}},{key:"_handleUserFail",value:function(e,t){var r;t&&(t.code||t.err)&&(mk(r=["TIME_OUT","USER_MESSAGE_TIMEOUT"]).call(r,t.code)?e.dc_fail_timeout++:3===t.err?e.dc_fail_no_receiver++:4===t.err?e.dc_fail_no_relay_path++:1===t.err&&e.dc_fail_timeout++)}},{key:"_sendUserAck",value:function(e,t,r,n,i){var o,a=this.userMessage[Om(o="".concat(t,"-")).call(o,e)];a&&(a.dc_send_ack++,a.dc_cost_time+=r,a.dc_cost_s2s+=n||0,a.dc_cost_peer_s2e+=i,a.dc_cost_e2s+=r-(n||0)-i,r<=100?(a.dc_send_ack_100++,a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=200?(a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=400?(a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=1e3&&a.dc_send_ack_1s++,r<a.dc_least_time&&(a.dc_least_time=r),r>a.dc_most_time&&(a.dc_most_time=r))}},{key:"sendRoomMessage",value:function(e,t){this.roomMessage[e]||(this.roomMessage[e]={dc_room_id:e,dc_send_total:0,dc_send_ack:0,dc_cost_time:0,dc_least_time:Number(1/0),dc_most_time:0,dc_send_fail:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_send_binary:0}),this.roomMessage[e].dc_send_total++,t&&this.roomMessage[e].dc_send_binary++}},{key:"sendRoomFail",value:function(e){var t=this.roomMessage[e];t&&t.dc_send_fail++}},{key:"sendRoomAck",value:function(e,t){var r=this.roomMessage[e];r&&(r.dc_send_ack++,r.dc_cost_time+=t,t<r.dc_least_time&&(r.dc_least_time=t),t>r.dc_most_time&&(r.dc_most_time=t),t<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=1e3&&r.dc_send_ack_1s++)}},{key:"sendP2PMessage",value:function(e,t){this._sendUserMessage(e,"p2p",t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,"p2p")}},{key:"sendP2PFail",value:function(e,t){this._sendUserFail(e,"p2p",t)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p",t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,"p2p_outside_room",t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,"p2p_outside_room")}},{key:"sendP2POutRoomFail",value:function(e,t){this._sendUserFail(e,"p2p_outside_room",t)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p_outside_room",t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("","p2server",e)}},{key:"sendP2serverFail",value:function(e){this._sendUserFail("","p2server",e)}},{key:"sendP2serveAck",value:function(e,t,r){this._sendUserAck("","p2server",e,t,r)}},{key:"countP2PMessage",value:function(e,t,r,n,i){this.sendP2PMessage(t,r),e?this.sendP2PAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2PFail(t,i)}},{key:"countRoomMessage",value:function(e,t,r,n){this.sendRoomMessage(t,r),e?this.sendRoomAck(t,Date.now()-n):this.sendRoomFail(t)}},{key:"countUserMessageOutsideRoom",value:function(e,t,r,n,i){this.sendP2POutRoomMessage(t,r),e?this.sendP2POutRoomAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2POutRoomFail(t,i)}},{key:"countServerMessage",value:function(e,t,r,n){this.sendP2serverMessage(t),e?(n=n||{},this.sendP2serveAck(Date.now()-r,n.s2s_time||0,n.s2e_time||0)):this.sendP2serverFail(n)}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),xO=function(e){kO.setCommonStats(e)},OO=function(e){kO.setUrl(e)},MO=new TO("global"),DO=function(e,t,r){MO.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},PO=function(e,t,r){MO.report("rtc_sdk_callback",{sdk_callback_name:e,error_code:t,message:r})},NO=function(e,t,r){MO.report("rtc_error",{message:e,error_code:t},r)},LO=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;MO.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)},UO=new $S,VO=function(e){return UO.get(e)};function FO(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r,n){if("function"==typeof n.value){var i=n.value;n.value=function(){for(var e,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];var s,c,u=this.engineId||this.id,d={};(t.forEach((function(e,t){d[e]=o[t]})),"joinRoom"===r)&&(null===(s=VO(u))||void 0===s||s.set({room_id:o[1],user_id:null===(c=o[2])||void 0===c?void 0:c.userId}));null===(e=VO(u))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:Nm(HO(o)),error_code:0},d);var l=i.apply(this,o);return"function"==typeof(null==l?void 0:l.then)?l.then((function(e){return BO(u,r,[e||{}]),e})).catch((function(e){throw BO(u,r,e.message,e.code),e})):(BO(u,r,[l||{}]),l)}}}}var BO=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4?arguments[4]:void 0,a={sdk_callback_name:t,error_code:i,message:Nm(Array.isArray(r)?HO(r):r)};o&&(a.room_id=o),null===(n=VO(e))||void 0===n||n.report("rtc_sdk_callback",a)},jO=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",a=arguments.length>5?arguments[5]:void 0;null===(n=VO(e))||void 0===n||n.report("rtc_invoke_status",{sdk_api_name:t,message:r,error_code:i,stream_id:o,elapse:0},a)};function HO(e){return jm(e).call(e,(function e(t){var r;if(null!=t&&t._reportName)return t._reportName;if(t instanceof HTMLElement)return t.toString();if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){var n,i,o=ArrayBuffer.isView(t)?t.buffer:t,a=o.byteLength,s=[];if(a>10){var c,u,d,l,h=new DataView(o),p=jm(c=qk({length:5})).call(c,(function(e,t){return h.getUint8(t)})),v=jm(u=jm(d=qk({length:5})).call(d,(function(e,t){return a-1-t})).reverse()).call(u,(function(e){return h.getUint8(e)}));s=Om(l=[]).call(l,Jk(p),["..."],Jk(v))}else s=qk(new Uint8Array(o));return Om(n=Om(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return jm(t).call(t,e);if(mk(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var f={};for(var _ in t)f[_]=e(t[_]);return f}return t}))}var GO=function(e){var t,r=VO(e.engineId),n={keys:sw(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId,deviceId:e.deviceId,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0},i=jm(t=e.requestDomains).call(t,(function(e){return"https://".concat(e,"/decision/v1/multi")}));null==r||r.report("rtc_get_config",{error_code:0,message:Nm(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=jm(i).call(i,function(){var e=Rm(Tm().mark((function e(t,r){var i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:Nm(n)}).then((function(e){return e.json()}));case 2:return i=e.sent,e.abrupt("return",{result:i,index:r});case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}());return new Y_((function(e){(function(e){return new Y_((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))})(o).then((function(t){var n=t.result,o=t.index;null==r||r.report("rtc_get_config",{error_code:200,message:Nm(n),elapse:0,host:i[o],type:"response",config_id:"",enable_cloud_proxy:!1}),e(n)})).catch((function(e){var t;null==r||r.report("rtc_get_config",{error_code:500,message:null===(t=e[0])||void 0===t?void 0:t.message,elapse:0,host:"",type:"response",config_id:"",enable_cloud_proxy:!1})}))}))},zO={exports:{}},KO=n;Ar({global:!0,forced:KO.globalThis!==KO},{globalThis:KO});var XO=n,WO={exports:{}};!function(e,r){var n;e.exports=(n=n||function(e,r){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),void 0!==XO&&XO.crypto&&(n=XO.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==t&&t.crypto&&(n=t.crypto),!n)try{n=require("crypto")}catch(_){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(_){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(_){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),a={},s=a.lib={},c=s.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=s.WordArray=c.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=t!=r?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var s=0;s<i;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e,t=c.clone.call(this);return t.words=km(e=this.words).call(e,0),t},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new u.init(t,e)}}),d=a.enc={},l=d.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=uy(e.substr(n,2),16)<<24-n%8*4;return new u.init(r,t/2)}},h=d.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new u.init(r,t)}},p=d.Utf8={stringify:function(e){try{return decodeURIComponent(escape(h.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return h.parse(unescape(encodeURIComponent(e)))}},v=s.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){var t;"string"==typeof e&&(e=p.parse(e)),Om(t=this._data).call(t,e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,s=o/(4*a),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,d=e.min(4*c,o);if(c){for(var l=0;l<c;l+=a)this._doProcessBlock(i,l);r=rk(i).call(i,0,c),n.sigBytes-=d}return new u.init(r,d)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=v.extend({cfg:c.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){v.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new f.HMAC.init(e,r).finalize(t)}}});var f=a.algo={};return a}(Math),n)}(WO),function(e,t){var r;e.exports=(r=WO.exports,function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init,n=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};n.prototype=e}}(),r.lib.WordArray)}(zO);var qO=zO.exports,YO={exports:{}},JO={exports:{}};!function(e,t){var r;e.exports=(r=WO.exports,function(){var e=r,t=e.lib.WordArray;function n(e,r,n){for(var i=[],o=0,a=0;a<r;a++)if(a%4){var s=n[e.charCodeAt(a-1)]<<a%4*2|n[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=s<<24-o%4*8,o++}return t.create(i,o)}e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)i.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<r.length;o++)i[r.charCodeAt(o)]=o}var a=r.charAt(64);if(a){var s=xE(e).call(e,a);-1!==s&&(t=s)}return n(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),r.enc.Base64)}(JO);var QO={exports:{}};!function(e,t){var r;e.exports=(r=WO.exports,function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,a=t.algo,s=[];!function(){for(var t=0;t<64;t++)s[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,a=e[t+0],c=e[t+1],p=e[t+2],v=e[t+3],f=e[t+4],_=e[t+5],m=e[t+6],y=e[t+7],g=e[t+8],S=e[t+9],b=e[t+10],E=e[t+11],k=e[t+12],T=e[t+13],I=e[t+14],R=e[t+15],A=o[0],w=o[1],C=o[2],x=o[3];A=u(A,w,C,x,a,7,s[0]),x=u(x,A,w,C,c,12,s[1]),C=u(C,x,A,w,p,17,s[2]),w=u(w,C,x,A,v,22,s[3]),A=u(A,w,C,x,f,7,s[4]),x=u(x,A,w,C,_,12,s[5]),C=u(C,x,A,w,m,17,s[6]),w=u(w,C,x,A,y,22,s[7]),A=u(A,w,C,x,g,7,s[8]),x=u(x,A,w,C,S,12,s[9]),C=u(C,x,A,w,b,17,s[10]),w=u(w,C,x,A,E,22,s[11]),A=u(A,w,C,x,k,7,s[12]),x=u(x,A,w,C,T,12,s[13]),C=u(C,x,A,w,I,17,s[14]),A=d(A,w=u(w,C,x,A,R,22,s[15]),C,x,c,5,s[16]),x=d(x,A,w,C,m,9,s[17]),C=d(C,x,A,w,E,14,s[18]),w=d(w,C,x,A,a,20,s[19]),A=d(A,w,C,x,_,5,s[20]),x=d(x,A,w,C,b,9,s[21]),C=d(C,x,A,w,R,14,s[22]),w=d(w,C,x,A,f,20,s[23]),A=d(A,w,C,x,S,5,s[24]),x=d(x,A,w,C,I,9,s[25]),C=d(C,x,A,w,v,14,s[26]),w=d(w,C,x,A,g,20,s[27]),A=d(A,w,C,x,T,5,s[28]),x=d(x,A,w,C,p,9,s[29]),C=d(C,x,A,w,y,14,s[30]),A=l(A,w=d(w,C,x,A,k,20,s[31]),C,x,_,4,s[32]),x=l(x,A,w,C,g,11,s[33]),C=l(C,x,A,w,E,16,s[34]),w=l(w,C,x,A,I,23,s[35]),A=l(A,w,C,x,c,4,s[36]),x=l(x,A,w,C,f,11,s[37]),C=l(C,x,A,w,y,16,s[38]),w=l(w,C,x,A,b,23,s[39]),A=l(A,w,C,x,T,4,s[40]),x=l(x,A,w,C,a,11,s[41]),C=l(C,x,A,w,v,16,s[42]),w=l(w,C,x,A,m,23,s[43]),A=l(A,w,C,x,S,4,s[44]),x=l(x,A,w,C,k,11,s[45]),C=l(C,x,A,w,R,16,s[46]),A=h(A,w=l(w,C,x,A,p,23,s[47]),C,x,a,6,s[48]),x=h(x,A,w,C,y,10,s[49]),C=h(C,x,A,w,I,15,s[50]),w=h(w,C,x,A,_,21,s[51]),A=h(A,w,C,x,k,6,s[52]),x=h(x,A,w,C,v,10,s[53]),C=h(C,x,A,w,b,15,s[54]),w=h(w,C,x,A,c,21,s[55]),A=h(A,w,C,x,g,6,s[56]),x=h(x,A,w,C,R,10,s[57]),C=h(C,x,A,w,m,15,s[58]),w=h(w,C,x,A,T,21,s[59]),A=h(A,w,C,x,f,6,s[60]),x=h(x,A,w,C,E,10,s[61]),C=h(C,x,A,w,p,15,s[62]),w=h(w,C,x,A,S,21,s[63]),o[0]=o[0]+A|0,o[1]=o[1]+w|0,o[2]=o[2]+C|0,o[3]=o[3]+x|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,c=s.words,u=0;u<4;u++){var d=c[u];c[u]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+i+a;return(s<<o|s>>>32-o)+t}function d(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+i+a;return(s<<o|s>>>32-o)+t}function l(e,t,r,n,i,o,a){var s=e+(t^r^n)+i+a;return(s<<o|s>>>32-o)+t}function h(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+i+a;return(s<<o|s>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),r.MD5)}(QO);var ZO={exports:{}},$O={exports:{}};!function(e,t){var r,n,i,o,a,s,c,u;e.exports=(n=(r=u=WO.exports).lib,i=n.WordArray,o=n.Hasher,a=r.algo,s=[],c=a.SHA1=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)s[u]=0|e[t+u];else{var d=s[u-3]^s[u-8]^s[u-14]^s[u-16];s[u]=d<<1|d>>>31}var l=(n<<5|n>>>27)+c+s[u];l+=u<20?1518500249+(i&o|~i&a):u<40?1859775393+(i^o^a):u<60?(i&o|i&a|o&a)-1894007588:(i^o^a)-899497514,c=a,a=o,o=i<<30|i>>>2,i=n,n=l}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=o._createHelper(c),r.HmacSHA1=o._createHmacHelper(c),u.SHA1)}($O);var eM={exports:{}};!function(e,t){var r,n,i;e.exports=(n=(r=WO.exports).lib.Base,i=r.enc.Utf8,void(r.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),a=this._iKey=t.clone(),s=o.words,c=a.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;o.sigBytes=a.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t,r=this._hasher,n=r.finalize(e);return r.reset(),r.finalize(Om(t=this._oKey.clone()).call(t,n))}})))}(eM),function(e,t){var r,n,i,o,a,s,c,u;e.exports=(n=(r=u=WO.exports).lib,i=n.Base,o=n.WordArray,a=r.algo,s=a.MD5,c=a.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=o.create(),s=a.words,c=n.keySize,u=n.iterations;s.length<c;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var d=1;d<u;d++)r=i.finalize(r),i.reset();Om(a).call(a,r)}return a.sigBytes=4*c,a}}),r.EvpKDF=function(e,t,r){return c.create(r).compute(e,t)},u.EvpKDF)}(ZO);var tM={exports:{}};!function(e,t){var r;e.exports=void((r=WO.exports).lib.Cipher||function(e){var t=r,n=t.lib,i=n.Base,o=n.WordArray,a=n.BufferedBlockAlgorithm,s=t.enc;s.Utf8;var c=s.Base64,u=t.algo.EvpKDF,d=n.Cipher=a.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?g:m}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()});n.StreamCipher=d.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var l=t.mode={},h=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),p=l.CBC=function(){var t=h.extend();function r(t,r,n){var i,o=this._iv;o?(i=o,this._iv=e):i=this._prevBlock;for(var a=0;a<n;a++)t[r+a]^=i[a]}return t.Encryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize;r.call(this,e,t,i),n.encryptBlock(e,t),this._prevBlock=km(e).call(e,t,t+i)}}),t.Decryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,o=km(e).call(e,t,t+i);n.decryptBlock(e,t),r.call(this,e,t,i),this._prevBlock=o}}),t}(),v=(t.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var c=o.create(a,n);Om(e).call(e,c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};n.BlockCipher=d.extend({cfg:d.cfg.extend({mode:p,padding:v}),reset:function(){var e;d.reset.call(this);var t=this.cfg,r=t.iv,n=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=n.createEncryptor:(e=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(n,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var f=n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),_=(t.format={}).OpenSSL={stringify:function(e){var t,r,n=e.ciphertext,i=e.salt;return(i?Om(t=Om(r=o.create([1398893684,1701076831])).call(r,i)).call(t,n):n).toString(c)},parse:function(e){var t,r=c.parse(e),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(t=o.create(km(n).call(n,2,4)),rk(n).call(n,0,4),r.sigBytes-=16),f.create({ciphertext:r,salt:t})}},m=n.SerializableCipher=i.extend({cfg:i.extend({format:_}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),a=i.cfg;return f.create({ciphertext:o,key:r,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),y=(t.kdf={}).OpenSSL={execute:function(e,t,r,n,i){var a;if(n||(n=o.random(8)),i)s=u.create({keySize:t+r,hasher:i}).compute(e,n);else var s=u.create({keySize:t+r}).compute(e,n);var c=o.create(km(a=s.words).call(a,t),4*r);return s.sigBytes=4*t,f.create({key:s,iv:c,salt:n})}},g=n.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:y}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize,n.salt,n.hasher);n.iv=i.iv;var o=m.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt,n.hasher);return n.iv=i.iv,m.decrypt.call(this,e,t,i.key,n)}})}())}(tM),function(e,t){var r;e.exports=(r=WO.exports,function(){var e=r,t=e.lib.BlockCipher,n=e.algo,i=[],o=[],a=[],s=[],c=[],u=[],d=[],l=[],h=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var v=n^n<<1^n<<2^n<<3^n<<4;v=v>>>8^255&v^99,i[r]=v,o[v]=r;var f=e[r],_=e[f],m=e[_],y=257*e[v]^16843008*v;a[r]=y<<24|y>>>8,s[r]=y<<16|y>>>16,c[r]=y<<8|y>>>24,u[r]=y,y=16843009*m^65537*_^257*f^16843008*r,d[v]=y<<24|y>>>8,l[v]=y<<16|y>>>16,h[v]=y<<8|y>>>24,p[v]=y,r?(r=f^e[e[e[m^f]]],n^=e[e[n]]):r=n=1}}();var v=[0,1,2,4,8,16,32,64,128,27,54],f=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a<n;a++)a<r?o[a]=t[a]:(u=o[a-1],a%r?r>6&&a%r==4&&(u=i[u>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u]):(u=i[(u=u<<8|u>>>24)>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u],u^=v[a/r|0]<<24),o[a]=o[a-r]^u);for(var s=this._invKeySchedule=[],c=0;c<n;c++){if(a=n-c,c%4)var u=o[a];else u=o[a-4];s[c]=c<4||a<=4?u:d[i[u>>>24]]^l[i[u>>>16&255]]^h[i[u>>>8&255]]^p[i[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,c,u,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,d,l,h,p,o),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,a,s){for(var c=this._nRounds,u=e[t]^r[0],d=e[t+1]^r[1],l=e[t+2]^r[2],h=e[t+3]^r[3],p=4,v=1;v<c;v++){var f=n[u>>>24]^i[d>>>16&255]^o[l>>>8&255]^a[255&h]^r[p++],_=n[d>>>24]^i[l>>>16&255]^o[h>>>8&255]^a[255&u]^r[p++],m=n[l>>>24]^i[h>>>16&255]^o[u>>>8&255]^a[255&d]^r[p++],y=n[h>>>24]^i[u>>>16&255]^o[d>>>8&255]^a[255&l]^r[p++];u=f,d=_,l=m,h=y}f=(s[u>>>24]<<24|s[d>>>16&255]<<16|s[l>>>8&255]<<8|s[255&h])^r[p++],_=(s[d>>>24]<<24|s[l>>>16&255]<<16|s[h>>>8&255]<<8|s[255&u])^r[p++],m=(s[l>>>24]<<24|s[h>>>16&255]<<16|s[u>>>8&255]<<8|s[255&d])^r[p++],y=(s[h>>>24]<<24|s[u>>>16&255]<<16|s[d>>>8&255]<<8|s[255&l])^r[p++],e[t]=f,e[t+1]=_,e[t+2]=m,e[t+3]=y},keySize:8});e.AES=t._createHelper(f)}(),r.AES)}(YO);var rM={exports:{}};!function(e,t){e.exports=WO.exports.enc.Hex}(rM);var nM=rM.exports,iM={exports:{}};!function(e,t){var r,n,i;e.exports=((i=WO.exports).mode.CTR=(r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,o=this._counter;i&&(o=this._counter=km(i).call(i,0),this._iv=void 0);var a=km(o).call(o,0);r.encryptBlock(a,0),o[n-1]=o[n-1]+1|0;for(var s=0;s<n;s++)e[t+s]^=a[s]}}),r.Decryptor=n,r),i.mode.CTR)}(iM);var oM=iM.exports,aM={exports:{}};!function(e,t){var r;e.exports=((r=WO.exports).pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)}(aM);var sM=aM.exports,cM=new TextDecoder,uM=new TextEncoder,dM=function(){return vw()},lM=function(){return Date.now()};function hM(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];for(var o=0,a=n;o<a.length;o++){var s=a[o];t+=s.length}for(var c=new e(t),u=0,d=0,l=n;d<l.length;d++){var h=l[d];c.set(h,u),u+=h.length}return c}var pM=function(){function e(){Vl(this,e)}var t,r;return Ul(e,null,[{key:"token2auth",value:function(t,r,n,i){return i?"Bearer ".concat(i):"Basic ".concat(e.createUnsafeToken(t,r,n))}},{key:"createUnsafeToken",value:function(e,t,r){var n;return window.btoa(Hs(n=[e,t,r]).call(n,(function(e){return null!==e})).join(":"))}},{key:"merge",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,i=RA(t);n<i.length;n++){var o=eI(i[n],2),a=o[0],s=o[1];null!==s&&"object"===Wd(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return cM.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 uM.encode(e).buffer}},{key:"ab2b64str",value:(r=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Y_((function(e){var r=new FileReader;r.onload=function(){return e(r.result)},r.readAsDataURL(new Blob([t]))}));case 2:return r=e.sent,e.abrupt("return",r.split(",",2)[1]);case 4:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"b64str2ab",value:(t=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,".concat(t)).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function vM(){for(var e,t,r=Number(WA(e=km(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=WA(r).call(r,28,"1").split(""),i=[];n.length;)i.push(rk(n).call(n,0,7));return jm(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return YA(r+e.join(""),2)}))}var fM=function(){return Math.floor(65535*Math.random())};function _M(e){return"string"==typeof e&&xE(e).call(e,"__web__rtc__rtt__")>-1}var mM,yM,gM,SM,bM,EM,kM,TM,IM=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]&&i[0],(r=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"})).createDataChannel("default"),r.addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),t&&(r.addTransceiver("audio",{direction:"sendonly"}),r.addTransceiver("video",{direction:"sendonly"})),e.next=8,r.createOffer();case 8:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),RM=function(e){return new Y_((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))};function AM(e){return Number(Math.max(-127,10*$A(Math.pow(e/255,2))).toFixed(2))}function wM(e){return(e&ul.AUDIO)===ul.AUDIO}function CM(e){return(e&ul.VIDEO)===ul.VIDEO}function xM(e){var t={};return an(e).forEach((function(r){"object"===Wd(e[r])?t[r]=xM(e[r]):hA(r).call(r,"_")||(t[r]=e[r])})),t}function OM(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 MM(e){return null==e?"undefined | null":"string"==typeof e?e:Nm({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function DM(e){return void 0===e}function PM(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Om(t="[RTC WebSDK]: Api: ".concat(r," has been abandoned from version ")).call(t,e));for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return i.apply(this,o)}}}function NM(e){console.warn("[RTC WebSDK]: ".concat(e))}function LM(e){return"number"==typeof e?e:"number"==typeof(null==e?void 0:e.exact)?e.exact:"number"==typeof(null==e?void 0:e.ideal)?e.ideal:"number"==typeof(null==e?void 0:e.max)?e.max:"number"==typeof(null==e?void 0:e.min)?e.min:1}function UM(e){for(var t=atob(e),r=t.length,n=new Uint8Array(r),i=0;i<r;i++)n[i]=t.charCodeAt(i);return n}function VM(e){for(var t="",r=e.byteLength,n=0;n<r;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function FM(e,t,r){var n=BM(e),i=BM(t),o=BM(r);return function(e){for(var t=e.toString(nM),r=new Uint8Array(t.length/2),n=0;n<t.length;n+=2)r[n/2]=uy(t.substr(n,2),16);return r}(YO.exports.encrypt(n,i,{iv:o,mode:oM,padding:sM}).ciphertext)}function BM(e){for(var t=[],r=0;r<e.length;r+=4)t.push(e[r]<<24|(e[r+1]||0)<<16|(e[r+2]||0)<<8|(e[r+3]||0));return qO.create(t,e.length)}var jM=function(){return"undefined"==typeof window},HM=jM()?"":window.navigator.userAgent;function GM(){var e="none";return jM()||(null!==HM.match("Firefox")?e="mozilla":null!==HM.match("Chrome")?(e="chrome-stable",null!==HM.match("Electron")&&(e="electron")):(null!==HM.match("Safari")||null!==HM.match("AppleWebKit"))&&(e="safari")),e}var zM="mozilla"===GM(),KM="safari"===GM(),XM="chrome-stable"===GM(),WM=!jM()&&/CriOS/i.test(HM),qM=!jM()&&/Edg\//i.test(HM),YM=!jM()&&/EdgA/i.test(HM),JM=!jM()&&/EdgiOS/i.test(HM),QM=qM||YM||JM;!jM()&&/(iPhone|iPod)/i.exec(HM);var ZM=!jM()&&(!!/(iPad)/i.exec(HM)||/Macintosh/i.test(HM)&&"ontouchend"in document),$M=!jM()&&/Macintosh/i.test(HM),eD=!jM()&&/MicroMessenger/i.test(HM),tD=!jM()&&mk(mM=HM.toLowerCase()).call(mM,"mobile");!jM()&&/SM-\w+/i.test(HM);var rD=!jM()&&!!/(iPhone|iPad|iPod)/i.exec(HM),nD=!jM()&&/Android/i.test(HM),iD=!jM()&&/Windows/i.test(HM),oD=0,aD=!jM()&&(null===(yM=HM.match(/version\/(\d+)/i))||void 0===yM?void 0:yM[1]);KM&&aD&&(oD=Number(aD));var sD=!jM()&&(null===(gM=HM.match(/Firefox\/(\d+)/i))||void 0===gM?void 0:gM[1]);zM&&sD&&(oD=Number(sD));var cD=oD,uD=oD,dD=null!==(SM=!jM()&&(null===(bM=HM.match(/ ([\d_]+) like Mac OS X/i))||void 0===bM||null===(EM=bM[1])||void 0===EM?void 0:jm(kM=EM.split("_")).call(kM,(function(e){return uy(e)}))))&&void 0!==SM?SM:[],lD=0,hD=!jM()&&(null===(TM=HM.match(/Chrome\/(\d+)/i))||void 0===TM?void 0:TM[1]);hD&&(lD=Number(hD));var pD=lD,vD="BytePlus",fD="RTC_DEVICE_ID",_D="RTC_ACCESS_NODE",mD="RTC_ACCESS_URLS",yD="ENGINE_WEB_CONFIG",gD="SERVER_CONFIG",SD=function(){function e(){Vl(this,e)}return Ul(e,[{key:"get",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{var r=JSON.parse(t);return r.ttl>0&&Date.now()-r.saveTime>r.ttl?(this.delete(e),null):r.message}catch(n){return null}}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n={ttl:r,saveTime:Date.now(),message:t};try{return localStorage.setItem(e,Nm(n)),!0}catch(i){return!1}}},{key:"getTtl",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{return JSON.parse(t).ttl}catch(r){return null}}},{key:"delete",value:function(e){try{return localStorage.removeItem(e),!0}catch(t){return!1}}}]),e}(),bD=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"_accessVersion","v2"),n}return Ul(r,[{key:"getDeviceId",value:function(){if(jM())return"";var e=this.get(fD);return e&&!/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e)||(e=function(e){for(var t="",r=0;r<e;r++)t+=Math.floor(10*Math.random());return t}(30)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return xO({device_id:e}),this.set(fD,e),e}},{key:"getAccessNode",value:function(e){var t,r;return this.get(Om(t=Om(r="".concat(_D,"_").concat(e,"-")).call(r,vD,"-")).call(t,this._accessVersion))}},{key:"setAccessNode",value:function(e,t,r){var n,i;return this.set(Om(n=Om(i="".concat(_D,"_").concat(e,"-")).call(i,vD,"-")).call(n,this._accessVersion),t,1e3*r)}},{key:"deleteAccessNode",value:function(e,t){var r,n,i=this.getAccessNode(e),o=this.getTtl(Om(r=Om(n="".concat(_D,"_").concat(e,"-")).call(n,vD,"-")).call(r,this._accessVersion));Array.isArray(i)&&i.length>0&&((i=Hs(i).call(i,(function(e){return e.mediaID!==t.mediaID&&e.msgKey!==t.msgKey}))).length>0?this.setAccessNode(e,i,o||0):this.clearAccessNode(e))}},{key:"clearAccessNode",value:function(e){var t,r;this.delete(Om(t=Om(r="".concat(_D,"_").concat(e,"-")).call(r,vD,"-")).call(t,this._accessVersion))}},{key:"getAccessUrls",value:function(){return this.get("".concat(mD,"-").concat(vD))}},{key:"setAccessUrls",value:function(e){var t=jm(e).call(e,(function(e){var t,r=e.host,n=e.path;return Om(t="https://".concat(r)).call(t,n)}));return this.set("".concat(mD,"-").concat(vD),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(mD,"-").concat(vD))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Om(r=Om(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(yD);return(null==a||null===(i=gE(a).call(a,(function(e){return e.key===o})))||void 0===i?void 0:i.config)||{}}},{key:"setEngineWebConfig",value:function(e,t,r){var n,i;if(r){var o=Om(n=Om(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(yD)||[];return(a=Hs(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(yD,km(a).call(a,-5))}}},{key:"getServerConfig",value:function(e){var t,r="".concat(e),n=this.get(gD);return(null==n||null===(t=gE(n).call(n,(function(e){return e.key===r})))||void 0===t?void 0:t.config)||{}}},{key:"setServerConfig",value:function(e,t){if(t){var r="".concat(e),n=this.get(gD)||[];return(n=Hs(n).call(n,(function(e){return e.key!==r}))).push({key:r,config:t}),this.set(gD,km(n).call(n,-5))}}}]),r}(SD),ED=new bD,kD=new Nw("JoinRoomConfig",0),TD=function(){function e(t){var r;Vl(this,e),Jd(this,"_useTcpAfterJoinTimeout",e.DEFAULT_CONF.useTcpAfterJoinTimeout),Jd(this,"_joinWithTcpOnly",e.DEFAULT_CONF.joinWithTcpOnly),Jd(this,"_joinWithTcpOnlyDelay",e.DEFAULT_CONF.joinWithTcpOnlyDelay),Jd(this,"_blackBrowserRegexList",[]),this._engineId=t,xE(r=location.search).call(r,"__rtc_tcp_only__")>-1&&(this._joinWithTcpOnly=!0,this._joinWithTcpOnlyDelay=0),this._report()}return Ul(e,[{key:"useTcpAfterJoinTimeout",get:function(){return this._useTcpAfterJoinTimeout}},{key:"useTcpJoin",get:function(){return this._joinWithTcpOnly}},{key:"useTcpJoinDelay",get:function(){return this._joinWithTcpOnlyDelay}},{key:"isBlackBrower",value:function(){var e;return gE(e=this._blackBrowserRegexList).call(e,(function(e){return new RegExp(e).test(navigator.userAgent)}))}},{key:"setServerConfig",value:function(e){var t,r,n,i,o,a,s=!1;"boolean"==typeof(null==e||null===(t=e.use_tcp_after_join_timeout)||void 0===t?void 0:t.enable)&&(this._useTcpAfterJoinTimeout=null===(i=e.use_tcp_after_join_timeout)||void 0===i?void 0:i.enable,s=!0);"boolean"==typeof(null==e||null===(r=e.join_with_tcp_only)||void 0===r?void 0:r.enable)&&(this._joinWithTcpOnly=null===(o=e.join_with_tcp_only)||void 0===o?void 0:o.enable,s=!0);"number"==typeof(null==e||null===(n=e.join_with_tcp_only)||void 0===n?void 0:n.delay_ms)&&(this._joinWithTcpOnlyDelay=null===(a=e.join_with_tcp_only)||void 0===a?void 0:a.delay_ms,s=!0);e&&Array.isArray(e.black_browser_regex_list)&&(this._blackBrowserRegexList=e.black_browser_regex_list,s=!0),s&&this._report()}},{key:"toString",value:function(){return Nm({use_tcp_after_join_timeout:this._useTcpAfterJoinTimeout,join_with_tcp_only:this._joinWithTcpOnly,join_with_tcp_only_delay:this._joinWithTcpOnlyDelay,black_browser_regex_list:this._blackBrowserRegexList})}},{key:"_report",value:function(){kD.print("_report",this.toString()),jO(this._engineId,"web_join_room_config",this.toString())}}],[{key:"setDefaulConf",value:function(t){var r=t.useTcpAfterJoinTimeout,n=t.joinWithTcpOnly,i=t.joinWithTcpOnlyDelay;return"boolean"==typeof r&&(e.DEFAULT_CONF.useTcpAfterJoinTimeout=r),"boolean"==typeof n&&(e.DEFAULT_CONF.joinWithTcpOnly=n),"number"==typeof i&&(e.DEFAULT_CONF.joinWithTcpOnlyDelay=Math.max(0,i)),e.DEFAULT_CONF}}]),e}();Jd(TD,"DEFAULT_CONF",{useTcpAfterJoinTimeout:!0,joinWithTcpOnly:!1,joinWithTcpOnlyDelay:5e3});var ID="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function RD(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://".concat(e)),"".concat(e,"/dispatch/v1/AccessInfo?Action=GetAccessInfo")}var AD="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",wD="rtc.rtcplus.com".split(","),CD={VERSION:"4.55.14",ICE_CONFIG_REQUEST_URLS_INTERNAL:jm(ID).call(ID,RD),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:AD,CONFIG_REQUEST_DOMAINS:wD,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",FORCE_ENABLED_REPORT_CALLBACKS:[],SKIP_WEB_AUDIO_IN_TRACK:!1,AUDIO_STALL:!0,VIDEO_STALL:!0,STATS_SCALLBACK_SUPPORT:!0,JOIN_ROOM_CONFIG:TD.DEFAULT_CONF,IOS_SAFARI_ORIENTATION:!1,ENABLE_REPORT_ERROR_BUFFER:!1,PUB_SUB_MODE:"recv_and_send",ENABLE_FALLBACK_HANDLER:!1,ENABLE_STANDARD_HANDLER:!1,PC_KILLSWITCH:{}};function xD(e,t){var r;if(DO("setParameter",0,Om(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("JOIN_ROOM_CONFIG"===e)return TD.setDefaulConf(t);if("ICE_CONFIG_REQUEST_URLS"===e)return"string"==typeof t&&(t=[t]),void(CD.ICE_CONFIG_REQUEST_URLS=jm(t).call(t,RD));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(CD.FORCE_ENABLED_REPORT_CALLBACKS=t);if("LOG_SERVER_URL"===e){var n=t===pl.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===pl.domestic?AD:"string"==typeof t?t:void 0;n&&(CD.LOG_SERVER_URL=n,OO(n))}else if("OVERSEA"===e)return xO({extra_is_oversea:t?"1":"0"}),void(CD.OVERSEA=t);"DEVICE_ID"===e&&ED.setDeviceId(t),"ENABLE_REPORT_ERROR_BUFFER"===e&&t&&kO.enableErrorBuffer(),CD[e]=t}else xO({product:t});else xO({platform:t})}}function OD(e){return"DEVICE_ID"===e?ED.getDeviceId():CD[e]}function MD(e,t,r){var n,i,o,a,s,c,u,d,l;return{type:"publicstream",action:t,publicStreamID:e,publicStreamMeta:{audio:{},video:{fps:(null===(n=r.video)||void 0===n?void 0:n.fps)||15,bitrate:1e3*((null===(i=r.video)||void 0===i?void 0:i.kBitRate)||40),width:(null===(o=r.video)||void 0===o?void 0:o.width)||640,height:(null===(a=r.video)||void 0===a?void 0:a.height)||360},layout:{layoutMode:2,interpolationMode:(null===(s=r.layout)||void 0===s?void 0:s.interpolationMode)||_l.PREV_FRAME,canvas:{bgColor:(null===(c=r.layout)||void 0===c?void 0:c.backgroundColor)||"#000000",bgImage:(null===(u=r.layout)||void 0===u?void 0:u.backgroundImage)||""},regions:(null===(d=r.layout)||void 0===d||null===(l=d.regions)||void 0===l?void 0:jm(l).call(l,(function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:!e.alpha||Number(e.alpha)>1||Number(e.alpha)<=0?1:Number(e.alpha),x:!e.x||Number(e.x)>=1||Number(e.x)<0?0:Number(e.x),y:!e.y||Number(e.y)>=1||Number(e.y)<0?0:Number(e.y),w:!e.w||Number(e.w)>1||Number(e.w)<=0?1:Number(e.w),h:!e.h||Number(e.h)>1||Number(e.h)<=0?1:Number(e.h),zorder:!e.zorder||Number(e.zorder)<0||Number(e.zorder)>100?0:Number(e.zorder),renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var DD={width:640,height:480,frameRate:15,maxKbps:600},PD={width:1920,height:1080,frameRate:15,maxKbps:3e3};function ND(e,t){if("boolean"!=typeof e)throw new mA(pA.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function LD(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(e<r||e>n||"number"!=typeof e){var i,o,a=new mA(pA.INVALID_PARAMS,Om(i=Om(o="Invalid ".concat(t,": the value range is [")).call(o,r,", ")).call(i,n,"]. integer only"));throw a}}function UD(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(null==e)throw new mA(pA.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!GD(e,i,o))throw new mA(pA.INVALID_PARAMS,Om(r=Om(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function VD(e,t,r){var n;if(!mk(r).call(r,e))throw new mA(pA.INVALID_PARAMS,Om(n="Invalid ".concat(t,": The value can only be set as ")).call(n,Nm(r)))}function FD(e){if(!(e instanceof MediaStreamTrack))throw new mA(pA.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function BD(e,t){if(zD(e))throw new mA(pA.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function jD(e,t){if(!(e instanceof ArrayBuffer))throw new mA(pA.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function HD(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 GD(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 zD(e){return null==e}function KD(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mA(pA.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function XD(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mA(pA.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function WD(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mA(pA.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function qD(e){BD(e,"userInfo"),XD(e.userId),zD(e.extraInfo)||UD(e.extraInfo,"userInfo.extraInfo",1,200)}function YD(e){BD(e,"roomConfig"),ND(e.isAutoPublish,"roomConfig.isAutoPublish"),ND(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),ND(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),zD(e.roomProfileType)||VD(e.roomProfileType,"roomConfig",[bl.communication,bl.chat,bl.chatRoom,bl.coHost,bl.meeting,bl.classRoom])}function JD(e){BD(e,"videoPlayerOption")}function QD(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64;if(!e||0===(null==e?void 0:e.byteLength))throw new mA(pA.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:pM.str2ab(Nm(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new mA(pA.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function ZD(e){var t,r=OD("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!mk(r).call(r,e))||!mk(t=[Nl.onRemoteStreamStats,Nl.onLocalStreamStats,Nl.onAudioVolumeIndication,Nl.onLocalAudioPropertiesReport,Nl.onRemoteAudioPropertiesReport]).call(t,e)}function $D(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new mA(pA.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function eP(e,t){if("number"!=typeof e||Number.isNaN(e)||!(e>=1)){var r=e;if(!(null!=r&&r.min||null!=r&&r.max||null!=r&&r.exact||null!=r&&r.ideal))throw new mA(pA.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function tP(e){var t,r=$T(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;LD(null==n?void 0:n.maxKbps,"maxKbps"),eP(null==n?void 0:n.width,"width"),eP(null==n?void 0:n.height,"height"),eP(null==n?void 0:n.frameRate,"frameRate")}}catch(i){r.e(i)}finally{r.f()}}function rP(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 LD(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var nP={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?km(n).call(n,1):n);return xs?Om(i).call(i,xs(e)):i},s.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a},s.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,d=this._events[s],l=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),l){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,i),!0;case 5:return d.fn.call(d.context,t,n,i,o),!0;case 6:return d.fn.call(d.context,t,n,i,o,a),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];d.fn.apply(d.context,c)}else{var h,p=d.length;for(u=0;u<p;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),l){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,n);break;case 4:d[u].fn.call(d[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];d[u].fn.apply(d[u].context,c)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var c=0,u=[],d=s.length;c<d;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(nP);var iP=nP.exports,oP=new Nw("VERTC",0),aP=function(e){DI(r,e);var t=QI(r);function r(){return Vl(this,r),t.apply(this,arguments)}return Ul(r,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var n,i,o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return(n=OI(CI(r.prototype),"emit",this)).call.apply(n,Om(i=[this,e]).call(i,a))}catch(cq){return oP.error("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,cq),console.error(cq),Boolean(t)}}}]),r}(nP.exports.EventEmitter),sP=O,cP=tr,uP=$,dP=nI,lP=Jt,hP=A,pP=mc,vP=V;Ar({target:"Reflect",stat:!0,forced:i((function(){var e=function(){},t=lP.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}))},{set:function e(t,r,n){var i,o,a,s=arguments.length<4?t:arguments[3],c=hP.f(cP(t),r);if(!c){if(uP(o=pP(t)))return e(o,r,n,s);c=vP(0)}if(dP(c)){if(!1===c.writable||!uP(s))return!1;if(i=hP.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,lP.f(s,r,i)}else lP.f(s,r,vP(0,n))}else{if(void 0===(a=c.set))return!1;sP(a,s,n)}return!0}});var fP=ee.Reflect.set,_P=hi.f("asyncIterator");function mP(e){var t,r,n,i=2;for(void 0!==wd&&(r=_P,n=Xd);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new yP(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function yP(e){function t(e){if(Object(e)!==e)return Y_.reject(new TypeError(e+" is not an object."));var t=e.done;return Y_.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(yP=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Y_.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Y_.reject(e):t(r.apply(this.s,arguments))}},new yP(e)}var gP=[{maxLayers:3,totalPixels:2073600},{maxLayers:3,totalPixels:921600},{maxLayers:3,totalPixels:518400},{maxLayers:2,totalPixels:230400},{maxLayers:2,totalPixels:129600},{maxLayers:1,totalPixels:57600},{maxLayers:1,totalPixels:0}];Yy("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hg);var SP=ee.Set;Ar({target:"Set",stat:!0,forced:!0},{from:bg}),Ar({target:"Set",stat:!0,forced:!0},{of:kg});var bP=O,EP=Ce,kP=tr,TP=function(){for(var e=kP(this),t=EP(e.add),r=0,n=arguments.length;r<n;r++)bP(t,e,arguments[r]);return e};Ar({target:"Set",proto:!0,real:!0,forced:!0},{addAll:TP}),Ar({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:Ag});var IP=gh,RP=tr,AP=Yt,wP=IP,CP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=RP(this),r=wP(t),n=AP(e,arguments.length>1?arguments[1]:void 0);return!CP(r,(function(e,r){if(!n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var xP=oe,OP=O,MP=Ce,DP=tr,PP=Rp,NP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){var t=DP(this),r=new(PP(t,xP("Set")))(t),n=MP(r.delete);return NP(e,(function(e){OP(n,r,e)})),r}});var LP=oe,UP=O,VP=Ce,FP=tr,BP=Yt,jP=Rp,HP=IP,GP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=FP(this),r=HP(t),n=BP(e,arguments.length>1?arguments[1]:void 0),i=new(jP(t,LP("Set"))),o=VP(i.add);return GP(r,(function(e){n(e,e,t)&&UP(o,i,e)}),{IS_ITERATOR:!0}),i}});var zP=tr,KP=Yt,XP=IP,WP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=zP(this),r=XP(t),n=KP(e,arguments.length>1?arguments[1]:void 0);return WP(r,(function(e,r){if(n(e,e,t))return r(e)}),{IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var qP=oe,YP=O,JP=Ce,QP=tr,ZP=Rp,$P=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){var t=QP(this),r=new(ZP(t,qP("Set"))),n=JP(t.has),i=JP(r.add);return $P(e,(function(e){YP(n,t,e)&&YP(i,r,e)})),r}});var eN=O,tN=Ce,rN=tr,nN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){var t=rN(this),r=tN(t.has);return!nN(e,(function(e,n){if(!0===eN(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var iN=oe,oN=O,aN=Ce,sN=R,cN=tr,uN=gh,dN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){var t=uN(this),r=cN(e),n=r.has;return sN(n)||(r=new(iN("Set"))(e),n=aN(r.has)),!dN(t,(function(e,t){if(!1===oN(n,r,e))return t()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var lN=O,hN=Ce,pN=tr,vN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){var t=pN(this),r=hN(t.has);return!vN(e,(function(e,n){if(!1===lN(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var fN=Ar,_N=tr,mN=yn,yN=IP,gN=Uh,SN=E([].join),bN=[].push;fN({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=_N(this),r=yN(t),n=void 0===e?",":mN(e),i=[];return gN(r,bN,{that:i,IS_ITERATOR:!0}),SN(i,n)}});var EN=oe,kN=Yt,TN=O,IN=Ce,RN=tr,AN=Rp,wN=IP,CN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=RN(this),r=wN(t),n=kN(e,arguments.length>1?arguments[1]:void 0),i=new(AN(t,EN("Set"))),o=IN(i.add);return CN(r,(function(e){TN(o,i,n(e,e,t))}),{IS_ITERATOR:!0}),i}});var xN=Ce,ON=tr,MN=IP,DN=Uh,PN=TypeError;Ar({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=ON(this),r=MN(t),n=arguments.length<2,i=n?void 0:arguments[1];if(xN(e),DN(r,(function(r){n?(n=!1,i=r):i=e(i,r,r,t)}),{IS_ITERATOR:!0}),n)throw PN("Reduce of empty set with no initial value");return i}});var NN=tr,LN=Yt,UN=IP,VN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=NN(this),r=UN(t),n=LN(e,arguments.length>1?arguments[1]:void 0);return VN(r,(function(e,r){if(n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var FN=oe,BN=O,jN=Ce,HN=tr,GN=Rp,zN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){var t=HN(this),r=new(GN(t,FN("Set")))(t),n=jN(r.delete),i=jN(r.add);return zN(e,(function(e){BN(n,r,e)||BN(i,r,e)})),r}});var KN=oe,XN=Ce,WN=tr,qN=Rp,YN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){var t=WN(this),r=new(qN(t,KN("Set")))(t);return YN(e,XN(r.add),{that:r}),r}});var JN=SP,QN=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!jM()&&window.RTCPeerConnection&&window.RTCPeerConnection.prototype.addTransceiver&&window.RTCPeerConnection.prototype.createDataChannel){e.next=3;break}return e.abrupt("return",!1);case 3:return e.next=5,cL();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,sL();case 9:e.t0=e.sent;case 10:return e.abrupt("return",e.t0);case 13:return e.prev=13,e.t1=e.catch(0),e.abrupt("return",!1);case 16:case"end":return e.stop()}}),e,null,[[0,13]])})));return function(){return e.apply(this,arguments)}}(),ZN=function(){var e=Rm(Tm().mark((function e(t){var r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t||"recv_and_send",n=[],e.next=4,cL();case 4:return i=e.sent,e.next=7,sL();case 7:return o=e.sent,e.next=10,dL();case 10:return a=e.sent,e.next=13,uL();case 13:return s=e.sent,"send_only"===r&&(o&&n.push("H264"),s&&n.push("vp8")),"recv_only"===r&&(i&&n.push("H264"),a&&n.push("vp8")),"recv_and_send"===r&&(o&&i&&n.push("H264"),s&&a&&n.push("vp8")),e.abrupt("return",n);case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),$N=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Nm(rL));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),eL=function(){var e=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ZN();case 2:return t=e.sent,e.abrupt("return",jm(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),tL={},rL={};function nL(e){var t,r=!1,n=$T(e.split("\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value;if(mk(i).call(i,"level-asymmetry-allowed=1")&&mk(i).call(i,"packetization-mode=1")&&mk(i).call(i,"profile-level-id=42e0")){r=!0;break}}}catch(d){n.e(d)}finally{n.f()}if(r){for(var o=navigator.userAgent.toLowerCase(),a=!1,s=0,c=["miuibrowser"];s<c.length;s++){var u=c[s];mk(o).call(o,u)&&(a=!0)}return!a}return!1}var iL=function(){var e=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("video",{direction:t}),e.next=4,r.createOffer();case 4:return n=e.sent,r.close(),e.abrupt("return",n.sdp.toLowerCase());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),oL=function(){var e=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,iL("sendonly");case 2:if(r=e.sent,!mk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,iL("sendonly");case 6:r=e.sent;case 7:return tL.h264encode=nL(r),rL.h264encode=r,tL.vp8encode=xE(r).call(r,"vp8")>-1,rL.vp8encode="same as h264encode",e.abrupt("return",tL);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),aL=function(){var e=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,iL("recvonly");case 2:if(r=e.sent,!mk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,iL("recvonly");case 6:r=e.sent;case 7:return tL.h264decode=nL(r),rL.h264decode=r,tL.vp8decode=xE(r).call(r,"vp8")>-1,rL.vp8decode="same as h264decode",e.abrupt("return",tL);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),sL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==tL.h264encode){e.next=10;break}return e.prev=1,e.next=4,oL();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),rL.h264encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",tL.h264encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),cL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==tL.h264decode){e.next=10;break}return e.prev=1,e.next=4,aL();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),rL.h264decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",tL.h264decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),uL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==tL.vp8encode){e.next=10;break}return e.prev=1,e.next=4,oL();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),rL.vp8encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",tL.vp8encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),dL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==tL.vp8decode){e.next=10;break}return e.prev=1,e.next=4,aL();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),rL.vp8decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",tL.vp8decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),lL=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},hL=function(){return $M?XM&&pD>=70||zM&&uD>=80||KM&&cD>=14:iD?XM&&pD>=70||zM&&uD>=80:rD?dD[0]>=14:!!nD&&(XM&&pD>=86)},pL=XM&&pD<=114,vL=!zM||uD>=96,fL=!(KM&&cD<=14);nD&&XM||rD&&(17===dD[0]||dD[0]);var _L=new $S,mL=function(){var e=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Y_((function(e,r){var n=OD("STATS_SCALLBACK_SUPPORT");if(XM&&void 0===window.InstallTrigger&&pL&&n)try{t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!mk(bL).call(bL,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(Zd(Zd({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return Hs(r).call(r,(function(t){return"ssrc"!==t.type||t.googTrackId===e}))}})}))}catch(cq){r(cq)}else e({all:[],getTrackStats:function(){return[]}})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),yL=function(){var e=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getStats();case 2:return n=e.sent,i={all:[]},o=new $S,n.forEach((function(e){var t=o.get(e.type)||new $S;t.set(e.id,e),o.set(e.type,t),i.all.push(e)})),a=function(e,t){e.forEach((function(e){var r,n,i,a,s,c,u=e.codecId,d=e.transportId,l=e.trackId,h=e.playoutId;if(null===(r=o.get(SL.codec))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=o.get(SL.transport))||void 0===n||n.forEach((function(e){e.id===d&&(s=e,t.add(e))})),null===(i=o.get(SL.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(a=o.get(SL.mediaPlayout))||void 0===a||a.forEach((function(e){e.id===h&&t.add(e)})),s){var p,v,f=s,_=f.localCertificateId,m=f.remoteCertificateId,y=f.selectedCandidatePairId;null===(p=o.get(SL.certificate))||void 0===p||p.forEach((function(e){(e.id===_||e.id===m)&&t.add(e)})),null===(v=o.get(SL.candidatePair))||void 0===v||v.forEach((function(e){e.id===y&&(c=e,t.add(e))}))}if(c){var g,S,b=c,E=b.localCandidateId,k=b.remoteCandidateId;null===(g=o.get(SL.localCandidate))||void 0===g||g.forEach((function(e){e.id===E&&t.add(e)})),null===(S=o.get(SL.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===k&&t.add(e)}))}}))},o.get(SL.mediaSource)?null===(s=o.get(SL.mediaSource))||void 0===s||s.forEach((function(e){var t,r=new JN;r.add(e);var n=[];null===(t=o.get(SL.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=o.get(SL.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=qk(r)})):o.get(SL.track)&&(null===(c=o.get(SL.track))||void 0===c||c.forEach((function(e){var t,r=new JN;r.add(e);var n=[];null===(t=o.get(SL.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.trackId===e.id&&(r.add(t),n.push(t),null===(i=o.get(SL.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=qk(r)}))),null===(r=o.get(SL.inboundRtp))||void 0===r||r.forEach((function(e){var t,r=new JN;r.add(e),null===(t=o.get(SL.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),a([e],r);var n,s=e.trackIdentifier;s||(null===(n=o.get(SL.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(s=t.trackIdentifier)})));i[s]=qk(r)})),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),gL=function(){var e=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!zM&&!KM){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=_L.get(t))||Date.now()-a.timestamp>150)&&(a={timestamp:Date.now(),statsPromise:yL(t),extraStatsPromise:mL(t)},_L.set(t,a)),e.next=14,a.statsPromise;case 14:if(s=e.sent,c=(i?s[i]:s.all)||[],n){e.next=21;break}return e.next=19,a.extraStatsPromise;case 19:u=e.sent,c=Om(c).call(c,(i?u.getTrackStats(i):u.all)||[]);case 21:return e.abrupt("return",c);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),SL=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}(SL||{}),bL=["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"],EL={},kL={},TL={exports:{}},IL=TL.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(IL).forEach((function(e){IL[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=TL.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t,o={},a=[],s=o;return Hs(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=km(e).call(e,2);"m"===t&&(a.push({rtp:[],fmtp:[]}),s=a[a.length-1]);for(var o=0;o<(n[t]||[]).length;o+=1){var c=n[t][o];if(c.reg.test(i))return r(c,s,i)}})),o.media=a,o};var o=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){var t;return pb(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return jm(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=jm(r=e.split(" ")).call(r,t),o=0;o<i.length;o+=3)n.push({component:i[o],ip:i[o+1],port:i[o+2]});return n},e.parseImageAttributes=function(e){var t;return jm(t=e.split(" ")).call(t,(function(e){var t;return pb(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return jm(r=e.split(";")).call(r,(function(e){var r;return jm(r=e.split(",")).call(r,(function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(kL);var RL=TL.exports,AL=/%[sdv%]/g,wL=function(e){var t=1,r=arguments,n=r.length;return e.replace(AL,(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""}}))},CL=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 wL.apply(null,n)},xL=["v","o","s","i","u","e","p","c","b","t","r","z","a"],OL=["i","c","b","a"],ML=kL,DL=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||xL,n=t.innerOrder||OL,i=[];return r.forEach((function(t){RL[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(CL(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(CL(t,r,e))}))}))})),e.media.forEach((function(e){i.push(CL("m",RL.m[0],e)),n.forEach((function(t){RL[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(CL(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(CL(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};EL.write=DL,EL.parse=ML.parse,EL.parseParams=ML.parseParams,EL.parseFmtpConfig=ML.parseFmtpConfig,EL.parsePayloads=ML.parsePayloads,EL.parseRemoteCandidates=ML.parseRemoteCandidates,EL.parseImageAttributes=ML.parseImageAttributes,EL.parseSimulcastStreamList=ML.parseSimulcastStreamList;var PL=Xe,NL=Nr,LL=Br,UL=function(e){for(var t=PL(this),r=LL(t),n=arguments.length,i=NL(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:NL(o,r);a>i;)t[i++]=e;return t};Ar({target:"Array",proto:!0},{fill:UL});var VL=Us("Array").fill,FL=ae,BL=VL,jL=Array.prototype,HL=function(e){var t=e.fill;return e===jL||FL(jL,e)&&t===jL.fill?BL:t},GL=new Nw("FirefoxHandler",3),zL=Math.pow(2,32),KL="kp34Za0H+aVf862l",XL="o/i14u9pJrxRKAsu";function WL(e){return e>zL-18?(GL.warn("generateAllSsrc","reset start id",e),WL(e=e-zL+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var qL=function(e,t,r){var n,i,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:XL;return[{id:r,attribute:"cname",value:a},{id:r,attribute:"msid",value:Om(n=Om(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Om(o="".concat(e,"-")).call(o,t)}]},YL=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.video,o=t.videoRtx,a=t.videoFec,s=[i,o],c=n.cname,u=n.flexfec;u&&s.push(a);var d,l=pb(s).call(s,(function(t,r){return Om(t).call(t,qL(e,"video",r,c))}),[]),h=[{semantics:"FID",ssrcs:Om(r="".concat(i," ")).call(r,o)}];u&&h.push({semantics:"FEC-FR",ssrcs:Om(d="".concat(i," ")).call(d,a)});return{ssrcs:l,ssrcGroups:h}};function JL(e){return e.direction="inactive",e.port=0,delete e.ext,delete e.ssrcs,delete e.ssrcGroups,delete e.simulcast,delete e.simulcast_03,delete e.rids,delete e.extmapAllowMixed,delete e.msid,delete e.bundleOnly,e}var QL=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=Zd(Zd({},e),{},{media:[]});return n&&(i.invalid=[{value:"realx-exts:rscp"}]),t&&i.media.push(t),r&&i.media.push(r),delete i.groups,delete i.msidSemantic,EL.write(i)};function ZL(e){return $L.apply(this,arguments)}function $L(){return($L=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},n=t.publicIPs,i=t.certFingerprint,o=t.iceParams,a=t.iceConfig,r.fingerprint={type:"sha-256",hash:i},r.icePwd=o.serverIcePwd,e.next=6,tU(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=eU(n,a),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function eU(e,t){if(!Array.isArray(e))return[];var r=0,n=2130706431,i=[];return e.forEach((function(e){var o={component:1,ip:e.ip,type:"host",generation:e.generation};e.udpPorts&&!t.tcpOnly&&e.udpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var tU=function(){var e=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new TextEncoder,n=r.encode("PREC"),e.t0=Uint8Array,e.next=5,pM.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=hM(Uint8Array,n,i,o,a),e.next=15,pM.ab2b64str(s.buffer);case 15:return c=e.sent,e.abrupt("return",c);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),rU=function(e){return e[e.kICEConfigTypeSrtpDtlsType=0]="kICEConfigTypeSrtpDtlsType",e[e.kICEConfigTypeRenominationType=1]="kICEConfigTypeRenominationType",e[e.kICEConfigTypeTcpType=2]="kICEConfigTypeTcpType",e[e.kICEConfigTypeMultiSendType=3]="kICEConfigTypeMultiSendType",e[e.kICEConfigTypeKcpType=4]="kICEConfigTypeKcpType",e[e.kICEConfigTypeSrtpSdesType=5]="kICEConfigTypeSrtpSdesType",e}(rU||{});function nU(e){var t,r=e.random,n=e.serverUfrag,i=e.serverPwd,o=e.clientPwd,a=e.options,s=(new TextEncoder).encode("WPRE");r||(r=new Uint8Array(4),crypto.getRandomValues(r));var c=UM(n);c.byteLength;var u=FM(UM(o),UM(i).subarray(0,16),UM(n).subarray(0,16));u.byteLength;var d=new Uint8Array(pb(t=an(a)).call(t,(function(e,t){var r=Number(t);return e.push(r),e.push(a[r]?1:0),e}),[]));d.byteLength;var l,h=hM(Uint8Array,s,r,[c.byteLength],c,[u.byteLength],u,d);h.byteLength%3!=0&&(h=hM(Uint8Array,h,HL(l=new Uint8Array(3-h.byteLength%3)).call(l,255)));return[VM(h),VM(hM(Uint8Array,r,c.subarray(0,20)))]}var iU=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=$T(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(mk(o=c.config).call(o,"level-asymmetry-allowed=1")&&mk(a=c.config).call(a,"packetization-mode=1")&&mk(s=c.config).call(s,"profile-level-id=42e0")){r=c.payload;break}}}catch(v){i.e(v)}finally{i.f()}for(var u=0;u<e.rtp.length;u++){var d=e.rtp[u];if("H264"===t){if(d.payload===r){var l;e.rtp.unshift(rk(l=e.rtp).call(l,u,1)[0]);break}}else if(d.codec===t){var h;e.rtp.unshift(rk(h=e.rtp).call(h,u,1)[0]);break}}var p=[];e.rtp.forEach((function(e){return p.push(e.payload)})),e.payloads=p.join(" ")}},oU=new Nw("BasicHandler",3),aU=function(e){DI(n,e);var t,r=QI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this)),"_peerConnection",void 0),Jd(tI(i),"_dataChannel",void 0),Jd(tI(i),"_context",void 0),Jd(tI(i),"peerConnectionMode",0),Jd(tI(i),"peerConnectionId",""),Jd(tI(i),"id",void 0),Jd(tI(i),"_monitor",void 0),Jd(tI(i),"_nextSsrc",Math.floor(Math.random()*zL+1e4)),Jd(tI(i),"_aSendonlyAnswerTpl",void 0),Jd(tI(i),"_vSendonlyAnswerTpl",void 0),Jd(tI(i),"_enableSubFlexfec",!1),Jd(tI(i),"audioTrack4ff",void 0),Jd(tI(i),"setLocalDescription",void 0),Jd(tI(i),"setRemoteDescription",void 0),i.peer=t,i.id=e.id,i._monitor=VO(i.id),i._peerConnection=t.getOriginRTCPeerConnection(),i._dataChannel=t.getOriginRTCDataChannel(),i.setLocalDescription=t.setLocalDescription.bind(t),i.setRemoteDescription=t.setRemoteDescription.bind(t),i._context=e,i.peer.on("ontrack",(function(e){i.emit("ontrack",e)})),i}return Ul(n,[{key:"destroy",value:function(){oU.info("destroy",this.peerConnectionId||""),OI(CI(n.prototype),"removeAllListeners",this).call(this)}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"getConnectionState",value:function(){return this._peerConnection.connectionState}},{key:"_simulcast",value:function(e,t,r,n,i){var o,a,s,c=[];1===e.videoEncodeConfig.length?(c=function(e,t){var r=[];if(t<=1)return r;var n=Math.min(e.width,e.height)/90;return r.push({scaleResolutionDownBy:n,width:Math.floor(e.width/n),height:Math.floor(e.height/n),maxkbps:100,frameRate:10}),t<=2||r.unshift({scaleResolutionDownBy:2,width:Math.floor(e.width/2),height:Math.floor(e.height/2),maxkbps:Math.floor(e.maxKbps/2),frameRate:e.frameRate>=30?Math.floor(e.frameRate/2):e.frameRate}),r}(t,i),oU.info("simulcast() ","simulcastLayers: %o",c)):(c=jm(o=km(a=km(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){var r=LM(e.width),n=t.width/r;return{width:r,height:Math.floor(t.height/n),scaleResolutionDownBy:n,frameRate:LM(e.frameRate)||15,maxkbps:e.maxKbps||600}})),oU.info("simulcast() ","simulcastLayers2: %o",c));var u=[!0];c.forEach((function(e,t){var i,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:e.scaleResolutionDownBy,rid:"".concat(t+1),maxFramerate:e.frameRate};null===(i=r.sendEncodings)||void 0===i||i.unshift(o),n.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)}),u.push(!0)})),this._context&&(this._context.activeSimStreams=u)}},{key:"internalPublish",value:function(e){var t=e.stream,r=e.videoTrack,n=e.audioTrack,i=e.enableSimulcast,o=e.pubAudio,a=e.pubVideo,s={direction:"sendonly",streams:[t]},c={direction:"sendonly",streams:[t]},u=[],d=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var l=null==r?void 0:r.getTrack(),h=Zd({},DD);if(l){var p=null==l?void 0:l.getSettings();h={width:Math.floor(p.width),height:Math.floor(p.height),frameRate:Math.floor(p.frameRate)}}"number"!=typeof h.frameRate&&(h.frameRate=30);var v=null==e?void 0:e.videoEncodeConfig[0],f={maxBitrate:1e3*v.maxKbps,rid:"0"};if(e.prevBitrate=v.maxKbps,c.sendEncodings=[f],u.push({width:h.width,height:h.height,framerate:h.frameRate,maxkbps:v.maxKbps,rid:"0"}),!zM&&i){var _,m,y=function(e){for(var t=0,r=e.width*e.height,n=0;n<gP.length;n++)if(r>=gP[n].totalPixels){t=n;break}if(0===t)return gP[t].maxLayers;var i=gP[t-1].totalPixels;return(i-r)/(i-gP[t].totalPixels)<.1?gP[t-1].maxLayers:gP[t].maxLayers}(h);if(oU.info("simulcast() ","maxLayers: %o",y),y>1)this._simulcast(e,Zd(Zd({},h),{},{maxKbps:v.maxKbps}),c,u,y),null!==(_=this._context)&&void 0!==_&&null!==(m=_.serverConfig)&&void 0!==m&&m.simulcastOnDemand&&(d=jm(u).call(u,(function(e,t){return Zd(Zd({},e),{},{video_index:t,sub_index:t})})))}}oU.info("publish videoTransceiverInit videoDescriptions","",c,u);var g=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==Ml.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(g=null==n?void 0:n.mixedAudioTrack),g=o&&g?g:"audio";var S=null==r?void 0:r.getTrack("preprocessing");S=a&&S?S:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",Nm({aTrack:MM(g),vTrack:MM(S),audioTransceiverInit:s,videoTransceiverInit:c}))}catch(cq){}return{semantics:"unified-plan",videoDescriptions:u,subVideoDescriptions:d,audioTransceiverInit:{track:g,init:s},videoTransceiverInit:{track:S,init:c}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;oU.info("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.getTrack(),a=e.videoTransceiver;if(o&&e.pubVideo&&a){var s=null===(r=e.videoEncodeConfig)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.maxKbps;if(s){if(s===e.prevBitrate)return void oU.warn("updateMaxBitrate()","no change");e.prevBitrate=s}var c=null===(i=a.sender)||void 0===i?void 0:i.getParameters();if(c){var u;c.encodings=null==c||null===(u=c.encodings)||void 0===u?void 0:jm(u).call(u,(function(t){var r,n=Number(t.rid)||0,i=null===(r=e.videoEncodeConfig[n])||void 0===r?void 0:r.maxKbps;return"number"==typeof i&&(t.maxBitrate=1e3*i),t})),null==a||a.sender.setParameters(c);try{this._reportRtcInvokeStatus("Handler.updateScaleResolutionDownBy",Nm(c.encodings))}catch(cq){}}}else oU.warn("updateMaxBitrate()","no pub")}},{key:"getStats",value:function(e,t){return gL(this._peerConnection,e,t)}},{key:"setCurrentDescription",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineAnswerTpl",value:function(e){var t=this;EL.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:gE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:gE(i=e.fmtp).call(i,(function(e){return e.payload===n.payload}));o&&t._context&&(o.config+=";stereo=1;sprop-stereo=1")}t._aSendonlyAnswerTpl=e}}else"video"===e.type&&("sendonly"===e.direction&&(t._vSendonlyAnswerTpl=e),Array.isArray(e.rtp)&&e.rtp.forEach((function(e){var r;null!==(r=e.codec)&&void 0!==r&&mk(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))}))}},{key:"pc",get:function(){return this._peerConnection}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n,i=r.codec,o=r.payload;if(mk(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=gE(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=Om(s=[]).call(s,Jk(c.config.split(";")),["x-google-min-bitrate=100","x-google-start-bitrate=".concat(t)]).join(";");else e.fmtp.push({payload:o,config:"x-google-min-bitrate=100;x-google-start-bitrate=".concat(t)})}}))}},{key:"_report",value:function(e,t,r){var n;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this.peer.getConnectionId(),group_connection_id:this.peer.getGroupConnectionId()}),r)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}]),n}(nP.exports.EventEmitter),sU=E,cU=Qy,uU=dy.exports.getWeakData,dU=mp,lU=tr,hU=z,pU=$,vU=Uh,fU=Ye,_U=Zi.set,mU=Zi.getterFor,yU=Po.find,gU=Po.findIndex,SU=sU([].splice),bU=0,EU=function(e){return e.frozen||(e.frozen=new kU)},kU=function(){this.entries=[]},TU=function(e,t){return yU(e.entries,(function(e){return e[0]===t}))};kU.prototype={get:function(e){var t=TU(this,e);if(t)return t[1]},has:function(e){return!!TU(this,e)},set:function(e,t){var r=TU(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=gU(this.entries,(function(t){return t[0]===e}));return~t&&SU(this.entries,t,1),!!~t}};var IU,RU={getConstructor:function(e,t,r,n){var i=e((function(e,i){dU(e,o),_U(e,{type:t,id:bU++,frozen:void 0}),hU(i)||vU(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=mU(t),s=function(e,t,r){var n=a(e),i=uU(lU(t),!0);return!0===i?EU(n).set(t,r):i[n.id]=r,e};return cU(o,{delete:function(e){var t=a(this);if(!pU(e))return!1;var r=uU(e);return!0===r?EU(t).delete(e):r&&fU(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!pU(e))return!1;var r=uU(e);return!0===r?EU(t).has(e):r&&fU(r,t.id)}}),cU(o,r?{get:function(e){var t=a(this);if(pU(e)){var r=uU(e);return!0===r?EU(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}},AU=n,wU=E,CU=Qy,xU=dy.exports,OU=Yy,MU=RU,DU=$,PU=my,NU=Zi.enforce,LU=Vi,UU=!AU.ActiveXObject&&"ActiveXObject"in AU,VU=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},FU=OU("WeakMap",VU,MU);if(LU&&UU){IU=MU.getConstructor(VU,"WeakMap",!0),xU.enable();var BU=FU.prototype,jU=wU(BU.delete),HU=wU(BU.has),GU=wU(BU.get),zU=wU(BU.set);CU(BU,{delete:function(e){if(DU(e)&&!PU(e)){var t=NU(this);return t.frozen||(t.frozen=new IU),jU(this,e)||t.frozen.delete(e)}return jU(this,e)},has:function(e){if(DU(e)&&!PU(e)){var t=NU(this);return t.frozen||(t.frozen=new IU),HU(this,e)||t.frozen.has(e)}return HU(this,e)},get:function(e){if(DU(e)&&!PU(e)){var t=NU(this);return t.frozen||(t.frozen=new IU),HU(this,e)?GU(this,e):t.frozen.get(e)}return GU(this,e)},set:function(e,t){if(DU(e)&&!PU(e)){var r=NU(this);r.frozen||(r.frozen=new IU),HU(this,e)?zU(this,e,t):r.frozen.set(e,t)}else zU(this,e,t);return this}})}var KU=ee.WeakMap;Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{emplace:Og}),Ar({target:"WeakMap",stat:!0,forced:!0},{from:bg}),Ar({target:"WeakMap",stat:!0,forced:!0},{of:kg}),Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{deleteAll:Ag}),Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{upsert:ZS});var XU=KU,WU=function(e){DI(p,e);var t,r,n,i,o,a,s,c,u,d,l,h=QI(p);function p(){var e,t,r;return Vl(this,p),Jd(tI(r=h.call(this)),"inited",!1),Jd(tI(r),"deviceMap",{audioinput:new $S,audiooutput:new $S,videoinput:new $S}),Jd(tI(r),"checkDeviceChangeTimer",null),Jd(tI(r),"isSupportedPermissionsQuery",!1),Jd(tI(r),"isGrantedMicrophonePermission",!1),Jd(tI(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!jM()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(tI(r)),!jM()&&r.refreshDevices(),r}return Ul(p,[{key:"refreshDevices",value:(l=Rm(Tm().mark((function e(){var t,r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices){e.next=2;break}return e.abrupt("return");case 2:if(t=void 0,!zM){e.next=12;break}return e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:!0});case 7:t=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:return e.next=14,navigator.mediaDevices.enumerateDevices();case 14:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),r.forEach((function(e){var t;e.deviceId&&(null===(t=n.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))})),this.inited||this.initListener(),this.inited=!0;case 19:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return l.apply(this,arguments)})},{key:"initListener",value:(d=Rm(Tm().mark((function e(){var t,r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.ondevicechange)&&"function"==typeof(null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)?navigator.mediaDevices.addEventListener("devicechange",(function(){o._handleDeviceChange(),setTimeout((function(){o._handleDeviceChange()}),300)})):this.checkDeviceChangeTimer=window.setInterval((function(){o._handleDeviceChange()}),3e3),!this.isSupportedPermissionsQuery){e.next=22;break}return e.prev=2,e.next=5,navigator.permissions.query({name:"microphone"});case 5:n=e.sent,this.isGrantedMicrophonePermission="granted"===n.state,n.addEventListener("change",(function(){o.isGrantedMicrophonePermission="granted"===n.state})),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.prev=12,e.next=15,navigator.permissions.query({name:"camera"});case 15:i=e.sent,this.isGrantedCameraPermission="granted"===i.state,i.addEventListener("change",(function(){o.isGrantedCameraPermission="granted"===i.state})),e.next=22;break;case 20:e.prev=20,e.t1=e.catch(12);case 22:case"end":return e.stop()}}),e,this,[[2,10],[12,20]])}))),function(){return d.apply(this,arguments)})},{key:"_handleDeviceChange",value:(u=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=void 0,!zM){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=Hs(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=qk(Om(t=[]).call(t,Jk(oR(r=this.deviceMap.audioinput).call(r)),Jk(oR(n=this.deviceMap.videoinput).call(n)),Jk(oR(i=this.deviceMap.audiooutput).call(i)))),(tD||ZM)&&!s.length&&a.length&&a.forEach((function(e){var t;null===(t=c.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e)})),a.forEach((function(e){var t,r,n=c.deviceMap[e.kind].get(e.deviceId);c.deviceMap[e.kind].set(e.deviceId,e),n||(mk(t=e.kind).call(t,"video")?c.emit(Nl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):mk(r=e.kind).call(r,"audio")&&c.emit(Nl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;gE(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),mk(t=e.kind).call(t,"video")?c.emit(Nl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):mk(r=e.kind).call(r,"audio")&&c.emit(Nl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 14:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getUserMedia",value:(c=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia(t);case 2:return r=e.sent,null!=t&&t.audio&&(this.isGrantedMicrophonePermission=!0),null!=t&&t.video&&(this.isGrantedCameraPermission=!0),this.refreshDevices(),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(s=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={audio:!1,video:!1},navigator.mediaDevices){e.next=3;break}return e.abrupt("return",t);case 3:return e.next=5,navigator.mediaDevices.enumerateDevices();case 5:return r=e.sent,t.audio=Hs(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=Hs(r).call(r,(function(e){return"videoinput"===e.kind&&e.label&&e.deviceId})).length>0,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"getPermissions",value:(a=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=l.length>0&&void 0!==l[0]?l[0]:{},n=r.audio,i=r.video,o=r.force,n||i||(n=!0,i=!0),a={audio:!1,video:!1,reason:void 0},o){e.next=30;break}if(!this.isSupportedPermissionsQuery){e.next=20;break}if(!n||!i){e.next=14;break}if(!this.isGrantedMicrophonePermission||!this.isGrantedCameraPermission){e.next=12;break}return a.audio=!0,a.video=!0,e.abrupt("return",a);case 12:e.next=18;break;case 14:if(!(n&&this.isGrantedMicrophonePermission||i&&this.isGrantedCameraPermission)){e.next=18;break}return a.audio=this.isGrantedMicrophonePermission,a.video=this.isGrantedCameraPermission,e.abrupt("return",a);case 18:e.next=30;break;case 20:return e.next=22,this.checkPermissionsByDevices();case 22:if(s=e.sent,!n||!i){e.next=28;break}if(!s.audio||!s.video){e.next=26;break}return e.abrupt("return",s);case 26:e.next=30;break;case 28:if(!(n&&s.audio||i&&s.video)){e.next=30;break}return e.abrupt("return",s);case 30:if(null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=70;break}return e.prev=31,e.next=34,navigator.mediaDevices.getUserMedia({audio:n,video:i});case 34:(c=e.sent)&&(c.getTracks().forEach((function(e){return e.stop()})),n&&(a.audio=!0,this.isGrantedMicrophonePermission=!0),i&&(a.video=!0,this.isGrantedCameraPermission=!0)),e.next=70;break;case 38:if(e.prev=38,e.t0=e.catch(31),a.reason=e.t0,!this.isSupportedPermissionsQuery){e.next=70;break}if(!n){e.next=56;break}return e.next=45,navigator.permissions.query({name:"microphone"}).catch((function(){}));case 45:if(e.t2=u=e.sent,e.t1=null===e.t2,e.t1){e.next=49;break}e.t1=void 0===u;case 49:if(!e.t1){e.next=53;break}e.t3=void 0,e.next=54;break;case 53:e.t3=u.state;case 54:e.t4=e.t3,a.audio="granted"===e.t4;case 56:if(!i){e.next=70;break}return e.next=59,navigator.permissions.query({name:"camera"}).catch((function(){}));case 59:if(e.t6=d=e.sent,e.t5=null===e.t6,e.t5){e.next=63;break}e.t5=void 0===d;case 63:if(!e.t5){e.next=67;break}e.t7=void 0,e.next=68;break;case 67:e.t7=d.state;case 68:e.t8=e.t7,a.video="granted"===e.t8;case 70:return e.next=72,this.refreshDevices();case 72:return e.abrupt("return",a);case 73:case"end":return e.stop()}}),e,this,[[31,38]])}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions();case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(Om(t=[]).call(t,Jk(oR(r=this.deviceMap.audioinput).call(r)),Jk(oR(n=this.deviceMap.videoinput).call(n)),Jk(oR(i=this.deviceMap.audiooutput).call(i)))));case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"enumerateAudioCaptureDevices",value:(i=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(oR(t=this.deviceMap.audioinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"enumerateVideoCaptureDevices",value:(n=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({video:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(oR(t=this.deviceMap.videoinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"enumerateAudioPlaybackDevices",value:(r=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(oR(t=this.deviceMap.audiooutput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getDeviceById",value:(t=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateDevices();case 2:return r=e.sent,e.abrupt("return",gE(r).call(r,(function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),p}(aP),qU=new WU;!jM()&&(window.__rtc_dd__=qU);var YU=new Nw("InternalEventBus",1),JU=function(e){return e.ON_IOS_INTERRUPTION_START="ON_IOS_INTERRUPTION_START",e.ON_IOS_INTERRUPTION_END="ON_IOS_INTERRUPTION_END",e.ON_IOS_LOCAL_TRACK_MUTE="ON_IOS_LOCAL_TRACK_MUTE",e.ON_IOS_LOCAL_TRACK_UNMUTE="ON_IOS_LOCAL_TRACK_UNMUTE",e}(JU||{}),QU=function(e){DI(r,e);var t=QI(r);function r(){return Vl(this,r),t.apply(this,arguments)}return Ul(r,[{key:"emit",value:function(e){var t,n;YU.info(e);for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return(t=OI(CI(r.prototype),"emit",this)).call.apply(t,Om(n=[this,e]).call(n,o))}}]),r}(nP.exports.EventEmitter),ZU=new QU,$U=new Nw("AudioContext",1),eV=function(){function e(){var t=this;Vl(this,e),Jd(this,"_audioContextInstance",void 0),Jd(this,"_previousState",""),Jd(this,"_currentState",""),Jd(this,"_contextStuckAt",0);var r=0;jM()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,$U.info("currentTime resume"),LO("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,$U.warn("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),LO("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return Ul(e,[{key:"getAudioContextInstance",value:function(){var e=this;if(!this._audioContextInstance){var t=window.AudioContext||window.webkitAudioContext;this._audioContextInstance=new t,this._audioContextInstance.onstatechange=function(){var t,r,n;$U.warn("state change",null===(t=e._audioContextInstance)||void 0===t?void 0:t.state),e._previousState=e._currentState,e._currentState=(null===(r=e._audioContextInstance)||void 0===r?void 0:r.state)||"","interrupted"===(null===(n=e._audioContextInstance)||void 0===n?void 0:n.state)&&e._audioContextInstance.resume(),(rD||ZM)&&("running"===e._previousState&&"interrupted"===e._currentState&&ZU.emit(JU.ON_IOS_INTERRUPTION_START),"interrupted"===e._previousState&&"running"===e._currentState&&ZU.emit(JU.ON_IOS_INTERRUPTION_END))}}return this._audioContextInstance}}]),e}(),tV=function(){function e(t){Vl(this,e),Jd(this,"_ctx",void 0),Jd(this,"_analyserNode",void 0),Jd(this,"_audioSource",void 0);var r=rV.getAudioContextInstance();if(t instanceof MediaStreamTrack){var n=new MediaStream;n.addTrack(t),this._audioSource=r.createMediaStreamSource(n)}else this._audioSource=r.createMediaElementSource(t),this._audioSource.connect(r.destination);var i=r.createAnalyser();this._audioSource.connect(i),this._analyserNode=i,this._ctx=r}var t;return Ul(e,[{key:"getAudioLevel",value:function(){var e;"suspended"===(null===(e=this._ctx)||void 0===e?void 0:e.state)&&this._ctx.resume();var t=new Uint8Array(2048);this._analyserNode.getByteTimeDomainData(t);var r=0;t.forEach((function(e){return r=Math.max(r,Math.abs(e-128))}));var n=r/128*255;return n>2?n:0}},{key:"resume",value:(t=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._ctx)||void 0===t?void 0:t.resume();case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._audioSource.disconnect(),this._analyserNode.disconnect()}}]),e}(),rV=new eV,nV=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}(nV||{}),iV=function(){function e(t){Vl(this,e),Jd(this,"_plugins",new $S),this.id=t}var t;return Ul(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(QR(t).call(t,(function(t){return t.name===e.name}))>-1)throw new Error("Failed to register ".concat(e.name,": name is repeated."));t.push(e),this._plugins.set(e.type,t)}},{key:"getPluginsByType",value:function(e){return this._plugins.get(e)||[]}},{key:"getPluginByName",value:function(e,t){var r;return gE(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.getTrack(),i=$T(r),e.prev=3,i.s();case 5:if((o=i.n()).done){e.next=12;break}return a=o.value,e.next=9,a.effect(t,n);case 9:n=e.sent;case 10:e.next=5;break;case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(3),i.e(e.t0);case 17:return e.prev=17,i.f(),e.finish(17);case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,this,[[3,14,17,20]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._plugins.forEach((function(e){e.forEach((function(e){return e.destroy()}))})),this._plugins.clear()}}]),e}(),oV=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(oV||{}),aV=new Nw("VERTC",0),sV=new XU,cV=function(e){DI(r,e);var t=QI(r);function r(e,n){var i;return Vl(this,r),Jd(tI(i=t.call(this)),"sourceType",1),Jd(tI(i),"mediaType",void 0),Jd(tI(i),"_trackId",void 0),Jd(tI(i),"_ac",void 0),Jd(tI(i),"_sourceNode",void 0),Jd(tI(i),"_gainNode",void 0),Jd(tI(i),"_destNode",void 0),Jd(tI(i),"_channelCount",void 0),i._trackId=e,i.mediaType=n,"audio"===n&&hL()&&!OD("SKIP_WEB_AUDIO_IN_TRACK")&&(i._ac=rV.getAudioContextInstance(),i._gainNode=i._ac.createGain(),i._destNode=i._ac.createMediaStreamDestination(),i._gainNode.connect(i._destNode)),i}return Ul(r,[{key:"getId",value:function(){return this._trackId}},{key:"setVolume",value:function(e){this._gainNode&&(this._gainNode.gain.value=e/100)}},{key:"getVolume",value:function(){return this._gainNode?Math.round(100*this._gainNode.gain.value):-1}},{key:"channelCount",get:function(){var e;return null!==(e=this._channelCount)&&void 0!==e?e:0}},{key:"connectAudioTrack",value:function(e){var t;if(this._channelCount=e.getSettings().channelCount,!hL()||OD("SKIP_WEB_AUDIO_IN_TRACK"))return e;this._sourceNode&&(this._sourceNode.mediaStream.getTracks().forEach((function(e){e.stop()})),delete this._sourceNode);var r,n=new MediaStream;(n.addTrack(e),this._sourceNode=null===(t=this._ac)||void 0===t?void 0:t.createMediaStreamSource(n),this._gainNode)&&(null===(r=this._sourceNode)||void 0===r||r.connect(this._gainNode));return this._destNode.stream.getTracks()[0]}},{key:"destroy",value:function(){var e,t,r,n;(null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),13!==cD)&&(null===(n=this._destNode)||void 0===n||n.stream.getTracks().forEach((function(e){e.stop()})));null===(t=this._sourceNode)||void 0===t||t.disconnect(),null===(r=this._gainNode)||void 0===r||r.disconnect(),delete this._sourceNode,delete this._gainNode,delete this._destNode}}]),r}(aP),uV=function(e){DI(n,e);var t,r=QI(n);function n(e,t,i){var o;return Vl(this,n),Jd(tI(o=r.call(this,t,i)),"_mediaTrack",void 0),Jd(tI(o),"_preProcessingTrack",void 0),Jd(tI(o),"_originTrack",void 0),Jd(tI(o),"captureSessionId",""),Jd(tI(o),"handleTrackEnded",(function(){o.emit("track-ended",tI(o)),o.close()})),Jd(tI(o),"handleMute",(function(){o.emit("track-mute",tI(o))})),Jd(tI(o),"handleUnmute",(function(){o.emit("track-unmute",tI(o))})),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o._initListeners(),o}return Ul(n,[{key:"getTrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"origin";return"origin"===e?this._mediaTrack:this._preProcessingTrack||this._mediaTrack}},{key:"setTrack",value:function(e,t){this._mediaTrack="audio"===this.mediaType?this.connectAudioTrack(e):e,this._originTrack=e,t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._preProcessingTrack=void 0,e.prev=1,e.next=4,t.getPreProcessingTrack(this);case 4:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e){return t.apply(this,arguments)})},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){var e,t,r,n,i;return this._mediaTrack.onended=null,this._mediaTrack.onmute=null,this._mediaTrack.onunmute=null,null===(e=this._originTrack)||void 0===e||e.removeEventListener("ended",this.handleTrackEnded),null===(t=this._originTrack)||void 0===t||t.removeEventListener("mute",this.handleMute),null===(r=this._originTrack)||void 0===r||r.removeEventListener("unmute",this.handleUnmute),null===(n=this._preProcessingTrack)||void 0===n||n.stop(),"audio"===this.mediaType?this.destroy():null===(i=this._mediaTrack)||void 0===i?void 0:i.stop()}},{key:"_initListeners",value:function(){this._originTrack instanceof MediaStreamTrack&&(this._originTrack.addEventListener("ended",this.handleTrackEnded),this._originTrack.addEventListener("mute",this.handleMute),this._originTrack.addEventListener("unmute",this.handleUnmute))}}]),n}(cV),dV=function(e){DI(r,e);var t=QI(r);function r(e,n,i){var o;return Vl(this,r),Jd(tI(o=t.call(this,n,i)),"_mediaTrack",void 0),Jd(tI(o),"_originTrack",void 0),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o}return Ul(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){return this.destroy()}}]),r}(cV),lV=function(e){DI(n,e);var t,r=QI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this,e,t,"video")),"resolution",void 0),Jd(tI(i),"dummy",!1),i.resolution={width:0,height:0},i}return Ul(n,[{key:"updateVideoCaptureConfig",value:(t=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return aV.info("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=Zd({},t)).contentHint,zM&&this.streamIndex===cl.STREAM_INDEX_MAIN&&(r.frameRate={ideal:30,max:30}),e.next=8,this.getTrack().applyConstraints(r);case 8:((n=this.getTrack().getSettings()).width&&n.width!==this.resolution.width||n.height&&n.height!==this.resolution.height)&&(this.resolution={width:n.width,height:n.height},this.emit("resolution-change",this.resolution));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){var t;this._mediaTrack&&"contentHint"in this._mediaTrack&&mk(t=["text","motion","detail"]).call(t,e)&&(this._mediaTrack.contentHint=e)}}]),n}(uV),hV=function(e){DI(n,e);var t,r=QI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),Jd(tI(i),"_audioLevelFetcher",void 0),Jd(tI(i),"mixedAudioTrack",void 0),Jd(tI(i),"mixType",Ml.PLAYOUT_AND_PUBLISH),i}return Ul(n,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new tV(this.getTrack("preprocessing"))),this._audioLevelFetcher.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.audioCaptureConfig){e.next=2;break}return e.abrupt("return");case 2:return aV.info("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,null===(t=this.getOrgTrack())||void 0===t?void 0:t.applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(uV),pV=function(e){DI(r,e);var t=QI(r);function r(e,n){return Vl(this,r),t.call(this,e,n,"video")}return Ul(r)}(dV),vV=function(e){DI(r,e);var t=QI(r);function r(e,n){var i;return Vl(this,r),Jd(tI(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return Ul(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new tV(this.getOrgTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(dV),fV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),n}return Ul(r)}(hV),_V=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),n}return Ul(r)}(lV),mV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(lV),yV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(hV),gV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),n}return Ul(r)}(lV),SV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),n}return Ul(r)}(hV),bV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(lV),EV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(hV);function kV(e,t){return TV.apply(this,arguments)}function TV(){return(TV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new _V(t,dM())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function IV(e,t){return RV.apply(this,arguments)}function RV(){return(RV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new gV(t,dM())).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 AV(e,t){return wV.apply(this,arguments)}function wV(){return(wV=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=VO(r.id),s=dM(),e.prev=3,aV.info("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o,capture_session_id:s}),c=lM(),zM&&(t.frameRate={ideal:30,max:30}),e.next=10,qU.getUserMedia({video:t});case 10:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:lM()-c,capture_session_id:s}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(3),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:s}),new mA(pA.GET_VIDEO_TRACK_FAILED,Om(u="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(u,e.t0.message||"unknown message","."),e.t0);case 18:return d=i.getVideoTracks()[0],sV.set(d,i),(l=new _V(d,dM())).captureSessionId=s,e.next=24,l.generatePreProcessingTrack(r);case 24:return e.abrupt("return",l);case 25:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function CV(e,t){return xV.apply(this,arguments)}function xV(){return(xV=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aV.info("createMicrophoneAudioTrack","constraints:",t),o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=VO(r.id),s=dM(),e.prev=4,null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_begin",media_device_id:o,event_session_id:s}),u=lM(),(d=r.getPluginByName(nV.PRE_PROCESSING,"RTCAIAnsExtension"))&&(d.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=11,qU.getUserMedia({audio:t});case 11:i=e.sent,null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_result",media_device_id:o,media_device_name:(null===(c=i.getAudioTracks()[0])||void 0===c?void 0:c.label)||"",reason:"success",elapse:lM()-u,event_session_id:s}),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(4),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_end",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message,event_session_id:s}),new mA(pA.GET_AUDIO_TRACK_FAILED,Om(l="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(l,e.t0.message||"unknown message","."),e.t0);case 19:return h=i.getAudioTracks()[0],sV.set(h,i),(p=new fV(h,dM())).captureSessionId=s,e.next=25,p.generatePreProcessingTrack(r);case 25:return e.abrupt("return",p);case 26:case"end":return e.stop()}}),e,null,[[4,15]])})))).apply(this,arguments)}function OV(){return MV.apply(this,arguments)}function MV(){return MV=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=h.length>0&&void 0!==h[0]&&h[0],r=h.length>1?h[1]:void 0,n=h.length>2?h[2]:void 0,aV.info("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=VO(r.id),a=dM(),e.prev=6,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen",capture_session_id:a}),s=lM(),e.next=11,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!KM||16!==cD))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!0,autoGainControl:!1}});case 11:i=e.sent,null==o||o.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",reason:"success",elapse:lM()-s,capture_session_id:a}),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(6),null==o||o.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:"screen",error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:a}),new mA(pA.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 19:return c=i.getVideoTracks()[0],u=new gV(c,dM()),e.next=23,u.generatePreProcessingTrack(r);case 23:if(!(d=i.getAudioTracks()[0])){e.next=29;break}return l=new SV(d,dM()),e.next=28,l.generatePreProcessingTrack(r);case 28:return e.abrupt("return",[u,l]);case 29:return e.abrupt("return",[u,void 0]);case 30:case"end":return e.stop()}}),e,null,[[6,15]])}))),MV.apply(this,arguments)}function DV(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dM();return new vV(e,t)}function PV(e,t){return NV.apply(this,arguments)}function NV(){return(NV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new mV(t,dM()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function LV(e,t){return UV.apply(this,arguments)}function UV(){return(UV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new yV(t,dM()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function VV(e,t){return FV.apply(this,arguments)}function FV(){return(FV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new bV(t,dM()),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 BV(e,t){return jV.apply(this,arguments)}function jV(){return(jV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new EV(t,dM()),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 HV=hV,GV=vV,zV=function(e){return e[e.NONE=0]="NONE",e}(zV||{}),KV={getNalunits:function(e){if(e.length-e.position<4)return[];var t=e.position;return 1===e.getInt32(t)||0===e.getInt16(t)&&1===e.getInt8(t+2)?KV.getAnnexbNals(e):KV.getAvccNals(e)},getAnnexbNals:function(e){for(var t=[],r=KV.getHeaderPositionAnnexB(e),n=r.pos,i=n;n<e.length-4;){var o,a,s=new Uint8Array(km(o=e.buffer).call(o,n,n+r.headerLength));r.pos===e.position&&e.skip(r.headerLength),i=(r=KV.getHeaderPositionAnnexB(e)).pos;var c={header:s,body:new Uint8Array(km(a=e.buffer).call(a,n+s.byteLength,i)),type:-1};KV.analyseNal(c),c.type<=9&&0!==c.type&&t.push(c),e.skip(i-e.position),n=i}return t},getAvccNals:function(e){for(var t=[];e.position<e.length-4;){var r=e.getInt32(e.position);if(!(e.length-e.position>=r))break;var n,i,o=new Uint8Array(km(n=e.buffer).call(n,e.position,e.position+4));e.skip(4);var a=new Uint8Array(km(i=e.buffer).call(i,e.position,e.position+r));e.skip(r);var s={header:o,body:a,type:-1};KV.analyseNal(s),s.type<=9&&0!==s.type&&t.push(s)}return t},analyseNal:function(e){var t=31&e.body[0];switch(e.type=t,t){case 1:e.ndr=!0;break;case 5:e.idr=!0;break;case 6:e.sei=!0;break;case 7:e.sps=!0;break;case 8:e.pps=!0}},getHeaderPositionAnnexB:function(e){for(var t=e.position,r=0,n=e.length;3!==r&&4!==r&&t<n-4;)0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:1===e.getInt8(t+2)?r=3:t++:t++;return t===n-4&&(0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:t=n:(t++,0===e.getInt16(t)&&1===e.getInt8(t)?r=3:t=n)),{pos:t,headerLength:r}}},XV=function(){function e(t){Vl(this,e),Jd(this,"_position",0),Jd(this,"_dataview",void 0),this._dataview=new DataView(t)}return Ul(e,[{key:"length",get:function(){return this.buffer.byteLength}},{key:"buffer",get:function(){return this._dataview.buffer}},{key:"position",get:function(){return this._position},set:function(e){this._position=e}},{key:"back",value:function(e){this.position-=e}},{key:"getUint8",value:function(e){return this._dataview.getUint8(e)}},{key:"getInt8",value:function(e){return this._dataview.getInt8(e)}},{key:"getInt16",value:function(e){return this._dataview.getInt16(e)}},{key:"getUint16",value:function(e){return this._dataview.getUint16(e)}},{key:"getUint32",value:function(e){return this._dataview.getUint32(e)}},{key:"getInt32",value:function(e){return this._dataview.getInt32(e)}},{key:"skip",value:function(t){for(var r=Math.floor(t/4),n=t%4,i=0;i<r;i++)e.readByte(this,4);n>0&&e.readByte(this,n)}},{key:"readUint8",value:function(){return e.readByte(this,1)}},{key:"readUint16",value:function(){return e.readByte(this,2)}},{key:"readUint24",value:function(){return e.readByte(this,3)}},{key:"readUint32",value:function(){return e.readByte(this,4)}},{key:"readUint64",value:function(){return e.readByte(this,8)}},{key:"readInt8",value:function(){return e.readByte(this,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}}],[{key:"readByte",value:function(e,t,r){var n;switch(t){case 1:n=r?e.getInt8(e.position):e.getUint8(e.position);break;case 2:n=r?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(r)throw new Error("not supported for readByte 3");n=e.getUint8(e.position)<<16,n|=e.getUint8(e.position+1)<<8,n|=e.getUint8(e.position+2);break;case 4:n=r?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(r)throw new Error("not supported for readBody 8");n=e.getUint32(e.position)<<32,n|=e.getUint32(e.position+4);break;default:n=""}return e.position+=t,n}}]),e}(),WV=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(WV||{}),qV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),YV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]),JV=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 QV(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function ZV(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 $V=function(){function e(){Vl(this,e)}return Ul(e,null,[{key:"generateSEI",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new Uint8Array([0,0,0,1]),i=new Uint8Array([6]),o=new Uint8Array([5]),a=r?qV:YV,s=QV(e.byteLength+a.byteLength),c=JV(e);return new Uint8Array(Om(t=[]).call(t,Jk(n),Jk(i),Jk(o),Jk(s),Jk(a),Jk(c),[128]))}},{key:"decodeSeiBody",value:function(e){var t=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]||t.push(e[r]);return new Uint8Array(t)}(e=km(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=eI(ZV(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=YV.byteLength&&i>=YV.byteLength&&km(t).call(t,r,r+YV.byteLength).toString()===YV.toString()?(r+=YV.byteLength,o=1):t.byteLength>=YV.byteLength&&i>=YV.byteLength&&km(t).call(t,r,r+qV.byteLength).toString()===qV.toString()&&(r+=qV.byteLength,o=0),{type:o,payload:km(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new $S,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=eI(ZV(e.payload,r),2),i=n[0];r=n[1];var o,a=eI(ZV(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,km(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=$T(e);try{for(n.s();!(t=n.n()).done;){var i=eI(t.value,2),o=i[0],a=i[1],s=QV(o),c=QV(a.byteLength);r.push(s,c,a)}}catch(l){n.e(l)}finally{n.f()}var u=pb(r).call(r,(function(e,t){return e+t.byteLength}),0),d=new Uint8Array(u);return pb(r).call(r,(function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),eF=new Nw("Stats",3),tF=function(){function e(t){Vl(this,e),Jd(this,"player",void 0),Jd(this,"_timer",void 0),Jd(this,"handler",void 0),Jd(this,"_monitor",void 0),Jd(this,"_destroyed",!1),this._context=t,this._monitor=VO(t.id)}return Ul(e,[{key:"setVar",value:function(e){this.handler=e}},{key:"stopReport",value:function(e){var t;this._timer&&(eF.info("stopReport","invoke"),clearTimeout(this._timer),delete this._timer,jO(this._context.id,"del_media_statistics_timer",Om(t="reason: ".concat(e,", stack: ")).call(t,(new Error).stack),0,this._stream.streamId||""))}},{key:"filterIllegal",value:function(e){var t={};return an(e).forEach((function(r){null===e[r]||void 0===e[r]||Number.isNaN(e[r])||(t[r]=e[r])})),t}},{key:"destroy",value:function(){eF.info("destroy","invoke"),jO(this._context.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.stopReport("destroy"),this._destroyed=!0}}]),e}(),rF=function(e){DI(i,e);var t,r,n=QI(i);function i(e,t){var r;return Vl(this,i),(r=n.call(this,e))._stream=t,r}return Ul(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t){var r,n,i,o=this;if(!this._timer){eF.info("setLocalStreamStatsEvtInterval","invoke"),this.setVar(t),this._destroyed=!1;var a={audio:{},video:{}},s=this._stream,c=null===(r=s.audioTrack)||void 0===r?void 0:r.getTrack("preprocessing"),u=null===(n=s.videoTrack)||void 0===n?void 0:n.getTrack("preprocessing");this.getAudioStats(c,a,null===(i=s.audioTrack)||void 0===i?void 0:i.getAudioLevel()),this.getVideoStats(u,a);var d=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=s.audioTrack)||void 0===t?void 0:t.getTrack("preprocessing"),c=null===(r=s.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,o.getAudioStats(i,a,null===(n=s.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return u=e.sent,e.next=7,o.getVideoStats(c,a);case 7:return d=e.sent,e.abrupt("return",{audioStats:u,videoStats:d,isScreen:s.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),l=function(){var t=Rm(Tm().mark((function t(){var r;return Tm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,d();case 2:r=t.sent,e(r),o._destroyed||(o._timer=setTimeout(l,2e3));case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();this._timer=setTimeout(l,2e3)}}},{key:"getAudioStats",value:(r=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,y;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s={},c={timestamp:Date.now()},u=this._stream,d=u.streamId,l=u.audioMid,h=u.isScreen,p=u.pubAttributes,v=u.pubAudio,f=u.audioTrack,_={media_type:"audio",is_screen:!!h,direction:"up",stream_id:d,vid:l,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:p.localaudio?"capture_state_on":"capture_state_off",mute_state:v?"mute_state_off":"mute_state_on"},f&&(_.playback_volume=f.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",s);case 7:return e.next=9,this.handler.getStats(t);case 9:if((m=e.sent).length){e.next=12;break}return e.abrupt("return",s);case 12:if(m.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,o=e.clockRate,a=e.roundTripTime,u=e.channels,d=e.audioLevel;e.googRtt;var l=e.mimeType,h=e.availableIncomingBitrate,p=e.availableOutgoingBitrate,v=e.bytesReceived,f=e.nominated,m=e.id,y=e.currentRoundTripTime,g=e.state,S=e.writable,b=e.requestsReceived,E=e.responsesReceived,k=e.requestsSent,T=e.consentRequestsSent,I=e.responsesSent,R=e.jitter,A=e.candidateType,w=e.ip,C=e.address,x=e.networkType,O=e.port,M=e.protocol,D=e.nackCount,P=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?(c.packetsSent=r,c.bytesSent=i,_.bytes=i,_.packetsSent=r,_.nackCount=D,_.ssrc=U,_.retransmitted_bytes_sent=P,_.retransmitted_packets_sent=N,c.retransmittedBytesSent=P,c.retransmittedPacketsSent=N):"remote-inbound-rtp"===t?(c.packetsLost=n,_.packetsLost=n,_.net_jitter=1e3*R,s.rtt=1e3*a,_.rtt=s.rtt,s._fractionLost=j||0):"codec"===t?(s.recordSampleRate=o,s.numChannels=u,_.codecName=l):"media-source"===t&&void 0!==d?(_.audio_level=d?-10*$A(Math.pow(d,2)):d,_.volume=255*d,_.total_audio_energy=V,_.totalInputDuration=F):"ssrc"===t&&"audio"===B?_.send_level=L:"candidate-pair"===t?(_.ice_available_incoming_bitrate=h,_.ice_available_outgoing_bitrate=p,_.ice_bytes_received=v,_.ice_bytes_sent=i,_.ice_nominated=Number(f),_.ice_pair_id=m,_.ice_pair_rtt=y,_.ice_pair_state=g,_.ice_pair_writable=S,_.recv_ping_requests=b,_.recv_ping_responses=E,_.sent_ping_requests_before_first_response=k,_.sent_ping_requests_total=k+(T||0),_.sent_ping_responses=I):"local-candidate"===t?(_.local_candidate_type=A,_.local_ip=w||C,_.local_network_type=x,_.local_port=O,_.protocol=M):"remote-candidate"===t&&(_.remote_candidate_type=A,_.remote_ip=w||C,_.remote_port=O);var H=OD("STATS_SCALLBACK_SUPPORT");pL&&H||"media-source"===t&&(_.send_level=d)})),void 0===_.volume&&void 0!==n&&(_.volume=n,_.audio_level=n?-10*$A(Math.pow(n/255,2)):n),(y=r.audio).timestamp){e.next=18;break}return r.audio=c,e.abrupt("return",this.filterIllegal(s));case 18:return void 0!==c.packetsLost&&(s.audioLossRate=(c.packetsLost-y.packetsLost)/(c.packetsSent-y.packetsSent),s.audioLossRate=Number.isNaN(s.audioLossRate)?0:s.audioLossRate,_.fraction_lost=s.audioLossRate),s.statsInterval=c.timestamp-y.timestamp,_.stats_interval=s.statsInterval,s.sendKBitrate=(c.bytesSent-y.bytesSent||0)/s.statsInterval*8,_.mediaBitratebps=Math.round(1e3*s.sendKBitrate),_.bandwidth=Math.round(_.mediaBitratebps/1024),void 0!==c.retransmittedBytesSent&&(_.retransmitBitratebps=(c.retransmittedBytesSent-y.retransmittedBytesSent||0)/s.statsInterval),r.audio=c,_.vendor_mode=(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,_.pc_session_id=null===(o=this.handler)||void 0===o?void 0:o.peerConnectionId,null===(a=this._monitor)||void 0===a||a.report("rtc_media_statistics",_),s._retransmittedRate=(c.retransmittedPacketsSent-y.retransmittedPacketsSent)/(c.packetsSent-y.packetsSent),void 0===s.audioLossRate&&(s.audioLossRate=s._retransmittedRate,_.fraction_lost=s.audioLossRate),s._fractionLost=Math.max(s._fractionLost,s.audioLossRate),e.abrupt("return",this.filterIllegal(s));case 33:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},i={timestamp:Date.now(),simulcast:{}},o=this._stream,a=o.streamId,s=o.videoMid,c=o.isScreen,u=o.pubAttributes,d=o.enableSimulcast,l=o.pubVideo,e.t0=Zd,e.t1={media_type:"video",is_screen:!!c,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:u.localvideo?"capture_state_on":"capture_state_off",mute_state:l?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,h=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",n);case 11:return h.cap_frame_width=t.getSettings().width,h.cap_frame_height=t.getSettings().height,h.frameRateSent=t.getSettings().frameRate,n.isScreen=c,e.next=17,this.handler.getStats(t);case 17:if((p=e.sent).length){e.next=20;break}return e.abrupt("return",n);case 20:if(v=0,p.forEach((function(e){var t=e.type,o=e.framesEncoded,a=e.packetsLost,s=e.bytesSent,c=e.framesSent,u=e.retransmittedBytesSent,l=e.totalPacketSendDelay,p=e.totalEncodeTime,f=e.firCount,_=e.targetBitrate,m=e.roundTripTime,y=e.mimeType,g=e.frameWidth,S=e.frameHeight,b=e.packetsSent,E=e.googActualEncBitrate,k=e.googAvailableReceiveBandwidth,T=e.googAvailableSendBandwidth,I=e.googAvgEncodeMs,R=e.googBucketDelay,A=e.googEncodeUsagePercent,w=e.googFrameRateInput,C=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,O=e.bytesReceived,M=e.nominated,D=e.id,P=e.currentRoundTripTime,N=e.state,L=e.writable,U=e.candidateType,V=e.ip,F=e.address,B=e.networkType,j=e.port,H=e.nackCount,G=e.pliCount,z=e.protocol,K=e.qpSum,X=e.requestsReceived,W=e.responsesReceived,q=e.googRetransmitBitrate,Y=e.requestsSent,J=e.consentRequestsSent,Q=e.responsesSent,Z=e.ssrc,$=e.googTargetEncBitrate,ee=e.googTransmitBitrate,te=e.retransmittedPacketsSent,re=e.encoderImplementation,ne=e.jitter,ie=e.rid,oe=e.fractionLost,ae=e.googAdaptationChanges,se=e.qualityLimitationReason,ce=e.qualityLimitationDurations,ue=e.googFirsReceived,de=e.googFrameRateSent,le=e.keyFramesEncoded,he=e.scalabilityMode,pe=e.framesPerSecond,ve=e.frames;"outbound-rtp"===t?(d&&(ie?i.simulcast[ie]=e:i.simulcast[v]=e,v++),i.framesEncoded=o||i.framesEncoded||0,h.key_frames_encoded=le||0,i.bytesSent=s||i.bytesSent||0,i.framesSent=c||i.framesSent,h.bytes=s||h.bytes||0,i.packetsSent=b||i.packetsSent||0,h.packetsSent=b||h.packetsSent||0,h.nackCount=H||h.nackCount||0,h.pli_count=G||h.pli_count||0,h.qp_sum=K||h.qp_sum||0,h.ssrc=Z||h.ssrc||0,h.retransmitted_packets_sent=te,i.retransmittedPacketsSent=te,i.retransmittedBytesSent=u,h.encoder_implementation=re,h.qualityLimitationReason=se,h.qualityLimitationDurations=ce,h.scalabilityMode=he,void 0!==g&&((!n.encodedFrameWidth||g>n.encodedFrameWidth)&&(n.encodedFrameWidth=g),(!n.encodedFrameHeight||S>n.encodedFrameHeight)&&(n.encodedFrameHeight=S),h.frame_size_height=S,h.frame_size_width=g)):"track"===t?(n.encodedFrameWidth=g,n.encodedFrameHeight=S,h.frame_size_height=S,h.frame_size_width=g):"remote-inbound-rtp"===t?(i.packetsLost=a,n.rtt=1e3*m,h.rtt=n.rtt,h.jitter=1e3*ne,h.packetsLost=a,n._fractionLost=oe||0):"codec"===t?(n.codecType=y,h.codecName=y):"candidate-pair"===t?(h.ice_available_incoming_bitrate=C,h.ice_available_outgoing_bitrate=x,h.ice_bytes_received=O,h.ice_bytes_sent=s,h.ice_nominated=Number(M),h.ice_pair_id=D,h.ice_pair_rtt=P,h.ice_pair_state=N,h.ice_pair_writable=L,h.recv_ping_requests=X,h.recv_ping_responses=W,h.sent_ping_requests_before_first_response=Y,h.sent_ping_requests_total=Y+J,h.sent_ping_responses=Q):"local-candidate"===t?(h.local_candidate_type=U,h.local_ip=V||F,h.local_network_type=B,h.local_port=j,h.protocol=z):"remote-candidate"===t?(h.remote_candidate_type=U,h.remote_ip=V||F,h.remote_port=j):"VideoBwe"===t?(h.encBitratebps=E,h.available_receive_bandwidth=k,h.available_send_bandwidth=T,h.bucket_delay=R,h.retransmitBitratebps=q,h.targetEncBitratebps=$,h.transmit_bitrate=ee,n._sendBandWidth=Number(T)):"ssrc"===t&&(h.avg_encode_ms=I,h.encodeUsage=A,h.frame_rate_input=w,h.orignal_input_Framerate=Number(w),h.ddaptationChanges=ae,h.firsReceived=ue,h.frameRateSent=de);var fe=OD("STATS_SCALLBACK_SUPPORT");if(!pL||!fe){var _e=r.video,me=i.timestamp-_e.timestamp;if("outbound-rtp"===t){var ye=s-_e.bytesSent,ge=u-_e.retransmittedBytesSent;h.encBitratebps=Math.round(8e3*(ye-ge)/me),h.bucket_delay=l/b,h.retransmitBitratebps=Math.round(8e3*ge/me),h.targetEncBitratebps=_,h.transmit_bitrate=Math.round(1e3*(s-_e.bytesSent)*8/me),h.avg_encode_ms=1e3*p/o,h.firsReceived=f+G}else"candidate-pair"===t?(h.available_send_bandwidth=x,n._sendBandWidth=x):"media-source"===t&&(h.frame_rate_input=pe,h.orignal_input_Framerate=Number(pe),h.frame_input=ve)}})),(f=r.video).timestamp){e.next=26;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 26:return n.statsInterval=i.timestamp-f.timestamp,h.stats_interval=n.statsInterval,_=an(i.simulcast),d?(h.sim_enc_width=[],h.sim_enc_height=[],h.sim_enc_bps=[],h.sim_enc_framerate=[],h.sim_enc_key_frames=[],h.sim_rids=[],h.sim_enc_bandwidth=[],h.sim_sent_framerate=[],h.sim_fraction_lost=[],h.sim_keyencoded=[],h.active_sim_streams=(null===(m=this._context)||void 0===m?void 0:m.activeSimStreams)||[],h.sim_retransmittedRate=[],b=!1,HR(_).call(_,(function(e,t){return Number(e)-Number(t)})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,p=t.qualityLimitationDurations,v=t.qualityLimitationResolutionChanges,_=t.retransmittedPacketsSent,m=t.pliCount,y=t.keyFramesEncoded;void 0!==l&&(h.sim_qualityLimitationReason||(h.sim_qualityLimitationReason=[],h.sim_qualityLimitationDurations=[],h.sim_qualityLimitationResolutionChanges=[]),h.sim_qualityLimitationReason.push(l),h.sim_qualityLimitationDurations.push(p),h.sim_qualityLimitationResolutionChanges.push(v));var g=f.simulcast[e];if(h.sim_enc_width.push(r||0),h.sim_enc_height.push(o||0),h.sim_enc_key_frames.push(y||0),g){var S=(a-g.bytesSent||0)/n.statsInterval;h.sim_enc_bps.push(Math.round(8e3*S)),h.sim_enc_bandwidth.push(Math.round(8e3*S/1024));var E=1e3*(s-g.framesEncoded)/n.statsInterval;h.sim_enc_framerate.push(Math.round(E)),h.sim_rids.push(e);var k=void 0!==c?c-g.framesSent:s-g.framesEncoded,T=1e3*k/n.statsInterval;h.sim_sent_framerate.push(Math.round(T));var I=(u-g.packetsLost)/(d-g.packetsSent);n._retransmittedRate=(_-g.retransmittedPacketsSent)/(d-g.packetsSent),I=Number.isNaN(I)?0:I,h.sim_fraction_lost.push(I),h.sim_keyencoded.push(m-g.pliCount>0),h.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!b&&(n.sentKBitrate=8*S,n.encoderOutputFrameRate=E,n.encodedFrameCount=k,n.sentFrameRate=T,n.videoLossRate=I,b=!0)}})),h.vendor_mode=(null===(y=this._stream)||void 0===y?void 0:y.vendorCode)||0,h.pc_session_id=null===(g=this.handler)||void 0===g?void 0:g.peerConnectionId,null===(S=this._monitor)||void 0===S||S.report("rtc_media_statistics",h)):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-f.framesSent:i.framesEncoded-f.framesEncoded,n.sentKBitrate=(i.bytesSent-f.bytesSent||0)/n.statsInterval*8,h.bitrate=Math.round(1e3*n.sentKBitrate),h.bandwidth=Math.round(h.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-f.framesEncoded)/n.statsInterval,h.frame_rate_encoded=Math.round(n.encoderOutputFrameRate),n.sentFrameRate=1e3*n.encodedFrameCount/n.statsInterval,h.frame_rate_sent=Math.round(n.sentFrameRate),n.videoLossRate=(i.packetsLost-f.packetsLost)/(i.packetsSent-f.packetsSent),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,h.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-f.retransmittedPacketsSent)/(i.packetsSent-f.packetsSent),h.vendor_mode=(null===(E=this._stream)||void 0===E?void 0:E.vendorCode)||0,h.pc_session_id=null===(k=this.handler)||void 0===k?void 0:k.peerConnectionId,null===(T=this._monitor)||void 0===T||T.report("rtc_media_statistics",h)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 33:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(tF),nF=function(e){DI(o,e);var t,r,n,i=QI(o);function o(e,t){var r;return Vl(this,o),Jd(tI(r=i.call(this,e)),"isPaused",void 0),Jd(tI(r),"pauseStart",void 0),Jd(tI(r),"pauseDuration",void 0),Jd(tI(r),"_audioStallCount",void 0),Jd(tI(r),"_setAudioStallCount",void 0),Jd(tI(r),"_audioStallTimer",void 0),Jd(tI(r),"_audioStallInterval",void 0),Jd(tI(r),"_audioStallRatio",void 0),Jd(tI(r),"_videoInWaiting",void 0),r._stream=t,r._videoInWaiting=!1,r.pauseDuration=0,r}return Ul(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=Rm(Tm().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,p,v,f,_,m,y,g=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._timer){e.next=2;break}return e.abrupt("return");case 2:return eF.info("setRemoteStreamStatsEvtInterval","invoke"),this.setVar(r),this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,s={audio:{},video:{}},this._destroyed=!1,c=this._stream,u=null===(n=c.audioTrack)||void 0===n?void 0:n.getOrgTrack(),d=null===(i=c.videoTrack)||void 0===i?void 0:i.getTrack(),this.getRemoteVideoStats(d,s),e.next=14,this.getRemoteAudioStats(u,s,null===(a=this._stream.audioTrack)||void 0===a?void 0:a.getAudioLevel());case 14:this._stopAudioStallTimer(),l=0,h=0,v=[],f=0,_=lM(),this._setAudioStallCount=function(){if(CD.AUDIO_STALL&&g._audioStallInterval>0&&void 0!==s.audio.concealedSamples){var e=s.audio.concealedSamples,t=s.audio.totalSamplesReceived;_=lM();var r={isStall:!1,counted:!1,diff:0},n=.5*g._audioStallInterval;g._audioStallCount=Rm(Tm().mark((function i(){var o,a,s,u,d,p,m,y,S,b,E,k,T,I,R,A,w,C,x,O;return Tm().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=c.hasAudio,s=c.subAudio,u=c.virtual,d=c.virtualOccupy,!c.removeTrack){i.next=4;break}return clearTimeout(g._audioStallTimer),i.abrupt("return");case 4:if(a&&s){i.next=10;break}return r.isStall=!1,r.counted=!1,v.push({reason:Om(p="hasAudio: ".concat(a,", subAudio: ")).call(p,s)}),_=lM(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 10:if(!u||d){i.next=16;break}return r.isStall=!1,r.counted=!1,v.push({reason:Om(m="virtual: ".concat(u,", virtualOccupy: ")).call(m,d)}),_=lM(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 16:return y=null===(o=c.audioTrack)||void 0===o?void 0:o.getOrgTrack(),S=Date.now(),i.next=20,g.handler.getStats(y,!0);case 20:if(b=i.sent,E=Date.now(),k=lM(),!((T=k-_)<n)){i.next=27;break}return v.push({diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:Om(I="diff(".concat(T,") < minInterval(")).call(I,n,")")}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 27:if(R=b.length,A=gE(b).call(b,(function(e){return"inbound-rtp"===e.type}))){i.next=32;break}return v.push({diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:R?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 32:return w=A.concealedSamples,C=A.totalSamplesReceived,O=C-t,(x=w-e)>=0&&O>=0&&x>=g._audioStallRatio*O?(v.push({concealed:x,received:O,diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,is_stall:!0}),r.isStall?(r.counted?h+=T:(h=h+r.diff+T,l++),r.counted=!0):T>=200?(h+=T,l++,r.counted=!0):(r.counted=!1,r.diff=T),r.isStall=!0):(v.push({concealed:x,received:O,diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E}),r.isStall=!1,r.counted=!1),e=w,t=C,_=k,f++,i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 41:case"end":return i.stop()}}),i)}))),p=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!g._audioStallCount&&g._setAudioStallCount&&g._setAudioStallCount(),!g._audioStallCount){e.next=6;break}return e.next=4,g._audioStallCount();case 4:g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval)}},this._setAudioStallCount(),m=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i,o,a,u;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=c.audioTrack)||void 0===t?void 0:t.getOrgTrack(),o=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,g.getRemoteAudioStats(i,s,null===(n=g._stream.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return a=e.sent,l=0,h=0,v=[],f=0,e.next=11,g.getRemoteVideoStats(o,s);case 11:return u=e.sent,e.abrupt("return",{audioStats:a,videoStats:u,isScreen:c.isScreen,userId:c.userId,streamId:c.streamId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y=function(){var e=Rm(Tm().mark((function e(){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m();case 2:r=e.sent,t(r),p&&(_=lM(),g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval)),g._timer&&clearTimeout(g._timer),g._destroyed||(g._timer=setTimeout(y,2e3));case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(y,2e3);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_stopAudioStallTimer",value:function(){clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){eF.info("unsubscribe","invoke"),OI(CI(o.prototype),"stopReport",this).call(this,"unsubscribe"),this._stopAudioStallTimer(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d={},l={},h=this._stream,p=h.streamId,v=h.userId,f=h.isScreen,_=h.audioMid,m=h.subMediaType,y=h._attributes,g=h.virtual,S=h.audioTrack,b={media_type:"audio",is_screen:!!f,direction:"down",stream_id:p,stream_user_id:v,vid:_,audio_mux:g,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:wM(m)?"mute_state_off":"mute_state_on",remote_user_capture_state:y.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:y.localaudio&&y.audiostream?"mute_state_off":"mute_state_on"},S&&(b.playback_volume=S.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",d);case 7:return e.next=9,this.handler.getStats(t);case 9:if((E=e.sent).length){e.next=12;break}return e.abrupt("return",d);case 12:if(E.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,o=e.bytesReceived,a=e.jitterBufferDelay,s=e.jitterBufferEmittedCount,c=e.clockRate,u=e.channels,h=e.totalSamplesReceived,v=e.concealedSamples,f=e.silentConcealedSamples,_=e.concealmentEvents,m=e.totalRoundTripTime,y=e.packetsDiscarded,g=e.state,S=e.currentRoundTripTime,E=e.audioLevel,k=e.totalAudioEnergy,T=e.totalSamplesDuration,I=e.mimeType,R=e.googDecodingNormal,A=e.googDecodingMuted,w=e.availableIncomingBitrate,C=e.availableOutgoingBitrate,O=e.bytesSent,M=e.nominated,D=e.id,P=e.writable,N=e.jitter,L=e.candidateType,U=e.ip,V=e.address,F=e.networkType,B=e.port,j=e.protocol,H=e.audioOutputLevel,G=e.requestsReceived,z=e.responsesReceived,K=e.requestsSent,X=e.consentRequestsSent,W=e.responsesSent,q=e.ssrc;e.kind;var Y=e.nackCount,J=e.lastPacketReceivedTimestamp,Q=e.concealmentevents,Z=e.fecPacketsReceived;if("inbound-rtp"===t)l.packetsLost=r,l.packetsReceived=i,b.packetsLost=r,b.packetsReceived=i,b.packetsDiscarded=y,b.nackCount=Y,b.lastPacketReceivedTimestamp=J,b.concealmentevents=Q,l.bytesReceived=o,void 0!==a&&(d.jitterBufferDelay=a/s*1e3,b.average_jitter_buffer_delay_ms=d.jitterBufferDelay),void 0!==h&&(l.totalSamplesReceived=h,d.concealedSamples=v,l.concealedSamples=v,l.silentConcealedSamples=f,b.concealedSamples=v,d.concealmentEvents=_,b.totalSamplesReceived=h),void 0!==Z&&(b.fec_packets_received=Z,l.fecPacketsReceived=Z),b.jitter=1e3*N,b.ssrc=q,void 0!==E&&0!==E?(b.audio_level=E?-10*$A(Math.pow(E,2)):E,b.volume=255*E):(b.volume=null!=n?n:255*E,b.audio_level=n?-10*$A(Math.pow(n/255,2)):n),void 0!==k&&(b.total_audio_energy=k),void 0!==T&&(b.totalAudioDuration=T);else if("codec"===t)d.recordSampleRate=c,u&&(d.numChannels=u),b.codecName=I;else if("candidate-pair"===t){var $,ee,te;b.ice_available_incoming_bitrate=w,b.ice_available_outgoing_bitrate=C,b.ice_bytes_received=o,b.ice_bytes_sent=O,b.ice_nominated=Number(M),b.ice_pair_id=D,b.ice_pair_rtt=S,b.rtt=1e3*S,b.rtt&&null!==($=x._context)&&void 0!==$&&null!==(ee=$.streamRTT)&&void 0!==ee&&null!==(te=ee[p])&&void 0!==te&&te.audio&&(b.total_rtt_ms=Math.round(b.rtt+x._context.streamRTT[p].audio)),b.ice_pair_state=g,b.ice_pair_writable=P,b.recv_ping_requests=G,b.recv_ping_responses=z,b.sent_ping_requests_before_first_response=K,b.sent_ping_requests_total=K+(X||0),b.sent_ping_responses=W,"succeeded"===g&&(d.rtt=1e3*S,d.total_rtt=1e3*m)}else"track"===t&&void 0!==E?(0===E&&0!==n?(b.volume=n,b.audio_level=n?-10*$A(Math.pow(n/255,2)):n):(b.audio_level=E?-10*$A(Math.pow(E,2)):E,b.volume=255*E),b.total_audio_energy=k,b.totalAudioDuration=T):"ssrc"===t?(b.decodingNormal=R,b.recvAudioLevel=H,b.decodingMuted=A):"local-candidate"===t?(b.local_candidate_type=L,b.local_ip=U||V,b.local_network_type=F,b.local_port=B,b.protocol=j):"remote-candidate"===t&&(b.remote_candidate_type=L,b.remote_ip=U||V,b.remote_port=B)})),(k=r.audio).timestamp){e.next=18;break}return l.timestamp=Date.now(),r.audio=l,e.abrupt("return",this.filterIllegal(d));case 18:if(T={},void 0!==l.concealedSamples&&(b.interval_concealed_samples=l.concealedSamples-k.concealedSamples,b.interval_samples_received=l.totalSamplesReceived-k.totalSamplesReceived,b.interval_silent_concealed_samples=l.silentConcealedSamples-k.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==k.concealedSamples)){e.next=36;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=36;break}return e.next=26,this._audioStallCount();case 26:I=e.sent,R=I.stall_count,A=I.stall_duration,w=I.stall_list,C=I.stats_count,T.stall_list=w,T.stats_count=C,b.concealedSamples===b.interval_concealed_samples&&b.totalSamplesReceived===b.interval_samples_received?(b.stall_count=0,b.stall_duration=0):(b.stall_count=R,b.stall_duration=A),d.stallCount=b.stall_count,d.stallDuration=b.stall_duration;case 36:return l.timestamp=Date.now(),d.audioLossRate=(l.packetsLost-k.packetsLost)/(l.packetsReceived-k.packetsReceived+(l.packetsLost-k.packetsLost)),d.audioLossRate=Number.isNaN(d.audioLossRate)?0:d.audioLossRate,b.fraction_lost=d.audioLossRate,d.statsInterval=l.timestamp-k.timestamp,b.stats_interval=d.statsInterval,d.receivedKBitrate=(l.bytesReceived-k.bytesReceived||0)/d.statsInterval*8,b.bandwidth=Math.round(1e3*d.receivedKBitrate/1024),void 0!==l.concealedSamples&&(d.receivedSampleRate=1e3*b.interval_samples_received/d.statsInterval),void 0!==l.fecPacketsReceived&&(b.fecBitratebps=(l.fecPacketsReceived-k.fecPacketsReceived||0)/d.statsInterval),b.average_jitter_buffer_delay_ms&&b.total_rtt_ms&&(d.e2eDelay=b.average_jitter_buffer_delay_ms+b.total_rtt_ms),null!==(i=this._context)&&void 0!==i&&null!==(o=i.streamRTT)&&void 0!==o&&null!==(a=o[p])&&void 0!==a&&a.audio&&(d.totalRtt=(b.rtt?b.rtt:0)+this._context.streamRTT[p].audio),r.audio=l,b.vendor_mode=(null===(s=this._stream)||void 0===s?void 0:s.vendorCode)||0,b.pc_session_id=null===(c=this.handler)||void 0===c?void 0:c.peerConnectionId,null===(u=this._monitor)||void 0===u||u.report("rtc_media_statistics",b,T),e.abrupt("return",this.filterIllegal(d));case 53:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u={},d={timestamp:Date.now()},l=this._stream,h=l.streamId,p=l.userId,v=l.isScreen,f=l.subMediaType,_=l._attributes,e.t0=Zd,e.t1={media_type:"video",is_screen:!!v,direction:"down",stream_id:h,stream_user_id:p,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:CM(f)?"mute_state_off":"mute_state_on",remote_user_capture_state:_.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:_.localvideo&&_.videostream?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,m=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",u);case 11:return u.isScreen=v,e.next=14,this.handler.getStats(t);case 14:if((y=e.sent).length){e.next=17;break}return e.abrupt("return",u);case 17:if(y.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,i=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,s=e.framesDecoded,c=e.jitterBufferDelay,l=e.jitterBufferEmittedCount,p=e.mimeType,v=e.firCount,f=e.availableIncomingBitrate,_=e.availableOutgoingBitrate,y=e.bytesSent,g=e.nominated,S=e.id,E=e.currentRoundTripTime,k=e.state,T=e.writable,I=e.candidateType,R=e.ip,A=e.address,w=e.networkType,C=e.port,x=e.nackCount,O=e.pliCount,M=e.protocol,D=e.requestsReceived,P=e.responsesReceived,N=e.requestsSent,L=e.consentRequestsSent,U=e.responsesSent,V=e.ssrc,F=e.jitter,B=e.framesReceived,j=e.keyFramesDecoded,H=e.totalDecodeTime,G=e.decoderImplementation,z=e.lastPacketReceivedTimestamp,K=e.framesDropped;if("inbound-rtp"===t)d.packetsLost=i,m.packetsLost=i,d.packetsReceived=o,m.packetsReceived=o,d.bytesReceived=a,m.bytes=a,d.framesDecoded=s,d.totalDecodeTime=H,void 0!==c&&(d.jitterBufferDelay=c/l*1e3,m.average_jitter_buffer_delay_ms=d.jitterBufferDelay),m.fir_count=v,m.nackCount=x,d.nackCount=x,m.pli_count=O,m.ssrc=V,m.framesDropped=K,m.jitter=1e3*F,m.framesReceived=B,d.framesReceived=B,m.framesDecoded=s,m.key_frames_decoded=j,m.decoder_name=G,m.last_packet_received_timestamp=z,void 0!==n&&(u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r);else if("track"===t&&void 0!==n)u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r,void 0!==B&&(m.framesReceived=B,d.framesReceived=B);else if("codec"===t)m.codecName=p;else if("candidate-pair"===t){var X,W,q;m.ice_available_incoming_bitrate=f,m.ice_available_outgoing_bitrate=_,m.ice_bytes_received=a,m.ice_bytes_sent=y,m.ice_nominated=Number(g),m.ice_pair_id=S,m.ice_pair_rtt=E,m.rtt=1e3*E,m.rtt&&null!==(X=b._context)&&void 0!==X&&null!==(W=X.streamRTT)&&void 0!==W&&null!==(q=W[h])&&void 0!==q&&q.video&&(m.total_rtt_ms=Math.round(m.rtt+b._context.streamRTT[h].video)),u.rtt=m.rtt,m.ice_pair_state=k,m.ice_pair_writable=T,m.recv_ping_requests=D,m.recv_ping_responses=P,m.sent_ping_requests_before_first_response=N,m.sent_ping_requests_total=N+(L||0),m.sent_ping_responses=U}else"local-candidate"===t?(m.local_candidate_type=I,m.local_ip=R||A,m.local_network_type=w,m.local_port=C,m.protocol=M):"remote-candidate"===t&&(m.remote_candidate_type=I,m.remote_ip=R||A,m.remote_port=C)})),(g=r.video).timestamp){e.next=22;break}return r.video=d,e.abrupt("return",this.filterIllegal(u));case 22:return u.videoLossRate=(d.packetsLost-g.packetsLost)/(d.packetsReceived-g.packetsReceived+(d.packetsLost-g.packetsLost)),g.totalDecodeTime&&g.framesDecoded&&d.framesDecoded!==g.framesDecoded&&(m.decode_elapse_per_frame=Number(((d.totalDecodeTime-g.totalDecodeTime)/(d.framesDecoded-g.framesDecoded)*1e3).toFixed(2))),u._retransmittedRate=(d.nackCount-g.nackCount)/(d.packetsReceived-g.packetsReceived+(d.packetsLost-g.packetsLost)),u.videoLossRate=Number.isNaN(u.videoLossRate)?0:u.videoLossRate,m.fraction_lost=u.videoLossRate,u.statsInterval=d.timestamp-g.timestamp,m.stats_interval=u.statsInterval,u.receivedKBitrate=(d.bytesReceived-g.bytesReceived||0)/u.statsInterval*8,m.bitrate=Math.round(1e3*u.receivedKBitrate),m.bandwidth=Math.round(m.bitrate/1024),u.decoderOutputFrameRate=1e3*(d.framesDecoded-g.framesDecoded)/u.statsInterval,u.receivedFrameRate=1e3*(d.framesReceived-g.framesReceived)/u.statsInterval,m.frame_rate_decoded=Math.round(u.decoderOutputFrameRate),m.frame_rate_received=Math.round(u.receivedFrameRate),m.average_jitter_buffer_delay_ms&&m.total_rtt_ms&&(u.e2eDelay=m.average_jitter_buffer_delay_ms+m.total_rtt_ms),null!==(n=this._context)&&void 0!==n&&null!==(i=n.streamRTT)&&void 0!==i&&null!==(o=i[h])&&void 0!==o&&o.video&&(u.totalRtt=(m.rtt?m.rtt:0)+this._context.streamRTT[h].video),r.video=d,this.processStall(this._stream,m,u,v),this.isPaused?(S=d.timestamp-(this.pauseStart||0),m.pause_duration=this.pauseDuration+(S>500?S:0),this.pauseStart=d.timestamp):m.pause_duration=this.pauseDuration,m.pause_duration=Math.min(m.stall_duration||m.stuck_length||0,m.pause_duration),this.pauseDuration=0,m.vendor_mode=(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,m.pc_session_id=null===(s=this.handler)||void 0===s?void 0:s.peerConnectionId,null===(c=this._monitor)||void 0===c||c.report("rtc_media_statistics",m),e.abrupt("return",this.filterIllegal(u));case 47:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"processStall",value:function(e,t,r,n){var i=0,o=0,a=0;if(e.recordedVideoFrames&&this.player&&this.player.played){e.recordedVideoFrames.forEach((function(e){e.isStall&&(i+=e.stallCount,o+=e.stallDuration),a=e.playTime})),e.recordedVideoFrames.length||(o=2e3,i=this._videoInWaiting?0:1,this._videoInWaiting=!0);var s=e.recordedVideoFrames.pop();s&&(s.isStall?this._videoInWaiting=!0:this._videoInWaiting=!1),e.recordedVideoFrames=[]}t.stall_count=i,n?(t.stuck_length=Math.min(o,t.stats_interval),t.stall_duration=void 0):(t.stall_duration=Math.min(o,t.stats_interval),t.stuck_length=void 0),t.play_time=a,r.stallCount=i,r.stallDuration=o}},{key:"destroy",value:function(){OI(CI(o.prototype),"destroy",this).call(this),OI(CI(o.prototype),"stopReport",this).call(this,"destroy"),this._stopAudioStallTimer(),this._videoInWaiting=!1}}],[{key:"audioStallConfig",set:function(e){o.audioStallInterval=((null==e?void 0:e.audio_stall_interval)||200)/2,o.audioStallRatio=null==e?void 0:e.audio_stall_ratio}}]),o}(tF);Jd(nF,"audioStallInterval",void 0),Jd(nF,"audioStallRatio",void 0);var iF,oF,aF=new Nw("Stream",0),sF=function(e){DI(r,e);var t=QI(r);function r(e){var n;return Vl(this,r),Jd(tI(n=t.call(this)),"videoDom",void 0),Jd(tI(n),"audioMid",void 0),Jd(tI(n),"videoMid",void 0),Jd(tI(n),"videoTransceiver",void 0),Jd(tI(n),"audioTransceiver",void 0),Jd(tI(n),"vendorHandler",void 0),Jd(tI(n),"vendorCode",0),Jd(tI(n),"engineId",void 0),Jd(tI(n),"__seiHelper",$V),n._ctx=e,n.engineId=e.id,n}return Ul(r,[{key:"requestVideoFrameCallback",value:function(){var e=this;return new Y_((function(t){var r,n=null===(r=e.videoDom)||void 0===r?void 0:r.requestVideoFrameCallback;if("function"==typeof n){var i=function(e,r){var n={};an(r).forEach((function(e){var t=e.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return Om(t="".concat(e[0],"_")).call(t,e[1].toLowerCase())}));n["video_".concat(t)]=r[e]})),clearInterval(o),t(n)};n.call(e.videoDom,i);var o=setTimeout((function(){var r;null===(r=e.videoDom)||void 0===r||r.cancelVideoFrameCallback(i),t({})}),500)}else t({})}))}},{key:"stopReport",value:function(e){this.statsReport.stopReport(e)}},{key:"destroy",value:function(){var e,t;delete this.audioMid,delete this.videoMid,this.statsReport.destroy(),null===(e=this.observer)||void 0===e||e.reset(),delete this.videoTransceiver,delete this.audioTransceiver,null===(t=this.vendorHandler)||void 0===t||t.destroy(),this.vendorCode=0,delete this.vendorHandler}}]),r}(aP),cF=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(cF||{}),uF=function(e){DI(r,e);var t=QI(r);function r(e){var n;return Vl(this,r),Jd(tI(n=t.call(this,e)),"isScreen",!1),Jd(tI(n),"stream",void 0),Jd(tI(n),"streamId",void 0),Jd(tI(n),"seiList",[]),Jd(tI(n),"videoTrack",void 0),Jd(tI(n),"audioTrack",void 0),Jd(tI(n),"videoEncodeConfig",[DD]),Jd(tI(n),"subVideoDescriptions",[]),Jd(tI(n),"enableSimulcast",!1),Jd(tI(n),"observer",void 0),Jd(tI(n),"statsReport",void 0),Jd(tI(n),"prevBitrate",0),Jd(tI(n),"pubAudio",!1),Jd(tI(n),"pubVideo",!1),Jd(tI(n),"pubAttributes",void 0),Jd(tI(n),"pcSessionId",void 0),n.stream=new MediaStream,n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},n.statsReport=new rF(e,tI(n)),n}return Ul(r,[{key:"audioHasCapture",get:function(){return this.pubAttributes.localaudio}},{key:"audioHasPublish",get:function(){return this.pubAttributes.audiostream}},{key:"videoHasCapture",get:function(){return this.pubAttributes.localvideo}},{key:"videoHasPublish",get:function(){return this.pubAttributes.videostream}},{key:"hasPublished",get:function(){return!!this.audioMid&&!!this.videoMid}},{key:"isEmptyStream",get:function(){return!this.audioTrack&&!this.videoTrack}},{key:"initStreamId",get:function(){return this.stream.id}},{key:"startReport",value:function(e,t){this.statsReport.setLocalStreamStatsEvtInterval(e,t)}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add&&lL()){var r=t.createEncodedStreams(),n=r.readable,i=r.writable,o=new TransformStream({transform:function(t,r){var n=e.seiList[0];if(n){var i,o=$V.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)rk(i=e.seiList).call(i,0,1);n.repeatCount--,a.set(new Uint8Array(t.data)),a.set(o,t.data.byteLength),t.data=a.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else aF.warn("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender)if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add){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 aF.warn("initAudioEncodedTransform","legacy EncodedTransform is not supported");else aF.warn("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){jO(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),OI(CI(r.prototype),"destroy",this).call(this),this.prevBitrate=0,this.subVideoDescriptions=[]}},{key:"switchTrackEnableState",value:function(e,t){var r,n;"audio"===e?n=this.audioTrack:"video"===e&&(n=this.videoTrack);var i=null===(r=n)||void 0===r?void 0:r.getTrack();return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}}]),r}(sF),dF=function(e){DI(r,e);var t=QI(r);function r(e,n,i,o,a,s){var c;return Vl(this,r),Jd(tI(c=t.call(this,e)),"streamId",void 0),Jd(tI(c),"userId",void 0),Jd(tI(c),"isScreen",void 0),Jd(tI(c),"isPublic",void 0),Jd(tI(c),"hasVideo",void 0),Jd(tI(c),"hasAudio",void 0),Jd(tI(c),"_attributes",void 0),Jd(tI(c),"streamState",void 0),Jd(tI(c),"removeTrack",!1),Jd(tI(c),"observer",void 0),Jd(tI(c),"statsReport",void 0),Jd(tI(c),"subVideo",void 0),Jd(tI(c),"subAudio",void 0),Jd(tI(c),"subMediaType",void 0),Jd(tI(c),"subLayer",void 0),Jd(tI(c),"_sequenceId",void 0),Jd(tI(c),"stream",void 0),Jd(tI(c),"videoTrack",void 0),Jd(tI(c),"audioTrack",void 0),Jd(tI(c),"recordedVideoFrames",void 0),Jd(tI(c),"stillExist",void 0),Jd(tI(c),"originalMediaType",void 0),Jd(tI(c),"priority",void 0),Jd(tI(c),"originalStreamIndex",0),Jd(tI(c),"virtual",void 0),Jd(tI(c),"pcSessionId",void 0),Jd(tI(c),"_virtualOccupy",void 0),c.virtual=!1,c._virtualOccupy=!1,c.userId=n,c.isScreen=o,c.isPublic=a,c.streamId=i,c.hasAudio=s.audiostream&&s.localaudio,c.hasVideo=s.videostream&&s.localvideo,c._attributes=s,c.vendorCode=(null==s?void 0:s.vendorCode)||0,c.subVideo=!1,c.subAudio=!1,c._sequenceId=0,c.subMediaType=zV.NONE,c.subLayer={spatialLayer:0,spatialSubLayer:-1},c.streamState=0,c.statsReport=new nF(e,tI(c)),c.enableVendorMode&&(c.pcSessionId=_w()),c}return Ul(r,[{key:"vendor",get:function(){return this._attributes.vendorCode}},{key:"audioHasCapture",get:function(){return this._attributes.localaudio}},{key:"audioHasPublish",get:function(){return this._attributes.audiostream}},{key:"videoHasCapture",get:function(){return this._attributes.localvideo}},{key:"videoHasPublish",get:function(){return this._attributes.videostream}},{key:"sequenceId",get:function(){return this._sequenceId||-1},set:function(e){"number"==typeof e&&(this._sequenceId=e)}},{key:"enableVendorMode",get:function(){return"number"==typeof this.attributes.vendorCode&&0!==this.attributes.vendorCode}},{key:"hasSubscribed",get:function(){return 2===this.streamState}},{key:"attributes",get:function(){return this._attributes},set:function(e){this.hasVideo=e.localvideo&&e.videostream,this.hasAudio=e.localaudio&&e.audiostream,this._attributes=e,this.vendorCode=e.vendorCode||0}},{key:"virtualOccupy",get:function(){return this._virtualOccupy},set:function(e){var t;if(this._virtualOccupy&&!e)null===(t=this.observer)||void 0===t||t.setPushTrack(!1);else if(!this._virtualOccupy&&e){var r;null===(r=this.observer)||void 0===r||r.setPushTrack(!0)}this._virtualOccupy=e}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver)if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){KV.getNalunits(new XV(t.data)).forEach((function(t){if(t.sei){var r=$V.decodeSeiBody(t.body);r&&r.type!==WV.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else aF.warn("initAudioEncodedTransform","legacy EncodedTransform is not supported");else aF.warn("no receiver found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.receiver)if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add){var e=this.audioTransceiver.receiver.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){e.data.byteLength<=1e3?t.enqueue(e):aF.print("too large audio frame",e.data.byteLength)}})).pipeTo(r)}else aF.warn("legacy EncodedTransform is not supported");else aF.warn("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n,i,o,a;try{var s;jO(this.engineId,"Stream.ontrack",Nm({uid:this.userId,streamId:this.streamId,streams:pb(s=e.streams).call(s,(function(e,t){return e+(null==(r=t)?"undefined | null":"string"==typeof r?r:Nm({id:r.id,active:r.active}));var r}),""),transceiver:(i=e.transceiver,null==i?"undefined | null":"string"==typeof i?i:Nm({currentDirection:i.currentDirection,direction:i.direction,mid:i.mid,stopped:i.stopped,receiver:(a=i.receiver,null==a?"undefined | null":"string"==typeof a?a:Nm({track:MM(a.track)})),sender:(o=i.sender,null==o?"undefined | null":"string"==typeof o?o:Nm({track:MM(o.track)}))})),track:MM(e.track)}),0,this.streamId||"")}catch(cq){}if(this.enableVendorMode||null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&mk(n).call(n,this.streamId)){var c,u=e.track;"video"===(null==u?void 0:u.kind)?this._setVideoTrack(u):"audio"===(null===(c=e.track)||void 0===c?void 0:c.kind)&&this._setAudioTrack(u),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e,t;aF.info("clean",Om(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),jO(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),OI(CI(r.prototype),"destroy",this).call(this),this.subAudio=!1,this.subVideo=!1,this.sequenceId=0,this.videoTrack=void 0,null===(t=this.audioTrack)||void 0===t||t.close(),this.audioTrack=void 0,this.stream=void 0,this.recordedVideoFrames=void 0,delete this.priority}},{key:"destroy",value:function(){this.clean(),this.attributes={audiostream:!1,localaudio:!1,localvideo:!1,videostream:!1,extvideo:!1,extaudio:!1,videoDescriptions:[]}}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{key:"_setStream",value:function(e){var t=this;this.stream=e,e.onaddtrack=function(e){"video"===e.track.kind?t._setVideoTrack(e.track):"audio"===e.track.kind&&t._setAudioTrack(e.track)}}},{key:"_setAudioTrack",value:function(e){var t,r;(null===(t=this.audioTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.audioTrack=DV(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]:dM();return new pV(e,t)}(e),this.emit("ontrack",this.videoTrack))}}]),r}(sF),lF=new Nw("queue",4),hF=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(hF||{}),pF=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(pF||{}),vF=(Jd(iF={},"publish","unpublish"),Jd(iF,"subscribe","unsubscribe"),Jd(iF,"pushtrack","removetrack"),iF),fF=(Jd(oF={},"publish",0),Jd(oF,"subscribe",0),Jd(oF,"pushtrack",0),Jd(oF,"unpublish",1),Jd(oF,"unsubscribe",1),Jd(oF,"removetrack",1),oF),_F=function(e){DI(r,e);var t=QI(r);function r(){var e;return Vl(this,r),Jd(tI(e=t.call(this)),"_queue",void 0),e._queue=[],e}return Ul(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t,r=this._queue.length,n="";return this._queue=Hs(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==vF[t.action]||(n=t.streamId,lF.info("offsetStreamId",n),!1)})),this._queue.length===r&&this._queue.push(e),this.emit("start"),n}},{key:"dequeue",value:function(){var e;if(!this._queue.length)return null;var t=this._queue.length;XM&&pD>=86&&pD<=92&&(t=Math.min(this._queue.length,5));for(var r=fF[this._queue[0].action],n=1;n<t;n++){var i;if(fF[this._queue[n].action]!==r)return{sdpStrategy:r,items:rk(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:rk(e=this._queue).call(e,0,t)}}}]),r}(iP),mF="object"==typeof global&&global&&global.Object===Object&&global,yF="object"==typeof self&&self&&self.Object===Object&&self,gF=mF||yF||Function("return this")(),SF=gF.Symbol,bF=Object.prototype,EF=bF.hasOwnProperty,kF=bF.toString,TF=SF?SF.toStringTag:void 0;var IF=Object.prototype.toString;var RF=SF?SF.toStringTag:void 0;function AF(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":RF&&RF 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 OF(e){return e}function MF(e){if(!xF(e))return!1;var t=AF(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var DF,PF=gF["__core-js_shared__"],NF=(DF=/[^.]+$/.exec(PF&&PF.keys&&PF.keys.IE_PROTO||""))?"Symbol(src)_1."+DF:"";var LF=Function.prototype.toString;function UF(e){if(null!=e){try{return LF.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var VF=/^\[object .+?Constructor\]$/,FF=Function.prototype,BF=Object.prototype,jF=FF.toString,HF=BF.hasOwnProperty,GF=RegExp("^"+jF.call(HF).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function zF(e){return!(!xF(e)||(t=e,NF&&NF in t))&&(MF(e)?GF:VF).test(UF(e));var t}function KF(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return zF(r)?r:void 0}var XF=KF(gF,"WeakMap"),WF=Object.create,qF=function(){function e(){}return function(t){if(!xF(t))return{};if(WF)return WF(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();function YF(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 JF=Date.now;var QF,ZF,$F,eB=function(){try{var e=KF(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),tB=eB,rB=tB?function(e,t){return tB(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:OF,nB=(QF=rB,ZF=0,$F=0,function(){var e=JF(),t=16-(e-$F);if($F=e,t>0){if(++ZF>=800)return arguments[0]}else ZF=0;return QF.apply(void 0,arguments)}),iB=nB;var oB=/^(?:0|[1-9]\d*)$/;function aB(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&oB.test(e))&&e>-1&&e%1==0&&e<t}function sB(e,t,r){"__proto__"==t&&tB?tB(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function cB(e,t){return e===t||e!=e&&t!=t}var uB=Object.prototype.hasOwnProperty;function dB(e,t,r){var n=e[t];uB.call(e,t)&&cB(n,r)&&(void 0!==r||t in e)||sB(e,t,r)}function lB(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?sB(r,s,c):dB(r,s,c)}return r}var hB=Math.max;function pB(e,t){return iB(function(e,t,r){return t=hB(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=hB(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),YF(e,this,s)}}(e,t,OF),e+"")}function vB(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function fB(e){return null!=e&&vB(e.length)&&!MF(e)}var _B=Object.prototype;function mB(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||_B)}function yB(e){return wF(e)&&"[object Arguments]"==AF(e)}var gB=Object.prototype,SB=gB.hasOwnProperty,bB=gB.propertyIsEnumerable,EB=yB(function(){return arguments}())?yB:function(e){return wF(e)&&SB.call(e,"callee")&&!bB.call(e,"callee")},kB=EB;var TB="object"==typeof exports&&exports&&!exports.nodeType&&exports,IB=TB&&"object"==typeof module&&module&&!module.nodeType&&module,RB=IB&&IB.exports===TB?gF.Buffer:void 0,AB=(RB?RB.isBuffer:void 0)||function(){return!1},wB={};function CB(e){return function(t){return e(t)}}wB["[object Float32Array]"]=wB["[object Float64Array]"]=wB["[object Int8Array]"]=wB["[object Int16Array]"]=wB["[object Int32Array]"]=wB["[object Uint8Array]"]=wB["[object Uint8ClampedArray]"]=wB["[object Uint16Array]"]=wB["[object Uint32Array]"]=!0,wB["[object Arguments]"]=wB["[object Array]"]=wB["[object ArrayBuffer]"]=wB["[object Boolean]"]=wB["[object DataView]"]=wB["[object Date]"]=wB["[object Error]"]=wB["[object Function]"]=wB["[object Map]"]=wB["[object Number]"]=wB["[object Object]"]=wB["[object RegExp]"]=wB["[object Set]"]=wB["[object String]"]=wB["[object WeakMap]"]=!1;var xB="object"==typeof exports&&exports&&!exports.nodeType&&exports,OB=xB&&"object"==typeof module&&module&&!module.nodeType&&module,MB=OB&&OB.exports===xB&&mF.process,DB=function(){try{var e=OB&&OB.require&&OB.require("util").types;return e||MB&&MB.binding&&MB.binding("util")}catch(t){}}(),PB=DB&&DB.isTypedArray,NB=PB?CB(PB):function(e){return wF(e)&&vB(e.length)&&!!wB[AF(e)]},LB=Object.prototype.hasOwnProperty;function UB(e,t){var r=CF(e),n=!r&&kB(e),i=!r&&!n&&AB(e),o=!r&&!n&&!i&&NB(e),a=r||n||i||o,s=a?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=s.length;for(var u in e)!t&&!LB.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||aB(u,c))||s.push(u);return s}function VB(e,t){return function(r){return e(t(r))}}var FB=VB(Object.keys,Object),BB=Object.prototype.hasOwnProperty;function jB(e){return fB(e)?UB(e):function(e){if(!mB(e))return FB(e);var t=[];for(var r in Object(e))BB.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var HB=Object.prototype.hasOwnProperty;function GB(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=mB(e),r=[];for(var n in e)("constructor"!=n||!t&&HB.call(e,n))&&r.push(n);return r}function zB(e){return fB(e)?UB(e,!0):GB(e)}var KB,XB=(KB=function(e,t){lB(t,zB(t),e)},pB((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=KB.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?fB(r)&&aB(t,r.length):"string"==n&&t in r)&&cB(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&&KB(e,a,r,i)}return e}))),WB=KF(Object,"create");var qB=Object.prototype.hasOwnProperty;var YB=Object.prototype.hasOwnProperty;function JB(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function QB(e,t){for(var r=e.length;r--;)if(cB(e[r][0],t))return r;return-1}JB.prototype.clear=function(){this.__data__=WB?WB(null):{},this.size=0},JB.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},JB.prototype.get=function(e){var t=this.__data__;if(WB){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return qB.call(t,e)?t[e]:void 0},JB.prototype.has=function(e){var t=this.__data__;return WB?void 0!==t[e]:YB.call(t,e)},JB.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=WB&&void 0===t?"__lodash_hash_undefined__":t,this};var ZB=Array.prototype.splice;function $B(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}$B.prototype.clear=function(){this.__data__=[],this.size=0},$B.prototype.delete=function(e){var t=this.__data__,r=QB(t,e);return!(r<0)&&(r==t.length-1?t.pop():ZB.call(t,r,1),--this.size,!0)},$B.prototype.get=function(e){var t=this.__data__,r=QB(t,e);return r<0?void 0:t[r][1]},$B.prototype.has=function(e){return QB(this.__data__,e)>-1},$B.prototype.set=function(e,t){var r=this.__data__,n=QB(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var ej=KF(gF,"Map");function tj(e,t){var r,n,i=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof t?"string":"hash"]:i.map}function rj(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function nj(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}rj.prototype.clear=function(){this.size=0,this.__data__={hash:new JB,map:new(ej||$B),string:new JB}},rj.prototype.delete=function(e){var t=tj(this,e).delete(e);return this.size-=t?1:0,t},rj.prototype.get=function(e){return tj(this,e).get(e)},rj.prototype.has=function(e){return tj(this,e).has(e)},rj.prototype.set=function(e,t){var r=tj(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};var ij=VB(Object.getPrototypeOf,Object);function oj(e){var t=this.__data__=new $B(e);this.size=t.size}oj.prototype.clear=function(){this.__data__=new $B,this.size=0},oj.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},oj.prototype.get=function(e){return this.__data__.get(e)},oj.prototype.has=function(e){return this.__data__.has(e)},oj.prototype.set=function(e,t){var r=this.__data__;if(r instanceof $B){var n=r.__data__;if(!ej||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new rj(n)}return r.set(e,t),this.size=r.size,this};var aj="object"==typeof exports&&exports&&!exports.nodeType&&exports,sj=aj&&"object"==typeof module&&module&&!module.nodeType&&module,cj=sj&&sj.exports===aj?gF.Buffer:void 0,uj=cj?cj.allocUnsafe:void 0;function dj(){return[]}var lj=Object.prototype.propertyIsEnumerable,hj=Object.getOwnPropertySymbols,pj=hj?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,o=[];++r<n;){var a=e[r];t(a,r,e)&&(o[i++]=a)}return o}(hj(e),(function(t){return lj.call(e,t)})))}:dj;var vj=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)nj(t,pj(e)),e=ij(e);return t}:dj;function fj(e,t,r){var n=t(e);return CF(e)?n:nj(n,r(e))}function _j(e){return fj(e,jB,pj)}function mj(e){return fj(e,zB,vj)}var yj=KF(gF,"DataView"),gj=KF(gF,"Promise"),Sj=KF(gF,"Set"),bj="[object Map]",Ej="[object Promise]",kj="[object Set]",Tj="[object WeakMap]",Ij="[object DataView]",Rj=UF(yj),Aj=UF(ej),wj=UF(gj),Cj=UF(Sj),xj=UF(XF),Oj=AF;(yj&&Oj(new yj(new ArrayBuffer(1)))!=Ij||ej&&Oj(new ej)!=bj||gj&&Oj(gj.resolve())!=Ej||Sj&&Oj(new Sj)!=kj||XF&&Oj(new XF)!=Tj)&&(Oj=function(e){var t=AF(e),r="[object Object]"==t?e.constructor:void 0,n=r?UF(r):"";if(n)switch(n){case Rj:return Ij;case Aj:return bj;case wj:return Ej;case Cj:return kj;case xj:return Tj}return t});var Mj=Oj,Dj=Object.prototype.hasOwnProperty;var Pj=gF.Uint8Array;function Nj(e){var t=new e.constructor(e.byteLength);return new Pj(t).set(new Pj(e)),t}var Lj=/\w*$/;var Uj=SF?SF.prototype:void 0,Vj=Uj?Uj.valueOf:void 0;function Fj(e,t,r){var n,i,o,a=e.constructor;switch(t){case"[object ArrayBuffer]":return Nj(e);case"[object Boolean]":case"[object Date]":return new a(+e);case"[object DataView]":return function(e,t){var r=t?Nj(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(e,t){var r=t?Nj(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,r);case"[object Map]":case"[object Set]":return new a;case"[object Number]":case"[object String]":return new a(e);case"[object RegExp]":return(o=new(i=e).constructor(i.source,Lj.exec(i))).lastIndex=i.lastIndex,o;case"[object Symbol]":return n=e,Vj?Object(Vj.call(n)):{}}}var Bj=DB&&DB.isMap,jj=Bj?CB(Bj):function(e){return wF(e)&&"[object Map]"==Mj(e)};var Hj=DB&&DB.isSet,Gj=Hj?CB(Hj):function(e){return wF(e)&&"[object Set]"==Mj(e)},zj="[object Arguments]",Kj="[object Function]",Xj="[object Object]",Wj={};function qj(e,t,r,n,i,o){var a,s=1&t,c=2&t,u=4&t;if(r&&(a=i?r(e,n,i,o):r(e)),void 0!==a)return a;if(!xF(e))return e;var d=CF(e);if(d){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&Dj.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!s)return function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}(e,a)}else{var l=Mj(e),h=l==Kj||"[object GeneratorFunction]"==l;if(AB(e))return function(e,t){if(t)return e.slice();var r=e.length,n=uj?uj(r):new e.constructor(r);return e.copy(n),n}(e,s);if(l==Xj||l==zj||h&&!i){if(a=c||h?{}:function(e){return"function"!=typeof e.constructor||mB(e)?{}:qF(ij(e))}(e),!s)return c?function(e,t){return lB(e,vj(e),t)}(e,function(e,t){return e&&lB(t,zB(t),e)}(a,e)):function(e,t){return lB(e,pj(e),t)}(e,function(e,t){return e&&lB(t,jB(t),e)}(a,e))}else{if(!Wj[l])return i?e:{};a=Fj(e,l,s)}}o||(o=new oj);var p=o.get(e);if(p)return p;o.set(e,a),Gj(e)?e.forEach((function(n){a.add(qj(n,t,r,n,e,o))})):jj(e)&&e.forEach((function(n,i){a.set(i,qj(n,t,r,i,e,o))}));var v=d?void 0:(u?c?mj:_j:c?zB:jB)(e);return function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););}(v||e,(function(n,i){v&&(n=e[i=n]),dB(a,i,qj(n,t,r,i,e,o))})),a}Wj[zj]=Wj["[object Array]"]=Wj["[object ArrayBuffer]"]=Wj["[object DataView]"]=Wj["[object Boolean]"]=Wj["[object Date]"]=Wj["[object Float32Array]"]=Wj["[object Float64Array]"]=Wj["[object Int8Array]"]=Wj["[object Int16Array]"]=Wj["[object Int32Array]"]=Wj["[object Map]"]=Wj["[object Number]"]=Wj[Xj]=Wj["[object RegExp]"]=Wj["[object Set]"]=Wj["[object String]"]=Wj["[object Symbol]"]=Wj["[object Uint8Array]"]=Wj["[object Uint8ClampedArray]"]=Wj["[object Uint16Array]"]=Wj["[object Uint32Array]"]=!0,Wj["[object Error]"]=Wj[Kj]=Wj["[object WeakMap]"]=!1;function Yj(e){return qj(e,5)}function Jj(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 Qj(e){return null==e?[]:Jj(e,jB(e))}var Zj=new Nw("ChromeHandler",3),$j=lL(),eH=function(e){DI(u,e);var t,r,n,i,o,a,s,c=QI(u);function u(e,t){var r;return Vl(this,u),Jd(tI(r=c.call(this,e,t)),"name","chrome"),Jd(tI(r),"_queueBusy",!1),Jd(tI(r),"_sdpQueue",void 0),Jd(tI(r),"_aSendonlyOfferTpl",void 0),Jd(tI(r),"_vSendonlyOfferTpl",void 0),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),Jd(tI(r),"_vRecvonlyOfferTpl",void 0),Jd(tI(r),"_mid",10),Jd(tI(r),"_inactiveMlineIndex",[]),Jd(tI(r),"_mlinesCache",{}),Jd(tI(r),"setDescription",void 0),r.setDescription=t.setDescription.bind(t),r._sdpQueue=new _F,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(Zj.info("dequeue start"),r.dequeue())})),r}return Ul(u,[{key:"destroy",value:function(){OI(CI(u.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(s=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D,P,N,L,U,V,F;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d=t.stream,l=t.enableSimulcast,h=OI(CI(u.prototype),"internalPublish",this).call(this,t),p=h.videoDescriptions,v=h.subVideoDescriptions,f=h.audioTransceiverInit,_=h.videoTransceiverInit,m=WL(this._nextSsrc),this._nextSsrc=m.next,y="".concat(this._mid++),g="".concat(this._mid++),S=Zd(Zd(Zd({},this._aSendonlyOfferTpl),this.peer._offerIce),{},{mid:y,msid:Om(r="".concat(d.id," ")).call(r,d.id,"-audio"),ssrcs:qL(d.id,"audio",m.audio,KL)}),b=Zd(Zd(Zd({},this._vSendonlyOfferTpl),this.peer._offerIce),{},{mid:g,msid:Om(n="".concat(d.id," ")).call(n,d.id,"-video")}),l?(Zj.info("subVideoDesc","desc: %o ",v),delete b.ssrcGroups,delete b.ssrcs,E=[],b.rids=jm(p).call(p,(function(e){var t=e.rid;return E.unshift(t),{id:t,direction:"send"}})),b.simulcast={dir1:"send",list1:E.join(";")}):(k=YL(d.id,m,{cname:KL}),T=k.ssrcs,I=k.ssrcGroups,b.ssrcs=T,b.ssrcGroups=I),null!==(i=this._context)&&void 0!==i&&null!==(o=i.serverConfig)&&void 0!==o&&o.audioRed&&Array.isArray(S.rtp)&&(-1!==(A=QR(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(C=rk(w=S.rtp).call(w,A,1),x=eI(C,1),O=x[0],S.rtp.unshift(O)),M=[],S.rtp.forEach((function(e){return M.push(e.payload)})),S.payloads=M.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&iU(b,null===(D=this._context)||void 0===D||null===(P=D.serverConfig)||void 0===P?void 0:P.videoCodec),!OD("IOS_SAFARI_ORIENTATION")&&(KM||rD)&&Array.isArray(b.ext)&&(b.ext=Hs(N=b.ext).call(N,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&mk(t).call(t,"video-orientation"))}))),(L=null==S?void 0:gE(c=S.rtp).call(c,(function(e){return"opus"===e.codec})))&&S.fmtp&&(F=gE(U=S.fmtp).call(U,(function(e){return e.payload===L.payload})))&&null!==(V=this._context)&&void 0!==V&&V.audioProfileManager&&(F.config=this._context.audioProfileManager.getOpusConfigStr(F.config)),l||KM||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:QL(this.peer._offerSession,S,b),audioMid:y,videoMid:g,type:"incroffer",semantics:"unified-plan",videoDescriptions:p,subVideoDescriptions:v,audioTransceiverInit:f,videoTransceiverInit:_,peerConnectionMode:this.peerConnectionMode});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"subscribe",value:(a=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D,P,N,L,U,V=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Zj.info("subscribe"),a="incroffer",s="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return c=e.sent,e.next=9,this.createAVMlineOfferTpl(c);case 9:if(u="",d="",l=!1,h=!1,p=void 0,v=void 0,this._mlinesCache[t.streamId]=[p,v],t.virtual?(u="".concat(this._mid++),l=!0):r.multiChatMode?(u="".concat(this._mid++),d="".concat(this._mid++),h=!0):(l=!0,h=!0,u="".concat(this._mid++),d="".concat(this._mid++)),u&&(p=Zd(Zd({},Yj(this._aRecvonlyOfferTpl)),{},{mid:u})),l&&(this._mlinesCache[t.streamId][0]=p,f={track:"audio",init:{direction:"recvonly"}}),d&&(v=Zd(Zd({},Yj(this._vRecvonlyOfferTpl)),{},{mid:d})),h&&(this._mlinesCache[t.streamId][1]=v,_={track:"video",init:{direction:"recvonly"}}),m=QL(this.peer._offerSession,p,v),y=void 0,t.enableVendorMode||r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl){e.next=32;break}return y=WL(this._nextSsrc),this._nextSsrc=y.next,R=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Om(g=Om(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(g,t.streamId,"-audio"),ssrcs:qL(t.streamId,"audio",y.audio)}),A=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:d,msid:Om(E=Om(k="".concat(t.streamId)).call(k,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},YL(t.streamId,y,{flexfec:this._enableSubFlexfec})),w=new Y_((function(e){V._sdpQueue.enqueue({action:pF.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:f,videoTransceiverInit:_,signalingAck:{sdp:EL.write(Zd(Zd({},V.peer._answerSession),{},{media:[R,A]})),sequenceId:t.sequenceId?++t.sequenceId:0},stream:t,sdp:m,onSuccess:function(){Zj.info("subscribe()","sub success"),e(0)}})})),e.next=31,w;case 31:null===(I=y)||void 0===I||delete I.next;case 32:return(C=null===(n=p)||void 0===n?void 0:gE(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=p)&&void 0!==o&&o.fmtp&&(M=null===(x=p)||void 0===x?void 0:gE(O=x.fmtp).call(O,(function(e){return e.payload===C.payload})))&&this._context&&(M.config+=";stereo=1;sprop-stereo=1"),t.isPublic&&pD>=86&&null!=(L=null===(D=v)||void 0===D?void 0:Hs(P=D.rtp).call(P,(function(e){return"H264"===e.codec})))&&L.length&&null!==(N=v)&&void 0!==N&&N.fmtp&&(null===(U=v)||void 0===U||U.fmtp.forEach((function(e){gE(L).call(L,(function(t){return t.payload===e.payload}))&&(e.config+=";sps-pps-idr-in-keyframe=1")}))),e.abrupt("return",{partialSdp:m,audioMid:u,videoMid:d,type:a,semantics:s,audioTransceiverInit:f,videoTransceiverInit:_,allSsrc:y,peerConnectionMode:this.peerConnectionMode});case 36:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handleAck",value:(o=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Zj.info("handleAck()","item: %o",t),!t.generatorSsrc){e.next=4;break}return Zj.warn("already set remote"),e.abrupt("return","");case 4:return e.abrupt("return",this._sdpQueue.enqueue(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"dequeue",value:(i=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),Zj.info("dequeue()","ret: %o",t),t){e.next=6;break}return this._queueBusy=!1,e.abrupt("return");case 6:if(e.prev=6,r=t.items,n=t.sdpStrategy,i=[],o=[],a=[],n!==hF.ADD){e.next=15;break}return e.delegateYield(Tm().mark((function e(){var t,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=Zd({},_.peer._answerIce)).candidates,s=!1,c=!1,e.prev=4,d=mP(r);case 6:return e.next=8,d.next();case 8:if(!(s=!(l=e.sent).done)){e.next=16;break}if(n=l.value,"break"!==function(){var e=n.audioMid,r=n.videoMid,s=n.action,c=n.audioTransceiverInit,u=n.videoTransceiverInit,d=n.signalingAck,l=n.stream,h=l instanceof dF;if(n.onSuccess&&a.push(n.onSuccess),h&&(null==d?void 0:d.sequenceId)<l.sequenceId)return"break";var p,v={},f={},m=EL.parse(d.sdp);Array.isArray(m.media)&&HR(p=m.media).call(p,(function(e,t){var r;return null==e||null===(r=e.type)||void 0===r?void 0:r.localeCompare(null==t?void 0:t.type)})).forEach((function(n){"audio"===(n=Zd(Zd({},n),t)).type?(v=n).mid=e:(f=n).mid=r}));var y,g=l.streamId;if(s===pF.publish&&(g=null===(y=l.stream)||void 0===y?void 0:y.id),!_._mlinesCache[g])return"break";var S=eI(_._mlinesCache[g],2),b=S[0],E=S[1];if(c&&b){l.audioTransceiver=_._peerConnection.addTransceiver(c.track,c.init),_._reportRtcInvokeStatus("chromeHandler.addTrack",Nm({audioStreamTrack:MM(c.track)}));var k=_._inactiveMlineIndex.shift();k||(k=_.peer._offerMlines.length),_.peer._offerMlines[k]=Zd({},b),_.peer._answerMlines[k]=v,$j&&l.initAudioEncodedTransform()}if(u&&E){var T,I;l.videoTransceiver=_._peerConnection.addTransceiver(u.track,u.init),_._reportRtcInvokeStatus("chromeHandler.addTrack",Nm({videoStreamTrack:MM(u.track)}));var R,A,w=_._inactiveMlineIndex.shift();w||(w=_.peer._offerMlines.length),_.peer._offerMlines[w]=Zd({},E),s===pF.publish&&null!==(T=_._context)&&void 0!==T&&null!==(I=T.serverConfig)&&void 0!==I&&I.videoCodec&&iU(f,null===(R=_._context)||void 0===R||null===(A=R.serverConfig)||void 0===A?void 0:A.videoCodec),_.peer._answerMlines[w]=f,$j&&l.initVideoEncodedTransform()}i.push(l.streamId||""),o.push(h?l.userId:"local"),h&&(l.sequenceId=null==d?void 0:d.sequenceId),delete _._mlinesCache[g]}()){e.next=13;break}return e.abrupt("break",16);case 13:s=!1,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),c=!0,u=e.t0;case 22:if(e.prev=22,e.prev=23,!s||null==d.return){e.next=27;break}return e.next=27,d.return();case 27:if(e.prev=27,!c){e.next=30;break}throw u;case 30:return e.finish(27);case 31:return e.finish(22);case 32:case"end":return e.stop()}}),e,null,[[4,18,22,32],[23,,27,31]])}))(),"t0",13);case 13:e.next=20;break;case 15:f={},r.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;f[t]=t,n!==pF.removetrack&&(f[r]=r),f[t]=t})),this.peer._offerMlines=jm(h=this.peer._offerMlines).call(h,(function(e,t){return f[e.mid]&&(e=JL(e),_._inactiveMlineIndex.push(t)),e})),HR(p=this._inactiveMlineIndex).call(p,(function(e,t){return e-t})),this.peer._answerMlines=jm(v=this.peer._answerMlines).call(v,(function(e){return f[e.mid]&&(e=JL(e)),e}));case 20:return e.next=22,this.peer.getOriginRTCPeerConnection().createOffer();case 22:return e.next=24,this.setDescription(i.length?{streamId:i.join(","),streamUserId:o.join(",")}:void 0);case 24:try{a.forEach((function(e){return e()}))}catch(cq){}Zj.info("dequeue","loop"),e.next=31;break;case 28:e.prev=28,e.t1=e.catch(6),Zj.error("dequeue","unknown error: %o",e.t1);case 31:return e.prev=31,this.dequeue(),e.finish(31);case 34:case"end":return e.stop()}}),e,this,[[6,28,31,34]])}))),function(){return i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._genOfferSdp();case 2:return r=e.sent,this.createAVMlineOfferTpl(r),n=EL.parse(r),i=[],n.media=Hs(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=Hs(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),i.push("".concat(e.mid)),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:EL.write(n),semantics:"unified-plan",type:"incroffer"});case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"rollback",value:(r=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete this._mlinesCache[t];case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;EL.parse(e).media.forEach((function(e){if(e.icePwd=t.peer._offerIce.icePwd,e.iceUfrag=t.peer._offerIce.iceUfrag,"audio"===e.type)if("sendonly"===e.direction)t._aSendonlyOfferTpl=e;else{var r;if(Array.isArray(e.ext))e.ext=Hs(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=Hs(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}}))}},{key:"_genOfferSdp",value:(t=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,IM(!0);case 3:if(t=e.sent){e.next=6;break}throw"pc.createOffer() return empty.";case 6:e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),r="Get offer Error. ".concat(e.t0.message|e.t0),new mA(pA.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return t.apply(this,arguments)})}]),u}(aU),tH=new Nw("FirefoxHandler",3),rH=function(e){DI(d,e);var t,r,n,i,o,a,s,c,u=QI(d);function d(){var e,t;Vl(this,d);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return Jd(tI(t=u.call.apply(u,Om(e=[this]).call(e,n))),"name","firefox"),Jd(tI(t),"_aRecvonlyOfferTpl",void 0),t}return Ul(d,[{key:"publish",value:(c=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,f,_,m=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=OI(CI(d.prototype),"internalPublish",this).call(this,t),o=i.videoDescriptions,a=i.subVideoDescriptions,s=i.audioTransceiverInit,c=i.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(s.track,s.init),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),u=lM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=7,this._peerConnection.createOffer();case 7:return l=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:lM()-u}),(h=EL.parse(l.sdp)).media=null===(r=h.media)||void 0===r?void 0:jm(r).call(r,(function(e){return Zd(Zd({},e),m.peer._offerIce)})),e.next=13,this.setLocalDescription(EL.write(h));case 13:return p=t.audioTransceiver.mid,v=t.videoTransceiver.mid,f=null,_=null,h.media=null===(n=h.media)||void 0===n?void 0:jm(n).call(n,(function(e){if("".concat(e.mid)===p){var t,r,n=null===(t=f=e)||void 0===t?void 0:gE(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&f.fmtp){var i,o,a=gE(i=f.fmtp).call(i,(function(e){return e.payload===n.payload}));a&&null!==(o=m._context)&&void 0!==o&&o.audioProfileManager&&(a.config=m._context.audioProfileManager.getOpusConfigStr(a.config))}}else if("".concat(e.mid)===v){var s,c,u,d;null!==(s=m._context)&&void 0!==s&&null!==(c=s.serverConfig)&&void 0!==c&&c.videoCodec&&iU(e,null===(u=m._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec),_=e}return e})),this.addBitrateLimit(_,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(EL.write(h));case 21:return e.abrupt("return",{partialSdp:QL(h,f,_,!1),audioMid:p,videoMid:v,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:c,peerConnectionMode:this.peerConnectionMode});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tH.info("subscribe()"),c="",u="",d=!1,l=!1,h=void 0,p=void 0,t.virtual?d=!0:(r.multiChatMode||(d=!0),l=!0),d&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),l&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),v=lM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return f=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:lM()-v}),(_=EL.parse(f.sdp)).media=null===(n=_.media)||void 0===n?void 0:jm(n).call(n,(function(e){return Zd(Zd({},e),A.peer._offerIce)})),jm(i=_.media).call(i,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=21,this.setLocalDescription(EL.write(_),{streamId:t.streamId||"",streamUserId:t.userId});case 21:if(c=null===(o=t.audioTransceiver)||void 0===o?void 0:o.mid,u=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid,null===(s=_.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===c?h=e:"".concat(e.mid)===u&&(p=e)})),c&&h||(c="audio_".concat(u),h=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:c})),t.audioMid=c,t.videoMid=u,m=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=36;break}return m=WL(this._nextSsrc),this._nextSsrc=m.next,I=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:c,msid:Om(y=Om(g="".concat(t.streamId)).call(g,null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:qL(t.streamId,"audio",m.audio)}),R=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Om(b=Om(E="".concat(t.streamId)).call(E,null!==(k=this._context)&&void 0!==k&&k.avSync?"":"-video"," ")).call(b,t.streamId,"-video")},YL(t.streamId,m,{flexfec:this._enableSubFlexfec})),e.next=35,this._internalSetRemoteDescription([I,R],t);case 35:null===(T=m)||void 0===T||delete T.next;case 36:return e.abrupt("return",{partialSdp:QL(_,h,p,!1),audioMid:c,videoMid:u,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:m,peerConnectionMode:this.peerConnectionMode});case 37:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==pF.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==pF.unpublish&&i!==pF.unsubscribe){e.next=7;break}return e.next=6,this.close(n);case 6:return e.abrupt("return",n.streamId||"");case 7:if(!t.generatorSsrc){e.next=10;break}return tH.warn("already set remote"),e.abrupt("return","");case 10:return o=EL.parse(null==r?void 0:r.sdp),e.next=13,this._internalSetRemoteDescription(o.media,n);case 13:return e.abrupt("return","");case 14:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=EL.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){if("audio"===(e=Zd(Zd({},e),l.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type){if(r instanceof uF&&uD<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=Hs(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=Hs(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=Hs(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=Hs(o=e.fmtp).call(o,(function(e){return!a[e.payload]})))}r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e}})),u=EL.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=jm(o=u.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,jm(a=c.media).call(a,(function(e){var t,r,n;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type})),uD>=138&&(e.ext=null===(n=e.ext)||void 0===n?void 0:Hs(n).call(n,(function(e){var t;return!mk(t=e.uri).call(t,"sdes:mid")}))))})),e.next=11,this.setRemoteDescription(EL.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=EL.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Hs(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:EL.write(i),semantics:"unified-plan",type:"incroffer"});case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tH.warn("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tH.info("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=EL.parse(null==c?void 0:c.sdp)).media=jm(n=u.media).call(n,(function(e){return a[e.mid]&&(e=JL(e)),"inactive"!==e.direction&&s.push(e.mid),Zd(Zd({},e),h.peer._offerIce)})),d=EL.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=jm(o=u.media).call(o,(function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(EL.write(u));case 17:return e.next=19,this.setRemoteDescription(EL.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;EL.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(aU),nH=new Nw("FallbackHandler",3),iH=function(e){DI(d,e);var t,r,n,i,o,a,s,c,u=QI(d);function d(e,t){var r;return Vl(this,d),Jd(tI(r=u.call(this,e,t)),"name","fallback"),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),nH.warn("ctor","using fallback handler"),r._report("rtc_error",{message:"using fallback handler",error_code:-1}),r}return Ul(d,[{key:"publish",value:(c=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,f;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=OI(CI(d.prototype),"internalPublish",this).call(this,t),i=n.videoDescriptions,o=n.subVideoDescriptions,a=n.audioTransceiverInit,s=n.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(a.track,a.init),t.videoTransceiver=this._peerConnection.addTransceiver(s.track,s.init),c=lM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=7,this._peerConnection.createOffer();case 7:return u=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:lM()-c}),l=EL.parse(u.sdp),e.next=12,this.setLocalDescription(u.sdp);case 12:return h=t.audioTransceiver.mid,p=t.videoTransceiver.mid,v=null,f=null,l.media=null===(r=l.media)||void 0===r?void 0:jm(r).call(r,(function(e){return"".concat(e.mid)===h?v=e:"".concat(e.mid)===p&&(f=e),e})),lL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:QL(l,v,f,!1),audioMid:h,videoMid:p,type:"incroffer",semantics:"unified-plan",videoDescriptions:i,subVideoDescriptions:o,audioTransceiverInit:a,videoTransceiverInit:s,peerConnectionMode:this.peerConnectionMode});case 19:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nH.info("subscribe()"),a="",s="",c=!1,u=!1,d=void 0,l=void 0,t.virtual?c=!0:(r.multiChatMode||(c=!0),u=!0),c&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),u&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),h=lM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return p=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:lM()-h}),v=EL.parse(p.sdp),e.next=19,this.setLocalDescription(p.sdp,{streamId:t.streamId||"",streamUserId:t.userId});case 19:if(a=null===(n=t.audioTransceiver)||void 0===n?void 0:n.mid,s=null===(i=t.videoTransceiver)||void 0===i?void 0:i.mid,null===(o=v.media)||void 0===o||o.forEach((function(e){"".concat(e.mid)===a?d=e:"".concat(e.mid)===s&&(l=e)})),a&&d||(a="audio_".concat(s),d=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:a})),t.audioMid=a,t.videoMid=s,f=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=34;break}return f=WL(this._nextSsrc),this._nextSsrc=f.next,k=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:a,msid:Om(_=Om(m="".concat(t.streamId)).call(m,null!==(y=this._context)&&void 0!==y&&y.avSync?"":"-audio"," ")).call(_,t.streamId,"-audio"),ssrcs:qL(t.streamId,"audio",f.audio)}),T=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:s,msid:Om(g=Om(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-video"," ")).call(g,t.streamId,"-video")},YL(t.streamId,f,{flexfec:this._enableSubFlexfec})),e.next=33,this._internalSetRemoteDescription([k,T],t);case 33:null===(E=f)||void 0===E||delete E.next;case 34:return lL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:QL(v,d,l,!1),audioMid:a,videoMid:s,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:f,peerConnectionMode:this.peerConnectionMode});case 36:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==pF.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==pF.unpublish&&i!==pF.unsubscribe){e.next=7;break}return e.next=6,this.close(n);case 6:return e.abrupt("return",n.streamId||"");case 7:if(!t.generatorSsrc){e.next=10;break}return nH.warn("already set remote"),e.abrupt("return","");case 10:return o=EL.parse(null==r?void 0:r.sdp),e.next=13,this._internalSetRemoteDescription(o.media,n);case 13:return e.abrupt("return","");case 14:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=EL.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){"audio"===(e=Zd(Zd({},e),l.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e)})),u=EL.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=jm(o=u.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,jm(a=c.media).call(a,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(EL.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=EL.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Hs(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:EL.write(i),semantics:"unified-plan",type:"incroffer"});case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nH.warn("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nH.info("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=EL.parse(null==c?void 0:c.sdp)).media=jm(n=u.media).call(n,(function(e){return a[e.mid]&&(e=JL(e)),"inactive"!==e.direction&&s.push(e.mid),Zd(Zd({},e),h.peer._offerIce)})),d=EL.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=jm(o=u.media).call(o,(function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(null==c?void 0:c.sdp);case 17:return e.next=19,this.setRemoteDescription(EL.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;EL.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(aU);function oH(e,t){var r=(new Error).stack;NO("[DCHECK FAILED] ".concat(t),-1,{stack:r})}var aH=ad,sH=tc,cH=function(e,t,r,n){for(var i,o=n>1?void 0:n?sH(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&&aH(t,r,o),o},uH=function(){function e(t){Vl(this,e),Jd(this,"_queue",[]),Jd(this,"_runningTask",[]),Jd(this,"executor",void 0),Jd(this,"busy",!1),this.executor=t}var t;return Ul(e,[{key:"add",value:function(e){var t=vH(),r=t.promise,n=t.resolve,i=t.reject;return this._queue.push({item:e,resolve:n,reject:i}),this.busy||this._emit(),r}},{key:"destroy",value:function(){var e;Om(e=[]).call(e,Jk(this._queue),Jk(this._runningTask)).forEach((function(e){(0,e.reject)(new mA(pA.OPERATION_CANCEL,"queue close"))})),this.busy=!1,this._queue=[]}},{key:"_emit",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._queue,this._runningTask=t,this._queue=[],0!==t.length){e.next=6;break}return this.busy=!1,e.abrupt("return");case 6:return r=jm(t).call(t,(function(e){return e.item})),n=jm(t).call(t,(function(e){return e.resolve})),i=jm(t).call(t,(function(e){return e.reject})),e.prev=9,this.busy=!0,e.next=13,this.executor(r);case 13:o=e.sent,n.forEach((function(e){return e(o)})),e.next=20;break;case 17:e.prev=17,e.t0=e.catch(9),i.forEach((function(t){return t(e.t0)}));case 20:return this._runningTask=[],setTimeout((function(){a._emit()})),e.abrupt("return");case 23:case"end":return e.stop()}}),e,this,[[9,17]])}))),function(){return t.apply(this,arguments)})}]),e}(),dH=new Nw("StandardHandler",3),lH=function(e){DI(h,e);var t,r,n,i,o,a,s,c,u,d,l=QI(h);function h(e,t){var r;return Vl(this,h),Jd(tI(r=l.call(this,e,t)),"name","standard"),Jd(tI(r),"_applyQueue",new uH(r.apply.bind(tI(r)))),Jd(tI(r),"_createQueue",new uH(r.create.bind(tI(r)))),Jd(tI(r),"_pqueue",new pH),Jd(tI(r),"_midMap",new $S),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),dH.warn("ctor","using standard handler"),r}return Ul(h,[{key:"publish",value:(d=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,p,v,f,_;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.info("publish()","streamId: ".concat(t.streamId)),n=OI(CI(h.prototype),"internalPublish",this).call(this,t),i=n.videoDescriptions,o=n.subVideoDescriptions,a=n.audioTransceiverInit,s=n.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(a.track,Zd(Zd({},a.init),{},{direction:"sendonly"})),Array.isArray(s.init.sendEncodings)&&1===s.init.sendEncodings.length&&(s.init.sendEncodings=jm(c=s.init.sendEncodings).call(c,(function(e){return delete e.rid,e}))),t.videoTransceiver=this._peerConnection.addTransceiver(s.track,Zd(Zd({},s.init),{},{direction:"sendonly"})),u=lM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=9,this._createQueue.add();case 9:return d=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:lM()-u}),l=t.audioTransceiver.mid,p=t.videoTransceiver.mid,oH(0,"Transceiver not return MID after setLocalDescription"),t.audioMid=l,t.videoMid=p,v=null,f=null,(_=EL.parse(d)).media=null===(r=_.media)||void 0===r?void 0:jm(r).call(r,(function(e){return"".concat(e.mid)===l?v=e:"".concat(e.mid)===p&&(f=e),e})),lL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:QL(_,v,f,!1),audioMid:l,videoMid:p,type:"incroffer",semantics:"unified-plan",videoDescriptions:i,subVideoDescriptions:o,audioTransceiverInit:a,videoTransceiverInit:s,peerConnectionMode:this.peerConnectionMode});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"subscribe",value:(u=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.info("subscribe()","streamId: ".concat(t.streamId)),c=!1,u=!1,d=void 0,l=void 0,t.virtual?c=!0:(r.multiChatMode||(c=!0),u=!0),c&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),u&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),h=lM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=12,this._createQueue.add();case 12:if(p=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:lM()-h}),v=null!==(n=null===(i=t.audioTransceiver)||void 0===i?void 0:i.mid)&&void 0!==n?n:void 0,f=null!==(o=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid)&&void 0!==o?o:void 0,_=EL.parse(p),null===(s=_.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===v?d=e:"".concat(e.mid)===f&&(l=e)})),v&&d||(v="audio_".concat(f),d=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:v})),t.audioMid=v,t.videoMid=f,m=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=29;break}return m=this._generateAllSsrc(),I=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:v,msid:Om(y=Om(g="".concat(t.streamId)).call(g,null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:qL(t.streamId,"audio",m.audio)}),R=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:f,msid:Om(b=Om(E="".concat(t.streamId)).call(E,null!==(k=this._context)&&void 0!==k&&k.avSync?"":"-video"," ")).call(b,t.streamId,"-video")},YL(t.streamId,m,{flexfec:this._enableSubFlexfec})),e.next=28,this._internalSetRemoteDescription([I,R],t);case 28:null===(T=m)||void 0===T||delete T.next;case 29:return lL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:QL(_,d,l,!1),audioMid:v,videoMid:f||"",type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:m,peerConnectionMode:this.peerConnectionMode});case 31:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"handleAck",value:(c=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==pF.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==pF.unpublish&&i!==pF.unsubscribe){e.next=7;break}return e.next=6,this.close(n);case 6:return e.abrupt("return",n.streamId||"");case 7:if(!t.generatorSsrc){e.next=10;break}return dH.warn("already set remote"),e.abrupt("return","");case 10:return o=EL.parse(null==r?void 0:r.sdp),e.next=13,this._internalSetRemoteDescription(o.media,n);case 13:return e.abrupt("return","");case 14:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(s=Rm(Tm().mark((function e(t,r){var n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){"audio"===(e=Zd(Zd({},e),n.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,n._midMap.set(r.audioMid,e)):n._midMap.set(e.mid,e)),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,n._midMap.set(r.videoMid,e)):n._midMap.set(e.mid,e))})),r instanceof uF?this.handlePublishAction({stream:r}):this.handleSubscribeAction({stream:r}),e.next=7,this._applyQueue.add();case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handlePublishAction",value:function(e){var t,r,n,i,o,a,s,c,u=e.stream,d=u.audioMid?this._midMap.get(u.audioMid):void 0,l=u.videoMid?this._midMap.get(u.videoMid):void 0;null!==(t=this._context)&&void 0!==t&&t.pcKillSwitch.sld_rtcpfb_rrtr_add&&fL&&(hH.addRRTR(d),hH.addRRTR(l));var h,p=null!==(r=this._context)&&void 0!==r&&null!==(n=r.serverConfig)&&void 0!==n&&n.audioRed?"RED":"OPUS";("OPUS"!==p&&d&&function(e,t){if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){for(var r=0;r<e.rtp.length;r++)if(e.rtp[r].codec.toUpperCase()===t.toUpperCase()){var n;e.rtp.unshift(rk(n=e.rtp).call(n,r,1)[0]);break}var i=[];e.rtp.forEach((function(e){return i.push(e.payload)})),e.payloads=i.join(" ")}}(d,p),null!==(i=this._context)&&void 0!==i&&i.pcKillSwitch.sld_fmtp_opus_add)&&hH.decorateOpusConfig(d,null===(h=this._context)||void 0===h?void 0:h.audioProfileManager);zM&&uD<=87&&hH.removeRtxInMLine(l);var v=null===(o=this._context)||void 0===o||null===(a=o.serverConfig)||void 0===a?void 0:a.videoCodec;v&&l&&iU(l,v),null!==(s=this._context)&&void 0!==s&&s.pcKillSwitch.sld_ext_sdesmid_remove&&zM&&uD>=138&&hH.removeExtSdesMid(l),null!==(c=this._context)&&void 0!==c&&c.pcKillSwitch.sld_fmtp_bitrate_add&&(u.enableSimulcast||KM||!l||this.addBitrateLimit(l,u.videoEncodeConfig[0].maxKbps)),zM&&hH.selectCC(l,vL?"tcc":"remb"),u.audioMid&&d&&this._midMap.set(u.audioMid,d),u.videoMid&&l&&this._midMap.set(u.videoMid,l)}},{key:"handleSubscribeAction",value:function(e){var t,r,n,i=e.stream,o=i.audioMid?this._midMap.get(i.audioMid):void 0,a=i.videoMid?this._midMap.get(i.videoMid):void 0;zM||(hH.removeRtpStreamId(o),hH.removeRtpStreamId(a)),null!==(t=this._context)&&void 0!==t&&t.pcKillSwitch.sld_rtcpfb_rrtr_add&&fL&&(hH.addRRTR(o),hH.addRRTR(a)),null!==(r=this._context)&&void 0!==r&&r.pcKillSwitch.sld_fmtp_opus_add&&hH.decorateOpusConfig(o,this._context.audioProfileManager),OD("IOS_SAFARI_ORIENTATION")||!KM&&!rD||hH.removeExtVideoOrientation(a),null!==(n=this._context)&&void 0!==n&&n.pcKillSwitch.sld_fmtp_sps_add&&i.isPublic&&XM&&pD>=86&&hH.decorateSpsPpsIdrInKeyframe(a),i.audioMid&&o&&this._midMap.set(i.audioMid,o),i.videoMid&&a&&this._midMap.set(i.videoMid,a)}},{key:"getDefaultSdp",value:(a=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=EL.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Hs(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),fL&&i.media.forEach((function(e){"audio"!==e.type&&"video"!==e.type||e.rtp.forEach((function(t){var r;e.rtcpFb||(e.rtcpFb=[]),gE(r=e.rtcpFb).call(r,(function(e){return e.payload===t.payload&&"rrtr"===e.type}))||e.rtcpFb.push({payload:t.payload,type:"rrtr"})}))})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:EL.write(i),semantics:"unified-plan",type:"incroffer"});case 14:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"rollback",value:(o=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.warn("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return o.apply(this,arguments)})},{key:"close",value:(i=Rm(Tm().mark((function e(t,r,n){var i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(dH.info("close()"),i=t.audioMid||r,o=t.videoMid||n,t.audioTransceiver&&i)try{t.audioTransceiver.stop(),delete t.audioTransceiver}catch(c){}if(t.videoTransceiver&&o)try{t.videoTransceiver.stop(),delete t.videoTransceiver}catch(u){}return a=i?this._midMap.get(i):void 0,s=o?this._midMap.get(o):void 0,a&&JL(a),s&&JL(s),i&&a&&this._midMap.set(i,a),o&&s&&this._midMap.set(o,s),e.next=13,this._applyQueue.add();case 13:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return i.apply(this,arguments)})},{key:"setCurrentDescription",value:(n=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._applyQueue.add();case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;EL.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}},{key:"_generateAllSsrc",value:function(){var e=WL(this._nextSsrc);return this._nextSsrc=e.next,e}},{key:"create",value:(r=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.info("RTCPeerConnection create"),e.next=3,this._peerConnection.createOffer();case 3:return t=e.sent,r=t.sdp,oH(0,"RTCPeerConnection not return SDP"),e.next=8,this.peer.setLocalDescription(r);case 8:return e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"apply",value:(t=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.info("RTCPeerConnection apply"),e.next=3,this._peerConnection.createOffer();case 3:return t=e.sent,r=t.sdp,oH(0,"RTCPeerConnection not return SDP"),n=EL.parse(r),r=this.generateOffer(n,r),i=this.generateAnswer(n),e.next=11,this.setLocalDescription(r);case 11:return e.next=13,this.setRemoteDescription(i);case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"generateOffer",value:function(e,t){var r,n,i,o=this,a=!1;"v1"===this.peer.getIceVersion()&&zM&&(e.media=jm(n=e.media).call(n,(function(e){return Zd(Zd({},e),o.peer._offerIce)})),a=!0);null!==(r=this._context)&&void 0!==r&&r.pcKillSwitch.sld_rtcpfb_rrtr_add&&(e.media=jm(i=e.media).call(i,(function(e){return hH.addRRTR(e),e})),a=!0);return a?EL.write(e):t}},{key:"generateAnswer",value:function(e){var t=this,r=[];return e.media.forEach((function(e){if("application"===e.type){oH(e.mid,"should always have mid in mline");var n=t._midMap.get(e.mid);return n||(n=t.generateDCAnswer(e),t._midMap.set(e.mid,n)),void r.push(Zd({},n))}var i="".concat(e.mid);oH(0,"No MID in offer m-line: ".concat(e));var o=t._midMap.get(i);o||(dH.info("generateInactiveAnswerMLine","mid: %o, mLine: %o",e.mid,e),o=t.generateInactiveAnswerMLine(e)),r.push(o)})),this.peer.createAnswerSdp(r,e.groups)}},{key:"generateInactiveAnswerMLine",value:function(e){return Zd(Zd(Zd({},e),this.peer._answerIce),{},{direction:"inactive"})}},{key:"generateDCAnswer",value:function(e){var t=Zd(Zd(Zd({},e),this.peer._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}});return zM&&(delete t.bundleOnly,t.port=9),t}},{key:"destroy",value:function(){OI(CI(h.prototype),"destroy",this).call(this),this._pqueue.destroy(),this._applyQueue.destroy(),this._createQueue.destroy()}}]),h}(aU);cH([function(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.info("SDP Lock","pending task %o",t),e.next=3,this._pqueue.enqueue(0);case 3:for(r=e.sent,dH.info("SDP Lock","running task %o",t),e.prev=5,i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=9,null==n?void 0:n.apply(this,o);case 9:return e.abrupt("return",e.sent);case 10:return e.prev=10,dH.info("SDP Lock","unlocking by task %o",t),r(),e.finish(10);case 14:case"end":return e.stop()}}),e,this,[[5,,10,14]])}))),r}],lH.prototype,"create",1),cH([function(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.info("SDP Lock","pending task %o",t),e.next=3,this._pqueue.enqueue(1);case 3:for(r=e.sent,dH.info("SDP Lock","running task %o",t),e.prev=5,i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=9,null==n?void 0:n.apply(this,o);case 9:return e.abrupt("return",e.sent);case 10:return e.prev=10,dH.info("SDP Lock","unlocking by task %o",t),r(),e.finish(10);case 14:case"end":return e.stop()}}),e,this,[[5,,10,14]])}))),r}],lH.prototype,"apply",1);var hH={decorateOpusConfig:function(e,t){var r;if(e){var n=null==e?void 0:gE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&e.fmtp){var i,o=gE(i=e.fmtp).call(i,(function(e){return e.payload===n.payload}));o&&t&&(o.config=t.getOpusConfigStr(o.config))}}},removeRtxInMLine:function(e){var t,r,n,i;if(e){var o=[];e.rtp=Hs(t=e.rtp).call(t,(function(e){return"rtx"===e.codec&&o.push(e.payload),"rtx"!==e.codec})),e.fmtp=Hs(r=e.fmtp).call(r,(function(e){return mk(o).call(o,e.payload)})),e.payloads=null===(n=e.payloads)||void 0===n?void 0:Hs(i=n.split(" ")).call(i,(function(e){return!mk(o).call(o,uy(e))})).join(" ")}},removeExtSdesMid:function(e){var t;e&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return!mk(t=e.uri).call(t,"sdes:mid")})))},selectCC:function(e,t){var r,n;if(e)if("tcc"===t)e.ext=null===(r=e.ext)||void 0===r?void 0:Hs(r).call(r,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:Hs(n).call(n,(function(e){return"goog-remb"!==e.type}));else if("remb"===t){var i,o;e.rtcpFb=null===(i=e.rtcpFb)||void 0===i?void 0:Hs(i).call(i,(function(e){return"transport-cc"!==e.type})),e.ext=null===(o=e.ext)||void 0===o?void 0:Hs(o).call(o,(function(e){var t;return-1===xE(t=e.uri).call(t,"transport")}))}},addRRTR:function(e){e&&e.rtp.forEach((function(t){var r;e.rtcpFb||(e.rtcpFb=[]),gE(r=e.rtcpFb).call(r,(function(e){return e.payload===t.payload&&"rrtr"===e.type}))||e.rtcpFb.push({payload:t.payload,type:"rrtr"})}))},removeRtpStreamId:function(e){var t;e&&(Array.isArray(e.ext)&&(e.ext=Hs(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))))},decorateSpsPpsIdrInKeyframe:function(e){var t;if(e){var r=Hs(t=e.rtp).call(t,(function(e){return"H264"===e.codec}));r.length&&e.fmtp&&e.fmtp.forEach((function(e){gE(r).call(r,(function(t){return t.payload===e.payload}))&&(e.config+=";sps-pps-idr-in-keyframe=1")}))}},removeExtVideoOrientation:function(e){var t;e&&(Array.isArray(e.ext)&&(e.ext=Hs(t=e.ext).call(t,(function(e){var t;return!mk(t=e.uri).call(t,"video-orientation")}))))},removeExtFramemarking:function(e){var t;e&&(Array.isArray(e.ext)&&(e.ext=Hs(t=e.ext).call(t,(function(e){var t;return!mk(t=e.uri).call(t,"framemarking")}))))}},pH=function(){function e(){Vl(this,e),Jd(this,"queue",[]),Jd(this,"processing",!1)}var t;return Ul(e,[{key:"enqueue",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u=this,d=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=d.length>0&&void 0!==d[0]?d[0]:0,n=vH(),i=n.promise,o=n.resolve,a={priority:r,resolve:o},-1===(s=QR(t=this.queue).call(t,(function(e){return e.priority>r})))?this.queue.push(a):rk(c=this.queue).call(c,s,0,a),this.tryProcess(),e.next=8,i;case 8:return this.processing=!0,e.abrupt("return",(function(){u.processing=!1,u.tryProcess()}));case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this.queue.forEach((function(e){(0,e.resolve)()})),this.queue=[],this.processing=!1}},{key:"tryProcess",value:function(){if(!this.processing){var e=this.queue.shift();e&&e.resolve()}}}]),e}();function vH(){var e=void 0,t=void 0,r=new Y_((function(r,n){e=r,t=n}));if(!e||!t)throw Error("Broken Implement of Promise");return{promise:r,resolve:e,reject:t}}var fH,_H,mH=function(e,t){return e.enableFallbackHandler?new iH(e,t):e.enableStandardHandler?new lH(e,t):zM?new rH(e,t):new eH(e,t)},yH=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}(yH||{}),gH=function(e){return e.PushLimitWarn="PushLimitWarn",e}(gH||{}),SH=function(e){return e.ON_ADD_STREAM="onAddStream",e.ON_ADD_STREAM_LIST="onAddStreamList",e.ON_REMOVE_STREAM="onRemoveStream",e.ON_REMOVE_STREAM_LIST="onRemoveStreamList",e.USER_DISCONNECTION="userDisconnection",e.USER_DISCONNECTION_LIST="userDisconnectionList",e.USER_CONNECTION="userConnection",e.USER_CONNECTION_LIST="userConnectionList",e.ON_UPDATE_STREAM_ATTRIBUTES="onUpdateStreamAttributes",e.ON_UPDATE_ROOM_ATTRIBUTES="onUpdateRoomAttributes",e.ON_UPDATE_USER_ATTRIBUTES="onUpdateUserAttributes",e.ON_PUSH_TRACK="onPushTrack",e.ON_REMOVE_TRACK="onRemoveTrack",e.ON_CUSTOM_MESSAGE="onCustomMessage",e.NODE_CHANGE="nodeChange",e.USER_MESSAGE_RECEIVED="userMessageReceived",e.USER_BINARY_MESSAGE_RECEIVED="userBinaryMessageReceived",e.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM="userMessageReceivedOutsideRoom",e.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM="userBinaryMessageReceivedOutsideRoom",e.POST_PROCESSING_MESSAGE="postProcessingMessage",e.ON_USER_TOKEN_WILL_EXPIRE="onUserTokenWillExpire",e.STREAM_CONTROL_MESSAGE="streamControlMessage",e.ON_SPEAKER_CHANGE="onSpeakerChange",e.ON_STREAM_FAILED="streamFailed",e.ON_NOTIFY_RECONNECT="notifyReconnect",e.ON_FORWARD_DST_ROOM_USER_KICK="onForwardDstRoomUserKick",e}(SH||{}),bH=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(bH||{}),EH=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ON_VENDOR_CONNECTION_STATE_CHANGE="onVendorConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(EH||{}),kH=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(kH||{}),TH=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(TH||{}),IH=new Nw("Locker",2),RH=1,AH=function(){function e(t){var r;Vl(this,e),Jd(this,"lockingPromise",Y_.resolve()),Jd(this,"locks",0),Jd(this,"name",""),Jd(this,"lockId",void 0),this.lockId=RH++,t&&(this.name=t),IH.info(Om(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return Ul(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,IH.info(Om(e=Om(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new Y_((function(e){r=function(){var t,r;n.locks-=1,IH.info(Om(t=Om(r="[lock-".concat(n.name,"-")).call(r,n.lockId,"] unlocked, current queue ")).call(t,n.locks,".")),e()}})),o=this.lockingPromise.then((function(){return r}));return this.lockingPromise=this.lockingPromise.then((function(){return i})),o}}]),e}(),wH=function(e){return e.RESUBSCRIBE="resubscribe",e.STREAM_FAILED="stream_failed",e.SUBSCRIBE_PUSH_TRACK="subscribe_push_track",e.REMOVE_PUSH_TRACK="remove_push_track",e.VIDEO_FIRST_FRAME="video_first_frame",e.ON_USER_PUBLISH_STATE_CHANGE="on_user_publish_state_change",e.ON_USER_START_AUDIO_CAPTURE="on_user_start_audio_capture",e.ON_USER_STOP_AUDIO_CAPTURE="on_user_stop_audio_capture",e.ON_USER_START_VIDEO_CAPTURE="on_user_start_video_capture",e.ON_USER_STOP_VIDEO_CAPTURE="on_user_stop_video_capture",e.ON_SEI_MESSAGED_RECEIVED="on_sei_messaged_received",e.ON_PUBLISH_RESULT="on_publish_result",e.ON_UPDATE_TOKEN_SUCCESS="on_update_token_success",e.ON_REMOTE_STREAM_STATS="ON_REMOTE_STREAM_STATS",e.ON_LOCAL_STREAM_STATS="ON_LOCAL_STREAM_STATS",e.ON_USER_LEAVE="on_user_leave",e.ON_ROOM_ERROR="on_room_error",e.ON_NETWORK_QUALITY="on_network_quality",e.ON_SIMULCAST_SUBSCRIBE_FALLBACK="on_simulcast_subscribe_fallback",e.ON_REMOTE_VIDEO_SIZE_CHANGED="on_remote_video_size_changed",e.RECONNECT_FAILED="reconnect_failed",e.ON_SUBTITLE_STATE_CHANGED="ON_SUBTITLE_STATE_CHANGED",e.ON_SUBTITLE_MESSAGE_RECEIVED="ON_SUBTITLE_MESSAGE_RECEIVED",e.ON_VIDEO_STREAM_BANNED="ON_VIDEO_STREAM_BANNED",e.ON_AUDIO_STREAM_BANNED="ON_AUDIO_STREAM_BANNED",e.ON_FORWARD_STREAM_ERROR="ON_FORWARD_STREAM_ERROR",e.ON_REJOIN_WITH_TCP="ON_REJOIN_WITH_TCP",e.ON_ICE_CONNECT_WITH_TCP="ON_ICE_CONNECT_WITH_TCP",e}(wH||{}),CH=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}(CH||{}),xH=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(xH||{}),OH=function(e){return e[e.SUB=0]="SUB",e[e.UNSUB=1]="UNSUB",e}(OH||{}),MH=(Jd(fH={},bl.communication,[0]),Jd(fH,bl.chat,[0]),Jd(fH,bl.chatRoom,[1,"IES_chatroom"]),Jd(fH,bl.coHost,[1,"IES_PK"]),Jd(fH,bl.meeting,[16]),Jd(fH,bl.classRoom,[0]),fH),DH=lL(),PH=function(e){DI(s,e);var t,r,n,i,o,a=QI(s);function s(e,t){var r;return Vl(this,s),Jd(tI(r=a.call(this,e,t)),"peerConnectionId",dM()),Jd(tI(r),"peerConnectionMode",1),Jd(tI(r),"name","vendor"),Jd(tI(r),"direction","up"),Jd(tI(r),"stream",void 0),t.on("ice_state",(function(e){r._report("rtc_ice_state",{pc_session_id:r.peerConnectionId,direction:r.direction,error_code:0,ice_state:e.toUpperCase(),message:"",peer_connection_id:r.peerConnectionId,stream_id:"",stream_user_id:""})})),r}return Ul(s,[{key:"publish",value:(o=Rm(Tm().mark((function e(t){var r,n,i,o,a,c,u,d,l,h,p=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.enableSimulcast=!1,this.stream=t,r=OI(CI(s.prototype),"internalPublish",this).call(this,t),n=r.videoDescriptions,i=r.subVideoDescriptions,o=r.audioTransceiverInit,a=r.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(o.track,o.init),t.videoTransceiver=this._peerConnection.addTransceiver(a.track,a.init),DH&&(t.initAudioEncodedTransform(),t.initVideoEncodedTransform()),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:(null==t?void 0:t.vendorCode)||0}),e.next=9,this._peerConnection.createOffer();case 9:return c=e.sent,u=lM(),d=EL.parse(c.sdp),Array.isArray(d.media)&&(d.media=jm(l=d.media).call(l,(function(e){var r,n,i,o,a;if("video"===e.type)null!==(r=p._context)&&void 0!==r&&null!==(n=r.serverConfig)&&void 0!==n&&n.videoCodec&&iU(e,null===(i=p._context)||void 0===i||null===(o=i.serverConfig)||void 0===o?void 0:o.videoCodec),(KM||rD)&&Array.isArray(e.ext)&&(e.ext=Hs(a=e.ext).call(a,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&mk(t).call(t,"video-orientation"))}))),KM||p.addBitrateLimit(e,t.videoEncodeConfig[0].maxKbps);else if("audio"===e.type){var s,c=null==e?void 0:gE(s=e.rtp).call(s,(function(e){return"opus"===e.codec}));if(c&&e.fmtp){var u,d,l=gE(u=e.fmtp).call(u,(function(e){return e.payload===c.payload}));l&&null!==(d=p._context)&&void 0!==d&&d.audioProfileManager&&(l.config=p._context.audioProfileManager.getOpusConfigStr(l.config))}}return e}))),h=new RTCSessionDescription({type:"offer",sdp:EL.write(d)}),e.prev=14,e.next=17,this._peerConnection.setLocalDescription(h);case 17:this._report("rtc_set_description",{error_code:0,message:h.sdp||"",is_local:"1",direction:"up",stream_id:"",stream_user_id:"",elapse:lM()-u},{type:"offer"}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(14),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+h.sdp,is_local:"1",direction:"up",stream_id:"",stream_user_id:"",elapse:lM()-u},{type:"offer"}),e.t0;case 24:return e.abrupt("return",{partialSdp:h.sdp||"",audioMid:"0",videoMid:"1",type:"offer",semantics:"unified-plan",videoDescriptions:n,subVideoDescriptions:i,audioTransceiverInit:o,videoTransceiverInit:a,peerConnectionMode:this.peerConnectionMode,peerConnectionId:this.peerConnectionId});case 25:case"end":return e.stop()}}),e,this,[[14,20]])}))),function(e){return o.apply(this,arguments)})},{key:"subscribe",value:(i=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stream=t,this.direction="down",t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"}),DH&&(t.initAudioEncodedTransform(),t.initVideoEncodedTransform()),this._report("rtc_begin_create_offer",{direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:t.vendorCode||0}),e.next=8,this._peerConnection.createOffer();case 8:return r=e.sent,n=lM(),i=EL.parse(r.sdp),Array.isArray(i.media)&&(i.media=jm(o=i.media).call(o,(function(e){if("audio"===e.type){var t,r=null==e?void 0:gE(t=e.rtp).call(t,(function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n,i=null==e?void 0:gE(n=e.fmtp).call(n,(function(e){return e.payload===r.payload}));i&&s._context&&(i.config+=";stereo=1;sprop-stereo=1")}}return e}))),a=new RTCSessionDescription({type:"offer",sdp:EL.write(i)}),e.prev=13,e.next=16,this._peerConnection.setLocalDescription(a);case 16:this._report("rtc_set_description",{error_code:0,message:a.sdp||"",is_local:"1",direction:"down",stream_id:t.streamId,stream_user_id:t.userId,elapse:lM()-n},{type:"offer"}),e.next=23;break;case 19:throw e.prev=19,e.t0=e.catch(13),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+a.sdp,is_local:"1",direction:"down",stream_id:t.streamId,stream_user_id:t.userId,elapse:lM()-n},{type:"offer"}),e.t0;case 23:return e.abrupt("return",{partialSdp:a.sdp||"",audioMid:"0",videoMid:"1",type:"offer",semantics:"unified-plan",peerConnectionMode:this.peerConnectionMode,peerConnectionId:this.peerConnectionId});case 24:case"end":return e.stop()}}),e,this,[[13,19]])}))),function(e){return i.apply(this,arguments)})},{key:"handleAck",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.action!==pF.publish&&t.action!==pF.subscribe){e.next=16;break}return n=new RTCSessionDescription({sdp:null===(r=t.signalingAck)||void 0===r?void 0:r.sdp,type:"answer"}),i=lM(),e.prev=3,e.next=6,this._peerConnection.setRemoteDescription(n);case 6:this._report("rtc_set_description",{error_code:0,message:n.sdp||"",is_local:"1",direction:"down",stream_id:null===(o=t.stream)||void 0===o?void 0:o.userId,stream_user_id:(null===(a=t.stream)||void 0===a?void 0:a.streamId)||"",elapse:lM()-i},{type:"answer"}),e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(3),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+n.sdp,is_local:"1",direction:"down",stream_id:null===(s=t.stream)||void 0===s?void 0:s.userId,stream_user_id:(null===(c=t.stream)||void 0===c?void 0:c.streamId)||"",elapse:lM()-i},{type:"offer"}),e.t0;case 13:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=17;break;case 16:t.action!==pF.unpublish&&t.action!==pF.unsubscribe||this.destroy();case 17:return e.abrupt("return","");case 18:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e){return n.apply(this,arguments)})},{key:"destroy",value:function(){this.peer.destroy(),OI(CI(s.prototype),"destroy",this).call(this)}},{key:"getDefaultSdp",value:(r=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{sdp:"",type:"offer",semantics:""});case 1:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)})},{key:"connect",value:function(){throw new Error("Method not implemented.")}},{key:"rollback",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{this._peerConnection.close()}catch(t){}case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),s}(aU),NH=function(e){return e[e.AUTOPLAY_FAILED=-1e3]="AUTOPLAY_FAILED",e[e.TRACK_ERROR=-1001]="TRACK_ERROR",e[e.Fetch_MODIFY=-1002]="Fetch_MODIFY",e[e.BLACK_BROWSER=-1003]="BLACK_BROWSER",e[e.DC_SEND_ERROR=-1004]="DC_SEND_ERROR",e}(NH||{}),LH={start_interval:100,multiplier:2,max_interval:3e4},UH=function(){function e(){Vl(this,e),Jd(this,"_times",0),Jd(this,"_config",LH),Jd(this,"initTs",lM())}return Ul(e,[{key:"getRetryDelay",value:function(){return Math.min(this._config.max_interval,Math.pow(this._config.multiplier,this._times++)*this._config.start_interval)}},{key:"setConfig",value:function(e){this._config=e}},{key:"reset",value:function(){this._times=0}}]),e}(),VH=new Nw("ICERequest",4),FH=function(){function e(t){Vl(this,e),Jd(this,"_reconnectTimer",void 0),Jd(this,"_abortControllers",[]),Jd(this,"_monitor",void 0),Jd(this,"_groupConfigId",dM()),Jd(this,"_retryLimiter",new UH),Jd(this,"_timer",void 0),this._ctx=t,this._monitor=VO(t.id)}var t,r,n,i,o;return Ul(e,[{key:"getICENode",value:(o=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return VH.info("getICENode","invoke"),e.prev=1,e.next=4,this._getAccessWithRetry(t);case 4:if(0!==(r=e.sent).length){e.next=7;break}throw"server return empty nodes.";case 7:e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(1),this._reportRtcInvokeStatus("es.join.getNodeFailed",e.t0),new mA(pA.ICE_SERVER_WRONG,"get ICE config failed: ".concat(e.t0),e.t0);case 13:return VH.success("getICENode","success"),this._reportRtcInvokeStatus("es.join.getNodeSuccess",r),e.abrupt("return",r);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return o.apply(this,arguments)})},{key:"_getAccessWithRetry",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 0!==r&&VH.info("_getAccessWithRetry()","invoke feedbackInfo: %o, 201count: %o",e,r),new Y_((function(n,i){t._getAccessNode(e).then((function(e){t._retryLimiter.reset(),n(e)})).catch((function(o){if(Array.isArray(o)&&o.length>0){if(QR(o).call(o,(function(e){return 400<=e.code&&e.code<500}))>-1)return t._retryLimiter.reset(),i("HTTP request failed(4xx)");if(o.every((function(e){var t;return 201===e.code||201===(null===(t=e.error)||void 0===t?void 0:t.code)}))&&r++,3===r)return t._retryLimiter.reset(),i("HTTP request failed(201)")}var a=t._retryLimiter.getRetryDelay();VH.warn("_getAccessWithRetry()","_getAccessWithRetry error, will retry after ".concat(a,"ms"),o),t._reconnectTimer=self.setTimeout((function(){t._getAccessWithRetry(e,r).then(n).catch(i)}),a)}))}))}},{key:"_getAccessNode",value:(i=Rm(Tm().mark((function e(t){var r=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Y_((function(e,n){var i=ED.getAccessNode(r._ctx.appId);i?(VH.info("getAccessNode","use cache node."),e(Array.isArray(i)?i:[i]),r._timer=window.setTimeout((function(){r._getAccessNodeFromServer(t),r._reportRtcInvokeStatus("es.R.node.cache",i),delete r._timer}),0)):r._getAccessNodeFromServer(t).then(e).catch(n)})));case 1:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"_getAccessNodeFromServer",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this._getAccessUrls(),n=r.urls,i=r.needFallback,e.abrupt("return",this.getICEConfigFromServer(n,t).then((function(e){var t=e.nodes;return!o._ctx.useCloudProxy&&ED.setAccessNode(o._ctx.appId,t,e.ttl||11200),e.dispatchDomains&&!o._ctx.useCloudProxy&&ED.setAccessUrls(e.dispatchDomains),t})).catch((function(e){if(i)return o._reportRtcInvokeStatus("es.R.req.fallback",""),ED.clearAccessUrls(),o._getAccessNodeFromServer(t);throw e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_getAccessUrls",value:function(){var e=ED.getAccessUrls()||[],t=!0;return this._reportRtcInvokeStatus("es.R.req.cache.urls",e),0===e.length&&(e=CD.ICE_CONFIG_REQUEST_URLS,t=!1,this._reportRtcInvokeStatus("es.R.req.external.urls",e)),0===e.length&&(e=CD.ICE_CONFIG_REQUEST_URLS_INTERNAL,t=!1,this._reportRtcInvokeStatus("es.R.req.internal.urls",e)),{urls:e,needFallback:t}}},{key:"getICEConfigFromServer",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={appID:this._ctx.appId,deviceID:ED.getDeviceId(),os:"web",sdkVersion:CD.VERSION,isOversea:CD.OVERSEA,expectedAddr:OD("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC,accessParams:Nm({requireICEUfragV2:!0}),userAgent:navigator.userAgent},r&&(n.feedbackInfo=r,"ICE_FAILED"!==(null===(i=r[0])||void 0===i||null===(o=i.feedbackReason)||void 0===o?void 0:o.type)&&delete n.expectedAddr),a=jm(t).call(t,(function(e){return s._httpRequest(e,n)})),e.abrupt("return",RM(a));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_httpRequest",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=dM(),r.connectSessionID=i,o=Date.now(),null===(n=this._monitor)||void 0===n||n.report("rtc_get_access",{error_code:0,message:Nm(r),elapse:0,type:"request",host:t,config_id:i,group_config_id:this._groupConfigId}),a=new AbortController,this._abortControllers.push(a),e.prev=6,e.prev=7,e.next=10,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:Nm(r),signal:a.signal});case 10:s=e.sent,e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),yw(fetch)||null===(d=this._monitor)||void 0===d||d.report("rtc_error",{error_code:NH.Fetch_MODIFY,message:"get access failed, possibly due to modifying the browser's Fetch API."},{origin_error:e.t0}),e.t0;case 17:if(this._abortControllers=Hs(c=this._abortControllers).call(c,(function(e){return e!==a})),200===s.status){e.next=20;break}throw{message:s.statusText,code:s.status};case 20:return e.next=22,s.json();case 22:if(200===(l=e.sent).code){e.next=25;break}throw l;case 25:return null===(u=this._monitor)||void 0===u||u.report("rtc_get_access",{error_code:200,message:Nm(l),elapse:Date.now()-o,type:"response",host:t,config_id:i,group_config_id:this._groupConfigId}),e.abrupt("return",l);case 29:throw e.prev=29,e.t1=e.catch(6),null===(h=this._monitor)||void 0===h||h.report("rtc_get_access",{error_code:Number((null===e.t1||void 0===e.t1?void 0:e.t1.code)||(null===e.t1||void 0===e.t1?void 0:e.t1.server_code)),message:null===e.t1||void 0===e.t1?void 0:e.t1.message,elapse:Date.now()-o,type:"response",host:t,config_id:i,group_config_id:this._groupConfigId},{error:Nm(e.t1)}),e.t1;case 33:case"end":return e.stop()}}),e,this,[[6,29],[7,13]])}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._abortControllers.forEach((function(e){return e.abort()})),this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer),this._timer&&(window.clearTimeout(this._timer),delete this._timer)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0;null===(r=this._monitor)||void 0===r||r.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:n,stream_id:"",elapse:0,group_config_id:this._groupConfigId},i)}}]),e}(),BH=lL(),jH={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"},HH=function(e){return e[e.DC_ERROR=0]="DC_ERROR",e[e.DC_CLOSE=1]="DC_CLOSE",e[e.ICE_FAILED=2]="ICE_FAILED",e[e.DESTROY=3]="DESTROY",e[e.TIMEOUT=4]="TIMEOUT",e}(HH||{}),GH=0,zH=function(e){DI(c,e);var t,r,n,i,o,a,s=QI(c);function c(e,t){var r;return Vl(this,c),Jd(tI(r=s.call(this)),"uuid",(GH++).toString()),Jd(tI(r),"_peerConnectionId",""),Jd(tI(r),"audioTrack4ff",void 0),Jd(tI(r),"_pc",void 0),Jd(tI(r),"_dc",void 0),Jd(tI(r),"_iceNode",void 0),Jd(tI(r),"_initSctpEvents",!1),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_offerIce",{}),Jd(tI(r),"_answerIce",{}),Jd(tI(r),"_offerSession",void 0),Jd(tI(r),"_answerSession",void 0),Jd(tI(r),"_offerMlines",[]),Jd(tI(r),"_answerMlines",[]),Jd(tI(r),"_connectReject",void 0),Jd(tI(r),"_logger",new Nw("PeerConnection_".concat(r.uuid),4)),Jd(tI(r),"_peerConfig",void 0),r._ctx=e,r._groupConnectionId=t,r._monitor=VO(e.id),r._ctx.enableFallbackHandler&&r._logger.warn("ctor","PeerConnection running in fallback mode"),r._peerConfig=KH(e),r._pc=new RTCPeerConnection(r._peerConfig),r._pc.ontrack=function(e){var t,n,i,o,a=null===(t=e.streams)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.id;r._print("pc.ontrack",Om(i=Om(o="".concat(e.track.kind," ")).call(o,e.track.id," ")).call(i,a)),"ff-stream"===a&&(r.audioTrack4ff=e.track),r.emit("ontrack",e)},r._pc.onconnectionstatechange=function(e){var t;r._print("onconnectionstatechange",Om(t="".concat(r._pc.connectionState,". ice -> ")).call(t,r._pc.iceConnectionState)),"failed"!==r._pc.iceConnectionState&&"closed"!==r._pc.iceConnectionState&&"failed"!==r._pc.connectionState||r.emit("disconnect","ice failed")},r._pc.oniceconnectionstatechange=function(){var e=r._pc.iceConnectionState;r._report("rtc_pre_ice_state",{message:e,ice_state:e.toUpperCase()}),r.emit("ice_state",e)},r}return Ul(c,[{key:"getOriginRTCPeerConnection",value:function(){return this._pc}},{key:"getOriginRTCDataChannel",value:function(){return this._dc}},{key:"getConnectionId",value:function(){return this._peerConnectionId}},{key:"getGroupConnectionId",value:function(){return this._groupConnectionId}},{key:"connect",value:(a=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._ctx.enableStandardHandler){e.next=2;break}return e.abrupt("return",this.startIceConnectStandard(t));case 2:return this._print("connect","invoke. %o",t),this._iceNode=t,this._dc=this._pc.createDataChannel("signaling",{negotiated:!0,id:100}),this._dc.binaryType="arraybuffer",e.next=8,this._genIceInfo(t);case 8:return r=e.sent,n=r.offerIce,i=r.answerIce,this._offerIce=n,this._answerIce=i,zM&&uD<138&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=16,this._pc.createOffer();case 16:if((o=e.sent).sdp){e.next=19;break}throw new mA(pA.NOT_SUPPORTED,"create offer sdp failed.");case 19:if(a=EL.parse(o.sdp),this._peerConnectionId=i.iceUfrag||"",(s=!n.iceUfrag&&!n.icePwd)&&((l="renomination"===(null===(c=a.media[0])||void 0===c?void 0:c.iceOptions))||(delete n.iceOptions,delete i.iceOptions),delete n.iceUfrag,delete n.icePwd,h=nU({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(u=a.media[0])||void 0===u?void 0:u.icePwd,options:(d={},Jd(d,rU.kICEConfigTypeSrtpDtlsType,!0),Jd(d,rU.kICEConfigTypeRenominationType,l),d)}),p=eI(h,2),v=p[0],f=p[1],this._peerConnectionId=f,i.iceUfrag=v,this._logger.info("use serverUfrag v2",Nm({dtls:!0,renomination:l}))),_=eI(a.media,1),m=_[0],this._offerIce.fingerprint=a.fingerprint||m.fingerprint,!zM&&!this._ctx.enableFallbackHandler){e.next=41;break}if(a.media=jm(y=a.media).call(y,(function(e){var t,r,n=Zd(Zd({},e),b._offerIce);return"video"===n.type&&(n.ext=null===(t=n.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),n.rtcpFb=null===(r=n.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type}))),n})),(S=Zd({},a)).fingerprint=this._answerIce.fingerprint,S.media=jm(g=S.media).call(g,(function(e){return delete(e=Zd(Zd({},e),b._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),!this._ctx.enableFallbackHandler){e.next=35;break}return e.next=33,this.setLocalDescription(o.sdp);case 33:e.next=37;break;case 35:return e.next=37,this.setLocalDescription(EL.write(a));case 37:return e.next=39,this.setRemoteDescription(EL.write(S));case 39:e.next=50;break;case 41:delete a.media,this._offerSession=Zd({},a),this._answerSession=Zd({},a),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),s&&(this._offerIce.iceUfrag=m.iceUfrag,this._offerIce.icePwd=m.icePwd),this._offerMlines=[Zd(Zd(Zd({},m),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[Zd(Zd(Zd({},m),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription();case 50:return e.next=52,new Y_((function(e,t){b._connectReject=t,b._dc.onopen=function(){b._print("connect","dataChannel open"),b._reportRtcInvokeStatus("es.dc.open",""),e(""),delete b._connectReject},b._dc.onerror=function(e){var t,r;b._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),b._reportRtcInvokeStatus("es.dc.error",""),null===(t=b._connectReject)||void 0===t||t.call(b,{message:"dc.onerror, ".concat(null===(r=e.error)||void 0===r?void 0:r.errorDetail),code:0}),b.emit("disconnect","dc onerror"),delete b._connectReject},b._dc.onclose=function(e){var t;b._reportRtcInvokeStatus("es.dc.close",""),null===(t=b._connectReject)||void 0===t||t.call(b,{message:"dc.onclose",code:1}),b.emit("disconnect","dc onclose"),delete b._connectReject},b._pc.addEventListener("connectionstatechange",(function(e){var t,r;"failed"!==b._pc.iceConnectionState&&"closed"!==b._pc.iceConnectionState&&"failed"!==b._pc.connectionState||(null===(t=b._connectReject)||void 0===t||t.call(b,{message:Om(r="pc.connectionstatechange -> ".concat(b._pc.connectionState,", ice -> ")).call(r,b._pc.iceConnectionState),code:2}),delete b._connectReject)})),setTimeout((function(){var e;null===(e=b._connectReject)||void 0===e||e.call(b,{code:4,message:"connect timeout"}),delete b._connectReject}),8e3)}));case 52:return this._print("connect","dataChannel establish success"),e.abrupt("return",this._dc);case 54:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"startIceConnectStandard",value:(o=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("connect","standard invoke. %o",t),this._iceNode=t,(i=this._pc.createDataChannel("signaling",{negotiated:!0,id:100})).binaryType="arraybuffer",this._dc=i,e.next=7,this._genIceInfo(t);case 7:return o=e.sent,a=o.offerIce,s=o.answerIce,this._offerIce=a,this._answerIce=s,zM&&uD<138&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=15,this._pc.createOffer();case 15:if(c=e.sent,u=c.sdp){e.next=19;break}throw new mA(pA.NOT_SUPPORTED,"create offer sdp failed.");case 19:if(d=EL.parse(u),this._answerSession=Zd({},d),l=gE(r=d.media).call(r,(function(e){return"application"===e.type})),this._peerConnectionId=s.iceUfrag||"",!a.iceUfrag&&!a.icePwd&&((p="renomination"===(null==l?void 0:l.iceOptions))||(delete a.iceOptions,delete s.iceOptions),delete a.iceUfrag,delete a.icePwd,v=nU({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null==l?void 0:l.icePwd,options:(h={},Jd(h,rU.kICEConfigTypeSrtpDtlsType,!0),Jd(h,rU.kICEConfigTypeRenominationType,p),h)}),f=eI(v,2),_=f[0],m=f[1],this._peerConnectionId=m,s.iceUfrag=_,this._logger.info("use serverUfrag v2",Nm({dtls:!0,renomination:p}))),this._offerIce.fingerprint=d.fingerprint||(null==l?void 0:l.fingerprint),(y=Zd({},d)).fingerprint=this._answerIce.fingerprint,y.media=jm(n=y.media).call(n,(function(e){if("application"===(e=Zd(Zd({},e),S._answerIce)).type&&(e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}),zM)if(delete e.bundleOnly,e.port=9,"audio"===e.type)e.msid="ff-stream ff-stream-audio",e.direction="sendonly";else if("video"===e.type){var t,r,n,i;vL?(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type}))):(e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:Hs(n).call(n,(function(e){return"transport-cc"!==e.type})),e.ext=null===(i=e.ext)||void 0===i?void 0:Hs(i).call(i,(function(e){var t;return-1===xE(t=e.uri).call(t,"transport")}))),e.direction="sendonly"}return e})),"v1"!==this.getIceVersion()){e.next=35;break}return d.media=jm(g=d.media).call(g,(function(e){return e=Zd(Zd({},e),S._offerIce)})),e.next=33,this.setLocalDescription(EL.write(d));case 33:e.next=37;break;case 35:return e.next=37,this.setLocalDescription(u);case 37:return e.next=39,this.setRemoteDescription(EL.write(y));case 39:return e.next=41,new Y_((function(e,t){S._connectReject=t,i.onopen=function(){S._print("connect","dataChannel open"),S._reportRtcInvokeStatus("es.dc.open",""),e(""),delete S._connectReject},i.onerror=function(e){var t,r,n,i;S._report("rtc_signaling_msg_error",{error_code:null==e||null===(t=e.error)||void 0===t?void 0:t.sdpLineNumber,message:null==e||null===(r=e.error)||void 0===r?void 0:r.errorDetail,reason:"invalid data"}),S._reportRtcInvokeStatus("es.dc.error",""),null===(n=S._connectReject)||void 0===n||n.call(S,{message:"dc.onerror, ".concat(null===(i=e.error)||void 0===i?void 0:i.errorDetail),code:0}),S.emit("disconnect","dc onerror"),delete S._connectReject},i.onclose=function(){var e;S._reportRtcInvokeStatus("es.dc.close",""),null===(e=S._connectReject)||void 0===e||e.call(S,{message:"dc.onclose",code:1}),S.emit("disconnect","dc onclose"),delete S._connectReject},S._pc.addEventListener("connectionstatechange",(function(){var e,t;"failed"!==S._pc.iceConnectionState&&"closed"!==S._pc.iceConnectionState&&"failed"!==S._pc.connectionState||(null===(e=S._connectReject)||void 0===e||e.call(S,{message:Om(t="pc.connectionstatechange -> ".concat(S._pc.connectionState,", ice -> ")).call(t,S._pc.iceConnectionState),code:2}),delete S._connectReject)})),setTimeout((function(){var e;null===(e=S._connectReject)||void 0===e||e.call(S,{code:4,message:"connect timeout"}),delete S._connectReject}),8e3)}));case 41:return this._print("connect","dataChannel establish success"),e.abrupt("return",i);case 43:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setDescription",value:(i=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("setDescription","invoke."),this._offerSession.media=this._offerMlines,this._answerSession.media=this._answerMlines,r=[],this._offerMlines.forEach((function(e){"inactive"!==e.direction&&r.push(e.mid)})),this._offerSession.groups&&this._answerSession.groups&&(this._offerSession.groups[0].mids=r.join(" "),this._answerSession.groups[0].mids=r.join(" ")),n=lM(),t&&this._report("rtc_begin_create_offer",{direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,pc_session_id:this._peerConnectionId,vendor_mode:0}),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:lM()-n}),e.next=11,this.setLocalDescription(EL.write(this._offerSession),t);case 11:return e.next=13,this.setRemoteDescription(EL.write(this._answerSession),t);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setLocalDescription",value:(n=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=lM(),e.prev=1,e.next=4,this._pc.setLocalDescription({type:"offer",sdp:t});case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:lM()-n},{type:"offer"}),this._initSctpEvents||(this._initSctpEvents=!0,(o=null===(i=this._pc)||void 0===i?void 0:i.sctp)&&(o.onstatechange=function(){a._reportRtcInvokeStatus("sctp","sctp state change TO: ".concat(o.state))},o.transport&&(o.transport.onstatechange=function(){var e;a._reportRtcInvokeStatus("dtls","dtls state change TO: ".concat(null==o||null===(e=o.transport)||void 0===e?void 0:e.state))}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:"",stream_user_id:"",elapse:lM()-n},{type:"offer"});case 12:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(r=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=lM(),e.prev=1,e.next=4,this._pc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:t}));case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:lM()-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:lM()-n},{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"disconnect",value:function(){var e,t;null===(e=this._connectReject)||void 0===e||e.call(this,{code:3,message:"invoke destroy()"}),delete this._connectReject,this._pc.close(),null===(t=this._dc)||void 0===t||t.close(),this._pc.ontrack=null}},{key:"getIceVersion",value:function(){var e,t;return null!==(e=this._iceNode)&&void 0!==e&&e.iceParams.clientIceUfrag||null!==(t=this._iceNode)&&void 0!==t&&t.iceParams.clientIcePwd?"v1":"v2"}},{key:"createAnswerSdp",value:function(e,t){oH(this._answerSession,"_answerSession should be existed");var r=Zd({},this._answerSession);return r.media=e,r.groups=t,EL.write(r)}},{key:"destroy",value:function(){this._print("destroy",this._peerConnectionId),OI(CI(c.prototype),"removeAllListeners",this).call(this),this.disconnect()}},{key:"_genIceInfo",value:(t=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=3,ZL(t);case 3:return o=e.sent,e.abrupt("return",{offerIce:i,answerIce:o});case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"_print",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];(t=this._logger).info.apply(t,Om(r=["".concat(e)]).call(r,i))}},{key:"_report",value:function(e,t,r){var n,i,o,a;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this._peerConnectionId,group_connection_id:this._groupConnectionId}),Zd(Zd({},r),{},{tcp_only:null===(i=this._iceNode)||void 0===i?void 0:i.iceConfig.tcpOnly,ms_addr:Nm((null===(o=this._iceNode)||void 0===o?void 0:jm(a=o.publicIPs).call(a,(function(e){return{ip:e.ip,tcp:e.tcpPorts,udp:e.udpPorts}})))||[])}))}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}],[{key:"checkSupported",value:function(){if(!RTCPeerConnection)throw new mA(pA.NOT_SUPPORTED,"missing RTCPeerConnection API.");["addTransceiver","createDataChannel","createOffer","setLocalDescription","setRemoteDescription"].forEach((function(e){var t,r;if(null===(t=RTCPeerConnection)||void 0===t||null===(r=t.prototype)||void 0===r||!r[e])throw new mA(pA.NOT_SUPPORTED,"missing peer.".concat(e," API."))}))}}]),c}(aP),KH=function(e){var t=Zd({},jH);return e.pcKillSwitch.ctor_sdpsemantics_add&&(t.sdpSemantics="unified-plan"),e.pcKillSwitch.ctor_encodedinsetablestream_add&&BH&&(t.encodedInsertableStreams=!0),t};function XH(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=an(e);for(n=0;n<o.length;n++)r=o[n],xE(t).call(t,r)>=0||(i[r]=e[r]);return i}(e,t);if(xs){var o=xs(e);for(n=0;n<o.length;n++)r=o[n],xE(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var WH=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(WH||{}),qH=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}(qH||{}),YH=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}(YH||{}),JH=(Jd(_H={},0,[0,"success"]),Jd(_H,1,[pA.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),Jd(_H,2,[pA.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),Jd(_H,3,[pA.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),Jd(_H,4,[pA.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),Jd(_H,5,[pA.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),Jd(_H,17,[pA.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),Jd(_H,18,[pA.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),Jd(_H,100,[pA.USER_MESSAGE_NOT_JOIN,"not join room"]),Jd(_H,105,[pA.USER_MESSAGE_NOT_LOGIN,"not login."]),Jd(_H,106,[pA.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),Jd(_H,1e3,[pA.USER_MESSAGE_UNKNOWN,"unknown."]),_H),QH=["msg"],ZH=new Nw("DataChannelSignaling",3),$H=[],eG=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}(eG||{}),tG=function(e){DI(a,e);var t,r,n,i,o=QI(a);function a(e,t){var r;return Vl(this,a),Jd(tI(r=o.call(this)),"_singlingCache",new $S),Jd(tI(r),"_p2pCache",new $S),Jd(tI(r),"_rttIds",{}),Jd(tI(r),"_p2pMessageId",1),Jd(tI(r),"_clearDataChannelListener",void 0),Jd(tI(r),"_monitor",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=VO(e),r}return Ul(a,[{key:"destroy",value:function(){var e=this;this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.forEach((function(t,r){t.error(new mA(pA.OPERATION_CANCEL,"disconnect")),e._singlingCache.delete(r)})),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=1,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n,i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:6e4;return null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:Nm(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new Y_((function(n,a){var s,c=i._genHeader(r);c.id=vM();var u=c.id.join("-"),d="customMessage"===e;d&&wO.samplingOne2ManyMsg(i.id,Number(c.id.join("")),t);var l=setTimeout((function(){i._singlingCache.delete(u),a(new mA(pA.TIME_OUT,"".concat(e," message time out"))),d&&wO.updateOne2ManyMsgAck(i.id,t,999)}),o);i._singlingCache.set(u,{signalingType:e,success:function(e){clearTimeout(l),n(e),d&&wO.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(l),a(e),d&&wO.updateOne2ManyMsgAck(i.id,t,e.code)}}),ZH.info("Signal",Om(s=">>>>>> [".concat(e,"][")).call(s,u,"]"),t),i._sendMessage(e,c,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=Rm(Tm().mark((function e(t,r){var n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=XH(t,QH),o=n instanceof ArrayBuffer,e.t0=this,e.t1=wO,e.t2=this.id,e.t3=Zd,e.t4=Zd({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:WH.SEND,type:qH.P2P,err:YH.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,pM.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 _M(e.msg)?this._rttIds[e.id]=e.id:e.dir===WH.SEND&&ZH.info("_sendP2PMessage [DC Signaling p2p >>]",Nm(e)),new Y_((function(n,i){var o=t._genHeader(Zd(Zd({needAck:!0,functionType:1},r),{},{id:vM()}));if(e.dir===WH.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new mA(pA.USER_MESSAGE_TIMEOUT,"P2P message timeout")),wO.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),wO.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),wO.updateP2PMsgAck(t.id,e,r.err);var o=eI(JH[r.err]||[pA.USER_MESSAGE_UNKNOWN,Om(n="err: ".concat(r.err,", msg: ")).call(n,r.msg)],2),s=o[0],c=o[1];i({err:r.err,code:s,message:r.msg||c})}})}try{t._sendMessage("p2p",o,e)}catch(s){throw s.code===pA.NOT_CONNECTED_YET&&(s.code=pA.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new mA(pA.NOT_CONNECTED_YET,"DataChannel not open");var i=t.version+(Number(t.zip)<<5)+(Number(t.encrypt)<<6),o=Number(t.needAck)+(Number(t.direction)<<1)+(Number(t.functionType)<<2)+(Number(t.binary)<<6),a=pM.str2ab(Nm([e,r])),s=hM(Uint8Array,Om(n=[i,o]).call(n,Jk(t.id||[])),new Uint8Array(a));try{this._dataChannel.send(s.buffer)}catch(u){var c;throw null===(c=this._monitor)||void 0===c||c.report("rtc_error",{message:"datachannel send error: ".concat(u.message),error_code:NH.DC_SEND_ERROR}),u}"p2p"===e?wO.updateP2PMsgReq(this.id,r,s.buffer.byteLength):"customMessage"===e&&wO.updateOne2ManyMsgReq(this.id,r,s.buffer.byteLength)}},{key:"_dispartData",value:function(e){var t=new Uint8Array(e),r=0,n=t[r++],i=t[r++],o={version:15&n,zip:16==(16&n),encrypt:32==(32&n),needAck:1==(1&i),direction:(2&i)>>1,functionType:(60&i)>>2,binary:64==(64&i)};if(o.needAck||1===o.direction){for(;r<=6;r++)if(128!=(128&t[r])){r++;break}o.id=qk(km(t).call(t,2,r))}return{header:o,data:km(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:jm(n=e.split("-")).call(n,(function(e){return Number(e)}))});mk($H).call($H,t)||ZH.info("Signal",Om(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=Date.now(),n=t.byteLength,i=this._dispartData(t),o=i.data,(a=i.header).zip&&((s=new vO.Inflate).push(o,!0),o=s.result),c=pM.ab2str(o),u=[],e.prev=8,u=JSON.parse(c),e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(8),e.t0 instanceof Error&&(null===(d=this._monitor)||void 0===d||d.report("rtc_signaling_msg_error",{error_code:-1,message:e.t0.message,reason:"message parse failed"})),e.abrupt("return");case 16:e.t1=a.functionType,e.next=0===e.t1?19:1===e.t1?21:2===e.t1?23:25;break;case 19:return this.C2S(a,u,c,n,r),e.abrupt("break",26);case 21:return this.C2C(u,n,r),e.abrupt("break",26);case 23:return this.C2GW(a,u,c),e.abrupt("break",26);case 25:return e.abrupt("break",26);case 26:case"end":return e.stop()}}),e,this,[[8,12]])}))),function(e){return n.apply(this,arguments)})},{key:"C2S",value:(r=Rm(Tm().mark((function e(t,r,n,i,o){var a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=(null===(a=t.id)||void 0===a?void 0:a.join("-"))||"",1!==t.direction){e.next=5;break}this._handleAckMessage(s,r[0]||{},n),e.next=18;break;case 5:if(!Array.isArray(r)){e.next=18;break}if(u=r[0],r=r[1],mk($H).call($H,u)||ZH.info("Signal","<<<<<< ".concat(u),r,s),this._feedbackSignaling(s,u,u===SH.ON_CUSTOM_MESSAGE?Zd(Zd({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,pM.b64str2ab(r.message);case 13:r.message=e.sent;case 14:d=Date.now(),this.emit(u,Zd({},r)),u===SH.ON_CUSTOM_MESSAGE&&wO.reportOne2ManyMsgRecv(this.id,r,{msg_size:i,recv_msg_ts:o,fwd_msg_ts:d}),null===(c=this._monitor)||void 0===c||c.report("rtc_signaling",{error_code:0,message:n,signaling_event:"on-".concat(u),signaling_type:"Recv",stream_id:r.streamId,stream_user_id:r.clientId,direction:"down"});case 18:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"C2C",value:(t=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Array.isArray(t)&&(t=t[1]),c=null===(i=t)||void 0===i?void 0:i.id,this._rttIds[c]||(null===(o=t)||void 0===o?void 0:o.dir)===WH.FEEDBACK||_M(null===(a=t)||void 0===a?void 0:a.msg)?delete this._rttIds[c]:ZH.info("Signal","<<<<<< p2p response",t),e.t0=t.dir,e.next=e.t0===WH.SEND?6:e.t0===WH.FEEDBACK?46:48;break;case 6:if(u=Date.now(),_M(null===(s=t)||void 0===s?void 0:s.msg)){e.next=43;break}if(l=(d=t).binary,h=d.msg,p=d.room,v=d.to,f=d.from,_=""===p?l?SH.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:SH.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:l?SH.USER_BINARY_MESSAGE_RECEIVED:SH.USER_MESSAGE_RECEIVED,v){e.next=27;break}if(e.t1=this,e.t2=SH.ON_CUSTOM_MESSAGE,e.t3=f,e.t4=l,!l){e.next=21;break}return e.next=18,pM.b64str2ab(h);case 18:e.t5=e.sent,e.next=22;break;case 21:e.t5=h;case 22:e.t6=e.t5,e.t7={clientId:e.t3,binary:e.t4,message:e.t6},e.t1.emit.call(e.t1,e.t2,e.t7),e.next=43;break;case 27:if(e.t8=this,e.t9=_,e.t10=Zd,e.t11=Zd({},t),e.t12={},!l){e.next=38;break}return e.next=35,pM.b64str2ab(h);case 35:e.t13=e.sent,e.next=39;break;case 38:e.t13=h;case 39:e.t14=e.t13,e.t15={msg:e.t14},e.t16=(0,e.t10)(e.t11,e.t12,e.t15),e.t8.emit.call(e.t8,e.t9,e.t16);case 43:return this._sendP2PMessage(Zd(Zd({},t),{},{dir:WH.FEEDBACK,msg:""})),wO.reportP2PMsgRecv(this.id,t,{msg_size:r,recv_msg_ts:n,fwd_msg_ts:u}),e.abrupt("break",49);case 46:return this._handleP2PMsgFeedback(t),e.abrupt("break",49);case 48:return e.abrupt("break",49);case 49:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"C2GW",value:function(e,t,r){if(1===e.direction){var n,i=(null===(n=e.id)||void 0===n?void 0:n.join("-"))||"";this._handleAckMessage(i,t[0]||{},r)}else{var o=eI(t,2),a=o[0],s=o[1],c=void 0===s?{}:s;if("RXMediaMsg"===a){var u,d=c.type,l=c.data;switch(null===(u=this._monitor)||void 0===u||u.report("rtc_signaling",{error_code:0,message:r,signaling_event:"on-".concat(d),signaling_type:"Recv",stream_id:"",stream_user_id:"",direction:"down"}),d){case"RSCP":try{var h=JSON.parse(l);Array.isArray(h)&&this.emit(d,h)}catch(f){}break;case"RTT":try{var p=JSON.parse(l);p.length&&this.emit(d,p[0])}catch(f){}break;case"SSC":try{var v=JSON.parse(l);v.length&&this.emit(d,v[0])}catch(f){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(e){ZH.warn("_handleHandler","dataChannel close",e)},r=function(e){ZH.error("_handleHandler","dataChannel error",e)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Zd({version:2,zip:!1,encrypt:!1,needAck:!0,direction:0,functionType:0,binary:!1},e)}},{key:"_handleAckMessage",value:function(e,t,r){var n,i,o=this._singlingCache.get(e);o&&(this._singlingCache.delete(e),200===t.code?o.success(t):o.error(t),ZH.info("Signal",Om(i="<<<<<< [".concat(o.signalingType,"-ack] ")).call(i,e),t));null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:r,signaling_event:null==o?void 0:o.signalingType,signaling_type:"Ack",stream_id:"",stream_user_id:"",direction:"down"})}},{key:"_handleP2PMsgFeedback",value:function(e){var t=this._p2pCache.get(e.id);t&&(this._p2pCache.delete(e.id),e.err===YH.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(nP.exports.EventEmitter),rG=new Nw("ConnectionManager",3),nG=function(e){DI(o,e);var t,r,n,i=QI(o);function o(e){var t;return Vl(this,o),Jd(tI(t=i.call(this)),"id",void 0),Jd(tI(t),"_monitor",void 0),Jd(tI(t),"_getAccessManager",void 0),Jd(tI(t),"_connectionPool",new $S),Jd(tI(t),"_curConnection",void 0),Jd(tI(t),"_hasReportBrowerWarning",!1),Jd(tI(t),"_reconnectTimer",void 0),Jd(tI(t),"_connecting",!1),Jd(tI(t),"_isFirstTimeConnected",!0),Jd(tI(t),"_feedbackNodes",[]),Jd(tI(t),"_preIceStartTime",-1),Jd(tI(t),"_tcpOnlyTimer",void 0),Jd(tI(t),"_destroyed",!1),t._ctx=e,rG.info("constructor","invoke"),t.id=e.id,t._monitor=VO(t.id),t._getAccessManager=new FH(e),t}return Ul(o,[{key:"connect",value:function(){var e=this;rG.info("connect","invoke");try{zH.checkSupported()}catch(t){this.safeEmit("disconnected",t)}this._connecting||(this._onConnectStart("init"),Y_.resolve().then((function(){return e.emit("__onGetIceConfigHook")})),this._getAccess())}},{key:"reconnectByNodeChange",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:rG.info("reconnectByNodeChange","invoke %o",t),o=t.nodes,a=t.reason,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:Nm(t),reason:Nm(a)}),ED.clearAccessNode(this._ctx.appId),s=(null===(n=this._curConnection)||void 0===n||null===(i=n.node.publicIPs[0])||void 0===i?void 0:i.ip)||"",this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart("node change"),Array.isArray(o)&&o.length>0?this._startIceConnect(o):this._getAccess([{feedbackIP:s,feedbackReason:{type:"NODE_CHANGED",reason:a}}]);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"reconnect",value:(r=Rm(Tm().mark((function e(t){var r,n=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],rG.info("reconnect","invoke. ".concat(r?"ICE over TCP":"")),this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart(t),this._getAccess(void 0,r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){rG.info("destroy","invoke"),this._destroyed=!0,this.safeEmit("disconnected",new mA(pA.OPERATION_CANCEL,"destroy")),OI(CI(o.prototype),"removeAllListeners",this).call(this),this._clearReconnectTimer(),this._clearConnectionPool(),this._getAccessManager.destroy(),this._closeCurrentConnection()}},{key:"_getAccess",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._getAccessManager.getICENode(e).then((function(e){t.emit("__onGetIceSuccessHook",e),t._startIceConnect(e,r)})).catch((function(e){t.safeEmit("disconnected",e)})).finally((function(){t._feedbackNodes=[]}))}},{key:"_startIceConnect",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this._destroyed){rG.info("_startIceConnect","invoke");var n=_w();this._preIceStartTime=lM();var i=this._ctx.joinRoomConfig.useTcpJoin,o=this._ctx.joinRoomConfig.useTcpJoinDelay,a=function(){var e=Rm(Tm().mark((function e(i){var o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r&&((i=Yj(i)).iceConfig.tcpOnly=!0),o={node:i},e.prev=2,a=new zH(t._ctx,n),o.pc=a,t._connectionPool.set(a.uuid,o),e.next=8,a.connect(i);case 8:return s=e.sent,c=new tG(t.id,s),o.signaling=c,e.next=13,c.sendPingSignaling();case 13:t._onConnectSuccess({node:i,pc:a,signaling:c,dc:s}),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(2),t._onConnectionFailed(o,e.t0);case 19:case"end":return e.stop()}}),e,null,[[2,16]])})));return function(t){return e.apply(this,arguments)}}();this.emit("__onIceConnectStartHook"),e.forEach(a),i&&!r&&(rG.info("_startIceConnect","tcp-only will try after ".concat(o,"ms")),this._tcpOnlyTimer=window.setTimeout((function(){t.emit("connectWidthTcp"),e.forEach((function(e){(e=Yj(e)).iceConfig.tcpOnly=!0,a(e)})),delete t._tcpOnlyTimer}),o))}}},{key:"_onConnectSuccess",value:function(e){var t,r,n,i=this;(rG.info("connect","peer_%s connect success.",e.pc.uuid),this.emit("__onIceConnectSuccessHook",e),this._curConnection)?(e.pc.destroy(),null===(t=e.signaling)||void 0===t||t.destroy(),this._connectionPool.delete(e.pc.uuid)):(this._curConnection=e,this._addConnectionHandler(e.pc,e.dc),null===(r=this._monitor)||void 0===r||r.set({connection_id:e.pc.getConnectionId(),rtc_vid:(null===(n=e.node.iceConfig)||void 0===n?void 0:n._abtest_vid)||""}),this._connectionPool.delete(e.pc.uuid),this._feedbackNodes.forEach((function(e){return i._feedbackBySignaling(e)})),this._feedbackNodes=[],this._onConnectEnded(e))}},{key:"_onConnectionFailed",value:function(e,t){var r,n,i=this;(rG.info("connect","peer_%s connect failed. %s",(null===(r=e.pc)||void 0===r?void 0:r.uuid)||"",t.message),this.emit("__onIceConnectFailedHook",e),t.code!==HH.DESTROY&&t.code!==pA.OPERATION_CANCEL)&&(this._curConnection?this._feedbackBySignaling(e.node):this._feedbackNodes.push(e.node),rG.info("connect","remove cache node"),ED.deleteAccessNode(this._ctx.appId,e.node),e.pc&&(this._connectionPool.delete(e.pc.uuid),e.pc.destroy()),null===(n=e.signaling)||void 0===n||n.destroy());0!==this._connectionPool.size||this._curConnection||this._destroyed||(rG.error("connect","establish peerConnection failed"),this._checkBrowserUA(),lM()-this._preIceStartTime<1e3?(this._clearReconnectTimer(),this._reconnectTimer=window.setTimeout((function(){delete i._reconnectTimer,i._reconnectWithIceFailed(i._feedbackNodes)}),1e3)):this._reconnectWithIceFailed(this._feedbackNodes))}},{key:"_feedbackBySignaling",value:function(e){var t;null===(t=this._curConnection)||void 0===t||t.signaling.sendSignaling("scheduleMessage",{type:"feedback",body:{feedbackIP:e.publicIPs[0].ip,feedbackReason:{type:"ICE_FAILED",reason:{}}}})}},{key:"_reconnectWithIceFailed",value:(t=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._onConnectStart("ice failed"),rG.warn("reconnect","because of ice failed"),this._getAccess(jm(t).call(t,(function(e){return{feedbackIP:e.publicIPs[0].ip,feedbackReason:{type:"ICE_FAILED",reason:{}}}})));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_checkBrowserUA",value:function(){var e;!this._hasReportBrowerWarning&&this._ctx.joinRoomConfig.isBlackBrower()&&(this._hasReportBrowerWarning=!0,null===(e=this._monitor)||void 0===e||e.report("rtc_error",{error_code:NH.BLACK_BROWSER,message:"failed to establish data-channel, and the current browser is on the browser blacklist."}))}},{key:"_onConnectStart",value:function(e){var t;rG.info("_onConnectStart","invoke, reason: ".concat(e)),this._connecting=!0,this.safeEmit(this._isFirstTimeConnected?"connecting":"reconnecting");var r,n=_w();(null===(t=this._monitor)||void 0===t||t.set({connect_session_id:n}),this._isFirstTimeConnected)||(null===(r=this._monitor)||void 0===r||r.report("rtc_reconnect",{error_code:1002,message:"peerconnection reconnecting",reconnect_id:n,reconnect_type:"peerconnection"},{reason:e}))}},{key:"_onConnectEnded",value:function(e){var t;(rG.info("_onConnectEnded","invoke"),this._connecting=!1,this._isFirstTimeConnected=!1,this.safeEmit("connected",e),this._isFirstTimeConnected)||(null===(t=this._monitor)||void 0===t||t.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"}));e.node.iceConfig.tcpOnly&&(rG.info("_onConnectEnded","use tcp only"),jO(this._ctx.id,"connected_with_tcp_only",Nm(e.node))),this._tcpOnlyTimer&&(window.clearTimeout(this._tcpOnlyTimer),delete this._tcpOnlyTimer),this._clearConnectionPool()}},{key:"_addConnectionHandler",value:function(e,t){var r=this;e.on("disconnect",(function(e){r._closeCurrentConnection(),r._clearReconnectTimer(),navigator.onLine?r.reconnect(e):r._reconnectTimer=window.setTimeout((function(){return r.reconnect(e)}),3e3)}))}},{key:"_closeCurrentConnection",value:function(){var e,t;null===(e=this._curConnection)||void 0===e||e.pc.destroy(),null===(t=this._curConnection)||void 0===t||t.signaling.destroy(),delete this._curConnection}},{key:"_clearConnectionPool",value:function(){var e=this;this._connectionPool.forEach((function(t,r){var n,i;null===(n=t.pc)||void 0===n||n.destroy(),null===(i=t.signaling)||void 0===i||i.destroy(),e._connectionPool.delete(r)}))}},{key:"_clearReconnectTimer",value:function(){this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer)}}]),o}(aP),iG=ad,oG=tc,aG=function(e,t,r,n){for(var i,o=n>1?void 0:n?oG(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&&iG(t,r,o),o},sG=new Nw("MediaServerClient",2),cG=6e4,uG=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(uG||{}),dG=function(e,t){sG.info(e,"userId: %o, subAudio: %o, subVideo: %o, audioMid: %o, videoMid: %o, sequenceId: %o",t.userId,t.subAudio,t.subVideo,t.audioMid,t.videoMid,t.sequenceId)},lG=function(e){DI(T,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k=QI(T);function T(e){var t;return Vl(this,T),Jd(tI(t=k.call(this)),"id",void 0),Jd(tI(t),"_token",void 0),Jd(tI(t),"_roomId",void 0),Jd(tI(t),"_roomAttributes",void 0),Jd(tI(t),"_vendorConfig",{enableMultiVendor:!1,vendorCode:0}),Jd(tI(t),"_clientId",void 0),Jd(tI(t),"_businessId",void 0),Jd(tI(t),"_userInfo",void 0),Jd(tI(t),"_authorization",void 0),Jd(tI(t),"_sessionId",""),Jd(tI(t),"_liveControlMessage",void 0),Jd(tI(t),"isReconnecting",!1),Jd(tI(t),"_ontrackCallbackMap",new $S),Jd(tI(t),"_subResolves",{}),Jd(tI(t),"supportConcurrent",!1),Jd(tI(t),"_handler",void 0),Jd(tI(t),"_pubSubLock",void 0),Jd(tI(t),"_joinLeaveLock",void 0),Jd(tI(t),"_state",void 0),Jd(tI(t),"_dataChannelSignal",void 0),Jd(tI(t),"_joinRoomStartTs",void 0),Jd(tI(t),"_subConfig",{}),Jd(tI(t),"_monitor",void 0),Jd(tI(t),"_roomProfile",bl.communication),Jd(tI(t),"_context",void 0),Jd(tI(t),"_subStreamQueue",{}),Jd(tI(t),"_connectionManager",void 0),Jd(tI(t),"_joinRoom5xxTimer",void 0),Jd(tI(t),"_joinResolve",void 0),Jd(tI(t),"_joinReject",void 0),sG.info("constructor","invoke"),t.id=e.id,t._monitor=VO(t.id),t._pubSubLock=new AH("pubSubLock"),t._joinLeaveLock=new AH("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._context=e,t.on("SUB_END",(function(e){return t._handleSubStreamQueue(e)})),t._connectionManager=new nG(e),t._addConnectHandler(),t}return Ul(T,[{key:"_addSignalEventHandler",value:function(){var e,t,r=this;[SH.ON_ADD_STREAM,SH.ON_ADD_STREAM_LIST,SH.ON_REMOVE_STREAM,SH.ON_REMOVE_STREAM_LIST,SH.USER_CONNECTION,SH.USER_CONNECTION_LIST,SH.USER_DISCONNECTION,SH.USER_DISCONNECTION_LIST,SH.ON_UPDATE_STREAM_ATTRIBUTES,SH.ON_UPDATE_ROOM_ATTRIBUTES,SH.ON_PUSH_TRACK,SH.ON_REMOVE_TRACK,SH.ON_CUSTOM_MESSAGE,SH.USER_MESSAGE_RECEIVED,SH.USER_BINARY_MESSAGE_RECEIVED,SH.POST_PROCESSING_MESSAGE,SH.ON_USER_TOKEN_WILL_EXPIRE,SH.STREAM_CONTROL_MESSAGE,SH.ON_UPDATE_USER_ATTRIBUTES,SH.ON_SPEAKER_CHANGE,bH.RSCP,bH.RTT,SH.ON_STREAM_FAILED,SH.ON_NOTIFY_RECONNECT,bH.SSC,SH.ON_FORWARD_DST_ROOM_USER_KICK].forEach((function(e){var t;null===(t=r._dataChannelSignal)||void 0===t||t.on(e,(function(t){r.safeEmit(e,t)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.on(SH.NODE_CHANGE,(function(e){r._connectionManager.reconnectByNodeChange(e)})),null===(t=this._dataChannelSignal)||void 0===t||t.on(SH.ON_NOTIFY_RECONNECT,(function(){r._connectionManager.reconnect("recv notifyReconnect signaling")}))}},{key:"_removeSignalEventHandler",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.removeAllListeners(),null===(t=this._handler)||void 0===t||t.removeAllListeners()}},{key:"connectionState",get:function(){return this._state},set:function(e){this._state!==e&&(this.safeEmit(EH.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"businessId",set:function(e){this._businessId=e}},{key:"setLiveControlMessage",value:function(e){this._liveControlMessage=e}},{key:"connect",value:function(){var e=this;return new Y_((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"join",value:(E=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sG.info("join()","info: %o",t),this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._roomProfile=t.roomProfile,this._reportJoinRoomStart(),e.next=10,new Y_((function(e,t){n._joinResolve=e,n._joinReject=t,(n._handler?Y_.resolve():n.connect()).then((function(){n._callJoinRoom()})).catch((function(e){var t=Array.isArray(e)&&e.length>0?e[0]:e;n._joinRoomFailed(t.message)}))}));case 10:return r=e.sent,e.abrupt("return",r);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"_callJoinRoom",value:(b=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m=this,y=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=y.length>0&&void 0!==y[0]&&y[0],sG.info("_callJoinRoom","invoke"),e.t0=pM.token2auth(this._context.appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId,e.t2=Date.now(),e.t3=this._liveControlMessage,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=9,null===(t=this._handler)||void 0===t?void 0:t.getDefaultSdp();case 9:return e.t5=e.sent,e.next=12,ZN(OD("PUB_SUB_MODE"));case 12:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=CD.VERSION,e.t9=ED.getDeviceId(),e.t10=this._context.appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._context.useCloudProxy,e.t15=MH[this._roomProfile]?"".concat(MH[this._roomProfile][0]):"0",e.t16={supportedCodecs:e.t6,deviceType:"web",userAgent:e.t7,sdkVersion:e.t8,deviceId:e.t9,appId:e.t10,roomId:e.t11,userId:e.t12,businessId:e.t13,enableCloudProxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0,supportMultiVendor:!0},e.t18=Nm({requireICEUfragV2:!0}),n={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17,accessParams:e.t18},e.prev=26,e.t19=jO,e.t20=this.id,e.t21=Nm,e.next=32,$N();case 32:e.t22=e.sent,e.t23=OD("PUB_SUB_MODE")||"recv_and_send",e.t24={supportedCodecsSdpOffer:e.t22,pubSubMode:e.t23},e.t25=(0,e.t21)(e.t24),(0,e.t19)(e.t20,"MediaClient.internalGetSupportedCodecsSdpOffer",e.t25),e.next=41;break;case 39:e.prev=39,e.t26=e.catch(26);case 41:return Y_.resolve().then((function(){return m.emit("onSendingJoinMessageHook")})),e.prev=42,o=r?"reconnected":"joinRoom",e.next=46,this._joinRoomWithRetry(o,n);case 46:a=e.sent,sG.success("join","send join message success"),s=a.config||{},c=s.engine_WEB,this.connectionState="connected",this._authorization=n.Authorization,ED.setEngineWebConfig(this._context.appId,this._roomId,c),this._context&&(this._context.serverConfig={videoCodec:(null==c?void 0:c.video_codec)||"H264",audioRed:!(null==c||!c.pub_audio_red),muteReplaceUnsub:!(null===(u=a.config)||void 0===u||!u.mute_replace_unsub),simulcastOnDemand:!(zM||!1===(null===(d=a.config)||void 0===d||null===(l=d.engine_VPM)||void 0===l||null===(h=l.ondemand)||void 0===h?void 0:h.enable)),forceUniHandler:1===(null==a||null===(p=a.config)||void 0===p||null===(v=p.vendor_param)||void 0===v?void 0:v.vendor_stream_sub_mode)},"boolean"==typeof(null==c?void 0:c.av_sync)&&(this._context.avSync=c.av_sync)),a.vendorConfig&&(this._vendorConfig=a.vendorConfig),nF.audioStallConfig=c,null!=a&&null!==(i=a.relayMessage)&&void 0!==i&&i.sdp&&(null===(f=this._handler)||void 0===f||f.createAVMlineAnswerTpl(a.relayMessage.sdp)),this.emit("joinSuccess",{joinRes:a,reconnect:r}),this._joinRoomSuccess(a),e.next=63;break;case 60:e.prev=60,e.t27=e.catch(42),(null===e.t27||void 0===e.t27?void 0:e.t27.code)>=700&&(null===e.t27||void 0===e.t27?void 0:e.t27.code)<800?this._joinRoomFailed("token_error",pA.INVALID_TOKEN):(null===e.t27||void 0===e.t27?void 0:e.t27.code)===pA.TIME_OUT&&this._context.joinRoomConfig.useTcpAfterJoinTimeout?(_="joinRoom timeout, retry with tcp only",sG.error("join",_),this.safeEmit(wH.ON_REJOIN_WITH_TCP),this._connectionManager.reconnect(_,!0)):e.t27.code===pA.OPERATION_CANCEL&&"connecting"===this.connectionState||this._joinRoomFailed((null===e.t27||void 0===e.t27?void 0:e.t27.message)||"signaling_error");case 63:case"end":return e.stop()}}),e,this,[[26,39],[42,60]])}))),function(){return b.apply(this,arguments)})},{key:"publish",value:(S=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D,P,N=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(sG.info("publish()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,i=lM(),o="",a="",s=this._handler,e.prev=7,!this._vendorConfig.enableMultiVendor){e.next=20;break}return T=new zH(this._context,""),t.vendorHandler=new PH(this._context,T),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),e.next=14,t.vendorHandler.publish(t);case 14:k=e.sent,(s=t.vendorHandler).on("ice_state",(function(e){N.emit(EH.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:ll.CONNECTION_STATE_CONNECTING,connected:ll.CONNECTION_STATE_CONNECTED,disconnected:ll.CONNECTION_STATE_RECONNECTING}[e],userId:N._clientId})})),T.once("disconnect",Rm(Tm().mark((function e(){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=s)||void 0===r||r.removeAllListeners(),"connected"===(null===(n=N._handler)||void 0===n||null===(i=n.pc)||void 0===i?void 0:i.iceConnectionState)){e.next=4;break}return sG.error("vendor ice failed",t.streamId),e.abrupt("return");case 4:t.clean(),N.unpublish(t),N.publish(t);case 7:case"end":return e.stop()}}),e)})))),e.next=23;break;case 20:return e.next=22,null===(I=this._handler)||void 0===I?void 0:I.publish(t);case 22:k=e.sent;case 23:if(null===(c=t.observer)||void 0===c||c.setHandler(s),k){e.next=26;break}throw new mA(pA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 26:if("H264"!==(null===(u=this._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec)){e.next=32;break}return e.next=29,sL();case 29:if(e.sent){e.next=32;break}throw new mA(pA.PUBLISH_FAILED,"h264 is not supported");case 32:return o=k.audioMid,a=k.videoMid,t.pubAttributes={localaudio:!!n,localvideo:!!r,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(r instanceof mV),extaudio:!!(n instanceof yV)},R={attributes:Zd({videoDescriptions:k.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:o,videoMid:a,sdpInfo:{msid:t.stream.id,type:k.type,sdp:k.partialSdp,semantics:k.semantics},peerConnectionMode:null===(l=k)||void 0===l?void 0:l.peerConnectionMode,supportMultiVendor:!0},(A=!this._vendorConfig.enableMultiVendor&&t.enableSimulcast&&(null===(h=this._context)||void 0===h||null===(p=h.serverConfig)||void 0===p?void 0:p.simulcastOnDemand)&&(null===(v=k.subVideoDescriptions)||void 0===v?void 0:v.length))&&(R.attributes.subVideoDescriptions=k.subVideoDescriptions),null!==(f=k)&&void 0!==f&&f.peerConnectionId&&(R.peerConnectionId=k.peerConnectionId),e.next=41,null===(_=this._dataChannelSignal)||void 0===_?void 0:_.sendSignaling("publish",R);case 41:if(200===(null==(w=e.sent)?void 0:w.code)){e.next=44;break}throw new mA(pA.PUBLISH_FAILED,(null==w?void 0:w.message)||"publish failed");case 44:if(null===(m=this._monitor)||void 0===m||m.report("rtc_recv_answer",{error_code:0,answer_type:null==w?void 0:w.relayMessage.type,sequence_id:(null==w||null===(y=w.relayMessage)||void 0===y?void 0:y.sequenceId)||0,message:null==w||null===(g=w.relayMessage)||void 0===g?void 0:g.sdp,direction:"up",stream_id:"",stream_user_id:"",pc_session_id:(null===(S=s)||void 0===S?void 0:S.peerConnectionId)||""}),C=new Y_((function(e,r){var n,i,c,u,d,l;null===(n=s)||void 0===n||n.handleAck({action:pF.publish,streamId:w.streamId,audioMid:o,videoMid:a,audioTransceiverInit:null===(i=k)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(c=k)||void 0===c?void 0:c.videoTransceiverInit,signalingAck:{sdp:null==w||null===(u=w.relayMessage)||void 0===u?void 0:u.sdp,sequenceId:null==w||null===(d=w.relayMessage)||void 0===d?void 0:d.sequenceId},sdp:null===(l=k)||void 0===l?void 0:l.sdp,stream:t,onSuccess:function(){sG.info("publish()","publish success"),e(0)}})})),"chrome"!==(null===(b=this.handler)||void 0===b?void 0:b.name)){e.next=49;break}return e.next=49,C;case 49:return A&&this.emit(bH.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}],!0),t.streamId=w.streamId,t.videoMid=a,t.audioMid=o,t.subVideoDescriptions=k.subVideoDescriptions,null===(E=this._monitor)||void 0===E||E.report("rtc_publish_stat",{result:"success",is_screen:"0",start:i,message:"unknown"}),e.abrupt("return");case 58:return e.prev=58,e.t0=e.catch(7),e.t0 instanceof Error?null===(O=this._monitor)||void 0===O||O.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:Om(M="".concat(e.t0.name,": ")).call(M,e.t0.message)}):e.t0 instanceof mA&&(null===(D=this._monitor)||void 0===D||D.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:Om(P="".concat(e.t0.code,": ")).call(P,e.t0.message)})),e.next=63,null===(x=s)||void 0===x?void 0:x.rollback(t.stream.id,t);case 63:throw e.t0;case 64:case"end":return e.stop()}}),e,this,[[7,58]])}))),function(e){return S.apply(this,arguments)})},{key:"updatePubTrack",value:(g=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(sG.info("updatePubTrack()","localStream: %o",t),i=t.videoTrack,o=t.audioTrack,a=t.pubAudio,s=t.pubVideo,c=t.vendorHandler||this.handler,u=null==o?void 0:o.getTrack("preprocessing"),d=null==i?void 0:i.getTrack("preprocessing"),!s||!d){e.next=10;break}return e.next=8,null===(l=t.videoTransceiver)||void 0===l?void 0:l.sender.replaceTrack(d);case 8:e.next=12;break;case 10:return e.next=12,null===(h=t.videoTransceiver)||void 0===h?void 0:h.sender.replaceTrack(null);case 12:if(null==c||c.updateMaxBitrate(t),!a||!u){e.next=20;break}return v=o.mixType,(f=o.mixedAudioTrack)&&v!==Ml.PLAYOUT&&u.enabled&&(u=f),e.next=18,null===(p=t.audioTransceiver)||void 0===p?void 0:p.sender.replaceTrack(u);case 18:e.next=23;break;case 20:return e.next=22,null===(_=t.audioTransceiver)||void 0===_?void 0:_.sender.replaceTrack(null);case 22:jO(this.id,"MediaClient.updatePubTrack(audio)","null");case 23:try{jO(this.id,"MediaClient.updatePubTrack",Nm({audioStreamTrack:MM(u),videoStreamTrack:MM(d)}))}catch(cq){}for(y={},g=0,S=RA(m={localaudio:!!o,localvideo:!!i,videostream:s,audiostream:a,extvideo:!!(i instanceof mV),extaudio:!!(o instanceof yV)});g<S.length;g++)b=eI(S[g],2),E=b[0],(k=b[1])!==dI(t.pubAttributes,E)&&fP(y,E,k);if(an(y).length){e.next=29;break}return e.abrupt("return");case 29:return t.observer&&(T=t.observer,I=y.audiostream,R=y.videostream,A=y.localaudio,w=y.localvideo,C=y.extaudio,x=y.extvideo,void 0!==w?void 0!==x?T.setPushVideo(x):T.setEnableVideo(w):void 0!==R&&T.setUnmuteVideo(R),void 0!==A?void 0!==C?T.setPushAudio(C):T.setEnableAudio(A):void 0!==I&&T.setUnmuteAudio(I)),t.pubAttributes=m,O={roomId:this._roomId,streamId:t.streamId,attributes:y},e.next=34,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateStreamAttributes",O);case 34:if(200===(null==(M=e.sent)?void 0:M.code)){e.next=37;break}throw new mA(pA.UPDATE_TRACK_FAILED,(null==M?void 0:M.message)||"update track failed");case 37:if("chrome"===(null===(n=this.handler)||void 0===n?void 0:n.name)){e.next=40;break}return e.next=40,null==c?void 0:c.setCurrentDescription();case 40:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"updateToken",value:(y=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(sG.info("updateToken()","newToken: %o",t),this._token=t,this._context.appId&&null!==(r=this._userInfo)&&void 0!==r&&r.userId&&this._roomId){e.next=4;break}return e.abrupt("return");case 4:return i={roomId:this._roomId,userId:null===(n=this._userInfo)||void 0===n?void 0:n.userId,appId:this._context.appId,token:"Bearer ".concat(t)},e.prev=5,e.next=8,null===(o=this._dataChannelSignal)||void 0===o?void 0:o.sendSignaling("updateToken",i);case 8:if(200===(null==(a=e.sent)?void 0:a.code)){e.next=11;break}throw new mA(pA.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 11:e.next=16;break;case 13:throw e.prev=13,e.t0=e.catch(5),new mA(pA.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 16:case"end":return e.stop()}}),e,this,[[5,13]])}))),function(e){return y.apply(this,arguments)})},{key:"unpublish",value:(m=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sG.info("unpublish()","localStream: %o",t),n={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",n),i=t.vendorHandler||this._handler,e.next=6,null==i?void 0:i.handleAck({action:pF.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 6:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"subscribe",value:(_=Rm(Tm().mark((function e(t,r,n){var i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Y_(function(){var e=Rm(Tm().mark((function e(o,a){var s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D,P,N,L,U,V,F,B,j,H,G,z,K,X,W,q,Y,J,Q,Z,$;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.streamState!==cF.SUB_ED){e.next=2;break}return e.abrupt("return",i._updateSubTrack(t,r,OH.SUB).then(o,a));case 2:if(t.streamState!==cF.SUB_ING){e.next=7;break}return i._subStreamQueue[t.streamId]||(i._subStreamQueue[t.streamId]=[]),sG.info("_subStreamQueue","streamId: %o, enqueue",t.streamId),i._subStreamQueue[t.streamId].push({fn:i.subscribe,args:[t,r,n],resolve:o,reject:a}),e.abrupt("return");case 7:if(sG.info("subscribe()","mediaType: %o",r),dG("subscribe()",t),t.streamState=cF.SUB_ING,c=!1,u=!1,wM(r)&&(u=!0),CM(r)&&(c=!0),c||!i.multiChatMode()){e.next=17;break}return t.streamState=cF.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",o(null));case 17:if(d=lM(),l=t.subVideo,h=[],p=!i.multiChatMode(),i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),h.push(new Y_((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),cG);t.on("ontrack",(function r(i){"video"===i.mediaType&&(sG.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p&&h.push(new Y_((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),cG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(sG.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v=function(e){t.ontrack(e)},null===(s=i._handler)||void 0===s||s.on("ontrack",v),i._ontrackCallbackMap.set(t,v),f=i._handler,e.prev=28,null!==(_=i._context.serverConfig)&&void 0!==_&&_.forceUniHandler||!t.enableVendorMode){e.next=42;break}return V=new zH(i._context,""),t.vendorHandler=new PH(i._context,V),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),(f=t.vendorHandler).on("ontrack",v),e.next=37,t.vendorHandler.subscribe(t);case 37:U=e.sent,f.on("ice_state",(function(e){i.emit(EH.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:ll.CONNECTION_STATE_CONNECTING,connected:ll.CONNECTION_STATE_CONNECTED,disconnected:ll.CONNECTION_STATE_RECONNECTING}[e],userId:t.userId})})),V.once("disconnect",Rm(Tm().mark((function e(){var r,n,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=f)||void 0===r||r.removeAllListeners(),"connected"===(null===(n=i._handler)||void 0===n||null===(o=n.pc)||void 0===o?void 0:o.iceConnectionState)){e.next=4;break}return sG.error("vendor ice failed",t.streamId),e.abrupt("return");case 4:return t.resetHasSubscribed(),i.unsubscribe(t,ul.AUDIO_AND_VIDEO,!0),e.next=8,i.subscribe(t,t.subMediaType);case 8:i.emit(wH.RESUBSCRIBE,{stream:t});case 9:case"end":return e.stop()}}),e)})))),e.next=45;break;case 42:return e.next=44,null===(F=i._handler)||void 0===F?void 0:F.subscribe(t,{multiChatMode:i.multiChatMode()});case 44:U=e.sent;case 45:if(null===(m=t.observer)||void 0===m||m.setHandler(f),U){e.next=48;break}throw new mA(pA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 48:return B=U.audioMid,j=U.videoMid,t.subVideo=c,H={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},G={audio:!i.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:j,audioMid:B,sdpInfo:{sdp:null===(y=U)||void 0===y?void 0:y.partialSdp,semantics:null===(g=U)||void 0===g?void 0:g.semantics,type:null===(S=U)||void 0===S?void 0:S.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i.multiChatMode()||u,video:c},qualityLayer:H},extra:{enableSendRTT:!0},peerConnectionMode:null===(b=U)||void 0===b?void 0:b.peerConnectionMode,supportMultiVendor:!0},null!==(E=U)&&void 0!==E&&E.peerConnectionId&&(G.peerConnectionId=U.peerConnectionId),z=i._context||{},K=z.subscribeFallbackOption,X=z.userPriority,"number"==typeof K&&(G.config.fallbackOption=K),X.has(t.userId)&&(G.config.priority=X.get(t.userId)),null!==(k=U)&&void 0!==k&&k.allSsrc&&(G.extra.subscribeSSRC=U.allSsrc),e.next=60,null===(T=i._dataChannelSignal)||void 0===T?void 0:T.sendSignaling("subscribe",G);case 60:if(200===(null==(W=e.sent)?void 0:W.code)){e.next=63;break}throw new mA(pA.SUBSCRIBE_FAILED,(null==W?void 0:W.message)||"subscribe failed");case 63:return q=null==W?void 0:W.relayMessage,Y=q.audioMid,J=q.videoMid,Jd(I={},B,Y),Jd(I,j,J),Q=I,sG.info("sub midmap",t.userId,Q),t.videoMid=j,t.audioMid=B,t.subMediaType=r,t.streamState=cF.SUB_ED,t.subLayer=H,null===(R=i._monitor)||void 0===R||R.report("rtc_recv_answer",{error_code:0,answer_type:null==W||null===(A=W.relayMessage)||void 0===A?void 0:A.type,sequence_id:(null==W||null===(w=W.relayMessage)||void 0===w?void 0:w.sequenceId)||0,message:null==W||null===(C=W.relayMessage)||void 0===C?void 0:C.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:(null===(x=f)||void 0===x?void 0:x.peerConnectionId)||""}),e.next=74,null===(O=f)||void 0===O?void 0:O.handleAck({action:pF.subscribe,streamId:t.streamId,audioMid:B,videoMid:j,audioTransceiverInit:null===(M=U)||void 0===M?void 0:M.audioTransceiverInit,videoTransceiverInit:null===(D=U)||void 0===D?void 0:D.videoTransceiverInit,signalingAck:{sdp:null==W||null===(P=W.relayMessage)||void 0===P?void 0:P.sdp,sequenceId:null==W||null===(N=W.relayMessage)||void 0===N?void 0:N.sequenceId},stream:t,sdp:U.sdp,generatorSsrc:!!U.allSsrc});case 74:return e.next=76,Y_.all(h);case 76:i.multiChatMode()||(t.subAudio=u),null===(L=i._monitor)||void 0===L||L.report("rtc_subscribe_stat",{result:"success",start:d,message:"unknown",stream_user_id:t.userId}),i._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return i.emit("onRemoteStreamStats",e)}),f),o(null),i.emit("SUB_END",t.streamId),e.next=92;break;case 83:return e.prev=83,e.t0=e.catch(28),e.t0 instanceof Error&&(null===($=i._monitor)||void 0===$||$.report("rtc_subscribe_stat",{result:"fail",start:d,message:e.t0.message,stream_user_id:t.userId})),t.subVideo=l,t.streamState=cF.INIT,e.next=90,null===(Z=f)||void 0===Z?void 0:Z.rollback(t.streamId,t);case 90:a(e.t0),i.emit("SUB_END",t.streamId);case 92:case"end":return e.stop()}}),e,null,[[28,83]])})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)}))),function(e,t,r){return _.apply(this,arguments)})},{key:"_handleSubStreamQueue",value:function(e){var t,r=this;if(null!==(t=this._subStreamQueue[e])&&void 0!==t&&t.length){sG.info("_subStreamQueue","streamId: %o, exec",e);var n=this._subStreamQueue[e].shift(),i=n.fn,o=n.args,a=n.resolve,s=n.reject;i.apply(this,o).then(a,s).finally((function(){return r._handleSubStreamQueue(e)}))}else sG.warn("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(f=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sG.info("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"updateUserAttributes",value:(v=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sG.info("updateUserAttributes()","attributes: %o",t),e.next=3,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateUserAttributes",{roomId:this._roomId,sessionId:this._sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"updateSubTrack",value:(p=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._updateSubTrack(t,r,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return p.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(h=Rm(Tm().mark((function e(t,r){var n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(sG.info("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return sG.warn("updateSubTrack()","subLayer no change"),e.abrupt("return");case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new mA(pA.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.subLayer=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"updateSubPriority",value:(l=Rm(Tm().mark((function e(t,r){var n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(sG.info("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return sG.warn("updateSubPriority()","priority no change"),e.abrupt("return",t);case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{priority:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new mA(pA.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.priority=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"_updateSubTrack",value:(d=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(sG.info("updateSubTrack()","mediaType: %o",r),dG("updateSubTrack()",t),!this.multiChatMode()||r!==ul.AUDIO){e.next=5;break}return sG.warn("updateSubTrack","multiChatMode mediaType only audio"),e.abrupt("return",t);case 5:return a=0,a=n===OH.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),sG.info("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,a),t.subMediaType===a&&sG.info("updateSubTrack","mediaType no change"),s=!1,c=!1,wM(a)&&(c=!0),CM(a)&&(s=!0),u={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:s,audio:!!this.multiChatMode()||c}}},e.next=15,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("updateSubscribe",u);case 15:if(200===(null==(d=e.sent)?void 0:d.code)){e.next=18;break}throw new mA(pA.UPDATE_TRACK_FAILED,(null==d?void 0:d.message)||"update track failed");case 18:return this.multiChatMode()||(null===(l=t.observer)||void 0===l||l.setUnmuteAudio(c),t.subAudio=c),null===(o=t.observer)||void 0===o||o.setUnmuteVideo(s),t.subVideo=s,t.subMediaType=a,e.abrupt("return",t);case 23:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return d.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(u=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sG.info("subscribe4pushTrack()","streamInfo: %o",r),dG("subscribe4pushTrack()",t),t.subAudio=!0,e.next=5,null===(n=this._handler)||void 0===n?void 0:n.subscribe(t,{multiChatMode:this.multiChatMode()});case 5:if(a=e.sent){e.next=8;break}throw new mA(pA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 8:return s=a.audioMid,c=a.videoMid,(u=[]).push(new Y_((function(e,r){var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),cG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(sG.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),d=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",d),this._ontrackCallbackMap.set(t,d),e.next=17,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:pF.pushtrack,streamId:t.streamId,audioMid:s,videoMid:c,stream:t,audioTransceiverInit:null==a?void 0:a.audioTransceiverInit,videoTransceiverInit:null==a?void 0:a.videoTransceiverInit,signalingAck:null==r?void 0:r.message,sdp:a.sdp});case 17:return e.next=19,Y_.all(u);case 19:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return l.emit("onRemoteStreamStats",e)}),this._handler);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(c=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(dG("unsubscribe4removeTrack()",t),sG.info("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId,"trackType: ",n),!(r.sequenceId<t.sequenceId)){e.next=5;break}return sG.warn("unsubscribe4removeTrack()","sequenceId return"),e.abrupt("return");case 5:return u=!!((c=n+1)&ul.AUDIO),d=!!(c&ul.VIDEO),e.next=10,null===(i=this._handler)||void 0===i?void 0:i.handleAck({action:pF.removetrack,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:null===(o=t.observer)||void 0===o||o.setPushTrack(!1),null===(a=t.observer)||void 0===a||a.setUnmuteAudio(!u),t.subAudio=!u,null===(s=t.observer)||void 0===s||s.setUnmuteVideo(!d),t.subVideo=!d,t.subMediaType=t.subMediaType-(t.subMediaType&c),t.virtual&&(t.clean(),t.resetHasSubscribed(),t.statsReport.unsubscribe());case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return c.apply(this,arguments)})},{key:"unsubscribe",value:(s=Rm(Tm().mark((function e(t,r){var n,i,o=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],dG("unsubscribe()",t),!n){e.next=4;break}return e.abrupt("return",this._unsubscribe(t,r));case 4:if(!this.multiChatMode()||!CM(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!==zV.NONE){e.next=9;break}return e.abrupt("return",this._unsubscribe(t,r));case 9:return e.abrupt("return",this._updateSubTrack(t,r,OH.UNSUB));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_unsubscribe",value:(a=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subConfig.muteReplaceUnsub){e.next=2;break}return e.abrupt("return",this._updateSubTrack(t,r,OH.UNSUB));case 2:return a={roomId:this._roomId,streamId:t.streamId,userId:t.userId},s=t.vendorHandler||this.handler,null===(n=this._dataChannelSignal)||void 0===n||n.sendSignaling("unsubscribe",a).catch((function(){})),t.streamState=cF.INIT,this._subStreamQueue[t.streamId]&&(this._subStreamQueue[t.streamId].forEach((function(e){return(0,e.resolve)(null)})),delete this._subStreamQueue[t.streamId]),t.subVideo=!1,null===(i=t.observer)||void 0===i||i.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(o=t.observer)||void 0===o||o.setSubscribeAudio(!1)),e.next=12,null==s?void 0:s.handleAck({action:pF.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 12:c=e.sent,this._subResolves[c]&&this._subResolves[c].forEach((function(e){return e(0)})),sG.info("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t=this._ontrackCallbackMap.get(e);if(t){var r=e.vendorHandler||this._handler;null==r||r.off("ontrack",t),this._ontrackCallbackMap.delete(e)}}},{key:"handleRemoveStream",value:(o=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(dG("handleRemoveStream()",t),t.subVideo=!1,t.streamState!==cF.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t,ul.AUDIO_AND_VIDEO,!0);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"leave",value:(i=Rm(Tm().mark((function e(){var t,r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(sG.info("leave()"),this._stopJoinRoom5xxRetry(),this._joinRoomFailed("leave_room"),"connected"!==this.connectionState){e.next=20;break}return t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=7,this._joinLeaveLock.lock();case 7:return r=e.sent,e.prev=8,e.next=11,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 11:r(),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(8),r(),e.t0;case 18:e.next=21;break;case 20:return e.abrupt("return",Y_.reject(new mA(pA.NOT_CONNECTED_YET,"server not connected")));case 21:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(){return i.apply(this,arguments)})},{key:"subscribePublicStream",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._handler)||void 0===r?void 0:r.subscribe(t,{multiChatMode:!1});case 2:if(s=e.sent){e.next=5;break}throw new mA(pA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=lM(),u=s.audioMid,d=s.videoMid,e.t0=this._context.appId,e.t1=t.streamId,e.t2=u,e.t3=d,e.t4={sdp:null==s?void 0:s.partialSdp,semantics:null==s?void 0:s.semantics,type:null==s?void 0:s.type},e.next=15,ZN();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=CD.VERSION,e.t8=ED.getDeviceId(),e.t9=this._context.appId,e.t10=this._businessId,e.t11=this._context.useCloudProxy,e.t12={supportedCodecs:e.t5,deviceType:"web",userAgent:e.t6,sdkVersion:e.t7,deviceId:e.t8,appId:e.t9,businessId:e.t10,enableCloudProxy:e.t11},e.t13={enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}},l={appId:e.t0,streamId:e.t1,audio:!0,video:!0,data:!0,audioMid:e.t2,videoMid:e.t3,sdpInfo:e.t4,params:e.t12,config:e.t13},e.next=27,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",l);case 27:return h=e.sent,p=[],this._subResolves[t.streamId]=[],p.push(new Y_((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),cG);t.on("ontrack",(function r(i){"video"===i.mediaType&&(sG.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p.push(new Y_((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),cG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(sG.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",v),this._ontrackCallbackMap.set(t,v),f=null==h?void 0:h.relayMessage,_=f.sequenceId,m=f.sdp,t.videoMid=d,t.audioMid=u,t.sequenceId=_,t.streamState=cF.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:pF.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:m,sequenceId:_},stream:t});case 44:return e.next=46,Y_.all(p);case 46:null===(a=this._monitor)||void 0===a||a.report("rtc_subscribe_stat",{result:"success",start:c,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return y.emit("onRemoteStreamStats",e)}),this._handler);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(r=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dG("unsubscribePublicStream()",t),n={appId:this._context.appId,streamId:t.streamId},e.prev=2,e.next=5,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=cF.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:pF.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;sG.info("destroy()"),this._joinRoomFailed("leave_room"),this._token=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId="",this._stopJoinRoom5xxRetry(),null===(e=this._handler)||void 0===e||e.destroy(),this._handler=void 0,null===(t=this._dataChannelSignal)||void 0===t||t.destroy(),this._dataChannelSignal=void 0,this._connectionManager.destroy(),null===(r=this._monitor)||void 0===r||r.set({connection_id:""}),this._removeSignalEventHandler(),this.removeAllListeners(),this.connectionState="disconnected"}},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendP2PMessage({to:e,from:this._userInfo.userId,room:this._roomId,app:this._context.appId,msg:t})}},{key:"sendRoomMessage",value:function(e){var t;return null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("customMessage",e)}},{key:"_joinRoomWithRetry",value:function(e,t,r){var n=this;return new Y_((function(i,o){n._dataChannelSignal.sendSignaling(e,t,void 0,1e4).then((function(e){n.emit("onJoinRoomAck",e),i(e)})).catch((function(a){if(r=r||new UH,a.code>=500&&a.code<600&&lM()-r.initTs<6e4){var s,c=r.getRetryDelay();return sG.warn("_joinRoomWithRetry",Om(s="joinRoom failed(code: ".concat(a.code,"), will retry after ")).call(s,c,"ms")),void(n._joinRoom5xxTimer=window.setTimeout((function(){delete n._joinRoom5xxTimer,n._joinRoomWithRetry(e,t,r).then(i).catch(o)}),c))}o(a)}))}))}},{key:"_stopJoinRoom5xxRetry",value:function(){this._joinRoom5xxTimer&&(clearTimeout(this._joinRoom5xxTimer),delete this._joinRoom5xxTimer)}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n,i;sG.info("connectStateChange","connected"),e.connectionState="connected",null===(r=e._dataChannelSignal)||void 0===r||r.destroy(),null===(n=e._handler)||void 0===n||n.destroy(),e._handler=mH(e._context,t.pc),e._dataChannelSignal=t.signaling,e.supportConcurrent="chrome"===(null===(i=e._handler)||void 0===i?void 0:i.name),e._addSignalEventHandler(),e.isReconnecting&&(e._reportJoinRoomStart(),e._callJoinRoom(!0))})),this._connectionManager.on("disconnected",(function(t){e.connectionState="disconnected",sG.error("connectStateChange","disconnected. %o",t),e.isReconnecting&&e.safeEmit(wH.RECONNECT_FAILED)})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",sG.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.connectionState="disconnected",e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",sG.warn("connectStateChange","reconnecting"),e.safeEmit("reconnecting")})),this._connectionManager.on("connectWidthTcp",(function(){e.safeEmit(wH.ON_ICE_CONNECT_WITH_TCP)})),["__onGetIceConfigHook","__onIceConnectSuccessHook"].forEach((function(t){e._connectionManager.on(t,(function(){return e.emit(t)}))}))}},{key:"_reportJoinRoomStart",value:function(){var e;this._joinRoomStartTs=lM(),this.emit("__joinRoomStartReport"),null===(e=this._monitor)||void 0===e||e.report("join_room",{type:"begin",start:this._joinRoomStartTs,result:!1,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC})}},{key:"_joinRoomSuccess",value:function(e){var t,r;(this._joinReject&&this._joinResolve&&(this._joinResolve(e),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomSuccessReport"),null===(t=this._monitor)||void 0===t||t.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!0,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),null===(r=this._monitor)||void 0===r||r.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:lM()-this._joinRoomStartTs}),delete this._joinRoomStartTs)}},{key:"_joinRoomFailed",value:function(e,t){var r;(this._joinReject&&this._joinResolve&&(this._joinReject(new mA(t||pA.JOIN_ROOM_FAILED,e)),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomFailedReport"),null===(r=this._monitor)||void 0===r||r.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!1,reason:e},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),delete this._joinRoomStartTs)}},{key:"multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"sendForwardStreamSignal",value:(t=Rm(Tm().mark((function e(t,r,n){var i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o={forwardStreamType:t,roomId:r},("start"===t||"update"===t)&&(o.dstRoomInfos=null==n?void 0:jm(n).call(n,(function(e){return{dstRoomId:e.roomId,dstToken:pM.token2auth(a._context.appId,e.roomId,a._clientId,e.token)}}))),e.abrupt("return",null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("forwardStream",o));case 4:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}},{key:"vendorConfig",get:function(){return this._vendorConfig}}]),T}(aP);function hG(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._handler||"connected"!==this._state){e.next=6;break}for(r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=4,n.apply(this,i);case 4:e.next=7;break;case 6:throw new mA(pA.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function pG(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var t,r,i,o,a=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pubSubLock.lock();case 2:for(t=e.sent,this.supportConcurrent&&t(),e.prev=4,r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=8,n.apply(this,i);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,this.supportConcurrent||t(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[4,,9,12]])}))),r}aG([function(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var t,r,i,o,a=this,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=s.length,r=new Array(t),i=0;i<t;i++)r[i]=s[i];return o=!1,e.abrupt("return",new Y_(function(){var e=Rm(Tm().mark((function e(t,i){var s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new mA(pA.OPERATION_CANCEL,"operation not finish when leave"))})),e.prev=1,e.next=4,n.apply(a,r);case 4:s=e.sent,t(s),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o||i(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)}))),r}],lG.prototype,"join",1),aG([pG,hG],lG.prototype,"publish",1),aG([pG,hG],lG.prototype,"updatePubTrack",1),aG([pG,hG],lG.prototype,"unpublish",1),aG([pG,hG],lG.prototype,"subscribe",1),aG([hG],lG.prototype,"controlMessage",1),aG([hG],lG.prototype,"updateUserAttributes",1),aG([hG],lG.prototype,"updateSubTrack",1),aG([hG],lG.prototype,"updateSubTrackLayer",1),aG([hG],lG.prototype,"updateSubPriority",1),aG([pG,hG],lG.prototype,"subscribe4pushTrack",1),aG([pG,hG],lG.prototype,"unsubscribe4removeTrack",1),aG([pG,hG],lG.prototype,"unsubscribe",1),aG([hG],lG.prototype,"handleRemoveStream",1),aG([pG],lG.prototype,"subscribePublicStream",1),aG([pG],lG.prototype,"unsubscribePublicStream",1);var vG,fG=function(){var e=Rm(Tm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,f,_,m,y;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getOrgTrack():null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getOrgTrack(),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.receiver:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.receiver,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,gL(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,f=gE(p=v||[]).call(p,(function(e){return"inbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(_=e.sent,m=[],null==_||_.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==(null==v?void 0:v.length)||0===m.length){e.next=22;break}return e.next=21,gL(r.pc);case 21:y=e.sent;case 22:u=Nm({type:t,reports:jm(v).call(v,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==f?void 0:f.bytesReceived,framesReceived:null==f?void 0:f.framesReceived,packetsReceived:null==f?void 0:f.packetsReceived,allReports:y}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Nm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_recv_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),_G=function(){var e=Rm(Tm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,f,_,m,y;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack("preprocessing"):null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.sender:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.sender,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,gL(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,f=gE(p=v||[]).call(p,(function(e){return"outbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(_=e.sent,m=[],null==_||_.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==v.length||0===m.length){e.next=22;break}return e.next=21,gL(r.pc);case 21:y=e.sent;case 22:u=Nm({type:t,reports:jm(v).call(v,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==f?void 0:f.bytesSent,framesSent:null==f?void 0:f.framesSent,packetsSent:null==f?void 0:f.packetsSent,allReports:y}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Nm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_send_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),mG=new Nw("RecvFrameObserver",0),yG=function(e){DI(a,e);var t,r,n,i,o=QI(a);function a(e,t){var r;return Vl(this,a),Jd(tI(r=o.call(this)),"_audioEventSessionId",fM()),Jd(tI(r),"_videoEventSessionId",fM()),Jd(tI(r),"_handler",void 0),Jd(tI(r),"_stream",void 0),Jd(tI(r),"_firstAudioFrameTimer",void 0),Jd(tI(r),"_firstVideoFrameTimer",void 0),Jd(tI(r),"_transportDelayInterval",void 0),Jd(tI(r),"_transportDelay",void 0),Jd(tI(r),"_firstVideoFrameInterval",void 0),Jd(tI(r),"_firstAudioFrameInterval",void 0),Jd(tI(r),"_isScreen",!1),Jd(tI(r),"_audioFirstFrameState",0),Jd(tI(r),"_videoFirstFrameState",0),Jd(tI(r),"_timeout",1e4),Jd(tI(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(tI(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(tI(r),"_login",!1),Jd(tI(r),"_unMuteAudio",!1),Jd(tI(r),"_enableAudio",!1),Jd(tI(r),"_unMuteVideo",!1),Jd(tI(r),"_enableVideo",!1),Jd(tI(r),"_remoteUnmuteAudio",!1),Jd(tI(r),"_remoteUnmuteVideo",!1),Jd(tI(r),"_audioExternal",!1),Jd(tI(r),"_pushAudio",!1),Jd(tI(r),"_videoExternal",!1),Jd(tI(r),"_pushVideo",!1),Jd(tI(r),"_autoSubscribeVideo",!1),Jd(tI(r),"_autoSubscribeAudio",!1),Jd(tI(r),"_autoSubscribe",!1),Jd(tI(r),"_publishVideo",!1),Jd(tI(r),"_publishAudio",!1),Jd(tI(r),"_subscribeAudio",!1),Jd(tI(r),"_subscribeVideo",!1),Jd(tI(r),"_subscribe",!1),Jd(tI(r),"_pushTrack",!1),Jd(tI(r),"_multiChatMode",!1),Jd(tI(r),"_monitor",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=VO(e.engineId),r}return Ul(a,[{key:"beginRecvFrame",value:(i=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,xE(n=["login","unmute","subscribe","push_track"]).call(n,r)>=0&&(i=0,o=!1),"audio"===t?(o||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},p={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(a=this._stream)||void 0===a||!a.isScreen),start:null===(s=this._currentAudioRecv)||void 0===s?void 0:s.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,transport_delay:i,vendor_mode:(null===(u=this._stream)||void 0===u?void 0:u.vendorCode)||0,pc_session_id:(null===(d=this._stream)||void 0===d?void 0:d.pcSessionId)||(null===(l=this._handler)||void 0===l?void 0:l.peerConnectionId)},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){fG("audio",E._handler,E._stream,E._monitor),E.stopRecvFrame("audio","timeout"),E._firstAudioFrameInterval&&window.clearInterval(E._firstAudioFrameInterval)}),this._timeout),mG.info("rtcFirstFrameRecv",Nm(p)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",p),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):"video"===t&&(o||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},b={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(v=this._stream)||void 0===v||!v.isScreen),start:null===(f=this._currentVideoRecv)||void 0===f?void 0:f.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,transport_delay:i,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(y=this._stream)||void 0===y?void 0:y.pcSessionId)||(null===(g=this._handler)||void 0===g?void 0:g.peerConnectionId)},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){fG("video",E._handler,E._stream,E._monitor),E.stopRecvFrame("video","timeout"),E._firstVideoFrameInterval&&window.clearInterval(E._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),mG.info("rtcFirstFrameRecv",Nm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u;if(1!==this._audioFirstFrameState)return;var d={event_type:"recv_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioRecv)||void 0===n?void 0:n.startTime,reason:t,result:!1,stream_user_id:null===(i=this._stream)||void 0===i?void 0:i.userId,event_session_id:this._audioEventSessionId,type:null===(o=this._currentAudioRecv)||void 0===o?void 0:o.type,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,mG.info("rtcFirstFrameRecv",Nm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._audioFirstFrameState=2}else if("video"===e){var l,h,p,v,f,_,m,y;if(1!==this._videoFirstFrameState)return;var g={event_type:"recv_end",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),start:null===(h=this._currentVideoRecv)||void 0===h?void 0:h.startTime,reason:t,result:!1,stream_user_id:null===(p=this._stream)||void 0===p?void 0:p.userId,event_session_id:this._videoEventSessionId,type:null===(v=this._currentVideoRecv)||void 0===v?void 0:v.type,vendor_mode:(null===(f=this._stream)||void 0===f?void 0:f.vendorCode)||0,pc_session_id:(null===(_=this._stream)||void 0===_?void 0:_.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,mG.info("rtcFirstFrameRecv",Nm(g)),null===(y=this._monitor)||void 0===y||y.report("rtc_first_frame",g),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:if(r=this._transportDelay,"audio"!==t){e.next=19;break}if(1===this._audioFirstFrameState){e.next=6;break}return e.abrupt("return");case 6:if(this._currentAudioRecv){e.next=8;break}return e.abrupt("return");case 8:d=this._currentAudioRecv,l=d.type,h=d.startTime,xE(n=["login","unmute","subscribe","push_track"]).call(n,l)>=0&&(r=0),p={event_type:"recv_end",media_type:t,start:h,result:!0,is_screen:!(null===(i=this._stream)||void 0===i||!i.isScreen),stream_user_id:null===(o=this._stream)||void 0===o?void 0:o.userId,event_session_id:this._audioEventSessionId,type:l,transport_delay:r,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),mG.info("rtcFirstFrameRecv",Nm(p)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",p),this.emit("recvAudioFirstFrame"),this._audioFirstFrameState=3,e.next=33;break;case 19:if("video"!==t){e.next=33;break}if(1===this._videoFirstFrameState){e.next=22;break}return e.abrupt("return");case 22:if(this._currentVideoRecv){e.next=24;break}return e.abrupt("return");case 24:b=this._currentVideoRecv,E=b.type,k=b.startTime,xE(v=["login","unmute","subscribe","push_track"]).call(v,E)>=0&&(r=0),T={event_type:"recv_end",media_type:t,is_screen:!(null===(f=this._stream)||void 0===f||!f.isScreen),start:k,result:!0,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,event_session_id:this._videoEventSessionId,type:E,transport_delay:r,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(y=this._stream)||void 0===y?void 0:y.pcSessionId)||(null===(g=this._handler)||void 0===g?void 0:g.peerConnectionId)},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),mG.info("rtcFirstFrameRecv",Nm(T)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",T),this.emit("recvVideoFirstFrame"),this._videoFirstFrameState=3;case 33:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLogin",value:function(e){var t,r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};this._login!==e&&(this._login=e,e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&o.audio&&this.beginRecvFrame("audio","login"),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame("video","login"),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame("audio","leave_room"),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame("video","leave_room"))}},{key:"setUnmuteAudio",value:function(e){var t,r,n;if(this._unMuteAudio!==e){this._unMuteAudio=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasAudio);null!==(r=this._stream)&&void 0!==r&&r.audioHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.audioHasPublish&&(this._unMuteAudio&&i?this.beginRecvFrame("audio","unmute"):i&&this.stopRecvFrame("audio","mute"))}}},{key:"setRemoteUnmuteAudio",value:function(e){this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame("audio","remote_unmute"):this.stopRecvFrame("audio","remote_mute"))}},{key:"setEnableAudio",value:function(e){this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame("audio","enable"):this.stopRecvFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t,r,n;if(this._unMuteVideo!==e){this._unMuteVideo=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasVideo);null!==(r=this._stream)&&void 0!==r&&r.videoHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.videoHasPublish&&(this._unMuteVideo&&i?this.beginRecvFrame("video","unmute"):i&&this.stopRecvFrame("video","mute"))}}},{key:"setHandler",value:function(e){this._handler=e}},{key:"setRemoteUnmuteVideo",value:function(e){this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame("video","remote_unmute"):this.stopRecvFrame("video","remote_mute"))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame("video","enable"):this.stopRecvFrame("video","disable"))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal=e}},{key:"setPushAudio",value:function(e){var t;this._audioExternal&&this._pushAudio!==e&&(this._pushAudio=e),this._pushAudio&&this.beginRecvFrame("audio","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.beginRecvFrame("audio","push")}},{key:"setExternalVideoSource",value:function(e){this._videoExternal=e}},{key:"setPushVideo",value:function(e){var t;this._videoExternal&&this._pushVideo!==e&&(this._pushVideo=e),this._pushVideo&&this.beginRecvFrame("video","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.beginRecvFrame("video","push")}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame("video","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unpublish")}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame("audio","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unpublish")}},{key:"setAutoSubscribe",value:function(e){this._autoSubscribe=e}},{key:"setAutoSubscribeVideo",value:function(e){this._autoSubscribeVideo=e}},{key:"setAutoSubscribeAudio",value:function(e){this._autoSubscribeAudio=e}},{key:"setSubscribeAudio",value:function(e){var t,r;this._autoSubscribeAudio||this._subscribeAudio===e||(this._subscribe=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasAudio&&this.beginRecvFrame("audio","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unsubscribe")}},{key:"setSubscribeVideo",value:function(e){var t,r;this._autoSubscribeVideo||this._subscribeVideo===e||(this._subscribeVideo=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&this.beginRecvFrame("video","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unsubscribe")}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(e&&!this._isScreen&&this.beginRecvFrame("audio","push_track"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","remove_track"))}},{key:"setMultiChatMode",value:function(e){this._multiChatMode=e}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"_watchForFirstVideoFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(Rm(Tm().mark((function n(){var i,o,a,s,c,u,d,l;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a||!a.getTrack()){n.next=12;break}return n.next=3,gL(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.videoTrack)||void 0===u?void 0:u.getTrack());case 3:if(d=n.sent,!(l=gE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.framesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.framesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(Rm(Tm().mark((function n(){var i,o,a,s,c,u,d,l;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a||!a.getOrgTrack()){n.next=12;break}return n.next=3,gL(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.getOrgTrack());case 3:if(d=n.sent,!(l=gE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.totalSamplesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.totalSamplesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"getTransportDelay",value:(r=Rm(Tm().mark((function e(){var t=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelayIntl();case 2:window.clearInterval(this._transportDelayInterval),this._transportDelayInterval=window.setInterval(Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getTransportDelayIntl();case 2:case"end":return e.stop()}}),e)}))),2e3);case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getTransportDelayIntl",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc){e.next=7;break}return e.next=3,gL(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=gE(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=gE(n).call(n,(function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==i?void 0:i.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*o.currentRoundTripTime/2));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"setDisconnect",value:function(){this.stopRecvFrame("audio","connection_lost"),this.stopRecvFrame("video","connection_lost"),this.reset()}},{key:"reset",value:function(){this._currentAudioRecv={startTime:0,eventSessionId:0,type:"login"},this._currentVideoRecv={startTime:0,eventSessionId:0,type:"login"},this._login=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._remoteUnmuteAudio=!1,this._remoteUnmuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoSubscribeVideo=!1,this._autoSubscribeAudio=!1,this._autoSubscribe=!1,this._subscribeAudio=!1,this._subscribeVideo=!1,this._subscribe=!1,this._pushTrack=!1,this._multiChatMode=!1,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._transportDelayInterval&&window.clearInterval(this._transportDelayInterval)}},{key:"audioFirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}},{key:"FirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}}]),a}(nP.exports.EventEmitter),gG=new Nw("SendFrameObserver",0),SG=function(){function e(t,r){Vl(this,e),Jd(this,"_audioEventSessionId",fM()),Jd(this,"_videoEventSessionId",fM()),Jd(this,"_pcSessionId",void 0),Jd(this,"_handler",void 0),Jd(this,"_firstAudioFrameTimer",void 0),Jd(this,"_firstVideoFrameTimer",void 0),Jd(this,"_stream",void 0),Jd(this,"_firstVideoFrameInterval",void 0),Jd(this,"_firstAudioFrameInterval",void 0),Jd(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_login",!1),Jd(this,"_publisher",!1),Jd(this,"_unMuteAudio",!1),Jd(this,"_enableAudio",!1),Jd(this,"_unMuteVideo",!1),Jd(this,"_enableVideo",!1),Jd(this,"_audioExternal",!1),Jd(this,"_pushAudio",!1),Jd(this,"_videoExternal",!1),Jd(this,"_pushVideo",!1),Jd(this,"_autoPublish",!1),Jd(this,"_publish",!1),Jd(this,"_timeout",1e4),Jd(this,"_audioFirstFrameState",0),Jd(this,"_videoFirstFrameState",0),Jd(this,"_monitor",void 0),this._stream=t,this._handler=r,this._monitor=VO(t.engineId)}var t,r;return Ul(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if("audio"===e){var n,i,o,a,s,c,u;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var d={event_type:"begin_send",media_type:e,is_screen:!(null===(n=this._stream)||void 0===n||!n.isScreen),type:t,start:this._currentAudioSend.startTime,event_session_id:this._audioEventSessionId,vendor_mode:(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,pc_session_id:(null===(o=this._stream)||void 0===o?void 0:o.pcSessionId)||(null===(a=this._handler)||void 0===a?void 0:a.peerConnectionId),capture_session_id:null===(s=this._stream)||void 0===s||null===(c=s.audioTrack)||void 0===c?void 0:c.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){_G("audio",r._handler,r._stream,r._monitor),r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),gG.info("rtcFirstFrameSend",Nm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if("video"===e){var l,h,p,v,f,_,m;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var y={event_type:"begin_send",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),type:t,start:this._currentVideoSend.startTime,event_session_id:this._videoEventSessionId,vendor_mode:(null===(h=this._stream)||void 0===h?void 0:h.vendorCode)||0,pc_session_id:(null===(p=this._stream)||void 0===p?void 0:p.pcSessionId)||(null===(v=this._handler)||void 0===v?void 0:v.peerConnectionId),capture_session_id:null===(f=this._stream)||void 0===f||null===(_=f.videoTrack)||void 0===_?void 0:_.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){_G("video",r._handler,r._stream,r._monitor),r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),gG.info("rtcFirstFrameSend",Nm(y)),null===(m=this._monitor)||void 0===m||m.report("rtc_first_frame",y),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u,d;if(1!==this._audioFirstFrameState)return;var l={event_type:"sent_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioSend)||void 0===i?void 0:i.type,vendor_mode:(null===(o=this._stream)||void 0===o?void 0:o.vendorCode)||0,pc_session_id:(null===(a=this._stream)||void 0===a?void 0:a.pcSessionId)||(null===(s=this._handler)||void 0===s?void 0:s.peerConnectionId),capture_session_id:null===(c=this._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,gG.info("rtcFirstFrameSend",Nm(l)),null===(d=this._monitor)||void 0===d||d.report("rtc_first_frame",l),this._audioFirstFrameState=2}else if("video"===e){var h,p,v,f,_,m,y,g,S;if(1!==this._videoFirstFrameState)return;var b={event_type:"sent_end",media_type:e,start:null===(h=this._currentVideoSend)||void 0===h?void 0:h.startTime,is_screen:!(null===(p=this._stream)||void 0===p||!p.isScreen),reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(v=this._currentVideoSend)||void 0===v?void 0:v.type,vendor_mode:(null===(f=this._stream)||void 0===f?void 0:f.vendorCode)||0,pc_session_id:(null===(_=this._stream)||void 0===_?void 0:_.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId),capture_session_id:null===(y=this._stream)||void 0===y||null===(g=y.videoTrack)||void 0===g?void 0:g.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,gG.info("rtcFirstFrameSend",Nm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if("audio"===e){var t,r,n,i,o,a,s;if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var c=this._currentAudioSend,u=c.type,d=c.startTime,l={event_type:"sent_end",media_type:e,is_screen:!(null===(t=this._stream)||void 0===t||!t.isScreen),start:d,result:!0,event_session_id:this._audioEventSessionId,type:u,vendor_mode:(null===(r=this._stream)||void 0===r?void 0:r.vendorCode)||0,pc_session_id:(null===(n=this._stream)||void 0===n?void 0:n.pcSessionId)||(null===(i=this._handler)||void 0===i?void 0:i.peerConnectionId),capture_session_id:null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.captureSessionId};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),gG.info("rtcFirstFrameSend",Nm(l)),null===(s=this._monitor)||void 0===s||s.report("rtc_first_frame",l),this._audioFirstFrameState=3}else if("video"===e){var h,p,v,f,_,m,y;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var g=this._currentVideoSend,S=g.type,b=g.startTime,E={event_type:"sent_end",media_type:e,is_screen:!(null===(h=this._stream)||void 0===h||!h.isScreen),start:b,result:!0,event_session_id:this._videoEventSessionId,type:S,vendor_mode:(null===(p=this._stream)||void 0===p?void 0:p.vendorCode)||0,pc_session_id:(null===(v=this._stream)||void 0===v?void 0:v.pcSessionId)||(null===(f=this._handler)||void 0===f?void 0:f.peerConnectionId),capture_session_id:null===(_=this._stream)||void 0===_||null===(m=_.videoTrack)||void 0===m?void 0:m.captureSessionId};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),gG.info("rtcFirstFrameSend",Nm(E)),null===(y=this._monitor)||void 0===y||y.report("rtc_first_frame",E),this._videoFirstFrameState=3}}},{key:"setLogin",value:function(e){if(this._login!==e){var t,r;if(this._login=e,e)null!==(t=this._stream)&&void 0!==t&&t.videoTrack&&this.beginSendFrame("video","login"),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this.beginSendFrame("audio","login");!e&&this._audioSending&&this.stopSendFrame("audio","leave_room"),!e&&this._videoSending&&this.stopSendFrame("video","leave_room")}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&this._stream.pubVideo&&this.beginSendFrame("video","publish"),(null===(r=this._stream)||void 0===r?void 0:r.audioTrack)&&this._stream.pubAudio&&this.beginSendFrame("audio","publish");!e&&this._audioSending&&this.stopSendFrame("audio","unpublish"),!e&&this._videoSending&&this.stopSendFrame("video","unpublish")}}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&(e&&this.beginSendFrame("audio","unmute"),!e&&this._audioSending&&this.stopSendFrame("audio","mute")))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubAudio&&(this._enableAudio=e,e&&this.beginSendFrame("audio","enable"),!e&&this._audioSending&&this.stopSendFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&(e&&this.beginSendFrame("video","unmute"),!e&&this._videoSending&&this.stopSendFrame("video","mute")))}},{key:"setEnableVideo",value:function(e){var t;this._enableVideo!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubVideo&&(this._enableVideo=e,e&&this.beginSendFrame("video","enable"),!e&&this._videoSending&&this.stopSendFrame("video","disable"))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame("audio","push"),!e&&this._audioSending&&this.stopSendFrame("audio","stop_push"))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame("video","push"),!e&&this._videoSending&&this.stopSendFrame("video","stop_push"))}},{key:"setAutoPublish",value:function(e){this._autoPublish=e}},{key:"setPublisher",value:function(e){this._publisher!==e&&(this._publisher=e,!e&&this._audioSending&&this.stopSendFrame("audio","audience"),!e&&this._videoSending&&this.stopSendFrame("video","audience"))}},{key:"setDisconnect",value:function(){this._audioSending&&this.stopSendFrame("audio","connection_lost"),this._videoSending&&this.stopSendFrame("video","connection_lost"),this.reset()}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"setPCSessionId",value:function(e){this._pcSessionId=e}},{key:"setHandler",value:function(e){this._handler=e}},{key:"_getFirstVideoFrameStats",value:(r=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.videoTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=6;break}return e.next=3,gL(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,c=Hs(s).call(s,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.audioTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=5;break}return e.next=3,gL(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,e.abrupt("return",gE(s).call(s,(function(e){return"outbound-rtp"===e.type})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_watchForFirstVideoFrameSend",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(Rm(Tm().mark((function n(){var i,o,a;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e._getFirstVideoFrameStats();case 2:if(i=n.sent,o=0,a=0,null==i||jm(i).call(i,(function(e){o+=e.framesSent,a+=e.packetsSent})),!(i&&i.length>0&&(o>t||a>r))){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=o,r=a,n.abrupt("return");case 10:e.sendFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),100)}},{key:"_watchForFirstAudioFrameSend",value:function(){var e=this,t=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(Rm(Tm().mark((function r(){var n;return Tm().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e._getFirstAudioFrameStats();case 2:if(!((n=r.sent)&&n.packetsSent>t)){r.next=9;break}if(-1!==t){r.next=7;break}return t=n.packetsSent,r.abrupt("return");case 7:e.sendFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 9:case"end":return r.stop()}}),r)}))),100)}},{key:"reset",value:function(){this._login=!1,this._publisher=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoPublish=!1,this._publish=!1,this._audioFirstFrameState=0,this._videoFirstFrameState=0,this._currentAudioSend={startTime:0,eventSessionId:0,type:"login"},this._currentVideoSend={startTime:0,eventSessionId:0,type:"login"},window.clearTimeout(this._firstAudioFrameTimer),window.clearTimeout(this._firstVideoFrameTimer),window.clearInterval(this._firstAudioFrameInterval),window.clearInterval(this._firstVideoFrameInterval)}},{key:"destroy",value:function(){this.reset(),delete this._stream,delete this._handler}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),bG=(Jd(vG={},"audio",{delay:1200,stallRadio:.3}),Jd(vG,"video",{delay:1200,stallRadio:.6}),Jd(vG,"screen_audio",{delay:1600,stallRadio:.8}),Jd(vG,"screen_video",{delay:1600,stallRadio:.8}),vG),EG=function(){function e(){Vl(this,e),Jd(this,"_preUplinkStats",new $S),Jd(this,"_preDownlinkStats",new $S),Jd(this,"_timer",void 0),Jd(this,"_delayTimer",void 0),Jd(this,"_msc",void 0),Jd(this,"reportor",void 0)}return Ul(e,[{key:"updateUplinkStats",value:function(e){var t=e.audioStats,r=e.videoStats,n=e.isScreen;if(t.sendKBitrate>0&&t.rtt){var i,o,a=n?"screen_audio":"audio",s=t.rtt,c=t._fractionLost,u=t._retransmittedRate,d=this._getQosLevel(s,c||0,u||0),l=this._preUplinkStats.get(a)||[d];this._preUplinkStats.set(a,km(i=Om(o=[]).call(o,Jk(l),[d])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var h,p,v=n?"screen_video":"video",f=r._fractionLost,_=r.rtt,m=r._sendBandWidth,y=r._retransmittedRate;0===m&&(f=Math.max(.65,f));var g=this._getQosLevel(_,f||0,y||0),S=this._preUplinkStats.get(v)||[g];this._preUplinkStats.set(v,km(h=Om(p=[]).call(p,Jk(S),[g])).call(h,-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){if(t){var r,n,i=this._getStreamActiveState(t),o=i.audioActive,a=i.videoActive,s=e.audioStats,c=e.videoStats,u=e.isScreen,d=e.userId;if(o)if(0===s.receivedKBitrate)r=gl.VBAD;else{var l=s.rtt,h=s.audioLossRate,p=s.stallDuration,v=s.statsInterval,f=s.e2eDelay,_=p/v,m=u?"screen_audio":"audio",y=this._getQosLevel(l,h||0,c._retransmittedRate||0),g=this._getDownlinkQoE(m,_,f);r=this._getNetworkQuality(y,g)}if(a)if(0===c.receivedKBitrate||0===c.rtt)n=gl.VBAD;else{var S=c.rtt,b=c.videoLossRate,E=c.stallDuration,k=c.statsInterval,T=c.e2eDelay,I=c._retransmittedRate,R=E/k,A=u?"screen_video":"video",w=this._getQosLevel(S,b||0,I||0),C=this._getDownlinkQoE(A,R,T);n=this._getNetworkQuality(w,C)}var x=r&&n?Math.ceil((r+n)/2):r||n;if(x){var O,M,D,P=Om(O="".concat(d)).call(O,u?"_screen":""),N=this._preDownlinkStats.get(P)||[x];this._preDownlinkStats.set(P,km(M=Om(D=[]).call(D,Jk(N),[x])).call(M,-2)),this._startNetworkQualityReport()}}}},{key:"setMSC",value:function(e){this._msc=e}},{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._delayTimer&&(window.clearTimeout(this._delayTimer),delete this._delayTimer),this._preUplinkStats.clear(),this._preDownlinkStats.clear()}},{key:"_startNetworkQualityReport",value:function(){var e=this;this._delayTimer||this._timer||(this._preUplinkStats.size>0||this._preDownlinkStats.size>0)&&(this._delayTimer=window.setTimeout((function(){delete e._delayTimer,e._reportNetworkQuality(),e._timer=window.setInterval((function(){e._reportNetworkQuality()}),2e3)}),300))}},{key:"_reportNetworkQuality",value:function(){var e,t,r,n,i,o=this;if(mk(e=["connected","connecting"]).call(e,null===(t=this._msc)||void 0===t||null===(r=t.handler)||void 0===r?void 0:r.getConnectionState())){var a,s,c,u=this._getBetterQualityAndRemoveOldest("audio","up"),d=this._getBetterQualityAndRemoveOldest("video","up");n=u&&d?Math.ceil((u+d)/2):u||d||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||gl.EXCELLENT;var l=Hs(a=jm(s=qk(sw(c=this._preDownlinkStats).call(c))).call(s,(function(e){return o._getBetterQualityAndRemoveOldest(e,"down")}))).call(a,(function(e){return e}));i=Math.ceil(pb(l).call(l,(function(e,t){return t+e}),0)/l.length)||gl.UNKNOWN}else n=i=gl.DOWN;navigator.onLine||(n=gl.DOWN,i=gl.DOWN),"function"==typeof this.reportor&&this.reportor(n,i)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getQosLevel",value:function(e,t,r){var n;return n=(!e||e<=250)&&t<=.15?1:(!e||e<=500)&&t<=.3?2:(!e||e<=750)&&t<=.45?3:(!e||e<=1e3)&&t<=.6?4:5,r>.5?n=Math.max(n,4):r>.35?n=Math.max(n,3):r>.15&&(n=Math.max(n,2)),n}},{key:"_getUplinkQoE",value:function(e,t){var r=0;switch(e){case"audio":case"video":r=t<.05?1:t<.1?2:3;break;case"screen_video":case"screen_audio":r=t<.04?1:t<.08?2:3}return r}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=bG[e];return t>n.stallRadio||r>n.delay||t>n.stallRadio/2&&r>n.delay/2?3:(t>n.stallRadio/2||n.delay,2)}},{key:"_getBetterQualityAndRemoveOldest",value:function(e,t){var r=gl.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=Hs(i).call(i,(function(e){return e}));o.length>0&&(r=Math.min.apply(Math,Jk(o))),i.shift(),0===i.length&&n.delete(e)}return r}},{key:"_getStreamActiveState",value:function(e){var t=e.subMediaType,r=e._attributes,n=e.subVideo;return{audioActive:e.subAudio&&wM(t)&&r.localaudio&&r.audiostream,videoActive:n&&CM(t)&&r.localvideo&&r.videostream}}}]),e}(),kG=function(){function e(t){Vl(this,e),Jd(this,"_timer",void 0),Jd(this,"_remoteVideoSizeCache",{}),Jd(this,"_remoteScreenSizeCache",{}),Jd(this,"onchange",void 0),this._room=t,this._start()}return Ul(e,[{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._remoteVideoSizeCache={},this._remoteScreenSizeCache={}}},{key:"_start",value:function(){var e=this;this._timer||(this._timer=window.setInterval((function(){var t={},r={};e._room.remoteStreams.forEach((function(n,i){n.forEach((function(n){var o,a=null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack();if(a){var s=n.isScreen?e._remoteScreenSizeCache:e._remoteVideoSizeCache,c=s[i]||{},u=c.width,d=void 0===u?0:u,l=c.height,h=void 0===l?0:l,p=a.getSettings(),v=p.width,f=void 0===v?0:v,_=p.height,m=void 0===_?0:_;h===m&&d===f||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,f,m),delete s[i],(n.isScreen?r:t)[i]={width:f,height:m}}}))})),an(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),an(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),TG=qk((new TextEncoder).encode("subt")),IG={1:pA.SUBTITLE_ERR_POSTPROCESS,2:pA.SUBTITLE_ERR_CONNECTION_ERROR,3:pA.SUBTITLE_ERR_PROCESS_ERROR},RG=new Nw("SubtitleTool",1),AG=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&xE(t=["zh","en","ja"]).call(t,r.source_language)}catch(a){}else{var n,i,o=(null===(n=navigator.language)||void 0===n?void 0:n.substring(0,2))||"";xE(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=Nm({source_language:o}))}},wG=function(){function e(t){var r,n,i;Vl(this,e),Jd(this,"_taskId",void 0),Jd(this,"_appId",void 0),Jd(this,"_roomId",void 0),Jd(this,"_userId",void 0),Jd(this,"onEvent",void 0),Jd(this,"onMessage",void 0),Jd(this,"_preConfig",void 0),Jd(this,"_timer",void 0),this._room=t,this._appId=null===(r=this._room._roomInfo)||void 0===r?void 0:r.appId,this._roomId=null===(n=this._room._roomInfo)||void 0===n?void 0:n.roomId,this._userId=null===(i=this._room._roomInfo)||void 0===i?void 0:i.userInfo.userId}var t,r,n;return Ul(e,[{key:"start",value:(n=Rm(Tm().mark((function e(t){var r=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(RG.info("start","Invoke config: %o",t),VD(t.mode,"mode",[Rl.ASR_ONLY,Rl.ASR_AND_TRANSLATION]),t.mode!==Rl.ASR_AND_TRANSLATION||-1!==xE(xG).call(xG,t.targetLanguage||"")){e.next=4;break}throw new mA(pA.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new mA(pA.SUBTITLE_ALREADY_ON,"Already turned on subtitle");case 6:return this._preConfig=t,this._taskId=(Date.now().toString()+this._roomId+this._userId).substring(0,20),e.next=10,this._room.subtitleControlMessage(this._genSubtitleSignaling("started",t,this._taskId));case 10:this._preConfig=t,this._timer=self.setTimeout((function(){var e;null===(e=r.onEvent)||void 0===e||e.call(r,{event:Al.ERROR,errorCode:pA.TIME_OUT,errorMessage:"start subtitle timeout."}),delete r._timer,r.stop()}),3e4);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"update",value:(r=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(VD(t.mode,"mode",[Rl.ASR_ONLY,Rl.ASR_AND_TRANSLATION]),t.mode!==Rl.ASR_AND_TRANSLATION||-1!==xE(xG).call(xG,t.targetLanguage||"")){e.next=3;break}throw new mA(pA.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new mA(pA.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new mA(pA.SUBTITLE_NOT_TURNED_ON,"Start subtitle first.");case 7:if((null===(r=this._preConfig)||void 0===r?void 0:r.mode)===t.mode&&this._preConfig.targetLanguage===t.targetLanguage){e.next=11;break}return this._preConfig=t,e.next=11,this._room.subtitleControlMessage(this._genSubtitleSignaling("update",t,this._taskId));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stop",value:function(){var e=this;RG.info("stop","Invoke"),this._taskId&&this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId}).finally((function(){var t;delete e._taskId,null===(t=e.onEvent)||void 0===t||t.call(e,{event:Al.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._taskId||!this._preConfig){e.next=5;break}return e.next=3,this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId});case 3:delete this._taskId,this.start(this._preConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getConfig",value:function(){return this._preConfig}},{key:"destroy",value:function(){RG.info("destroy","Invoke"),this.stop(),delete this._preConfig,delete this._taskId}},{key:"onResult",value:function(e){var t=e.body,r=t.error,n=t.errorMessage,i=t.eventType;if(0!==r){var o,a=new mA(IG[r]||pA.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:Al.ERROR,errorCode:a.code,errorMessage:a.message}),this._clearTimer()}else if("SubtitleStarted"===i){var s;null===(s=this.onEvent)||void 0===s||s.call(this,{event:Al.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(this._taskId&&this._preConfig){var t=CG(e);if(t&&t.length>0){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){i===Rl.ASR_ONLY?e.mode===i&&a.push(e):i===Rl.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==Rl.ASR_ONLY||a.push(e),e.mode===Rl.ASR_ONLY&&e.language===o&&a.push(Zd(Zd({},e),{},{mode:Rl.ASR_AND_TRANSLATION})))})),a.length>0)null===(r=this.onMessage)||void 0===r||r.call(this,a)}return!!t}return!1}},{key:"_genSubtitleSignaling",value:function(e,t,r){return{taskId:r,type:"subtitle",action:e,roomId:this._roomId,appId:this._appId,userId:this._userId,subtitleMeta:{subtitleConfig:{mode:t.mode,usersConfig:[{userId:this._userId,targetLanguages:[t.targetLanguage||""]}]},vendorConfig:{type:0}}}}},{key:"_clearTimer",value:function(){this._timer&&(self.clearTimeout(this._timer),delete this._timer)}}]),e}(),CG=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(TG.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=pM.ab2str(km(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(c){}return!1},xG=["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"],OG=ad,MG=tc,DG=function(e,t,r,n){for(var i,o=n>1?void 0:n?MG(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&&OG(t,r,o),o},PG=function(){function e(t){Vl(this,e),Jd(this,"_forwardDstRooms",new $S),Jd(this,"forwardStreamState","stopped"),Jd(this,"_monitor",void 0),this._room=t,this._monitor=VO(this._room.id)}var t,r,n,i,o,a;return Ul(e,[{key:"startForwardStream2Rooms",value:(a=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!==this.forwardStreamState&&"paused"!==this.forwardStreamState){e.next=2;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke startForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("start",this._room.roomInfo.roomId,t);case 4:return r=e.sent,this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),this.forwardStreamState="running",e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(o=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke updateForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult(t),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("update",this._room._roomInfo.roomId,t);case 6:r=e.sent;case 7:return this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(i=Rm(Tm().mark((function e(){var t,r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke stopForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult([]),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 6:r=e.sent;case 7:if(this._updateDstRooms([],r),!(Jk(sw(t=this._forwardDstRooms).call(t)).length>0)){e.next=10;break}throw new mA(pA.UNEXPECTED_ERROR,"stopforwardstream failed: ".concat(Nm(r)));case 10:return n=this._transformForwardStreamResult(r),this.forwardStreamState="stopped",e.abrupt("return",n);case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(n=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("paused"!==this.forwardStreamState&&"stopped"!==this.forwardStreamState){e.next=2;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke pauseForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 4:return t=e.sent,r=this._transformForwardStreamResult(t),this.forwardStreamState="paused",e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(r=Rm(Tm().mark((function e(){var t,r,n,i,o=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o.length>0&&void 0!==o[0]&&o[0]||!mk(t=["running","stopped"]).call(t,this.forwardStreamState)){e.next=3;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke resumeForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 3:return r=this._getDstRooms(),e.next=6,this._sendForwardStreamSignaling("start",this._room._roomInfo.roomId,r);case 6:return n=e.sent,this._updateDstRooms(r,n),i=this._transformForwardStreamResult(n),this.forwardStreamState="running",e.abrupt("return",i);case 11:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"resumeFromReconnect",value:function(){var e=this;"running"===this.forwardStreamState&&this.resumeForwardStream2AllRooms(!0).then((function(t){t.forEach((function(t){t.state===wl.FORWARD_STREAM_STATE_FAILURE&&e._room.safeEmit(wH.ON_FORWARD_STREAM_ERROR,t)}))}))}},{key:"onForwardDstRoomUserKick",value:function(e){var t=[{dstRoomId:e.dstRoomId,code:200,forwardStreamType:"stop"}];this._updateDstRooms([],t),this._room.safeEmit(wH.ON_FORWARD_STREAM_ERROR,{roomId:e.dstRoomId,state:wl.FORWARD_STREAM_STATE_FAILURE,error:Cl.FORWARD_STREAM_ERROR_REMOTE_KICKED})}},{key:"clear",value:function(){this._forwardDstRooms.clear(),this.forwardStreamState="stopped"}},{key:"_mockForwardStreamResult",value:function(e){var t=this,r=[];return this._forwardDstRooms.forEach((function(e,t){r.push({dstRoomId:t,forwardStreamType:"stop",code:200})})),e.forEach((function(e){var n,i=QR(r).call(r,(function(t){return t.dstRoomId===e.roomId}));-1===i?r.push({dstRoomId:e.roomId,forwardStreamType:"start",code:e.roomId===(null===(n=t._room.roomInfo)||void 0===n?void 0:n.roomId)?400:200}):r[i].forwardStreamType="update"})),r}},{key:"_transformForwardStreamResult",value:function(e){e||(e=[]);var t,r=[],n=$T(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=i.dstRoomId,a=i.code,s={roomId:o,state:wl.FORWARD_STREAM_STATE_SUCCESS,error:Cl.FORWARD_STREAM_ERROR_OK};200===a||(400===a?(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_REMOTE_KICKED):a>=700&&a<800?(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_INVALID_TOKEN):(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_RESPONSE)),r.push(s)}}catch(c){n.e(c)}finally{n.f()}return r}},{key:"_updateDstRooms",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];0===(null==r?void 0:r.length)&&this._forwardDstRooms.clear(),r.forEach((function(r){var n=r.dstRoomId,i=r.code,o=r.forwardStreamType;if(200===i)if("stop"===o)t._forwardDstRooms.delete(n);else{var a,s=gE(e).call(e,(function(e){return e.roomId===n}));if(!s&&!t._forwardDstRooms.has(n))throw new mA(pA.UNEXPECTED_ERROR,"unknow roomid ".concat(n," in signaling return"));var c=null!==(a=t._forwardDstRooms.get(n))&&void 0!==a?a:{token:void 0};c=wb(c,s),t._forwardDstRooms.set(n,c)}else t._forwardDstRooms.has(n)&&t._forwardDstRooms.delete(n)}))}},{key:"_getDstRooms",value:function(){var e=[];return this._forwardDstRooms.forEach((function(t,r){e.push({roomId:r,token:t.token})})),e}},{key:"_sendForwardStreamSignaling",value:(t=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="".concat(fM()),"stop"!==t&&(a=jm(n).call(n,(function(e){return e.roomId})),null===(o=this._monitor)||void 0===o||o.report("rtc_forward_stream",{type:"begin",dst_rooms:"{ ".concat(jm(a).call(a,(function(e){return'"'.concat(e,'"')})).join(",")," }"),event_session_id:i})),e.next=4,this._room._mediaServerClient.sendForwardStreamSignal(t,r,n);case 4:if(s=e.sent,c=[],200===(null==s?void 0:s.code)){e.next=9;break}throw"stop"!==t&&(null==n||n.forEach((function(e){c.push({dst_room_id:e.roomId,result:"server error ".concat(null==s?void 0:s.code)})})),null===(u=this._monitor)||void 0===u||u.report("rtc_forward_stream",{type:"end",dst_rooms:Nm(c),event_session_id:i})),new mA(pA.UNEXPECTED_ERROR,"server side internal error, error code: ".concat(s));case 9:return"stop"!==t&&(null===(d=s.forwardStreamResults)||void 0===d||d.forEach((function(e){c.push({dst_room_id:e.dstRoomId,result:"dst room lost"})})),null===(l=s.forwardStreamResults)||void 0===l||l.forEach((function(e){var t=gE(c).call(c,(function(t){return t.dst_room_id===e.dstRoomId}));t&&(200===e.code?"update"===e.forwardStreamType?t.result="update":t.result="success":t.result="server error ".concat(e.code))})),null===(h=this._monitor)||void 0===h||h.report("rtc_forward_stream",{type:"end",dst_rooms:Nm(c),event_session_id:i})),e.abrupt("return",s.forwardStreamResults);case 11:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})}]),e}();function NG(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=this._room._roomInfo)||void 0===r||!r.roomId){e.next=7;break}for(i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=4,n.apply(this,o);case 4:return e.abrupt("return",e.sent);case 7:throw new mA(pA.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 8:case"end":return e.stop()}}),e,this)}))),r}DG([NG],PG.prototype,"startForwardStream2Rooms",1),DG([NG],PG.prototype,"updateForwardStream2Rooms",1),DG([NG],PG.prototype,"stopForwardStream2Rooms",1),DG([NG],PG.prototype,"pauseForwardStream2AllRooms",1),DG([NG],PG.prototype,"resumeForwardStream2AllRooms",1);var LG=new Nw("Room",1),UG={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},VG=function(e){DI(O,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x=QI(O);function O(e,t){var r;return Vl(this,O),Jd(tI(r=x.call(this)),"id",void 0),Jd(tI(r),"_mediaServerClient",void 0),Jd(tI(r),"_localStream",void 0),Jd(tI(r),"_localScreenStream",void 0),Jd(tI(r),"_remoteUsers",new $S),Jd(tI(r),"_remoteStreams",new $S),Jd(tI(r),"_remoteStreamStreamIdUserIdMap",{}),Jd(tI(r),"_virtualStreams",[]),Jd(tI(r),"_context",void 0),Jd(tI(r),"_sessionId",void 0),Jd(tI(r),"_connectionLostTimer",void 0),Jd(tI(r),"_serverConfig",void 0),Jd(tI(r),"_roomConfig",void 0),Jd(tI(r),"_roomInfo",void 0),Jd(tI(r),"_userDuplicateLoginTimerMap",new $S),Jd(tI(r),"_networkQualityManager",void 0),Jd(tI(r),"_videoSizeObserver",void 0),Jd(tI(r),"_hasPublished",!1),Jd(tI(r),"_subtitleTool",void 0),Jd(tI(r),"_csrcUserIdMap",void 0),Jd(tI(r),"_publishOnDemandItem",void 0),Jd(tI(r),"_onceTriggerBySignal",!1),Jd(tI(r),"_pubTransceiverReady",!1),Jd(tI(r),"_publishOnDemandBusy",!1),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_forwardStreamManager",void 0),LG.info("constructor","invoke"),r.id=t.id,r._roomConfig=e,r._mediaServerClient=new lG(t),r._networkQualityManager=new EG,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(tI(r)),r._videoSizeObserver=new kG(tI(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(tI(r)),r._context=t,r._csrcUserIdMap={},r._monitor=VO(r.id),r._forwardStreamManager=new PG(tI(r)),r._addHandlerEventHandler(),r}return Ul(O,[{key:"hasScreenPublished",get:function(){var e;return null===(e=this._localScreenStream)||void 0===e?void 0:e.hasPublished}},{key:"hasPublished",get:function(){var e;return null===(e=this._localStream)||void 0===e?void 0:e.hasPublished}},{key:"connectionState",get:function(){return this._mediaServerClient.connectionState}},{key:"remoteUsers",get:function(){return this._remoteUsers}},{key:"remoteStreams",get:function(){return this._remoteStreams}},{key:"localStream",get:function(){return this._localStream}},{key:"localScreenStream",get:function(){return this._localScreenStream}},{key:"roomInfo",get:function(){return this._roomInfo}},{key:"roomConfig",set:function(e){this._roomConfig=e}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D=this;null===(e=this._mediaServerClient)||void 0===e||e.on(SH.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(SH.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return D._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(SH.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(SH.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return D._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(SH.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(SH.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return D._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(SH.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(SH.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return D._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(SH.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(SH.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(SH.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(SH.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(SH.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(SH.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(SH.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(SH.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(SH.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(SH.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(SH.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(SH.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(bH.RSCP,(function(e,t){!!gE(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:mk(t).call(t,null===(r=D._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(t?D._pubTransceiverReady=!0:D._onceTriggerBySignal=!0,t&&D._onceTriggerBySignal||(D._publishOnDemandItem=e),D._pubTransceiverReady&&D._onPublishOnDemand())})),null===(b=this._mediaServerClient)||void 0===b||b.on(bH.RTT,this._onRTT.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(bH.SSC,this._onSSC.bind(this)),null===(k=this._mediaServerClient)||void 0===k||k.on(EH.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(EH.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return D.emit(EH.ON_VENDOR_CONNECTION_STATE_CHANGE,e)})),null===(I=this._mediaServerClient)||void 0===I||I.on(SH.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){D._networkQualityManager.updateDownlinkStats(e,D._findRemoteStreamByScreen(e.userId,e.isScreen)),D.emit(wH.ON_REMOTE_STREAM_STATS,xM(e))})),null===(A=this._mediaServerClient)||void 0===A||A.on(wH.RESUBSCRIBE,(function(e){D.emit(wH.RESUBSCRIBE,e)})),null===(w=this._mediaServerClient)||void 0===w||w.on(wH.RECONNECT_FAILED,(function(){D.emit(wH.RECONNECT_FAILED)})),null===(C=this._mediaServerClient)||void 0===C||C.on("joinSuccess",this._onJoinSucc.bind(this)),null===(x=this._mediaServerClient)||void 0===x||x.on(SH.ON_FORWARD_DST_ROOM_USER_KICK,this._forwardStreamManager.onForwardDstRoomUserKick.bind(this._forwardStreamManager)),null===(O=this._mediaServerClient)||void 0===O||O.on(wH.ON_REJOIN_WITH_TCP,(function(){D.emit(wH.ON_REJOIN_WITH_TCP)})),null===(M=this._mediaServerClient)||void 0===M||M.on(wH.ON_ICE_CONNECT_WITH_TCP,(function(){D.emit(wH.ON_ICE_CONNECT_WITH_TCP)}))}},{key:"_onLocalStreamStats",value:function(e){this._networkQualityManager.updateUplinkStats(e),this.emit(wH.ON_LOCAL_STREAM_STATS,xM(e))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(C=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.connect();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"join",value:(w=Rm(Tm().mark((function e(t,r,n,i,o){var a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(a=this._monitor)||void 0===a||a.set({rtc_app_id:t,room_id:r,user_id:i.userId}),LG.info("join()"),this._mediaServerClient.setLiveControlMessage(o),this._roomInfo={appId:t,roomId:r,token:n,userInfo:i,roomProfile:this._roomConfig.roomProfileType},this.setSessionId(),e.prev=5,e.next=8,this._mediaServerClient.join(this._roomInfo);case 8:return c=e.sent,null!==(s=c.roomAttributes)&&void 0!==s&&s.multiChatMode&&this._handleFFAudioTrack(),this._initSubtitleTool(),e.abrupt("return",{users:c.clients,streams:c.streams});case 14:if(e.prev=14,e.t0=e.catch(5),e.t0.code===pA.OPERATION_CANCEL){e.next=18;break}throw e.t0;case 18:case"end":return e.stop()}}),e,this,[[5,14]])}))),function(e,t,r,n,i){return w.apply(this,arguments)})},{key:"publishScreen",value:(A=Rm(Tm().mark((function e(t,r,n,i,o){var a,s,c,u,d,l,h,p,v,f,_,m;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(LG.info("publishScreen()"),this._localScreenStream||(this._localScreenStream=new uF(this._context),null!==(a=this._mediaServerClient)&&void 0!==a&&null!==(s=a.vendorConfig)&&void 0!==s&&s.enableMultiVendor&&(this._localScreenStream.pcSessionId=_w()),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new SG(this._localScreenStream,this._mediaServerClient.handler))),c=!1,u=!1,d=!1,l=!1,!this._localScreenStream.videoTrack&&r?(r instanceof mV&&(u=!0),c=!0):this._localScreenStream.videoTrack&&!r&&(c=!1),!this._localScreenStream.audioTrack&&n?(n instanceof yV&&(l=!0),d=!0):this._localScreenStream.audioTrack&&!n&&(d=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(wM(i)&&(this._localScreenStream.pubAudio=o===xH.PUB),CM(i)&&(this._localScreenStream.pubVideo=o===xH.PUB),LG.info("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(h=this._localScreenStream)||void 0===h||!h.hasPublished){e.next=17;break}return e.abrupt("return",this.unpublishScreen());case 17:return e.abrupt("return");case 18:if(this._localScreenStream.hasPublished){e.next=24;break}return null===(p=this._localScreenStream.observer)||void 0===p||p.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return u?null===(v=this._localScreenStream.observer)||void 0===v||v.setPushVideo(c):null===(f=this._localScreenStream.observer)||void 0===f||f.setEnableVideo(c),l?null===(_=this._localScreenStream.observer)||void 0===_||_.setPushAudio(d):null===(m=this._localScreenStream.observer)||void 0===m||m.setEnableAudio(d),e.next=28,this.updatePubScreenTrack();case 28:this._localScreenStream.pubAudio||this._localScreenStream.pubVideo?this._localScreenStream.startReport(this._onLocalStreamStats.bind(this),this._mediaServerClient.handler):this._localScreenStream.stopReport("unpublish screen");case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return A.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(R=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(LG.info("updatePubScreenTrack","Invoke updatePubScreenTrack"),!this._localScreenStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return R.apply(this,arguments)})},{key:"unpublishScreen",value:(I=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(LG.info("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=8;break}return null===(t=this._localScreenStream.observer)||void 0===t||t.setPublish(!1),e.next=5,this._mediaServerClient.unpublish(this._localScreenStream);case 5:this._localScreenStream.stopReport("unpublish screen"),this._localScreenStream.clean(),this._localScreenStream=void 0;case 8:case"end":return e.stop()}}),e,this)}))),function(){return I.apply(this,arguments)})},{key:"liveControlMessage",value:(T=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return LG.info("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),e.next=4,this._mediaServerClient.controlMessage(t);case 4:this._mediaServerClient.setLiveControlMessage("stopped"===t.action?void 0:t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(k=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._mediaServerClient.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"subtitleControlMessage",value:(E=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.controlMessage(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"updateUserAttributes",value:(b=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return LG.info("updateUserAttributes","Invoke updateUserAttributes"),t.role&&this._roomInfo&&(this._roomInfo.userInfo.role=t.role),e.next=4,this._mediaServerClient.updateUserAttributes(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"publish",value:(S=Rm(Tm().mark((function e(t,r,n,i,o,a){var s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=E.length>6&&void 0!==E[6]&&E[6],LG.info("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new uF(this._context),null!==(u=this._mediaServerClient)&&void 0!==u&&null!==(d=u.vendorConfig)&&void 0!==d&&d.enableMultiVendor&&(this._localStream.pcSessionId=_w()),this._mediaServerClient.handler&&(this._localStream.observer=new SG(this._localStream,this._mediaServerClient.handler)),c=!0,this._localStream.vendorCode=(null===(l=this._mediaServerClient.vendorConfig)||void 0===l?void 0:l.vendorCode)||0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,o&&(wM(o)&&(this._localStream.pubAudio=a===xH.PUB),CM(o)&&(this._localStream.pubVideo=a===xH.PUB),LG.info("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=26;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=12;break}return e.abrupt("return");case 12:return e.prev=12,s?null===(h=this._localStream.observer)||void 0===h||h.setLogin(!0):c&&(p=!!this._localStream.videoTrack,v=!!this._localStream.audioTrack,f=this._localStream.videoTrack instanceof mV,_=this._localStream.audioTrack instanceof yV,this._roomConfig.isAutoPublish&&!this._hasPublished?(p&&(f?null===(m=this._localStream.observer)||void 0===m||m.setPushVideo(!0):null===(y=this._localStream.observer)||void 0===y||y.setEnableVideo(!0)),v&&(_?null===(g=this._localStream.observer)||void 0===g||g.setPushAudio(!0):null===(S=this._localStream.observer)||void 0===S||S.setEnableAudio(!0))):null===(b=this._localStream.observer)||void 0===b||b.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(wH.ON_PUBLISH_RESULT,{isScreen:!1,state:ol.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(wH.ON_PUBLISH_RESULT,{isScreen:!1,state:ol.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:this._localStream.pubAudio||this._localStream.pubVideo?this._localStream.startReport(this._onLocalStreamStats.bind(this),this._mediaServerClient.handler):this._localStream.stopReport("unpublish");case 29:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return S.apply(this,arguments)})},{key:"updatePubTrack",value:(g=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(LG.info("updatePubTrack","Invoke updatePubTrack"),!this._localStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"unpublish",value:(y=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(LG.info("unpublish","Invoke unpublish"),!this._localStream){e.next=7;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.stopReport("unpublish"),this._localStream.clean(),this._localStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"subscribe",value:(m=Rm(Tm().mark((function e(t,r,n){var i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return LG.info("subscribe","remoteStream %o",t),i=void 0,n&&(i=this._getSubLayer(n,t)),e.next=5,this._mediaServerClient.subscribe(t,r,i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return m.apply(this,arguments)})},{key:"updateSubTrack",value:(_=Rm(Tm().mark((function e(t,r,n,i){var o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(LG.info("updateSubTrack","Invoke updateSubTrack"),!i){e.next=4;break}return e.next=4,null===(a=this._mediaServerClient)||void 0===a?void 0:a.updateSubTrackLayer(t,i);case 4:return e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrack(t,r,n));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return _.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(f=Rm(Tm().mark((function e(t,r){var n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((a=this._findRemoteStreamByScreen(t,!1))&&a.hasSubscribed&&!((null==a||null===(n=a.attributes)||void 0===n||null===(i=n.videoDescriptions)||void 0===i?void 0:i.length)<=1)){e.next=3;break}return e.abrupt("return");case 3:return s=this._getSubLayer(r,a),a.originalStreamIndex=s.spatialLayer,e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrackLayer(a,s));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,c=s.videoDescriptions,u=s.subVideoDescriptions,d=Array.isArray(u)?u:c,l=-1,h=e.width*e.height,p=0;p<(null==d?void 0:d.length);p++){var v,f;if(h>=(null===(v=d[p])||void 0===v?void 0:v.width)*(null===(f=d[p])||void 0===f?void 0:f.height)){l=p;break}}var _=d[0];if(-1===l)_=d[l=d.length-1];else if(0!==l){var m=d[l-1].width*d[l-1].height,y=(m-h)/(m-d[l].width*d[l].height);_=y<.1?d[l-1]:d[l],l=y<.1?l-1:l}return a=null!==(r=null===(n=_)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=_)||void 0===o?void 0:o.video_index)&&void 0!==i?i:l,spatialSubLayer:a}}},{key:"unsubscribe",value:(v=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return LG.info("unsubscribe","Invoke unsubscribe"),e.next=3,this._mediaServerClient.unsubscribe(t,r);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"startSubtitle",value:(p=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subtitleTool){e.next=5;break}return e.next=3,this._subtitleTool.start(t);case 3:e.next=6;break;case 5:throw new mA(pA.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"stopSubtitle",value:(h=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(t=this._subtitleTool)||void 0===t||t.stop();case 1:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"startForwardStream2Rooms",value:(l=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.startForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(d=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.updateForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(u=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.stopForwardStream2Rooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(c=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.pauseForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(s=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.resumeForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"leave",value:(a=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=h.length>0&&void 0!==h[0]&&h[0],LG.info("leave","Invoke leave"),n=lM(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,e.prev=5,s=$T(oR(a=this._remoteStreams).call(a));try{for(s.s();!(c=s.n()).done;)u=c.value,Array.isArray(u)&&u.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(p){s.e(p)}finally{s.f()}return this._localStream&&(null===(d=this._localStream.observer)||void 0===d||d.setLogin(!1)),e.next=11,this._mediaServerClient.leave().catch((function(){}));case 11:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:lM()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=24;break;case 16:if(e.prev=16,e.t0=e.catch(5),!r){e.next=22;break}throw e.t0;case 22:this.destroy();case 23:e.t0 instanceof Error&&(null===(l=this._monitor)||void 0===l||l.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:lM()-n}));case 24:case"end":return e.stop()}}),e,this,[[5,16]])}))),function(){return a.apply(this,arguments)})},{key:"updateRemoteUserPriority",value:function(e){var t,r=this;null===(t=this.remoteStreams.get(e))||void 0===t||t.forEach((function(t){var n=(r._context||{}).userPriority;t.hasSubscribed&&n.has(e)&&r._mediaServerClient.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e;LG.info("destroy","Invoke destroy"),jO(this.id,"room_destroy","".concat((new Error).stack)),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._mediaServerClient.destroy(),this._removeHandlerEventHandler(),this._roomInfo=void 0,this._remoteUsers=new $S;var t,r,n,i=$T(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=eI(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.destroy()}))}}catch(a){i.e(a)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new $S,this._localStream)&&(null===(r=this._localStream)||void 0===r||r.clean(),this._localStream=void 0);this._localScreenStream&&(null===(n=this._localScreenStream)||void 0===n||n.clean(),this._localScreenStream=void 0);this._removeHandlerEventHandler(),clearTimeout(this._connectionLostTimer),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={},this._forwardStreamManager.clear()}},{key:"updateToken",value:(o=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return LG.info("updateToken","Invoke updateToken"),this._roomInfo&&(this._roomInfo.token=t),e.prev=2,e.next=5,this._mediaServerClient.updateToken(t);case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(2),this.safeEmit(wH.ON_ROOM_ERROR,{errorCode:pA.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return o.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._mediaServerClient)||void 0===r?void 0:r.sendUserMessage(e,t)}},{key:"setSessionId",value:function(){var e;this._sessionId=vw(),this._mediaServerClient._sessionId=this._sessionId,null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(i=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=s.length>1&&void 0!==s[1]&&s[1],a={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:o,message:"",roomId:null===(n=this._roomInfo)||void 0===n?void 0:n.roomId},!o){e.next=8;break}return e.next=5,pM.ab2b64str(t);case 5:a.message=e.sent,e.next=9;break;case 8:a.message=t;case 9:return e.abrupt("return",null===(i=this._mediaServerClient)||void 0===i?void 0:i.sendRoomMessage(a));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"_onJoinSucc",value:function(e){var t,r,n,i=this,o=e.joinRes,a=e.reconnect;LG.info("_onJoinSucc()","invoke. ".concat(a?"[reconnect]":"")),this._serverConfig=o.config,this._mediaServerClient.roomAttributes=o.roomAttributes;var s=[],c=[],u=[],d=[],l=[];null===(t=o.clientsDetail)||void 0===t||t.forEach((function(e){if(e.attributes&&(e.attributes.serverMuteVideo&&i.safeEmit(wH.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&i.safeEmit(wH.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio})),e.clientId!==o.clientId){var t=i._remoteUsers.get(e.clientId);t?t._stillExist=!0:s.push(e)}}));var h,p=$T(oR(r=this._remoteUsers).call(r));try{for(p.s();!(h=p.n()).done;){var v=h.value;v._stillExist||c.push({clientId:v.userId}),delete v._stillExist}}catch(y){p.e(y)}finally{p.f()}o.streams.forEach((function(e){var t=i._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,l.push(e)):d.push(e)}));var f,_=$T(oR(n=this._remoteStreams).call(n));try{for(_.s();!(f=_.n()).done;){var m=f.value;Array.isArray(m)&&m.forEach((function(e){e.stillExist?delete e.stillExist:u.push({clientId:e.userId,streamId:e.streamId,message:yH.clientDisconnected})}))}}catch(y){_.e(y)}finally{_.f()}c.forEach((function(e){return i._onUserDisconnection(e)})),s.forEach((function(e){return i._onUserConnection(e)})),u.forEach((function(e){return i._onRemoveStream(e)})),d.forEach((function(e){return i._onAddStream(e,{fromSignal:!1})})),l.forEach((function(e){return i._onUpdateStreamAttributes(e)})),a&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r,n,i,o=this;this._localStream&&(this._localStream.clean(),this._localStream.vendorCode=(null===(r=this._mediaServerClient.vendorConfig)||void 0===r?void 0:r.vendorCode)||0,null===(n=this._localStream.observer)||void 0===n||n.setLogin(!0),this._mediaServerClient.publish(this._localStream).catch((function(e){})));this._localScreenStream&&(this._localScreenStream.clean(),null===(i=this._localScreenStream.observer)||void 0===i||i.setLogin(!0),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var a,s=$T(oR(t=this._remoteStreams).call(t));try{for(s.s();!(a=s.n()).done;){var c=a.value;Array.isArray(c)&&c.forEach(function(){var e=Rm(Tm().mark((function e(t){var r,n,i,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=17;break}return t.resetHasSubscribed(),e.prev=2,LG.info(Om(r="start resubscribe ".concat(t.userId," with ")).call(r,t.subMediaType)),CM(t.subMediaType)&&(null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!0)),wM(t.subMediaType)&&(null===(i=t.observer)||void 0===i||i.setSubscribeAudio(!0)),e.next=8,o._mediaServerClient.subscribe(t,t.subMediaType);case 8:LG.info(Om(a="success resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType)),o.safeEmit(wH.RESUBSCRIBE,{stream:t}),e.next=17;break;case 12:e.prev=12,e.t0=e.catch(2),LG.error(Om(s=Om(c="failed resubscribe ".concat(t.userId," with ")).call(c,t.subMediaType,", error:")).call(s,e.t0)),t.clean(),null==t||t.resetHasSubscribed();case 17:case"end":return e.stop()}}),e,null,[[2,12]])})));return function(t){return e.apply(this,arguments)}}())}}catch(u){s.e(u)}finally{s.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect(),this._forwardStreamManager.resumeFromReconnect()}},{key:"_handleFFAudioTrack",value:function(){var e,t,r,n,i=null===(e=this._mediaServerClient)||void 0===e||null===(t=e.handler)||void 0===t?void 0:t.audioTrack4ff,o=null===(r=this._mediaServerClient)||void 0===r||null===(n=r.handler)||void 0===n?void 0:n.getTransceivers();if(i&&Array.isArray(o)){var a=gE(o).call(o,(function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===i}));if(a){var s=new dF(this._context,"ff-stream","ff-stream",!1,!1,UG);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=DV(i),this._virtualStreams.push(s),this.safeEmit(wH.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?gE(r).call(r,(function(e){return e.streamId===t})):null}},{key:"_findRemoteStreamByScreen",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?gE(r).call(r,(function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.needEmit,i=void 0===n||n,o=r.fromSignal,a=void 0===o||o,s=r.virtual,c=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var u=this._roomConfig,d=u.isAutoSubscribeAudio,l=u.isAutoSubscribeVideo,h=this._findRemoteStreamByScreen(e.clientId,e.screen);if(h&&h.streamId!==e.streamId){var p,v=null===(p=this._remoteStreams.get(e.clientId))||void 0===p?void 0:Hs(p).call(p,(function(e){return e.streamId!==h.streamId}));h.clean(),this._remoteStreams.set(e.clientId,v||[])}var f=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,f)f.attributes=e.attributes;else if((f=new dF(this._context,e.clientId,e.streamId,e.screen,!1,e.attributes)).virtual=c,this._initStreamListeners(f),!c){var _=this._remoteStreams.get(e.clientId);_?_.push(f):this._remoteStreams.set(e.clientId,[f])}if(this._mediaServerClient.handler&&(f.observer=new yG(f,this._mediaServerClient.handler)),!f.isScreen&&l){var m,y,g,S,b,E,k,T;if(a&&f.hasVideo)if(f.attributes.extvideo)null===(m=f.observer)||void 0===m||m.setExternalVideoSource(!0),null===(y=f.observer)||void 0===y||y.setPushVideo(!0);else null===(g=f.observer)||void 0===g||g.setExternalVideoSource(!1),null===(S=f.observer)||void 0===S||S.setPublishVideo(!0);if(a&&f.hasAudio&&d&&!this._mediaServerClient.roomAttributes.multiChatMode)if(f.attributes.extaudio)null===(b=f.observer)||void 0===b||b.setExternalAudioSource(!0),null===(E=f.observer)||void 0===E||E.setPushAudio(!0);else null===(k=f.observer)||void 0===k||k.setExternalAudioSource(!1),null===(T=f.observer)||void 0===T||T.setPublishAudio(!0);if(i&&!a){var I,R=this._roomConfig,A=R.isAutoSubscribeAudio,w=R.isAutoSubscribeVideo;null===(I=f.observer)||void 0===I||I.setLogin(!0,{audio:!!A&&!this.multiChatMode,video:!!w})}}return i&&this.safeEmit(SH.ON_ADD_STREAM,{stream:f}),f}}},{key:"_onUserConnection",value:function(e){var t;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var r=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof r)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(r);var n={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,Zd({},n)),this.safeEmit(SH.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(wH.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(wH.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var a=null;i===kH.kickedByAdmin?a=pA.KICKED_OUT:i===kH.onUserTokenDidExpire?a=pA.TOKEN_EXPIRED:i===kH.userDuplicateLogin&&(a=pA.DUPLICATE_LOGIN),o===TH.roomDismissByAdmin&&(a=pA.ROOM_DISMISS),a&&this.safeEmit(wH.ON_ROOM_ERROR,{errorCode:a})}else{var s=tl.DROPPED;i===kH.userLeave?s=tl.QUIT:i===kH.kickedByAdmin?s=tl.KICKED_BY_ADMIN:i===kH.roleChanged&&(s=tl.SWITCH_TO_INVISIBLE);var c=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:yH.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(wH.ON_USER_LEAVE,{userInfo:{userId:n},reason:s})};if(i===kH.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(n);u&&self.clearTimeout(u);var d=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(n,d)}else c()}}},{key:"_onRemoveStream",value:function(e){var t,r=this;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var n=this._remoteStreams.get(e.clientId);if(n){var i=gE(n).call(n,(function(t){return t.streamId===e.streamId}));if(i){var o,a,s;if(null===(o=this._mediaServerClient)||void 0===o||o.handleRemoveStream(i,e).then((function(){var t=r._remoteStreams.get(e.clientId);t&&(t=Hs(t).call(t,(function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),r._remoteStreams.set(e.clientId,t))})).finally((function(){r.safeEmit(SH.ON_REMOVE_STREAM,{stream:i,reason:e.message,callback:function(){return i.destroy()}})})),i.hasVideo)null===(a=i.observer)||void 0===a||a.setPublishVideo(!1);if(i.hasAudio&&!this._mediaServerClient.roomAttributes.multiChatMode)null===(s=i.observer)||void 0===s||s.setPublishAudio(!1)}}}}},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(wH.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(wH.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=Zd(Zd({},this._mediaServerClient.roomAttributes),e.roomAttributes)),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this._roomConfig,r=t.isAutoSubscribeAudio,n=t.isAutoSubscribeVideo,i=e.clientId,o=e.streamId,a=e.attributes,s=this._findRemoteStream(i,o);if(s){var c,u,d=s.attributes,l=Zd(Zd({},d),a),h=!1,p=l.localaudio!==d.localaudio,v=!1,f=!1,_=l.localvideo!==d.localvideo,m=!1,y=zV.NONE,g=zV.NONE;if(l.audiostream!==d.audiostream&&(h=l.localaudio,v=!!l.audiostream,l.audiostream?y|=ul.AUDIO:g|=ul.AUDIO),l.videostream!==d.videostream&&(f=l.localvideo,m=!!l.videostream,l.videostream?y|=ul.VIDEO:g|=ul.VIDEO),y&&this.safeEmit(wH.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:xH.PUB,remoteStream:s}),g&&this.safeEmit(wH.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:xH.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(wH.ON_USER_START_AUDIO_CAPTURE,{userId:i},s)}else{var T,I,R,A;if(l.extaudio)null===(T=s.observer)||void 0===T||T.setExternalAudioSource(!0),null===(I=s.observer)||void 0===I||I.setPushAudio(!1);else null===(R=s.observer)||void 0===R||R.setExternalAudioSource(!1),null===(A=s.observer)||void 0===A||A.setEnableAudio(!1);!s.isScreen&&this.safeEmit(wH.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(l.localvideo!==d.localvideo)if(l.localvideo){var w,C,x,O;if(n&&l.videostream)if(l.extvideo)null===(w=s.observer)||void 0===w||w.setExternalVideoSource(!0),null===(C=s.observer)||void 0===C||C.setPushVideo(!0);else null===(x=s.observer)||void 0===x||x.setExternalVideoSource(!1),null===(O=s.observer)||void 0===O||O.setEnableVideo(!0);this.safeEmit(wH.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var M,D,P,N;if(l.extvideo)null===(M=s.observer)||void 0===M||M.setExternalVideoSource(!0),null===(D=s.observer)||void 0===D||D.setPushVideo(!1);else null===(P=s.observer)||void 0===P||P.setExternalVideoSource(!1),null===(N=s.observer)||void 0===N||N.setEnableVideo(!1);!s.isScreen&&this.safeEmit(wH.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!p)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(v);if(f&&!_)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteVideo(m)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&hA(t).call(t,"audio_mux")){var n=this._onAddStream(Zd(Zd({},e),{},{attributes:UG}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(wH.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){LG.error("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:Om(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:NH.TRACK_ERROR})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message,o=e.trackType;LG.info("_onRemoveTrack","remove track: %o",r);var a=this._findRemoteStream(r,n);a&&(a.removeTrack=!0,null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(a,i,o),this.emit(wH.REMOVE_PUSH_TRACK,{stream:a,mediaType:o+1}))}},{key:"_onMeetingSpeakerChange",value:function(e){if(Array.isArray(null==e?void 0:e.speakerCsrcInfo)){var t={};null==e||e.speakerCsrcInfo.forEach((function(e){var r=e.csrc,n=e.userId;e.isScreen||(t[r]=n)})),this._csrcUserIdMap=t}Array.isArray(e.muxStreamInUse)&&this._virtualStreams.forEach((function(t){var r;null!==(r=e.muxStreamInUse)&&void 0!==r&&mk(r).call(r,t.streamId)?t.virtualOccupy=!0:t.virtualOccupy=!1}))}},{key:"getActiveSpeakerInMultiChatMode",value:function(){var e=this,t=[];return this._virtualStreams.forEach((function(r){var n,i=null===(n=r.audioTransceiver)||void 0===n?void 0:n.receiver;if(i){var o=eI(i.getContributingSources()||[],1)[0];if(o){var a=o.audioLevel,s=o.source;e._csrcUserIdMap[s]&&t.push({userId:e._csrcUserIdMap[s],audioLevel:a})}}})),t.length&&HR(t).call(t,(function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_onReconnecting",value:function(){var e,t,r,n,i,o,a,s=this;if(this._roomInfo){var c,u=$T(oR(a=this._remoteStreams).call(a));try{for(u.s();!(c=u.n()).done;){var d=c.value;Array.isArray(d)&&d.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()}))}}catch(l){u.e(l)}finally{u.f()}this._virtualStreams.forEach((function(e){var t;s.emit(wH.REMOVE_PUSH_TRACK,{stream:e,mediaType:ul.AUDIO}),null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()})),this._virtualStreams=[],null===(e=this.localStream)||void 0===e||null===(t=e.observer)||void 0===t||t.setDisconnect(),null===(r=this.localStream)||void 0===r||r.clean(),null===(n=this.localScreenStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setDisconnect(),null===(o=this.localScreenStream)||void 0===o||o.clean()}}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===uG.DISCONNECTED)t=ll.CONNECTION_STATE_DISCONNECTED;else if(e.next===uG.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._mediaServerClient.isReconnecting?ll.CONNECTION_STATE_RECONNECTED:ll.CONNECTION_STATE_CONNECTED;else{if(e.next!==uG.CONNECTING)return;this._mediaServerClient.isReconnecting?(t=ll.CONNECTION_STATE_RECONNECTING,this._onReconnecting()):t=ll.CONNECTION_STATE_CONNECTING}e.prev===uG.CONNECTED&&e.next===uG.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(EH.ON_CONNECTION_STATE_CHANGE,{state:ll.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setMSC(this._mediaServerClient),this.safeEmit(EH.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(wH.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:null===(n=t._roomInfo)||void 0===n?void 0:n.roomId,streamIndex:e.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(SH.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(SH.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(SH.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new wG(this),this._subtitleTool.onEvent=function(t){e.emit(wH.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(wH.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=CH.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=CH.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?CH.START_FAILED:CH.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?CH.STOP_FAILED:CH.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?CH.UPDATE_FAILED:CH.UPDATE_SUCCESS}this.safeEmit(SH.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(SH.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(SH.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("publish"!==t.type){e.next=11;break}if(s=void 0,(null===(r=this.localStream)||void 0===r?void 0:r.streamId)===t.streamId?s=this.localStream:(null===(n=this.localScreenStream)||void 0===n?void 0:n.streamId)===t.streamId&&(s=this.localScreenStream),s){e.next=5;break}return e.abrupt("return");case 5:return null===(i=s)||void 0===i||i.clean(),e.next=8,null===(o=this._mediaServerClient)||void 0===o?void 0:o.unpublish(s).catch((function(){}));case 8:null===(a=this._mediaServerClient)||void 0===a||a.publish(s).catch((function(){})),e.next=20;break;case 11:if("subscribe"!==t.type){e.next=20;break}if(c=this._remoteStreamStreamIdUserIdMap[t.streamId],!(u=this._findRemoteStream(c,t.streamId))){e.next=20;break}return e.next=17,null===(d=this._mediaServerClient)||void 0===d?void 0:d.unsubscribe(u,ul.AUDIO_AND_VIDEO);case 17:return e.next=19,null===(l=this._mediaServerClient)||void 0===l?void 0:l.subscribe(u,u.subMediaType,u.subLayer);case 19:this.safeEmit(wH.RESUBSCRIBE,{stream:u});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===gH.PushLimitWarn&&(null!==(t=this._localStream)&&void 0!==t&&t.pubAudio||null!==(r=this._localStream)&&void 0!==r&&r.pubVideo||this.unpublish())}},{key:"_onPublishOnDemand",value:(r=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publishOnDemandItem&&!this._publishOnDemandBusy&&!1!==(null===(t=this._serverConfig)||void 0===t||null===(r=t.engine_VPM)||void 0===r||null===(n=r.ondemand)||void 0===n?void 0:n.enable)){e.next=2;break}return e.abrupt("return");case 2:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(o=this._localStream)||void 0===o||!o.videoTransceiver){e.next=16;break}return this._publishOnDemandBusy=!0,u=this._publishOnDemandItem,this._publishOnDemandItem=void 0,d=[],l=null===(s=this._localStream)||void 0===s?void 0:s.stream.id,h=null===(c=this._localStream)||void 0===c?void 0:c.videoTransceiver.sender,p=h.getParameters(),Array.isArray(p.encodings)&&Array.isArray(u)&&(f={},LG.info("_onPublishOnDemand exec","usedDescriptions: %o",u),u.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&mk(t).call(t,l)){var r=null==e?void 0:e.Metadata.VideoIndex;f[r]=!0}})),p.encodings=jm(v=p.encodings).call(v,(function(e){if(e.rid){f[e.rid]?e.active=!0:e.active=!1;var t=Number(e.rid);d[t]=e.active}return e})),this._context&&(this._context.activeSimStreams=d)),e.next=13,h.setParameters(p);case 13:this._publishOnDemandBusy=!1,e.next=18;break;case 16:if(null!==(a=this._localStream)&&void 0!==a&&a.videoTransceiver){e.next=18;break}return e.abrupt("return");case 18:this._onPublishOnDemand();case 19:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_onRTT",value:function(e){var t=e.StreamIds,r=e.Metadata;if(t.length&&r){var n,i=t[0];null!==(n=this._context)&&void 0!==n&&n.streamRTT&&(this._context.streamRTT[i]={audio:r.audio_rtt,video:r.video_rtt})}}},{key:"_onSSC",value:function(e){var t=e.StreamIds,r=e.Metadata,n=t[0],i=this._remoteStreamStreamIdUserIdMap[n],o=this._findRemoteStream(i,n),a={userId:i,isScreen:!!o&&o.isScreen,beforeVideoIndex:r.ssc_items[0].prev_layer_id,afterVideoIndex:r.ssc_items[0].cur_layer_id,beforeEnable:0!==r.ssc_items[0].prev_video_open,afterEnable:0!==r.ssc_items[0].cur_video_open,reason:r.ssc_items[0].change_reason};this.emit(wH.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(wH.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(wH.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"multiChatMode",get:function(){var e;return null===(e=this._mediaServerClient)||void 0===e?void 0:e.multiChatMode()}},{key:"setAudioEncodeMaxBitrate",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(n=t===cl.STREAM_INDEX_MAIN?this.localStream:this.localScreenStream)||!n.pubAudio){e.next=7;break}if(null==(o=null===(i=n.audioTransceiver)||void 0===i?void 0:i.sender.getParameters())||!o.encodings.length){e.next=7;break}return o.encodings[0].maxBitrate=1e3*r,e.next=7,null===(a=n.audioTransceiver)||void 0===a?void 0:a.sender.setParameters(o);case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),O}(aP),FG=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=document.createElement(e);return t.id&&(r.id=t.id),t.classList&&t.classList.forEach((function(e){r.classList.add(e)})),t.style&&wb(r.style,t.style),t.attributes&&RA(t.attributes).forEach((function(e){var t=eI(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},BG=new Nw("Player",0),jG=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],HG={playsinline:"","webkit-playsinline":""},GG={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},zG=function(e){DI(n,e);var t,r=QI(n);function n(e,t){var i;Vl(this,n),Jd(tI(i=r.call(this)),"_containerDom",void 0),Jd(tI(i),"_videoDom",void 0),Jd(tI(i),"__cumulativeTime",void 0),Jd(tI(i),"userId",void 0),Jd(tI(i),"renderMode",void 0),Jd(tI(i),"mirrorType",hl.MIRROR_TYPE_NONE),Jd(tI(i),"isScreen",void 0),Jd(tI(i),"isLocal",void 0),Jd(tI(i),"played",!1),Jd(tI(i),"_needLoad",!1),Jd(tI(i),"_emitPlayFailed",!1),Jd(tI(i),"_videoContainer",void 0),Jd(tI(i),"_safari15VideoTimer",void 0),Jd(tI(i),"_monitor",void 0),Jd(tI(i),"_onLocalTrackMute",void 0),Jd(tI(i),"_onInterruptionEnd",void 0),Jd(tI(i),"_needResume",!1),Jd(tI(i),"emitVideoEvent",(function(e){var t,r,n={type:"video",rawEvent:e,readyState:(null===(t=i._videoDom)||void 0===t?void 0:t.readyState)||0,userId:i.userId,eventName:e.type,currentTime:(null===(r=i._videoDom)||void 0===r?void 0:r.currentTime)||0,isScreen:i.isScreen};switch(i.emit("playback_event",n),e.type){case"canplay":case"loadeddata":i._internalPlay();break;case"playing":BG.info("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"));break;case"pause":BG.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element pause")),i._needResume&&(BG.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element resume")),i._internalPlay(),i._needResume=!1)}})),Jd(tI(i),"_internalPlay",(function(){var e;if(null!==(e=i._videoDom)&&void 0!==e&&e.paused){var t=i._videoDom.play();null!=t&&t.then&&t.then((function(){var e;i.isLocal&&WM&&!i._needLoad&&(null===(e=i._videoDom)||void 0===e||e.load(),i._needLoad=!0)})).catch((function(e){var t,r,n,o,a,s;i._emitPlayFailed||("AbortError"!==e.name?(i._emitPlayFailed=!0,null===(t=i._monitor)||void 0===t||t.report("rtc_error",{message:Om(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:NH.AUTOPLAY_FAILED}),i.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(n=i._videoDom)||void 0===n?void 0:n.readyState)||0,userId:i.userId,eventName:"autoplay-error",currentTime:(null===(o=i._videoDom)||void 0===o?void 0:o.currentTime)||0,isScreen:i.isScreen})):null===(a=i._monitor)||void 0===a||a.report("rtc_error",{message:Om(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:NH.AUTOPLAY_FAILED}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=VO(e);var a=t.userId,s=t.isScreen?sl.RENDER_MODE_FIT:sl.RENDER_MODE_HIDDEN;i.renderMode=void 0!==t.renderMode?t.renderMode:s;var c="string"==typeof o?document.getElementById(o):o;if(!c)throw new mA(pA.CANT_FIND_DOM,"can't find dom");return i._videoContainer=document.createElement("div"),i._videoContainer.style.width="100%",i._videoContainer.style.height="100%",i._videoContainer.style.position="relative",i._videoContainer.style.overflow="hidden",i._containerDom=c,i.userId=a,i.isLocal=!!t.isLocal,i.isScreen=!!t.isScreen,i._initVideo(),i}return Ul(n,[{key:"_initVideo",value:function(){var e,t=this;this._videoDom||(this._videoDom=FG("video",{style:{width:"100%",height:"100%"},attributes:GG}),this._videoDom.id=Om(e="".concat(this.userId,"_")).call(e,dM()),this.setRenderMode(this.renderMode),this.mirror(this.mirrorType===hl.MIRROR_TYPE_RENDER));this._videoContainer.appendChild(this._videoDom),this._containerDom.appendChild(this._videoContainer),this._initListeners(),this._onLocalTrackMute=function(){t._needResume=!0},this._onInterruptionEnd=function(){BG.warn("resume player after iOS interruption"),t._internalPlay()},ZU.on(JU.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),ZU.on(JU.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),ZU.on(JU.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd)}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&jG.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&&jG.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(KM){var n;if(null===(n=this._videoDom)||void 0===n||!n.requestVideoFrameCallback)return;this._videoDom.requestVideoFrameCallback((function n(i,o){var a=o.presentationTime;if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t.__cumulativeTime){var s,c=(a-t.__cumulativeTime)%2e3,u=c>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:u,stallCount:u?1:0,stallDuration:c})}t.__cumulativeTime=a,t._videoDom.requestVideoFrameCallback(n)}))}else this.on("playback_event",(function(n){var i;if("timeupdate"===n.eventName){if(0===(null===(i=t._videoDom)||void 0===i?void 0:i.currentTime))return;if(void 0===t.__cumulativeTime)return void(t.__cumulativeTime=t._videoDom.currentTime);if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t._videoDom.currentTime>t.__cumulativeTime){var o=Math.floor(1e3*(t._videoDom.currentTime-t.__cumulativeTime)),a=t._videoDom.currentTime-t.__cumulativeTime>r;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"_recordPause",value:function(e){var t=this;void 0===e.statsReport.isPaused&&this.on("playback_event",(function(r){if("pause"===r.eventName)e.statsReport.isPaused=!0,e.statsReport.pauseStart=lM();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=lM()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{key:"setRenderMode",value:function(e){this.renderMode=e,this._videoDom&&(this.renderMode===sl.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this.renderMode===sl.RENDER_MODE_FILL?this._videoDom.style.objectFit="fill":this._videoDom.style.objectFit="cover")}},{key:"playVideo",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,BG.info("playVideo","play video track: ".concat(this.userId)),!(o&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(n=t.getTrack())||void 0===n?void 0:n.id))){e.next=5;break}try{jO(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(cq){}return e.abrupt("return");case 5:o||(this._initVideo(),o=this._videoDom),BG.info("playVideo","play video by dom: ".concat(null===(i=o)||void 0===i?void 0:i.id)),(a=new MediaStream).addTrack(t.getTrack("preprocessing")),o.srcObject=a,o&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),o&&!this._videoContainer.contains(o)&&this._videoContainer.appendChild(o),setTimeout((function(){return s._internalPlay()})),r&&CD.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(BG.info("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,!this._videoDom)throw new mA(pA.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||eD?this._videoDom.play():Y_.resolve()}},{key:"mirror",value:function(e){var t;BG.info("mirror",Om(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?hl.MIRROR_TYPE_RENDER:hl.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=this._containerDom;(BG.info("stop","stop video track: ".concat(this.userId)),this._videoDom)&&(t||(this._videoDom.srcObject=null),null!=r&&r.contains(this._videoContainer)&&r.removeChild(this._videoContainer),null!==(e=this._videoContainer)&&void 0!==e&&e.contains(this._videoDom)&&this._videoContainer.removeChild(this._videoDom));this.__cumulativeTime=void 0,this.played=!1}},{key:"destroy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];BG.info("destroy","video player: ".concat(this.userId)),this.stop(e),OI(CI(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),ZU.off(JU.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),ZU.off(JU.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),ZU.off(JU.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd),this._videoDom&&delete this._videoDom,this._safari15VideoTimer&&(window.clearInterval(this._safari15VideoTimer),this._safari15VideoTimer=void 0)}},{key:"domElement",get:function(){return this._videoDom}}]),n}(nP.exports.EventEmitter),KG=function(e){DI(i,e);var t,r,n=QI(i);function i(e,t){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{divId:void 0,muted:!1,isScreen:!1},a=o.divId,s=o.muted,c=o.isScreen;if(Vl(this,i),Jd(tI(r=n.call(this)),"_containerDom",void 0),Jd(tI(r),"_audioDom",void 0),Jd(tI(r),"_fakeAudioDom",void 0),Jd(tI(r),"userId",void 0),Jd(tI(r),"muted",!1),Jd(tI(r),"_emitPlayFailed",!1),Jd(tI(r),"played",!1),Jd(tI(r),"isScreen",void 0),Jd(tI(r),"_wechatTimer",void 0),Jd(tI(r),"_edgeTimer",void 0),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_pasued",!0),Jd(tI(r),"emitAudioEvent",(function(e){var t,n,i={type:"audio",rawEvent:e,readyState:(null===(t=r._audioDom)||void 0===t?void 0:t.readyState)||0,userId:r.userId,eventName:e.type,currentTime:(null===(n=r._audioDom)||void 0===n?void 0:n.currentTime)||0};"playing"===e.type&&BG.info("AudioPlayerPlaying","[userId-".concat(r.userId,"] audio element playing")),"pause"===e.type&&(BG.info("AudioPlayerPause","[userId-".concat(r.userId,"] audio element pause")),r._pasued||r._internalPlay()),nD&&eD&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),tD&&QM&&"error"===e.type&&(clearTimeout(r._edgeTimer),r._edgeTimer=window.setTimeout((function(){var e;0===(null===(e=r._audioDom)||void 0===e?void 0:e.currentTime)&&r._autoPlayError("edge")}),500)),r.emit("playback_event",i)})),Jd(tI(r),"_internalPlay",(function(){var e,t;if(jO(r.engineId,"_internalPlay",{paused:null===(e=r._audioDom)||void 0===e?void 0:e.paused}),null!==(t=r._audioDom)&&void 0!==t&&t.paused)try{var n,i=r._audioDom.play(),o=rV.getAudioContextInstance();if("suspended"===o.state){var a=o.resume(),s=setTimeout((function(){var e;"suspended"===o.state&&(r._autoPlayError("AudioContext cannot resume"),null===(e=r._monitor)||void 0===e||e.report("rtc_error",{message:"audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - timeout"),error_code:-1e3}));clearTimeout(s)}));a.catch((function(e){var t,n,i;r._autoPlayError("AudioContext cannot resume"),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Om(n=Om(i="audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - rejected by: [")).call(i,null==e?void 0:e.name,"]")).call(n,null==e?void 0:e.message),error_code:-1e3})})).finally((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(nD&&tD&&(i=i.then((function(){return new Y_((function(e){setTimeout(Rm(Tm().mark((function t(){var n;return Tm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(n=r._audioDom)||void 0===n||n.pause(),r._audioDom.volume=1,t.next=4,r._audioDom.play();case 4:e();case 5:case"end":return t.stop()}}),t)}))),500)}))}))),i.then((function(){jO(r.engineId,"_internalPlay successfully",{userId:r.userId}),r._pasued=!1})).catch((function(e){var t,n,i;r._autoPlayError(e),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Om(n=Om(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:NH.AUTOPLAY_FAILED})})))}catch(l){var c,u,d;r._autoPlayError(l),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:Om(u=Om(d="audio autoplay failed, userId: ".concat(r.userId,": ")).call(d,l.message," ")).call(u,l.name),error_code:NH.AUTOPLAY_FAILED})}})),r.engineId=e,a){var u=document.getElementById(a);if(!u)throw new mA(pA.CANT_FIND_DOM,"can't find dom");r._containerDom=u}else r._containerDom=document.body;return r.userId=t,r.muted=s,r.isScreen=c,r._monitor=VO(e),r._initAudio(),r}return Ul(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=FG("audio",{style:{display:"none"},attributes:HG}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Om(e="".concat(this.userId,"_")).call(e,dM()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&jG.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&&(jG.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.removeEventListener(t,e.emitAudioEvent)})),this._audioDom.removeEventListener("canplay",this._internalPlay),this._audioDom.removeEventListener("loadeddata",this._internalPlay))}},{key:"playAudio",value:(r=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.info("playAudio","play audio track: ".concat(this.userId)),!((o=this._audioDom)&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(r=t.getTrack())||void 0===r?void 0:r.id))){e.next=4;break}return e.abrupt("return");case 4:o||(this._initAudio(),o=this._audioDom),a=new MediaStream,t instanceof GV?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.getOrgTrack()]),a.addTrack(t.getTrack())):a.addTrack(t.getTrack("preprocessing")),nD&&tD&&(this._audioDom.volume=0),o.srcObject=a,null===(n=o)||void 0===n||n.addEventListener("canplay",this._internalPlay),null===(i=o)||void 0===i||i.addEventListener("loadeddata",this._internalPlay),setTimeout((function(){return s._internalPlay()})),this.played=!0;case 13:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_autoPlayError",value:function(e){var t,r;this._emitPlayFailed||(this._emitPlayFailed=!0,this.emit("playback_event",{type:"audio",rawEvent:e,readyState:(null===(t=this._audioDom)||void 0===t?void 0:t.readyState)||0,userId:this.userId,eventName:"autoplay-error",currentTime:(null===(r=this._audioDom)||void 0===r?void 0:r.currentTime)||0}))}},{key:"pause",value:function(){if(!this._audioDom)throw new mA(pA.INVALID_PARAMS,"Player not found");this._pasued=!0,this._audioDom.pause()}},{key:"manuallyPlay",value:function(){var e,t=this;if(BG.info("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new mA(pA.INVALID_PARAMS,"Player not found");if(!this.played)return Y_.resolve();this._audioDom.volume=1,this._audioDom.muted=!1,null===(e=this._fakeAudioDom)||void 0===e||e.play();var r=[],n=this._audioDom.play();null!=n&&n.then&&r.push(n);var i=rV.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?Y_.all(r):Y_.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BG.info("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,qU.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=jm(r).call(r,(function(e){return e.deviceId})),mk(n).call(n,t)&&this._audioDom&&this._audioDom.setSinkId){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,this._audioDom.setSinkId(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"stop",value:function(){var e=this._containerDom;BG.info("stopAudio","stop audio track: ".concat(this.userId)),this._audioDom&&(this._audioDom.srcObject=null,null!=e&&e.contains(this._audioDom)&&e.removeChild(this._audioDom)),this._fakeAudioDom&&(this._fakeAudioDom.srcObject=null,this._fakeAudioDom=void 0),this.played=!1}},{key:"domElement",get:function(){return this._audioDom}},{key:"destroy",value:function(){BG.info("destroy","audio player: ".concat(this.userId)),this.stop(),OI(CI(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom),this._edgeTimer&&clearTimeout(this._edgeTimer)}}]),i}(nP.exports.EventEmitter);function XG(e,t,r,n){var i=function(){var e=Rm(Tm().mark((function e(t,i){var o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null==n?void 0:n.get(i),Array.isArray(o)&&(o=null===(a=o)||void 0===a?void 0:gE(a).call(a,(function(e){return e.isScreen===r}))),!t){e.next=9;break}if(!t.played){e.next=8;break}return e.next=6,t.manuallyPlay();case 6:e.next=9;break;case 8:o&&(t instanceof zG&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof KG&&o.audioTrack&&t.playAudio(o.audioTrack));case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();if(t)return i(e.get(t),t);var o=[];return e.forEach((function(e,t){return o.push(i(e,t))})),Y_.all(o)}var WG=i,qG=lt("iterator"),YG=!WG((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[qG]||"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})),JG=Jt,QG=E,ZG=2147483647,$G=/[^\0-\u007E]/,ez=/[.\u3002\uFF0E\uFF61]/g,tz="Overflow: input needs wider integers to process",rz=RangeError,nz=QG(ez.exec),iz=Math.floor,oz=String.fromCharCode,az=QG("".charCodeAt),sz=QG([].join),cz=QG([].push),uz=QG("".replace),dz=QG("".split),lz=QG("".toLowerCase),hz=function(e){return e+22+75*(e<26)},pz=function(e,t,r){var n=0;for(e=r?iz(e/700):e>>1,e+=iz(e/t);e>455;)e=iz(e/35),n+=36;return iz(n+36*e/(e+38))},vz=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=az(e,r++);if(i>=55296&&i<=56319&&r<n){var o=az(e,r++);56320==(64512&o)?cz(t,((1023&i)<<10)+(1023&o)+65536):(cz(t,i),r--)}else cz(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&&cz(t,oz(n));var c=t.length,u=c;for(c&&cz(t,"-");u<i;){var d=ZG;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=u+1;if(d-o>iz((ZG-a)/l))throw rz(tz);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>ZG)throw rz(tz);if(n==o){for(var h=a,p=36;;){var v=p<=s?1:p>=s+26?26:p-s;if(h<v)break;var f=h-v,_=36-v;cz(t,oz(hz(v+f%_))),h=iz(f/_),p+=36}cz(t,oz(hz(h))),s=pz(a,l,u==c),a=0,u++}}a++,o++}return sz(t,"")},fz=Ar,_z=n,mz=O,yz=E,gz=w,Sz=YG,bz=li,Ez=Qy,kz=Ni,Tz=Pc,Iz=Zi,Rz=mp,Az=R,wz=Ye,Cz=Yt,xz=fn,Oz=tr,Mz=$,Dz=yn,Pz=Gn,Nz=V,Lz=gh,Uz=hh,Vz=wp,Fz=lR,Bz=lt("iterator"),jz="URLSearchParams",Hz="URLSearchParamsIterator",Gz=Iz.set,zz=Iz.getterFor(jz),Kz=Iz.getterFor(Hz),Xz=Object.getOwnPropertyDescriptor,Wz=function(e){if(!gz)return _z[e];var t=Xz(_z,e);return t&&t.value},qz=Wz("fetch"),Yz=Wz("Request"),Jz=Wz("Headers"),Qz=Yz&&Yz.prototype,Zz=Jz&&Jz.prototype,$z=_z.RegExp,eK=_z.TypeError,tK=_z.decodeURIComponent,rK=_z.encodeURIComponent,nK=yz("".charAt),iK=yz([].join),oK=yz([].push),aK=yz("".replace),sK=yz([].shift),cK=yz([].splice),uK=yz("".split),dK=yz("".slice),lK=/\+/g,hK=Array(4),pK=function(e){return hK[e-1]||(hK[e-1]=$z("((?:%[\\da-f]{2}){"+e+"})","gi"))},vK=function(e){try{return tK(e)}catch(cq){return e}},fK=function(e){var t=aK(e,lK," "),r=4;try{return tK(t)}catch(cq){for(;r;)t=aK(t,pK(r--),vK);return t}},_K=/[!'()~]|%20/g,mK={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},yK=function(e){return mK[e]},gK=function(e){return aK(rK(e),_K,yK)},SK=Tz((function(e,t){Gz(this,{type:Hz,iterator:Lz(zz(e).entries),kind:t})}),"Iterator",(function(){var e=Kz(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),bK=function(e){this.entries=[],this.url=null,void 0!==e&&(Mz(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===nK(e,0)?dK(e,1):e:Dz(e)))};bK.prototype={type:jz,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=Uz(e);if(c)for(r=(t=Lz(e,c)).next;!(n=mz(r,t)).done;){if(o=(i=Lz(Oz(n.value))).next,(a=mz(o,i)).done||(s=mz(o,i)).done||!mz(o,i).done)throw eK("Expected sequence with length 2");oK(this.entries,{key:Dz(a.value),value:Dz(s.value)})}else for(var u in e)wz(e,u)&&oK(this.entries,{key:u,value:Dz(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=uK(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=uK(t,"="),oK(this.entries,{key:fK(sK(r)),value:fK(iK(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],oK(r,gK(e.key)+"="+gK(e.value));return iK(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var EK=function(){Rz(this,kK);var e=arguments.length>0?arguments[0]:void 0;Gz(this,new bK(e))},kK=EK.prototype;if(Ez(kK,{append:function(e,t){Vz(arguments.length,2);var r=zz(this);oK(r.entries,{key:Dz(e),value:Dz(t)}),r.updateURL()},delete:function(e){Vz(arguments.length,1);for(var t=zz(this),r=t.entries,n=Dz(e),i=0;i<r.length;)r[i].key===n?cK(r,i,1):i++;t.updateURL()},get:function(e){Vz(arguments.length,1);for(var t=zz(this).entries,r=Dz(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){Vz(arguments.length,1);for(var t=zz(this).entries,r=Dz(e),n=[],i=0;i<t.length;i++)t[i].key===r&&oK(n,t[i].value);return n},has:function(e){Vz(arguments.length,1);for(var t=zz(this).entries,r=Dz(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){Vz(arguments.length,1);for(var r,n=zz(this),i=n.entries,o=!1,a=Dz(e),s=Dz(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?cK(i,c--,1):(o=!0,r.value=s));o||oK(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=zz(this);Fz(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=zz(this).entries,n=Cz(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 SK(this,"keys")},values:function(){return new SK(this,"values")},entries:function(){return new SK(this,"entries")}},{enumerable:!0}),bz(kK,Bz,kK.entries,{name:"entries"}),bz(kK,"toString",(function(){return zz(this).serialize()}),{enumerable:!0}),kz(EK,jz),fz({global:!0,constructor:!0,forced:!Sz},{URLSearchParams:EK}),!Sz&&Az(Jz)){var TK=yz(Zz.has),IK=yz(Zz.set),RK=function(e){if(Mz(e)){var t,r=e.body;if(xz(r)===jz)return t=e.headers?new Jz(e.headers):new Jz,TK(t,"content-type")||IK(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Pz(e,{body:Nz(0,Dz(r)),headers:Nz(0,t)})}return e};if(Az(qz)&&fz({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return qz(e,arguments.length>1?RK(arguments[1]):{})}}),Az(Yz)){var AK=function(e){return Rz(this,Qz),new Yz(e,arguments.length>1?RK(arguments[1]):{})};Qz.constructor=AK,AK.prototype=Qz,fz({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:AK})}}var wK,CK=Ar,xK=w,OK=YG,MK=n,DK=Yt,PK=E,NK=li,LK=function(e,t,r){return JG.f(e,t,r)},UK=mp,VK=Ye,FK=Rb,BK=Xk,jK=ni,HK=Ud.codeAt,GK=function(e){var t,r,n=[],i=dz(uz(lz(e),ez,"."),".");for(t=0;t<i.length;t++)r=i[t],cz(n,nz($G,r)?"xn--"+vz(r):r);return sz(n,".")},zK=yn,KK=Ni,XK=wp,WK={URLSearchParams:EK,getState:zz},qK=Zi,YK=qK.set,JK=qK.getterFor("URL"),QK=WK.URLSearchParams,ZK=WK.getState,$K=MK.URL,eX=MK.TypeError,tX=MK.parseInt,rX=Math.floor,nX=Math.pow,iX=PK("".charAt),oX=PK(/./.exec),aX=PK([].join),sX=PK(1..toString),cX=PK([].pop),uX=PK([].push),dX=PK("".replace),lX=PK([].shift),hX=PK("".split),pX=PK("".slice),vX=PK("".toLowerCase),fX=PK([].unshift),_X="Invalid scheme",mX="Invalid host",yX="Invalid port",gX=/[a-z]/i,SX=/[\d+-.a-z]/i,bX=/\d/,EX=/^0x/i,kX=/^[0-7]+$/,TX=/^\d+$/,IX=/^[\da-f]+$/i,RX=/[\0\t\n\r #%/:<>?@[\\\]^|]/,AX=/[\0\t\n\r #/:<>?@[\\\]^|]/,wX=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,CX=/[\t\n\r]/g,xX=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)fX(t,e%256),e=rX(e/256);return aX(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+=sX(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},OX={},MX=FK({},OX,{" ":1,'"':1,"<":1,">":1,"`":1}),DX=FK({},MX,{"#":1,"?":1,"{":1,"}":1}),PX=FK({},DX,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),NX=function(e,t){var r=HK(e,0);return r>32&&r<127&&!VK(t,e)?e:encodeURIComponent(e)},LX={ftp:21,file:null,http:80,https:443,ws:80,wss:443},UX=function(e,t){var r;return 2==e.length&&oX(gX,iX(e,0))&&(":"==(r=iX(e,1))||!t&&"|"==r)},VX=function(e){var t;return e.length>1&&UX(pX(e,0,2))&&(2==e.length||"/"===(t=iX(e,2))||"\\"===t||"?"===t||"#"===t)},FX=function(e){return"."===e||"%2e"===vX(e)},BX={},jX={},HX={},GX={},zX={},KX={},XX={},WX={},qX={},YX={},JX={},QX={},ZX={},$X={},eW={},tW={},rW={},nW={},iW={},oW={},aW={},sW=function(e,t,r){var n,i,o,a=zK(e);if(t){if(i=this.parse(a))throw eX(i);this.searchParams=null}else{if(void 0!==r&&(n=new sW(r,!0)),i=this.parse(a,null,n))throw eX(i);(o=ZK(new QK)).bindURL(this),this.searchParams=o}};sW.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||BX,d=0,l="",h=!1,p=!1,v=!1;for(e=zK(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=dX(e,wX,"")),e=dX(e,CX,""),n=BK(e);d<=n.length;){switch(i=n[d],u){case BX:if(!i||!oX(gX,i)){if(t)return _X;u=HX;continue}l+=vX(i),u=jX;break;case jX:if(i&&(oX(SX,i)||"+"==i||"-"==i||"."==i))l+=vX(i);else{if(":"!=i){if(t)return _X;l="",u=HX,d=0;continue}if(t&&(c.isSpecial()!=VK(LX,l)||"file"==l&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=l,t)return void(c.isSpecial()&&LX[c.scheme]==c.port&&(c.port=null));l="","file"==c.scheme?u=$X:c.isSpecial()&&r&&r.scheme==c.scheme?u=GX:c.isSpecial()?u=WX:"/"==n[d+1]?(u=zX,d++):(c.cannotBeABaseURL=!0,uX(c.path,""),u=iW)}break;case HX:if(!r||r.cannotBeABaseURL&&"#"!=i)return _X;if(r.cannotBeABaseURL&&"#"==i){c.scheme=r.scheme,c.path=jK(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=aW;break}u="file"==r.scheme?$X:KX;continue;case GX:if("/"!=i||"/"!=n[d+1]){u=KX;continue}u=qX,d++;break;case zX:if("/"==i){u=YX;break}u=nW;continue;case KX:if(c.scheme=r.scheme,i==wK)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=jK(r.path),c.query=r.query;else if("/"==i||"\\"==i&&c.isSpecial())u=XX;else if("?"==i)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=jK(r.path),c.query="",u=oW;else{if("#"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=jK(r.path),c.path.length--,u=nW;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=jK(r.path),c.query=r.query,c.fragment="",u=aW}break;case XX:if(!c.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=nW;continue}u=YX}else u=qX;break;case WX:if(u=qX,"/"!=i||"/"!=iX(l,d+1))continue;d++;break;case qX:if("/"!=i&&"\\"!=i){u=YX;continue}break;case YX:if("@"==i){h&&(l="%40"+l),h=!0,o=BK(l);for(var f=0;f<o.length;f++){var _=o[f];if(":"!=_||v){var m=NX(_,PX);v?c.password+=m:c.username+=m}else v=!0}l=""}else if(i==wK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(h&&""==l)return"Invalid authority";d-=BK(l).length+1,l="",u=JX}else l+=i;break;case JX:case QX:if(t&&"file"==c.scheme){u=tW;continue}if(":"!=i||p){if(i==wK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(c.isSpecial()&&""==l)return mX;if(t&&""==l&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(l))return a;if(l="",u=rW,t)return;continue}"["==i?p=!0:"]"==i&&(p=!1),l+=i}else{if(""==l)return mX;if(a=c.parseHost(l))return a;if(l="",u=ZX,t==QX)return}break;case ZX:if(!oX(bX,i)){if(i==wK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()||t){if(""!=l){var y=tX(l,10);if(y>65535)return yX;c.port=c.isSpecial()&&y===LX[c.scheme]?null:y,l=""}if(t)return;u=rW;continue}return yX}l+=i;break;case $X:if(c.scheme="file","/"==i||"\\"==i)u=eW;else{if(!r||"file"!=r.scheme){u=nW;continue}if(i==wK)c.host=r.host,c.path=jK(r.path),c.query=r.query;else if("?"==i)c.host=r.host,c.path=jK(r.path),c.query="",u=oW;else{if("#"!=i){VX(aX(jK(n,d),""))||(c.host=r.host,c.path=jK(r.path),c.shortenPath()),u=nW;continue}c.host=r.host,c.path=jK(r.path),c.query=r.query,c.fragment="",u=aW}}break;case eW:if("/"==i||"\\"==i){u=tW;break}r&&"file"==r.scheme&&!VX(aX(jK(n,d),""))&&(UX(r.path[0],!0)?uX(c.path,r.path[0]):c.host=r.host),u=nW;continue;case tW:if(i==wK||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&UX(l))u=nW;else if(""==l){if(c.host="",t)return;u=rW}else{if(a=c.parseHost(l))return a;if("localhost"==c.host&&(c.host=""),t)return;l="",u=rW}continue}l+=i;break;case rW:if(c.isSpecial()){if(u=nW,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=wK&&(u=nW,"/"!=i))continue}else c.fragment="",u=aW;else c.query="",u=oW;break;case nW:if(i==wK||"/"==i||"\\"==i&&c.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=vX(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"==i||"\\"==i&&c.isSpecial()||uX(c.path,"")):FX(l)?"/"==i||"\\"==i&&c.isSpecial()||uX(c.path,""):("file"==c.scheme&&!c.path.length&&UX(l)&&(c.host&&(c.host=""),l=iX(l,0)+":"),uX(c.path,l)),l="","file"==c.scheme&&(i==wK||"?"==i||"#"==i))for(;c.path.length>1&&""===c.path[0];)lX(c.path);"?"==i?(c.query="",u=oW):"#"==i&&(c.fragment="",u=aW)}else l+=NX(i,DX);break;case iW:"?"==i?(c.query="",u=oW):"#"==i?(c.fragment="",u=aW):i!=wK&&(c.path[0]+=NX(i,OX));break;case oW:t||"#"!=i?i!=wK&&("'"==i&&c.isSpecial()?c.query+="%27":c.query+="#"==i?"%23":NX(i,OX)):(c.fragment="",u=aW);break;case aW:i!=wK&&(c.fragment+=NX(i,MX))}d++}},parseHost:function(e){var t,r,n;if("["==iX(e,0)){if("]"!=iX(e,e.length-1))return mX;if(t=function(e){var t,r,n,i,o,a,s,c=[0,0,0,0,0,0,0,0],u=0,d=null,l=0,h=function(){return iX(e,l)};if(":"==h()){if(":"!=iX(e,1))return;l+=2,d=++u}for(;h();){if(8==u)return;if(":"!=h()){for(t=r=0;r<4&&oX(IX,h());)t=16*t+tX(h(),16),l++,r++;if("."==h()){if(0==r)return;if(l-=r,u>6)return;for(n=0;h();){if(i=null,n>0){if(!("."==h()&&n<4))return;l++}if(!oX(bX,h()))return;for(;oX(bX,h());){if(o=tX(h(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;l++}c[u]=256*c[u]+i,2!=++n&&4!=n||u++}if(4!=n)return;break}if(":"==h()){if(l++,!h())return}else if(h())return;c[u++]=t}else{if(null!==d)return;l++,d=++u}}if(null!==d)for(a=u-d,u=7;0!=u&&a>0;)s=c[u],c[u--]=c[d+a-1],c[d+--a]=s;else if(8!=u)return;return c}(pX(e,1,-1)),!t)return mX;this.host=t}else if(this.isSpecial()){if(e=GK(e),oX(RX,e))return mX;if(t=function(e){var t,r,n,i,o,a,s,c=hX(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(i=c[n]))return e;if(o=10,i.length>1&&"0"==iX(i,0)&&(o=oX(EX,i)?16:8,i=pX(i,8==o?1:2)),""===i)a=0;else{if(!oX(10==o?TX:8==o?kX:IX,i))return e;a=tX(i,o)}uX(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=nX(256,5-t))return null}else if(a>255)return null;for(s=cX(r),n=0;n<r.length;n++)s+=r[n]*nX(256,3-n);return s}(e),null===t)return mX;this.host=t}else{if(oX(AX,e))return mX;for(t="",r=BK(e),n=0;n<r.length;n++)t+=NX(r[n],OX);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return VK(LX,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&UX(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,i=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",e.includesCredentials()&&(u+=r+(n?":"+n:"")+"@"),u+=xX(i),null!==o&&(u+=":"+o)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+aX(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw eX(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new cW(e.path[0]).origin}catch(cq){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+xX(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(zK(e)+":",BX)},getUsername:function(){return this.username},setUsername:function(e){var t=BK(zK(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=NX(t[r],PX)}},getPassword:function(){return this.password},setPassword:function(e){var t=BK(zK(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=NX(t[r],PX)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?xX(e):xX(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,JX)},getHostname:function(){var e=this.host;return null===e?"":xX(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,QX)},getPort:function(){var e=this.port;return null===e?"":zK(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=zK(e))?this.port=null:this.parse(e,ZX))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+aX(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,rW))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=zK(e))?this.query=null:("?"==iX(e,0)&&(e=pX(e,1)),this.query="",this.parse(e,oW)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=zK(e))?("#"==iX(e,0)&&(e=pX(e,1)),this.fragment="",this.parse(e,aW)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var cW=function(e){var t=UK(this,uW),r=XK(arguments.length,1)>1?arguments[1]:void 0,n=YK(t,new sW(e,!1,r));xK||(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())},uW=cW.prototype,dW=function(e,t){return{get:function(){return JK(this)[e]()},set:t&&function(e){return JK(this)[t](e)},configurable:!0,enumerable:!0}};if(xK&&(LK(uW,"href",dW("serialize","setHref")),LK(uW,"origin",dW("getOrigin")),LK(uW,"protocol",dW("getProtocol","setProtocol")),LK(uW,"username",dW("getUsername","setUsername")),LK(uW,"password",dW("getPassword","setPassword")),LK(uW,"host",dW("getHost","setHost")),LK(uW,"hostname",dW("getHostname","setHostname")),LK(uW,"port",dW("getPort","setPort")),LK(uW,"pathname",dW("getPathname","setPathname")),LK(uW,"search",dW("getSearch","setSearch")),LK(uW,"searchParams",dW("getSearchParams")),LK(uW,"hash",dW("getHash","setHash"))),NK(uW,"toJSON",(function(){return JK(this).serialize()}),{enumerable:!0}),NK(uW,"toString",(function(){return JK(this).serialize()}),{enumerable:!0}),$K){var lW=$K.createObjectURL,hW=$K.revokeObjectURL;lW&&NK(cW,"createObjectURL",DK(lW,$K)),hW&&NK(cW,"revokeObjectURL",DK(hW,$K))}KK(cW,"URL"),CK({global:!0,constructor:!0,forced:!OK,sham:!xK},{URL:cW});var pW=ee.URL,vW=function(){var e=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(pW.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)}}(),fW=ad,_W=tc,mW=function(e,t,r,n){for(var i,o=n>1?void 0:n?_W(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&&fW(t,r,o),o},yW=function(){function e(t,r){Vl(this,e),Jd(this,"_sharedAudioContext",new AudioContext),Jd(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),Jd(this,"_localGainNode",this._sharedAudioContext.createGain()),Jd(this,"_bufferGainNode",this._sharedAudioContext.createGain()),Jd(this,"_audioBufferSource",void 0),Jd(this,"_localSource",void 0),Jd(this,"_context",void 0),Jd(this,"_failedAudioList",[]),Jd(this,"_startingIds",new $S),Jd(this,"_revokeURLs",new JN),Jd(this,"mixingMap",new $S),Jd(this,"resourcesCache",new $S),Jd(this,"volumeConfig",new $S),Jd(this,"cachedBuffer",[]),Jd(this,"id","AudioMixingManager"),this.engineId=r,this._context=t,this._localGainNode.gain.value=1}var t,r,n;return Ul(e,[{key:"mixMediaStream",value:function(e){this._localSource&&this._localSource.disconnect(this._localGainNode),this._localSource=this._sharedAudioContext.createMediaStreamSource(e),this._localSource.connect(this._localGainNode).connect(this._audioDestination)}},{key:"startAudioMixing",value:(n=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this._startingIds.get(t)){e.next=3;break}return console.warn("AudioMixing task id: ".concat(t," is starting")),e.abrupt("return");case 3:if(this._startingIds.set(t,t),i=n.playCount,VD(o=n.type,"mixingType",Qj(Ml)),a=this._context.getLocalAudioTrack()){e.next=9;break}return e.abrupt("return");case 9:if((s=a.getTrack("preprocessing"))&&this.mixMediaStream(new MediaStream([s])),null!=(c=this.mixingMap.get(t))&&c.audioNode){c.audioNode.pause(),this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_STOPPED,error:vA.AUDIO_MIXING_ERROR_OK});try{c.gainNode.disconnect(this._audioDestination),c.audioSource.disconnect(c.gainNode)}catch(y){}}if(!(d=this.resourcesCache.get(t))||d.filePath!==r){e.next=18;break}u=d.getAudioNode(),e.next=31;break;case 18:return e.next=20,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw m._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FAILED,error:vA.AUDIO_MIXING_ERROR_START_FAILED}),new mA(pA.LOAD_RESOURCES_FAILED,e.statusText)}));case 20:return l=e.sent,Qb(r).call(r,"mp3")?h={type:"audio/mpeg"}:Qb(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=24,vW(l,h);case 24:if(e.sent){e.next=28;break}throw this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FAILED,error:vA.AUDIO_MIXING_ERROR_START_FAILED}),new mA(pA.LOAD_RESOURCES_FAILED,"invalid audio resource");case 28:(u=new Audio).crossOrigin="anonymous",u.src=pW.createObjectURL(new Blob([l],h));case 31:return i<=0?u.loop=!0:i>0&&(p=i,u.onended=function(){--p>0?u.play():(m.mixingMap.delete(t),m._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FINISHED,error:vA.AUDIO_MIXING_ERROR_OK}))}),e.prev=32,e.next=35,u.play();case 35:e.next=42;break;case 37:e.prev=37,e.t0=e.catch(32),console.error(e.t0),this._failedAudioList.push(u),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:cl.STREAM_INDEX_MAIN,mediaType:ul.AUDIO});case 42:if(this._startingIds.delete(t),v=this._sharedAudioContext.createMediaElementSource(u),f=this._sharedAudioContext.createGain(),_=this.volumeConfig.get(t),f.gain.value=_?_/100:1,v.connect(f).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:v,audioNode:u,gainNode:f,type:"file"}),o===Ml.PUBLISH)try{f.disconnect(this._sharedAudioContext.destination)}catch(y){}else f.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_PLAYING,error:vA.AUDIO_MIXING_ERROR_OK});case 52:case"end":return e.stop()}}),e,this,[[32,37]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"stopAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&"file"===t.type&&(this.mixingMap.delete(e),t.audioNode.pause(),t.audioSource.disconnect(t.gainNode),t.gainNode.disconnect(this._audioDestination),this._context.emitMessage({mixId:e,state:Dl.AUDIO_MIXING_STATE_STOPPED,error:vA.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Dl.AUDIO_MIXING_STATE_PAUSED,error:vA.AUDIO_MIXING_ERROR_OK}),t.audioNode.pause())}},{key:"resumeAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Dl.AUDIO_MIXING_STATE_PLAYING,error:vA.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stopAudioMixing(t),e.next=3,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw new mA(pA.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FAILED,error:vA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof mA)throw e;throw new mA(pA.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,Qb(r).call(r,"mp3")?i={type:"audio/mpeg"}:Qb(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,vW(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FAILED,error:vA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new mA(pA.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_PRELOADED,error:vA.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=pW.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new Y_((function(e){var r=pW.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)),pW.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){VD(e,"type",Qj(Ml));var t=this._context.getLocalAudioTrack();if(t){var r=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([r])),e===Ml.PUBLISH)try{this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(n){}else this._bufferGainNode.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],e),this._bufferGainNode.connect(this._audioDestination),this._context.emitMessage({mixId:-1,state:Dl.AUDIO_MIXING_STATE_PCM_ENABLED,error:vA.AUDIO_MIXING_ERROR_OK})}}},{key:"disableAudioMixingBuffer",value:function(){if(this.cachedBuffer=[],this._audioBufferSource){try{this._audioBufferSource.disconnect(this._bufferGainNode),this._bufferGainNode.disconnect(this._audioDestination),this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(e){}finally{this._audioBufferSource=void 0}this._context.updateLocalAudioTrack(),this._context.emitMessage({mixId:-1,state:Dl.AUDIO_MIXING_STATE_PCM_DISABLED,error:vA.AUDIO_MIXING_ERROR_OK})}}},{key:"pushAudioMixingBuffer",value:function(e){var t=this;if(!(this._audioBufferSource&&(this.cachedBuffer.push(e),this.cachedBuffer.length>0))){this._audioBufferSource=this._sharedAudioContext.createBufferSource(),this._audioBufferSource.buffer=e,this._audioBufferSource.connect(this._bufferGainNode);try{this._audioBufferSource.start()}catch(r){this._failedAudioList.push(this._audioBufferSource)}this._audioBufferSource.onended=function(){var e;if(null===(e=t._audioBufferSource)||void 0===e||e.disconnect(t._bufferGainNode),t._audioBufferSource=void 0,t.cachedBuffer.length){var r=t.cachedBuffer.shift();r&&t.pushAudioMixingBuffer(r)}}}}},{key:"stopAll",value:function(){var e=this;if(this._localSource)try{this._localSource.disconnect(this._localGainNode),delete this._localSource}catch(t){}this.mixingMap.forEach((function(t,r){e.stopAudioMixing(r)}))}},{key:"mixTrack",get:function(){return this._audioDestination.stream.getAudioTracks()[0]}},{key:"sharedAudioContext",get:function(){return this._sharedAudioContext}},{key:"resumeLocalPlay",value:(t=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=$T(this._failedAudioList),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=24;break}if(i=n.value,e.prev=6,!(i instanceof HTMLAudioElement)){e.next=13;break}return i.muted=!1,e.next=11,i.play();case 11:e.next=14;break;case 13:i.start();case 14:e.next=22;break;case 16:return e.prev=16,e.t0=e.catch(6),t.push(i),console.error(e.t0),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:cl.STREAM_INDEX_MAIN,mediaType:ul.AUDIO}),e.abrupt("break",24);case 22:e.next=4;break;case 24:e.next=29;break;case 26:e.prev=26,e.t1=e.catch(2),r.e(e.t1);case 29:return e.prev=29,r.f(),e.finish(29);case 32:this._failedAudioList=t;case 33:case"end":return e.stop()}}),e,this,[[2,26,29,32],[6,16]])}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e=this._sharedAudioContext;"closed"!==e.state&&"function"==typeof e.close&&e.close(),this.cachedBuffer=[],this.mixingMap.clear(),this.resourcesCache.clear(),this.volumeConfig.clear(),this._startingIds=new $S,this._revokeURLs.forEach((function(e){pW.revokeObjectURL(e)}))}}]),e}();mW([FO("id","filePath","options")],yW.prototype,"startAudioMixing",1),mW([FO("id")],yW.prototype,"stopAudioMixing",1),mW([FO("id")],yW.prototype,"pauseAudioMixing",1),mW([FO("id")],yW.prototype,"resumeAudioMixing",1),mW([FO("id")],yW.prototype,"preloadAudioMixing",1),mW([FO("id")],yW.prototype,"unloadAudioMixing",1),mW([FO("id")],yW.prototype,"getAudioMixingVolume",1),mW([FO("id","volume")],yW.prototype,"setAudioMixingVolume",1),mW([FO("id")],yW.prototype,"getAudioMixingDuration",1),mW([FO("id")],yW.prototype,"getAudioMixingCurrentPosition",1),mW([FO("id","position")],yW.prototype,"setAudioMixingPosition",1),mW([FO("type")],yW.prototype,"enableAudioMixingBuffer",1),mW([FO()],yW.prototype,"disableAudioMixingBuffer",1),mW([FO("buffer")],yW.prototype,"pushAudioMixingBuffer",1);var gW=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(gW||{}),SW=new Nw("RTMClient",1),bW=function(e){DI(c,e);var t,r,n,i,o,a,s=QI(c);function c(e){var t;return Vl(this,c),Jd(tI(t=s.call(this)),"_dataChannelSignal",void 0),Jd(tI(t),"_handler",void 0),Jd(tI(t),"_dataChannelSignalState",uG.DISCONNECTED),Jd(tI(t),"_loginSessionId",null),Jd(tI(t),"_userId",null),Jd(tI(t),"_token",null),Jd(tI(t),"_loginResolveCallback",void 0),Jd(tI(t),"_loginRejectCallback",void 0),Jd(tI(t),"_wait_login_token",!1),Jd(tI(t),"_serverParamsCache",void 0),Jd(tI(t),"id",void 0),Jd(tI(t),"_connectionManager",void 0),Jd(tI(t),"isReconnecting",!1),t._ctx=e,t.id=e.id,t._connectionManager=new nG(e),t._addConnectHandler(),t}return Ul(c,[{key:"login",value:function(e,t){var r=this;return new Y_((function(n,i){var o;if(SW.info("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new mA(pA.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new mA(pA.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=VO(r.id))||void 0===o||o.set({rtm_user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():r.connect().then((function(){r._login()}))}))}},{key:"logout",value:(a=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(pA.NOT_LOGIN,"login first");case 2:return e.next=4,null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId},{functionType:eG.C2RTM}).catch((function(){}));case 4:this._clearState();case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"updateLoginToken",value:(o=Rm(Tm().mark((function e(t){var r=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new Y_((function(e,t){r._wait_login_token?(r._loginResolveCallback=e,r._loginRejectCallback=t,r._login()):e()})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(i=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(pA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,peerUserId:t},{functionType:eG.C2RTM});case 5:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(n=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(pA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"setServerParams",value:(r=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,UD(t,"signature"),UD(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new mA(pA.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,signature:t,url:r},{functionType:eG.C2RTM}).catch((function(e){throw new mA(pA.UNEXPECTED_ERROR,e.msg)}));case 8:this._serverParamsCache={signature:t,url:r},this.emit("onServerParamsSetResult"),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(0),this.emit("onServerParamsSetResult",e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,12]])}))),function(e,t){return r.apply(this,arguments)})},{key:"sendServerMessage",value:(t=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(pA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:"",room:"",type:qH.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e;SW.info("destroy","invoke."),OI(CI(c.prototype),"removeAllListeners",this).call(this),this._loginResolveCallback&&this._loginRejectCallback&&(this._loginRejectCallback(new mA(pA.LOGIN_FAILED,"logout")),delete this._loginResolveCallback,delete this._loginRejectCallback),null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),delete this._dataChannelSignal,this._clearState(),this._connectionManager.destroy(),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=dM();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:pM.token2auth(this._ctx.appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:CD.VERSION,deviceId:ED.getDeviceId(),appId:this._ctx.appId,userId:this._userId},accessParams:Nm({requireICEUfragV2:!0})},{functionType:eG.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,wO.setRtsSessionId(e.id,t),e._wait_login_token=!1,e._serverParamsCache&&e.setServerParams(e._serverParamsCache.signature,e._serverParamsCache.url)})).catch((function(t){var r,n,i=t||{},o=i.code,a=i.message;e._wait_login_token=!1,o>=700&&o<800?708===o?(r=pA.INVALID_PARAMS,n="Invalid userId"):(r=pA.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=pA.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new mA(r,a||n))})).finally((function(){delete e._loginResolveCallback,delete e._loginRejectCallback}))}}},{key:"connect",value:function(){var e=this;return new Y_((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==uG.CONNECTED)throw new mA(pA.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n;e._dataChannelSignalState=uG.CONNECTED,SW.info("connectStateChange","connected"),null===(r=e._handler)||void 0===r||r.destroy(),null===(n=e._dataChannelSignal)||void 0===n||n.destroy(),e._handler=mH(e._ctx,t.pc),e._dataChannelSignal=t.signaling,e._addSignalEventHandler(),e.isReconnecting&&e._login()})),this._connectionManager.on("disconnected",(function(t){e._dataChannelSignalState=uG.DISCONNECTED,SW.warn("connectStateChange","disconnected. %o",t),e.isReconnecting&&(e.emit("onUserDisconnection"),e._clearState())})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=uG.CONNECTING,SW.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=uG.CONNECTING,SW.warn("connectStateChange","reconnecting")}))}},{key:"_addSignalEventHandler",value:function(){var e,t,r,n=this;null===(e=this._dataChannelSignal)||void 0===e||e.on(SH.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(t=this._dataChannelSignal)||void 0===t||t.on(SH.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(r=this._dataChannelSignal)||void 0===r||r.on(SH.USER_DISCONNECTION,(function(){n.emit("onUserDisconnection"),n._clearState()}))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,wO.setRtsSessionId(this.id,"")}}]),c}(nP.exports.EventEmitter),EW=function(){function e(t){Vl(this,e),Jd(this,"_roomId",void 0),Jd(this,"_constraints",{}),Jd(this,"_profile",void 0),Jd(this,"_customMaxBitrate",0),this._appId=t}return Ul(e,[{key:"setRoomId",value:function(e){this._roomId=e}},{key:"setAudioProfile",value:function(e){this._profile=e,this._customMaxBitrate=0}},{key:"customMaxBitrate",get:function(){return this._customMaxBitrate}},{key:"setCustomMaxBitrate",value:function(e){var t=ED.getEngineWebConfig(this._appId,this._roomId||"").audio_encode;this._customMaxBitrate=null!=t&&t.bitrate?0:1e3*e}},{key:"getOpusConfigStr",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=ED.getEngineWebConfig(this._appId,this._roomId||""),n=r.audio_encode,i=this.getConstraints(),o=i.sampleRate,a=i.channelCount,s="number"==typeof o?o:null==o?void 0:o.exact,c="number"==typeof a?a:null==a?void 0:a.exact,u={};t.split(";").forEach((function(e){var t=eI(e.split("="),2),r=t[0],n=t[1];r&&n&&(u[r]=n)}));var d=(null==n?void 0:n.bitrate)||this._customMaxBitrate||this._getConfigByAudioProfile().bitrate;d&&(u.maxaveragebitrate=d);var l=(null==n?void 0:n.enc_sample_rate)||s;l&&(u["sprop-maxcapturerate"]=l);var h=(null==n?void 0:n.playback_rate)||s;return h&&(u.maxplaybackrate=h),(c&&c>1||null!=n&&n.stereo)&&(u["sprop-stereo"]=1,u.stereo=1),null!=n&&n.dtx&&(u.usedtx=1),jm(e=an(u)).call(e,(function(e){var t;return Om(t="".concat(e,"=")).call(t,u[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=Zd(Zd({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=Zd({},this._constraints),t=ED.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;DM(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),DM(null==t?void 0:t.channel)||(e.channelCount=t.channel),DM(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),DM(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),DM(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return DM(e.sampleRate)&&!DM(n)&&(e.sampleRate=n),DM(e.channelCount)&&!DM(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case El.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case El.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case El.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case El.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case El.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),kW=function(e){DI(o,e);var t,r,n,i=QI(o);function o(e,t,r){var n,a=r.businessId;return Vl(this,o),Jd(tI(n=i.call(this)),"_mediaServerClient",void 0),Jd(tI(n),"_appId",void 0),Jd(tI(n),"remoteStreams",void 0),Jd(tI(n),"_businessId",void 0),Jd(tI(n),"_ctx",void 0),n.id=e,n._appId=t,n.remoteStreams=new $S,n._businessId=a,n._ctx={id:n.id,appId:n._appId,avSync:!0,audioProfileManager:new EW(n._appId),useCloudProxy:!1,userPriority:new $S,joinRoomConfig:new TD(n.id),enableFallbackHandler:zW(t),enableStandardHandler:KW(t),pcKillSwitch:Zd(Zd({ctor_sdpsemantics_add:!0,ctor_encodedinsetablestream_add:!0,sld_rtcpfb_rrtr_add:!0,sld_ext_sdesmid_remove:!0,sld_fmtp_sps_add:!0,sld_fmtp_bitrate_add:!0,sld_fmtp_opus_add:!0},OD("PC_KILLSWITCH")),GW(n._appId))},n}return Ul(o,[{key:"connect",value:(n=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new lG(this._ctx),this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=5,this._mediaServerClient.connect();case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new mA(pA.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new dF(this._ctx,t,t,!1,!0,{audiostream:!0,localaudio:!0,videostream:!0,localvideo:!0,extaudio:!1,extvideo:!1,videoDescriptions:[]})).on("onSEIMessage",(function(e){if(e instanceof Uint8Array)for(var t=OM(e),i=0;i<t.seiCount;i++)n.emit(wH.ON_SEI_MESSAGED_RECEIVED,{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._mediaServerClient.subscribePublicStream(r);case 6:return this.remoteStreams.set(t,r),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopPlayPublicStream",value:function(e){var t=this.remoteStreams.get(e);if(t)return this.remoteStreams.delete(e),this._mediaServerClient.unsubscribePublicStream(t)}},{key:"destroy",value:function(){var e;this.remoteStreams.forEach((function(e){e.clean()})),this.remoteStreams=new $S,null===(e=this._mediaServerClient)||void 0===e||e.destroy(),this.removeAllListeners()}},{key:"_handleReconnected",value:(t=Rm(Tm().mark((function e(){var t,r,n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=$T(this.remoteStreams);try{for(n=function(){var e=eI(r.value,1)[0];i.remoteStreams.delete(e),i.startPlayPublicStream(e).then((function(){var t=i.remoteStreams.get(e);i.safeEmit(wH.RESUBSCRIBE,{stream:t})}))},t.s();!(r=t.n()).done;)n()}catch(o){t.e(o)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on("joinSuccess",(function(e){e.reconnect&&r._handleReconnected()})),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}(aP),TW=new Nw("AudioDeviceManager",1),IW=function(e){DI(c,e);var t,r,n,i,o,a,s=QI(c);function c(e){var t;return Vl(this,c),Jd(tI(t=s.call(this)),"_audioLevelFetcher",void 0),Jd(tI(t),"_playbackDeviceTestTimer",void 0),Jd(tI(t),"_audioElement",void 0),Jd(tI(t),"_audioTrack",void 0),Jd(tI(t),"_mediaRecorder",void 0),Jd(tI(t),"_recoderTimer",void 0),Jd(tI(t),"_isAudioPlaybackDeviceTesting",!1),Jd(tI(t),"_isAudioDeviceRecordTesting",!1),Jd(tI(t),"_audioCaptureAndRecoderResolve",void 0),Jd(tI(t),"_onAutoplayFailed",void 0),Jd(tI(t),"_audioPlaybackDeviceId",void 0),t._extensionManager=e,t}return Ul(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new mA(pA.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,TW.info("startAudioPlaybackDeviceTest()","Invoke"),e.prev=4,e.next=7,this._playAudioFile(t,{loop:!0});case 7:e.next=14;break;case 9:throw e.prev=9,e.t0=e.catch(4),TW.error("startAudioPlaybackDeviceTest()","error",e.t0),this.stopAudioPlaybackDeviceTest(),e.t0;case 14:this._startEmitAudioPlaybackDeviceTestVolume(r);case 15:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return a.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this._isAudioPlaybackDeviceTesting&&(TW.info("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=Rm(Tm().mark((function e(t,r,n){var i,o=this,a=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=a.length>3&&void 0!==a[3]?a[3]:3e4,window.MediaRecorder){e.next=3;break}throw new mA(pA.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 3:if(!this._isAudioDeviceRecordTesting&&!this._isAudioPlaybackDeviceTesting){e.next=5;break}throw new mA(pA.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 5:return this._isAudioDeviceRecordTesting=!0,TW.info("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){TW.info("startAudioDeviceRecordTest()","".concat(i,'ms automatic call method "stopAudioDeviceRecordAndPlayTest"')),o._stopAudioCaptureAndRecoder()}),i),e.prev=8,this._onAutoplayFailed=r,e.next=12,this._startAudioCaptureAndRecoder(t,null!=n?n:100);case 12:e.next=19;break;case 14:throw e.prev=14,e.t0=e.catch(8),this._isAudioDeviceRecordTesting=!1,delete this._onAutoplayFailed,e.t0;case 19:delete this._audioCaptureAndRecoderResolve;case 20:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(e,t,r){return o.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){TW.info("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(TW.info("stopAudioDevicePlayTest()","Invoke"),this._isAudioDeviceRecordTesting=!1,this.stopAudioDeviceRecordAndPlayTest(),this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement()),delete this._onAutoplayFailed}},{key:"getRecordTrack",value:function(){return this._audioTrack}},{key:"setSinkId",value:(i=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(TW.info("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new mA(pA.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,qU.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new mA(pA.INVALID_DEVICE_ID,"audio playback device id ".concat(t," is invalid"));case 8:return this._audioPlaybackDeviceId=t,this._setAudioCtxSinkId(),e.abrupt("return",r);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getSinkId",value:function(){return this._audioPlaybackDeviceId}},{key:"destroy",value:function(){TW.info("destroy()","Invoke"),OI(CI(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return TW.info("_playAudioFile()",Om(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new Y_((function(e,n){var o=FG("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new tV(o),o.onplaying=function(){o.onplaying=null,TW.info("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=Rm(Tm().mark((function e(t){var r,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:TW.error("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new mA(pA.LOAD_RESOURCES_FAILED,"Failed to play recorded audio".concat(i?", reason: ".concat(i):".")));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i._setAudioCtxSinkId().then((function(){var e,t;return null===(e=o.play())||void 0===e||null===(t=e.catch)||void 0===t?void 0:t.call(e,(function(e){var t;TW.warn("_playAudioFile()","autoplay error",e);var r=Om(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return Y_.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new mA(pA.LOAD_RESOURCES_FAILED,r))}))}))})));case 2:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"_destroyAudioElement",value:function(){this._audioElement&&(TW.info("_destroyAudioElement()","Invoke"),this._audioElement.onplaying=null,this._audioElement.onerror=null,this._audioElement.src="",delete this._audioElement,"function"==typeof this._audioCaptureAndRecoderResolve&&this._audioCaptureAndRecoderResolve())}},{key:"_startEmitAudioPlaybackDeviceTestVolume",value:function(e){var t=this;e=Math.max(e,100),this._audioElement&&(TW.info("_startEmitAudioPlaybackDeviceTestVolume()","start timer(".concat(e,"ms)")),this._playbackDeviceTestTimer=self.setInterval((function(){t._audioLevelFetcher&&t.emit("onAudioPlaybackDeviceTestVolume",t._audioLevelFetcher.getAudioLevel())}),e))}},{key:"_stopEmitAudioPlaybackDeviceTestVolume",value:function(){var e;void 0!==this._playbackDeviceTestTimer&&(TW.info("_stopEmitAudioPlaybackDeviceTestVolume()","stop timer"),self.clearInterval(this._playbackDeviceTestTimer),delete this._playbackDeviceTestTimer),null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),delete this._audioLevelFetcher}},{key:"_startAudioCaptureAndRecoder",value:(r=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,CV({},this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r),n=new MediaStream([this._audioTrack.getTrack("preprocessing")]),TW.info("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new Y_((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=gE(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),TW.info("startAudioDeviceRecordTest()","use mimeType: ".concat(o))),i._mediaRecorder=new MediaRecorder(n,o?{mimeType:o}:void 0);var s=i._mediaRecorder.mimeType;i._mediaRecorder.ondataavailable=function(){var n=Rm(Tm().mark((function n(o){var a,c;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return TW.info("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(pW.createObjectURL(c),{loop:!1});case 6:n.next=11;break;case 8:return n.prev=8,n.t0=n.catch(3),n.abrupt("return",r(n.t0));case 11:i._startEmitAudioPlaybackDeviceTestVolume(t),null===(a=i._audioElement)||void 0===a||a.addEventListener("ended",(function(){i.stopAudioDevicePlayTest(),e()})),i._audioCaptureAndRecoderResolve=e,n.next=17;break;case 16:e();case 17:case"end":return n.stop()}}),n,null,[[3,8]])})));return function(e){return n.apply(this,arguments)}}(),i._mediaRecorder.onerror=function(e){r(new mA(pA.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},i._audioCaptureAndRecoderResolve=e,i._mediaRecorder.start()})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_stopAudioCaptureAndRecoder",value:function(){var e;this._mediaRecorder&&("recording"===this._mediaRecorder.state&&this._mediaRecorder.stop(),delete this._mediaRecorder),null===(e=this._audioTrack)||void 0===e||e.close(),delete this._audioTrack}},{key:"_setAudioCtxSinkId",value:(t=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=rV.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),TW.info("setSinkId","ctx.sinkId=".concat(t))}catch(o){TW.error("setSinkId",Om(i="failed, ".concat(o.name," - ")).call(i,o.message))}}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),c}(nP.exports.EventEmitter),RW=new Nw("VideoSnapshot",1),AW=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},wW=function(){var e=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=document.createElement("canvas"),o=i.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(a=function(e,t,n){return t=t||e.width,n=n||e.height,i.width=t,i.height=n,r?o.setTransform(-1,0,0,1,t,0):o.setTransform(1,0,0,1,0,0),o.drawImage(e,0,0,t,n),o.getImageData(0,0,t,n)},s=Date.now(),!(c=AW(n))){e.next=16;break}return RW.info("takeSnapshot","VideoPlayer already set."),e.next=11,a(c,c.videoWidth,c.videoHeight);case 11:return u=e.sent,RW.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",u);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(d=new window.ImageCapture(t)).track.readyState||!d.track.enabled||d.track.muted){e.next=29;break}return RW.info("takeSnapshot","use ImageCapture"),e.t0=a,e.next=23,d.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return l=e.sent,RW.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 29:return RW.info("takeSnapshot","use temp video"),e.abrupt("return",new Y_((function(e,r){var n=new MediaStream([t]),i=document.createElement("video");i.setAttribute("playsinline",""),i.muted=!0,document.body.appendChild(i),i.onplaying=function(){var r=a(i,i.videoWidth,i.videoHeight);RW.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e(r),n.removeTrack(t),i.srcObject=null,i.load()},i.onerror=r,i.srcObject=n,i.play()})));case 31:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),CW=function(){return{url:"",video:{codec:Il.H264,width:640,height:360,fps:15,gop:2,kBitRate:xW(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:Tl.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function xW(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 OW(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new mA(pA.INVALID_PARAMS,"Invalid rtmp address")}function MW(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new mA(pA.INVALID_PARAMS,"regions should not be empty.");var t,r=$T(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new mA(pA.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new mA(pA.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(i){r.e(i)}finally{r.f()}}function DW(e,t){var r,n,i,o=function(e,r){var n=pb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=pb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),CW());return n&&r(n)?n:i},a=function(e){return e%2==0?e:e+1},s=a(o(["video","width"],(function(e){return e>=2&&e<=1920}))),c=a(o(["video","height"],(function(e){return e>=2&&e<=1920}))),u=o(["video","fps"],(function(e){return e>=1&&e<=60})),d=(null===(r=t.video)||void 0===r?void 0:r.kBitRate)||0,l=o(["audio","sampleRate"],(function(e){var t;return!!gE(t=[32e3,44100,48e3]).call(t,(function(t){return t===e||t/1e3===e}))}));return{type:"transcode",action:e,transcodeMeta:{transcode:{url:t.url},control:{protocol:"2.0"},audio:{codec:o(["audio","codec"],(function(e){return"AAC"===e})),bitRate:1e3*o(["audio","kBitRate"],(function(e){return e>=32&&e<=192})),sampleRate:l<100?1e3*l:l,channels:o(["audio","channels"],(function(e){var t;return mk(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return mk(t=[Tl.LC,Tl.HEv1,Tl.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return mk(t=["H264","H265"]).call(t,e)})),fps:u,gop:o(["video","gop"],(function(e){return e>=1&&e<=5}))*u,bitRate:1e3*(d>=16&&d<=1e4?d:xW(s,c,u)),width:s,height:c},layout:{canvas:{bgnd:o(["layout","backgroundColor"],(function(e){return/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(e)}))},regions:(null===(n=t.layout)||void 0===n||null===(i=n.regions)||void 0===i?void 0:jm(i).call(i,(function(e){var t,r;return{alpha:!e.alpha||Number(e.alpha)>1||Number(e.alpha)<=0?1:Number(e.alpha),uid:e.userId,zorder:!e.zorder||Number(e.zorder)<0||Number(e.zorder)>100?0:Number(e.zorder),x:!e.x||Number(e.x)>=1||Number(e.x)<0?0:Number(e.x),y:!e.y||Number(e.y)>=1||Number(e.y)<0?0:Number(e.y),w:!e.w||Number(e.w)>1||Number(e.w)<=0?1:Number(e.w),h:!e.h||Number(e.h)>1||Number(e.h)<=0?1:Number(e.h),renderMode:e.renderMode&&mk(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&mk(r=[0,1,2]).call(r,e.contentControl)?e.contentControl:0,screen:!!e.isScreenStream}})))||[],app_data:o(["layout","appData"],(function(e){return"string"==typeof e}))}}}}var PW,NW={getDefaultValue:CW,checkStartParams:function(e){var t;OW(e.url),MW(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&OW(e.url),MW(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return DW("started",e)},getUpdateParams:function(e){return DW("layoutChanged",e)}},LW=ad,UW=tc,VW=function(e,t,r,n){for(var i,o=n>1?void 0:n?UW(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&&LW(t,r,o),o},FW=new Nw("Engine",0),BW=function(e){DI(ke,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D,P,N,L,U,V,F,B,j,H,G,z,K,X,W,q,Y,J,Q,Z,$,ee,te,re,ne,ie,oe,ae,se,ce,ue,de,le,he,pe,ve,fe,_e,me,ye,ge,Se,be,Ee=QI(ke);function ke(e,t,r){var n;return Vl(this,ke),Jd(tI(n=Ee.call(this)),"monitor",void 0),Jd(tI(n),"_room",void 0),Jd(tI(n),"_publicStreamManager",void 0),Jd(tI(n),"_appId",void 0),Jd(tI(n),"_businessId",void 0),Jd(tI(n),"_visibility",!0),Jd(tI(n),"_localVideoTrack",void 0),Jd(tI(n),"_localAudioTrack",void 0),Jd(tI(n),"_localImgVideoTrack",void 0),Jd(tI(n),"_localImgScreenTrack",void 0),Jd(tI(n),"_localScreenVideoTrack",void 0),Jd(tI(n),"_localScreenAudioTrack",void 0),Jd(tI(n),"_tempMixingAudioTrack",void 0),Jd(tI(n),"_localAudioVolume",100),Jd(tI(n),"_localScreenAudioVolume",100),Jd(tI(n),"_remoteAudioVolume",new $S),Jd(tI(n),"_remoteScreenAudioVolume",new $S),Jd(tI(n),"_publicAudioVolume",new $S),Jd(tI(n),"_videoPlayer",void 0),Jd(tI(n),"_screenPlayer",void 0),Jd(tI(n),"_remoteVideoPlayer",new $S),Jd(tI(n),"_remoteScreenPlayer",new $S),Jd(tI(n),"_remoteAudioPlayer",new $S),Jd(tI(n),"_remoteScreenAudioPlayer",new $S),Jd(tI(n),"_publicStreamAudioPlayer",new $S),Jd(tI(n),"_publicStreamVideoPlayer",new $S),Jd(tI(n),"_publicStreamIds",new $S),Jd(tI(n),"_roomConfig",void 0),Jd(tI(n),"_videoStreamConstraints",DD),Jd(tI(n),"_audioStreamConstraints",{}),Jd(tI(n),"_enableSimulcast",!1),Jd(tI(n),"_videoStreamEncodeConfig",[DD]),Jd(tI(n),"_screenStreamEncodeConfig",[PD]),Jd(tI(n),"_dummyMainImage",void 0),Jd(tI(n),"_dummyScreenImage",void 0),Jd(tI(n),"_trackSourceType",void 0),Jd(tI(n),"_liveTranscodeConfig",void 0),Jd(tI(n),"_startCloudProxyTimestamp",void 0),Jd(tI(n),"_localVideoDeviceId",void 0),Jd(tI(n),"_localAudioDeviceId",void 0),Jd(tI(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),Jd(tI(n),"_audioVolumeIndicationTimer",void 0),Jd(tI(n),"_dummyMainTimer",void 0),Jd(tI(n),"_dummyScreenTimer",void 0),Jd(tI(n),"_audioPropertiesReportTimer",null),Jd(tI(n),"_mirrorType",hl.MIRROR_TYPE_RENDER),Jd(tI(n),"_audioMixingManager",void 0),Jd(tI(n),"_pubLock",void 0),Jd(tI(n),"_rtmClient",void 0),Jd(tI(n),"_messageStatisticsObserver",void 0),Jd(tI(n),"_tempRoomInfo",void 0),Jd(tI(n),"_originIceConfigRequestUrls",void 0),Jd(tI(n),"_originConfigServerUrls",void 0),Jd(tI(n),"_originLogServerUrl",void 0),Jd(tI(n),"_extensionManager",void 0),Jd(tI(n),"_audioDeviceManager",void 0),Jd(tI(n),"_remoteVideoConfig",new $S),Jd(tI(n),"_cameraCapturing",!1),Jd(tI(n),"_interruptCameraCapture",!1),Jd(tI(n),"_micCapturing",!1),Jd(tI(n),"_interruptMicCapture",!1),Jd(tI(n),"_config",void 0),Jd(tI(n),"_needClosePreTrack",!1),Jd(tI(n),"_ctx",void 0),Jd(tI(n),"_updateMixAudioTrack",function(){var e=Rm(Tm().mark((function e(t){var r,i,o=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:Ml.PLAYOUT_AND_PUBLISH,FW.info("_updateMixAudioTrack()"),n._localAudioTrack){e.next=5;break}return t&&(n._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(n._localAudioTrack.mixType=i,n._localAudioTrack.mixedAudioTrack=t):(delete n._localAudioTrack.mixType,delete n._localAudioTrack.mixedAudioTrack),null===(r=n._room)||void 0===r||!r.hasPublished){e.next=9;break}return e.next=9,n._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),Jd(tI(n),"_onAudioMixingMessage",(function(e){n.safeEmit(Nl.onAudioMixingStateChanged,e)})),Jd(tI(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(Nl.onAutoplayFailed,e)})),n.id=t,n._appId=e,n._pubLock=new AH("pubLock"),n._addDeviceEventHandler(),n._extensionManager=new iV(t),n._audioDeviceManager=new IW(n._extensionManager),n._audioMixingManager=new yW({getLocalAudioTrack:function(){return n._localAudioTrack},updateLocalAudioTrack:n._updateMixAudioTrack,emitMessage:n._onAudioMixingMessage,onAutoPlayFailed:n._onAudioMixingAutoplayFailed},t),n._ctx={id:t,appId:e,avSync:!0,streamRTT:{},useCloudProxy:!1,audioProfileManager:new EW(e),userPriority:new $S,expectedIDC:null==r?void 0:r.expectedIDC,joinRoomConfig:new TD(t),enableFallbackHandler:zW(e),enableStandardHandler:KW(e),pcKillSwitch:Zd(Zd({ctor_sdpsemantics_add:!0,ctor_encodedinsetablestream_add:!0,sld_rtcpfb_rrtr_add:!0,sld_ext_sdesmid_remove:!0,sld_fmtp_sps_add:!0,sld_fmtp_bitrate_add:!0,sld_fmtp_opus_add:!0},OD("PC_KILLSWITCH")),GW(n._appId))},window.__rtc_engine__=tI(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=tI(n),n._trackSourceType={video:$d.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:$d.VIDEO_SOURCE_TYPE_INTERNAL,audio:el.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:el.AUDIO_SOURCE_TYPE_INTERNAL},n._config=r,n._rtmClient=new bW(n._ctx),n._handleRTMClient(n._rtmClient),n._handleAudioDeviceManager(),n._messageStatisticsObserver=new CO(t),n.monitor=VO(t),wO.createRTSMsgReportor(n.id),n._getServerConfig(),n}return Ul(ke,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(be=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("updateToken()","token: %s",t),UD(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return n=this._tempRoomInfo,i=n.config,o=n.userInfo,a=n.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,a,o,i);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new mA(pA.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,null===(r=this._room)||void 0===r?void 0:r.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return be.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(Se=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("setVideoCaptureDevice()","deviceId: %s",t),UD(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:return r=XB({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},nD&&XM&&pD>=85&&pD<=91&&(null===(n=this._videoPlayer)||void 0===n||n.removeTrack()),this._needClosePreTrack=this._needClosePreTrack||nD&&XM,this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),FW.info("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=13,AV(r,this._extensionManager).catch((function(e){if(o._localVideoTrack&&!o._localVideoTrack.dummy)return FW.warn("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),o._removeLocalTrackEvents(o._localVideoTrack),o._localVideoTrack.close(),delete o._localVideoTrack,AV(r,o._extensionManager).then((function(e){return o._needClosePreTrack=!0,e})).catch(Rm(Tm().mark((function t(){var r;return Tm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return FW.error("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,AV(o._videoStreamConstraints,o._extensionManager);case 3:throw r=t.sent,o._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 13:return i=e.sent,FW.success("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=r,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),e.next=19,this._switchTrack(i);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return Se.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(ge=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("setAudioCaptureDevice()","deviceId: %s",t),UD(t,"deviceId"),this._localAudioDeviceId=t,this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.prev=8,this._micCapturing=!0,e.next=12,CV(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 12:if(i=e.sent,!this._interruptMicCapture){e.next=18;break}return this._interruptMicCapture=!1,i.close(),this._localAudioTrack=void 0,e.abrupt("return");case 18:if(this._initLocalTrackEvents(i),this._localAudioTrack=i,this._localAudioTrack.setVolume(this._localAudioVolume),this._room){e.next=23;break}return e.abrupt("return");case 23:if(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.pubAudio){e.next=26;break}return e.next=26,this._updatePublish();case 26:return e.prev=26,this._micCapturing=!1,e.finish(26);case 29:case"end":return e.stop()}}),e,this,[[8,,26,29]])}))),function(e){return ge.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){qU.on(Nl.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),qU.on(Nl.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D,P,N=this;null===(e=this._room)||void 0===e||e.on(SH.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(SH.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(SH.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(wH.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(wH.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(wH.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(SH.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(SH.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(SH.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(SH.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(SH.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?N._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?N._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&N._onLiveTranscodingResult(e)})),null===(l=this._room)||void 0===l||l.on(EH.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(EH.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return N.safeEmit(Nl.onVendorConnectionStateChanged,e)})),null===(p=this._room)||void 0===p||p.on(wH.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(v=this._room)||void 0===v||v.on(wH.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(wH.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(_=this._room)||void 0===_||_.on(wH.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=N._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&N.safeEmit(Nl.onAutoPublishResult,e)})),null===(m=this._room)||void 0===m||m.on(wH.ON_REMOTE_STREAM_STATS,(function(e){N.safeEmit(Nl.onRemoteStreamStats,e)})),null===(y=this._room)||void 0===y||y.on(wH.ON_LOCAL_STREAM_STATS,(function(e){N.safeEmit(Nl.onLocalStreamStats,e)})),null===(g=this._room)||void 0===g||g.on(wH.ON_SUBTITLE_STATE_CHANGED,(function(e){N.safeEmit(Nl.onSubtitleStateChanged,e)})),null===(S=this._room)||void 0===S||S.on(wH.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){N.safeEmit(Nl.onSubtitleMessageReceived,e)})),null===(b=this._room)||void 0===b||b.on(wH.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(E=this._room)||void 0===E||E.on(wH.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;N._updateAudioPlayerState(t),N.safeEmit(Nl.onUserStartAudioCapture,{userId:r})})),null===(k=this._room)||void 0===k||k.on(wH.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;N.safeEmit(Nl.onUserStopAudioCapture,{userId:t})})),null===(T=this._room)||void 0===T||T.on(wH.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;N.safeEmit(Nl.onUserStartVideoCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(wH.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;N.safeEmit(Nl.onUserStopVideoCapture,{userId:t})})),null===(R=this._room)||void 0===R||R.on(wH.ON_SEI_MESSAGED_RECEIVED,(function(e){N.safeEmit(Nl.onSEIMessageReceived,e)})),null===(A=this._room)||void 0===A||A.on(wH.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){N.safeEmit(Nl.onRemoteVideoSizeChanged,e,t)})),null===(w=this._room)||void 0===w||w.on(wH.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return N.safeEmit(Nl.onSimulcastSubscribeFallback,e)})),null===(C=this._room)||void 0===C||C.on(wH.RECONNECT_FAILED,(function(){N.safeEmit(Nl.onError,{errorCode:pA.RECONNECT_FAILED})})),null===(x=this._room)||void 0===x||x.on(wH.ON_VIDEO_STREAM_BANNED,(function(e){N.safeEmit(Nl.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(O=this._room)||void 0===O||O.on(wH.ON_AUDIO_STREAM_BANNED,(function(e){N.safeEmit(Nl.onAudioStreamBanned,{uid:e.uid,banned:e.banned})})),null===(M=this._room)||void 0===M||M.on(wH.ON_FORWARD_STREAM_ERROR,(function(e){N.safeEmit(Nl.onForwardStreamError,e)})),null===(D=this._room)||void 0===D||D.on(wH.ON_REJOIN_WITH_TCP,(function(){N.safeEmit(Nl.onRejoinWithTcp)})),null===(P=this._room)||void 0===P||P.on(wH.ON_ICE_CONNECT_WITH_TCP,(function(){N.safeEmit(Nl.onIceConnectWithTcp)}))}},{key:"safeEmit",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return ZD(e)&&BO(this.id,e,i),(t=OI(CI(ke.prototype),"safeEmit",this)).call.apply(t,Om(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(ye=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._room){e.next=2;break}return e.abrupt("return",!1);case 2:return this._room=new VG({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:bl.communication},this._ctx),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return ye.apply(this,arguments)})},{key:"joinRoom",value:(me=Rm(Tm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,i),zD(t)||UD(t,"token"),KD(r),qD(n),YD(i=XB({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:bl.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==uG.CONNECTED){e.next=8;break}throw new mA(pA.REPEAT_JOIN,"Already joined");case 8:return null===(a=this.monitor)||void 0===a||a.report("rtc_sdk_api_call",{sdk_api_name:"host",message:location.host,error_code:0}),this._room||(this._room=new VG(i,this._ctx),this._addHandlerEventHandler()),this._room.roomConfig=i,s=this._liveTranscodeConfig&&NW.getStartParams(this._liveTranscodeConfig),c=Zd(Zd({},n),{},{businessId:this._businessId,role:this._visibility?gW.NORMAL_USER:gW.SILENT_USER}),e.prev=13,this._ctx.useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),AG(c),e.next=18,this._room.join(this._appId,r,t,c,s);case 18:return d=e.sent,this._roomConfig=i,this._ctx.audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,null!==(u=i)&&void 0!==u&&u.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:ul.AUDIO_AND_VIDEO}):this.safeEmit(Nl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),wO.setRoomId(this.id,r),wO.setUserId(this.id,n.userId),e.abrupt("return",d);case 28:throw e.prev=28,e.t0=e.catch(13),e.t0.code===pA.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:c}),null===(l=this._room)||void 0===l||l.destroy(),delete this._room,e.t0;case 34:case"end":return e.stop()}}),e,this,[[13,28]])}))),function(e,t,r,n){return me.apply(this,arguments)})},{key:"leaveRoom",value:(_e=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],FW.info("leaveRoom()"),!t){e.next=7;break}return e.next=5,null===(r=this._room)||void 0===r?void 0:r.leave(t);case 5:e.next=8;break;case 7:null===(n=this._room)||void 0===n||n.leave(t).catch();case 8:this._removeHandlerEventHandler(),this._ctx.audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new $S,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new $S,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new $S,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new $S,this._roomConfig=void 0,this._publicStreamIds=new $S,wO.setRoomId(this.id,""),wO.setUserId(this.id,"");case 24:case"end":return e.stop()}}),e,this)}))),function(){return _e.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;FW.info("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,null===(t=this._videoPlayer)||void 0===t||t.destroy(),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._videoStreamEncodeConfig=[DD],this._screenStreamEncodeConfig=[PD],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),wO.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localScreenVideoTrack=void 0),this._localImgVideoTrack&&(this._localImgVideoTrack.stop(),this._localImgVideoTrack=void 0),this._localImgScreenTrack&&(this._localImgScreenTrack.stop(),this._localImgScreenTrack=void 0),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new $S,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new $S,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new $S,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new $S,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new $S,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new $S,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new $S,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new $S,this._ctx.userPriority.clear(),this._extensionManager.destroy(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1,this._ctx.avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(fe=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!CM(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,kV(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return fe.apply(this,arguments)})},{key:"unpublishStream",value:(ve=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("unpublishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!r){e.next=5;break}return e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.unpublish());case 5:return e.next=7,this._updatePublish({mediaType:t,pubState:xH.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return ve.apply(this,arguments)})},{key:"publishScreen",value:(pe=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!CM(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,IV(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:xH.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof mA)){e.next=18;break}throw e.t0;case 18:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return pe.apply(this,arguments)})},{key:"unpublishScreen",value:(he=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.info("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:xH.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return he.apply(this,arguments)})},{key:"subscribeStream",value:(le=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.info("subscribeStream()","userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!1,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return le.apply(this,arguments)})},{key:"_subscribe",value:(de=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),n!==ul.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=5;break}return FW.warn("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 5:if(u=this._room.remoteStreams.get(r),d=null==u?void 0:gE(u).call(u,(function(e){return e.isScreen===t}))){e.next=9;break}throw new mA(pA.STREAM_NOT_EXIST,"stream not exist");case 9:return l=this._pauseAllSubscribeState.audio,h=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&ul.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&ul.VIDEO),FW.warn("subscribeStream()","due to pauseAll mediaType: %o",n),p=d.hasSubscribed,v=this._remoteVideoConfig.get(r)||(null===(o=this._roomConfig)||void 0===o?void 0:o.remoteVideoConfig),d.originalMediaType=n,e.next=19,this._room.subscribe(d,n,v);case 19:wM(n)&&this._updateAudioPlayerState(d),CM(n)&&this._updateVideoPlayerState(d),f=0,_=0,l!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?f|=ul.AUDIO:_|=ul.AUDIO),h!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?f|=ul.VIDEO:_|=ul.VIDEO),f&&this.pauseAllSubscribedStream(f),_&&this.resumeAllSubscribedStream(_),this._pauseAllSubscribeState.resumeStreamIds[d.streamId]=d.streamId,!t&&(null!==(a=this._roomConfig)&&void 0!==a&&a.isAutoSubscribeAudio||null!==(s=this._roomConfig)&&void 0!==s&&s.isAutoSubscribeVideo)&&(d.audioTrack||d.videoTrack)&&(m={userId:r,isScreen:!1,state:il.SUBSCRIBE_SUCC},this.safeEmit(Nl.onAutoSubscribeResult,m)),null!==(c=this._room)&&void 0!==c&&c.multiChatMode||p||!wM(n)||!d.hasAudio||null===(y=d.observer)||void 0===y||y.setSubscribeAudio(!0),!p&&CM(n)&&d.hasVideo&&(null===(g=d.observer)||void 0===g||g.setSubscribeVideo(!0));case 31:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return de.apply(this,arguments)})},{key:"unsubscribeStream",value:(ue=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:FW.info("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this._unsubscribe(!1,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ue.apply(this,arguments)})},{key:"subscribeScreen",value:(ce=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.info("subscribeScreen() userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!0,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ce.apply(this,arguments)})},{key:"unsubscribeScreen",value:(se=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:FW.info("unsubscribeScreen() userId: %o, mediaType: %o",t,r),this._unsubscribe(!0,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return se.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(this._checkMediaType(r),this._assertNotInRoom(),r!==ul.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a,s=this._room.remoteStreams.get(t),c=null==s?void 0:gE(s).call(s,(function(t){return t.isScreen===e}));if(null==c||!c.hasSubscribed)throw new mA(pA.STREAM_NOT_EXIST,"stream not exist");if(nD&&pD&&pD>=85&&pD<=91&&r!==ul.AUDIO)null===(a=e?this._remoteScreenPlayer.get(t):this._remoteVideoPlayer.get(t))||void 0===a||a.stop();return this._room.unsubscribe(c,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[c.streamId]}))}FW.warn("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(ae=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.info("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),XD(t),$D(r),this._remoteVideoConfig.set(t,r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.updateSubVideoConfig(t,r).then((function(){})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return ae.apply(this,arguments)})},{key:"startVideoCapture",value:(oe=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("startVideoCapture()","deviceId: %s",t),zD(t)||UD(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!(this._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=8;break}throw new mA(pA.REPEAT_CAPTURE,"Has already capture");case 8:return a=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?a.facingMode=t:a.deviceId={exact:t},this._videoStreamConstraints=a),s={},e.prev=11,this._cameraCapturing=!0,e.next=15,AV(a,this._extensionManager);case 15:if(u=e.sent,!this._interruptCameraCapture){e.next=22;break}throw this._interruptCameraCapture=!1,this._removeLocalTrackEvents(u),this._localVideoTrack=void 0,u.close(),new mA(pA.INTERRUPT,"interrupt by stopVideoCapture");case 22:if(this._initLocalTrackEvents(u),this._localVideoTrack=u,null===(c=this._videoPlayer)||void 0===c||c.playVideo(u),(d=null==u?void 0:u.getTrack())&&(s=d.getSettings(),l={width:s.width,height:s.height},this._localVideoTrack.resolution=l,setTimeout((function(){return p.safeEmit(Nl.onLocalVideoSizeChanged,{streamIndex:cl.STREAM_INDEX_MAIN,info:l})}))),this._room){e.next=29;break}return e.abrupt("return",s);case 29:return e.prev=29,this._cameraCapturing=!1,e.finish(29);case 32:return h=this._room._roomConfig.isAutoPublish,(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubVideo||h)&&(this._visibility?this._updatePublish():this.safeEmit(Nl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableVideo(!0),e.abrupt("return",s);case 36:case"end":return e.stop()}}),e,this,[[11,,29,32]])}))),function(e){return oe.apply(this,arguments)})},{key:"stopVideoCapture",value:(ie=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("stopVideoCapture()"),!this._cameraCapturing){e.next=5;break}return this._interruptCameraCapture=!0,FW.warn("stopVideoCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 7:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),this._localVideoTrack&&(this._localVideoTrack.dummy||((s=this._extensionManager.getPluginByName(nV.PRE_PROCESSING,"RTCBeautyExtension"))&&s.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(null===(c=this._localVideoTrack)||void 0===c||c.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=11;break}return e.abrupt("return");case 11:if(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.pubVideo){e.next=14;break}return e.next=14,this._updatePublish();case 14:null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setEnableVideo(!1);case 15:case"end":return e.stop()}}),e,this)}))),function(){return ie.apply(this,arguments)})},{key:"startAudioCapture",value:(ne=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("startAudioCapture()","deviceId: $o",t),zD(t)||UD(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,this._trackSourceType.audio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:if(!this._micCapturing&&!this._localAudioTrack){e.next=8;break}throw new mA(pA.REPEAT_CAPTURE,"Has already capture");case 8:return t&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),a={},e.prev=10,this._micCapturing=!0,e.next=14,CV(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 14:if(s=e.sent,!this._interruptMicCapture){e.next=21;break}throw this._interruptMicCapture=!1,this._removeLocalTrackEvents(s),s.close(),this._localAudioTrack=void 0,new mA(pA.INTERRUPT,"interrupt by stopAudioCapture");case 21:if(this._initLocalTrackEvents(s),this._localAudioTrack=s,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),s.getOrgTrack()&&(a=s.getOrgTrack().getSettings()),this._room){e.next=28;break}return e.abrupt("return",a);case 28:return e.prev=28,this._micCapturing=!1,e.finish(28);case 31:return c=this._room._roomConfig.isAutoPublish,(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubAudio||c)&&(this._visibility?this._updatePublish():this.safeEmit(Nl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableAudio(!0),e.abrupt("return",a);case 35:case"end":return e.stop()}}),e,this,[[10,,28,31]])}))),function(e){return ne.apply(this,arguments)})},{key:"stopAudioCapture",value:(re=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("stopAudioCapture()"),!this._micCapturing){e.next=5;break}return this._interruptMicCapture=!0,FW.warn("stopAudioCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.audio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._room){e.next=12;break}return e.abrupt("return");case 12:if(null===(t=this._room)||void 0===t||null===(r=t.localStream)||void 0===r||!r.pubAudio){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return re.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return FW.info("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(te=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m=this,y=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=y.length>0&&void 0!==y[0]?y[0]:{},FW.info("startScreenCapture()","config: %o",c),u=c.enableAudio,d=void 0!==u&&u,this._trackSourceType.screenVideo!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,OV(d,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(l=e.sent,h=eI(l,2),p=h[0],null==(v=h[1])||v.setVolume(this._localScreenAudioVolume),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(t=this._localScreenAudioTrack)||void 0===t||t.close(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=p,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&p.setContentHint(null===(f=this._screenStreamEncodeConfig[0])||void 0===f?void 0:f.contentHint),(_=null==p?void 0:p.getTrack())&&setTimeout((function(){var e=_.getSettings(),t={width:e.width,height:e.height};p.resolution=t,m.safeEmit(Nl.onLocalVideoSizeChanged,{streamIndex:cl.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),v&&(this._localScreenAudioTrack=v,this._initLocalTrackEvents(v)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),!(null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubAudio||null!==(a=this._room)&&void 0!==a&&null!==(s=a.localScreenStream)&&void 0!==s&&s.pubVideo)){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return te.apply(this,arguments)})},{key:"stopScreenCapture",value:(ee=Rm(Tm().mark((function e(){var t,r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localImgScreenTrack&&(null===(a=this._localScreenVideoTrack)||void 0===a||a.setTrack(this._localImgScreenTrack,this._extensionManager),this._localScreenVideoTrack.dummy=!0))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,!(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localScreenStream)&&void 0!==n&&n.pubAudio||null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubVideo)){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return ee.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(FW.info("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),VD(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,i,o,a=Zd(Zd({userId:this._getUserId()},t),{},{isLocal:!0});if(JD(a),e===cl.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new zG(this.id,a),this._initPlayerEvents(this._videoPlayer,!1,e),this._videoPlayer.mirror(!!this._mirrorType),this._localVideoTrack&&!this._localVideoTrack.dummy&&(null===(r=this._config)||void 0===r?void 0:r.autoPlayPolicy)!==kl.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),(null===(n=this._room)||void 0===n?void 0:n.localStream)&&(this._room.localStream.videoDom=this._videoPlayer.domElement),this._videoPlayer.domElement;if(e===cl.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new zG(this.id,Zd(Zd({},a),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==kl.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),(null===(o=this._room)||void 0===o?void 0:o.localScreenStream)&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),this._screenPlayer.domElement;if(t&&void 0!==t.renderMode){var s=e===cl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer;null==s||s.setRenderMode(t.renderMode)}}else{var c,u;e===cl.STREAM_INDEX_MAIN?(null===(c=this._videoPlayer)||void 0===c||c.destroy(!0),delete this._videoPlayer):(null===(u=this._screenPlayer)||void 0===u||u.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:($=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("startLiveTranscoding()","transcode: %o",t),NW.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.roomInfo)&&n.roomId.length+n.userInfo.userId.length>126)){e.next=6;break}throw new mA(pA.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(Nl.onStreamMixingEvent,{event:CH.START,error:0,message:""}),!this._room||this._room.connectionState!==uG.CONNECTED){e.next=11;break}return e.next=11,null===(i=this._room)||void 0===i?void 0:i.liveControlMessage(NW.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof mA)){e.next=19;break}throw e.t0;case 19:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return $.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(Z=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=XB({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,NW.checckUpdateParams(i),this._liveTranscodeConfig=XB(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(Nl.onStreamMixingEvent,{event:CH.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(NW.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof mA)){e.next=21;break}throw e.t0;case 21:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return Z.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(Q=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(Nl.onStreamMixingEvent,{event:CH.STOP,error:0,message:""}),e.next=8,null===(t=this._room)||void 0===t?void 0:t.liveControlMessage({action:"stopped",type:"transcode"});case 8:e.next=17;break;case 10:if(e.prev=10,e.t0=e.catch(4),!(e.t0 instanceof mA)){e.next=16;break}throw e.t0;case 16:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return Q.apply(this,arguments)})},{key:"startSubtitle",value:(J=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.info("startSubtitle()","config: %o",t),this._assertNotInRoom(),e.next=4,null===(r=this._room)||void 0===r?void 0:r.startSubtitle(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return J.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;FW.info("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return FW.info("setBusinessId()","businessId: %s",e),!function(e){return"string"!=typeof e}(e)&&!this._room&&(this.monitor.set({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(Y=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("setUserVisibility()","enable: %o",t),t=!!t,this._visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._visibility=t,e.abrupt("return");case 7:if(this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),e.t0=!t,!e.t0){e.next=13;break}return e.next=13,this._room.unpublish();case 13:return e.next=15,this._room.updateUserAttributes({role:t?gW.NORMAL_USER:gW.SILENT_USER});case 15:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:ul.AUDIO_AND_VIDEO});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return Y.apply(this,arguments)})},{key:"_initPlayerEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:cl.STREAM_INDEX_MAIN,i=n===cl.STREAM_INDEX_SCREEN;e.on("playback_event",(function(n){switch(n.eventName){case"timeupdate":return;case"loadeddata":if("audio"===n.type){var o,a,s=e.userId.replace("_screen",""),c=null===(o=t._room)||void 0===o||null===(a=o.remoteStreams.get(s))||void 0===a?void 0:gE(a).call(a,(function(e){return e.isScreen===i})),u=function(){r?t.safeEmit(Nl.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(Nl.onAudioFirstFrameDecoded,{userId:s,isScreen:i}),t.safeEmit(Nl.onRemoteAudioFirstFrame,{userId:s,isScreen:i})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:i})};c&&c.observer&&!c.observer.audioFirstFrameReceived?c.observer.once("recvAudioFirstFrame",u):u()}else{var d,l,h={userId:e.userId,height:(null===(d=e.domElement)||void 0===d?void 0:d.videoHeight)||0,width:(null===(l=e.domElement)||void 0===l?void 0:l.videoWidth)||0,isScreen:i};r?(h.publicStreamId=h.userId,delete h.userId,delete h.isScreen,t.safeEmit(Nl.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(Nl.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(Nl.onVideoFirstFrameRendered,h),t.safeEmit(Nl.onVideoFirstFrameDecoded,h),t.safeEmit(Nl.onRemoteVideoFirstFrame,h)),t.monitor.report("first_remote_video_render",{stream_id:"",stream_user_id:n.userId||""},{isScreen:i})}break;case"autoplay-error":return r&&(n.publicStreamId=n.userId),jO(t.id,"autoplay-error",e instanceof zG?"video":"audio",0,n.userId||""),void t.safeEmit(Nl.onAutoplayFailed,{userId:n.userId,kind:e instanceof zG?"video":"audio",mediaType:e instanceof zG?ul.VIDEO:ul.AUDIO,streamIndex:e.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN})}t.safeEmit(Nl.onPlayerEvent,n)}))}},{key:"_initLocalTrackEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];["track-ended","track-mute","track-unmute"].forEach((function(r){e.on(r,function(){var e=Rm(Tm().mark((function e(n){var i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.monitor.report("rtc_error",{message:Om(i="track-".concat(r," mediaType: ")).call(i,n.getTrack().kind),error_code:NH.TRACK_ERROR,capture_session_id:n.captureSessionId,media_type:r,reason:r}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),a=n.getTrack(),s=a.kind,t.safeEmit({"track-ended":Nl.onTrackEnded,"track-mute":Nl.onTrackMute,"track-unmute":Nl.onTrackUnmute}[r],{kind:s,isScreen:o}),!rD&&!ZM){e.next=13;break}if("track-mute"!==r){e.next=12;break}if(ZU.emit(JU.ON_IOS_LOCAL_TRACK_MUTE,s),"audio"!==s){e.next=12;break}return e.next=11,t.stopAudioCapture();case 11:t.startAudioCapture();case 12:"track-unmute"===r&&ZU.emit(JU.ON_IOS_LOCAL_TRACK_UNMUTE,s);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),e.on("resolution-change",(function(e){t._extensionManager.getPluginsByType(nV.PRE_PROCESSING).forEach((function(t){var r;null==t||null===(r=t.applyConstraints)||void 0===r||r.call(t,e)})),t.safeEmit(Nl.onLocalVideoSizeChanged,{streamIndex:r?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN,info:e})}))}},{key:"_removeLocalTrackEvents",value:function(e){e.removeAllListeners("track-ended"),e.removeAllListeners("track-mute"),e.removeAllListeners("track-unmute"),e.removeAllListeners("resolution-change")}},{key:"setRemoteVideoPlayer",value:function(e,t){FW.info("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),VD(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),JD(t);var r,n,i,o=t.userId;if(e===cl.STREAM_INDEX_MAIN){var a,s,c;if(null===(a=this._remoteVideoPlayer.get(o))||void 0===a||a.destroy(),!t.renderDom)return;var u=new zG(this.id,t);this._initPlayerEvents(u,!1,e),this._remoteVideoPlayer.set(o,u);var d=null===(s=this._room)||void 0===s||null===(c=s.remoteStreams.get(o))||void 0===c?void 0:gE(c).call(c,(function(e){return!e.isScreen}));return d&&(this._updateVideoPlayerState(d),d.videoDom=u.domElement),u.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var l=new zG(this.id,Zd(Zd({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(o,l),this._initPlayerEvents(l,!1,e);var h=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(o))||void 0===i?void 0:gE(i).call(i,(function(e){return e.isScreen}));return h&&(this._updateVideoPlayerState(h),h.videoDom=l.domElement),l.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){FW.info("setLocalVideoMirrorType()","mirrorType: %o",e),VD(e,"mirrorType",[hl.MIRROR_TYPE_NONE,hl.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(q=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.info("setAudioPlaybackDevice()","deviceId: %s",t),UD(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(Nl.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:Nm(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return q.apply(this,arguments)})},{key:"play",value:(W=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=y.length>1&&void 0!==y[1]?y[1]:ul.AUDIO_AND_VIDEO,a=y.length>2?y[2]:void 0,FW.info("play()","userId: %s, mediaType: %s, streamIndex: %s",t,o,a),s=!t||t===this._getUserId()||"local_user"===t,c=void 0===a||a===cl.STREAM_INDEX_MAIN,u=void 0===a||a===cl.STREAM_INDEX_SCREEN,d=o!==ul.VIDEO,l=o!==ul.AUDIO,h=[],s&&l&&(c&&this._localVideoTrack&&(null===(p=this._videoPlayer)||void 0===p||p.mirror(!!this._mirrorType),h.push(null===(v=this._videoPlayer)||void 0===v?void 0:v.manuallyPlay())),u&&this._localScreenVideoTrack&&h.push(null===(f=this._screenPlayer)||void 0===f?void 0:f.manuallyPlay())),t===(null===(r=this._audioMixingManager)||void 0===r?void 0:r.id)&&h.push(this._audioMixingManager.resumeLocalPlay()),_=null===(n=this._room)||void 0===n?void 0:n.remoteStreams,l&&c&&h.push(XG(this._remoteVideoPlayer,t,!1,_)),l&&u&&h.push(XG(this._remoteScreenPlayer,t,!0,_)),d&&c&&h.push(XG(this._remoteAudioPlayer,t,!1,_)),l&&u&&h.push(XG(this._remoteScreenAudioPlayer,t,!0,_)),m=null===(i=this._publicStreamManager)||void 0===i?void 0:i.remoteStreams,d&&h.push(XG(this._publicStreamVideoPlayer,t,!1,m)),l&&h.push(XG(this._publicStreamAudioPlayer,t,!1,m)),e.abrupt("return",Y_.all(h).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return W.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(X=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),wM(t)&&(s._pauseAllSubscribeState.audio=!0),CM(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",Y_.resolve());case 6:n=[],i=$T(oR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(e.hasSubscribed){s._pauseAllSubscribeState.resumeStreamIds[e.streamId]=e.streamId;var r=s._unsubscribe(e.isScreen,e.userId,t,!0);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",Y_.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return X.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(K=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.info("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),wM(t)&&(s._pauseAllSubscribeState.audio=!1),CM(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",Y_.resolve());case 6:n=[],i=$T(oR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(s._pauseAllSubscribeState.resumeStreamIds[e.streamId]){delete s._pauseAllSubscribeState.resumeStreamIds[e.streamId];var r=s._subscribe(e.isScreen,e.userId,t);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",Y_.all(n).then((function(){var e,t;null===(e=s._room)||void 0===e||null===(t=e.remoteStreams)||void 0===t||t.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){s._updateAudioPlayerState(e),s._updateVideoPlayerState(e)}))}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return K.apply(this,arguments)})},{key:"sendUserMessage",value:(z=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XD(t),QD(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!1,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!1,o,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return z.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(G=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XD(t),jD(r,"message"),QD(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 G.apply(this,arguments)})},{key:"sendRoomMessage",value:(H=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return QD(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 H.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(j=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return QD(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t,!0))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return j.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(B=Rm(Tm().mark((function e(){var t,r=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.length>0&&void 0!==r[0]?r[0]:{},FW.info("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,HD(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._ctx.audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return B.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(F=Rm(Tm().mark((function e(){var t,r=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},FW.info("setVideoCaptureConfig()","config: %o",t),e.abrupt("return",this._setVideoCaptureConfig(t));case 3:case"end":return e.stop()}}),e,this)}))),function(){return F.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(V=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,HD(r),n=Zd(Zd({},r),{},{deviceId:this._videoStreamConstraints.deviceId}),!this._localVideoTrack){e.next=7;break}return e.next=7,this._localVideoTrack.updateVideoCaptureConfig(n);case 7:return this._videoStreamConstraints=n,e.abrupt("return",(null===(t=this._localVideoTrack)||void 0===t?void 0:t.getTrack().getSettings())||{});case 9:case"end":return e.stop()}}),e,this)}))),function(){return V.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return FW.info("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==(null==dD?void 0:dD[0])&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&NM("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(U=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(FW.info("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),tP(t=Hs(t).call(t,(function(e){return!!e}))),t.length>3&&(NM("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=km(t).call(t,0,3)),n=1;n<t.length;n++)i=LM(t[0].width)/LM(t[n].width)||1,Math.floor(i)!==i&&NM("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");HR(t).call(t,(function(e,t){return t.maxKbps-e.maxKbps})),this._setVideoCaptureConfig(Zd({},t[0])),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(cl.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 11:case"end":return e.stop()}}),e,this)}))),function(e){return U.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(L=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:FW.info("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&(this._localScreenVideoTrack.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(cl.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(FW.info("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!lL())throw new mA(pA.NOT_SUPPORTED,"Browser does not support sending SEI");VD(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),LD(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(pM.str2ab(t)):t;if(t.length){var i;if(e===cl.STREAM_INDEX_MAIN){var o,a,s;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=null===(s=this._room)||void 0===s?void 0:s.localStream}else{var c,u,d;if(null===(c=this._room)||void 0===c||null===(u=c.localScreenStream)||void 0===u||!u.hasPublished)return;i=null===(d=this._room)||void 0===d?void 0:d.localScreenStream}if(n.byteLength>4096)FW.warn("sei size must not bigger than 4KB");else{var l=dM();i.seiList.push({content:n,uuid:l,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=QR(e=i.seiList).call(e,(function(e){return e.uuid===l}));if(r)rk(t=i.seiList).call(t,r,1)}}),2e3)}}else FW.warn("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;FW.info("setAudioVolumeIndicationInterval()","interval %o: ",e),("number"!=typeof e||e<200)&&(e=200);var r=[];this._audioVolumeIndicationTimer&&clearInterval(this._audioVolumeIndicationTimer),this._audioVolumeIndicationTimer=setInterval((function(){var e,n;r=[],null===(e=t._room)||void 0===e||e.remoteStreams.forEach((function(e,t){var n;if(0!==e.length){var i=gE(e).call(e,(function(e){return!e.isScreen})),o=null==i||null===(n=i.audioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t,volume:o||0})}}));var i=null===(n=t._localAudioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t._getUserId(),volume:i||0}),t.safeEmit(Nl.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=pb(t).call(t,(function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=n?i?n.audioPropertiesInfo.nonlinearVolume>i.audioPropertiesInfo.nonlinearVolume?n:i:n:i)&&r.audioPropertiesInfo.nonlinearVolume>-35){var o,a;if(r.streamKey)o=this._room.remoteUsers.get(r.streamKey.userId);else o=null===(a=this._room._roomInfo)||void 0===a?void 0:a.userInfo;o&&this.safeEmit(Nl.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};FW.info("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.interval,o=void 0===i?100:i;this._stopAudioPropertiesReport(),o<=0||(o=Math.max(100,o),this._audioPropertiesReportTimer=self.setInterval((function(){if(n||"hidden"!==document.visibilityState){var t=[],r=e._audioDeviceManager.getRecordTrack()||e._localAudioTrack;if(r){var i=r.getAudioLevel();t.push({streamIndex:cl.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:i,nonlinearVolume:AM(i)}})}if(e._localScreenAudioTrack){var o=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:cl.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:o,nonlinearVolume:AM(o)}})}if(e.safeEmit(Nl.onLocalAudioPropertiesReport,t),e._room){var a,s=[];if(null!==(a=e._room)&&void 0!==a&&a.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i=255*t.audioLevel;s.push({streamKey:{userId:t.userId,streamIndex:cl.STREAM_INDEX_MAIN,roomId:null===(r=e._room)||void 0===r||null===(n=r._roomInfo)||void 0===n?void 0:n.roomId},audioPropertiesInfo:{linearVolume:i,nonlinearVolume:AM(i)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();s.push({streamKey:{userId:r,streamIndex:t.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN,roomId:null===(n=e._room)||void 0===n||null===(i=n.roomInfo)||void 0===i?void 0:i.roomId},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:AM(o)}})}}))}));e.safeEmit(Nl.onRemoteAudioPropertiesReport,s),e._sendActiveSpeaker(t,Hs(s).call(s,(function(e){return e.streamKey.streamIndex!==cl.STREAM_INDEX_SCREEN})))}}}),o))}},{key:"setVideoSourceType",value:(N=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),VD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),VD(r,"VideoSourceType",[$d.VIDEO_SOURCE_TYPE_EXTERNAL,$d.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===cl.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,FW.print("setVideoSourceType",Om(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==cl.STREAM_INDEX_MAIN){e.next=17;break}if(u=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(u=!0,(d=this._extensionManager.getPluginByName(nV.PRE_PROCESSING,"RTCBeautyExtension"))&&d.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(o=this._videoPlayer)||void 0===o||o.stop(),this._localVideoTrack=void 0,l=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,u?null===(h=this._room)||void 0===h||null===(p=h.localStream)||void 0===p||null===(v=p.observer)||void 0===v||v.setEnableVideo(!1):null===(f=this._room)||void 0===f||null===(_=f.localStream)||void 0===_||null===(m=_.observer)||void 0===m||m.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubVideo||l)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==cl.STREAM_INDEX_SCREEN){e.next=26;break}if(b=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(b=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(y=this._screenPlayer)||void 0===y||y.stop(),this._localScreenVideoTrack=void 0,b?null===(E=this._room)||void 0===E||null===(k=E.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setEnableVideo(!1):null===(I=this._room)||void 0===I||null===(R=I.localScreenStream)||void 0===R||null===(A=R.observer)||void 0===A||A.setPushVideo(!1),null===(g=this._room)||void 0===g||null===(S=g.localScreenStream)||void 0===S||!S.pubVideo){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return N.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(P=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.print("setExternalVideoTrack()","index: %o, track: %o",t,r),VD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),FD(r),t!==cl.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.video===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,PV(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,this._initLocalTrackEvents(this._localVideoTrack),null===(n=this._videoPlayer)||void 0===n||n.playVideo(this._localVideoTrack),s=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,!(null!==(o=this._room)&&void 0!==o&&null!==(a=o.localStream)&&void 0!==a&&a.pubVideo||s)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(t!==cl.STREAM_INDEX_SCREEN){e.next=27;break}if(this._trackSourceType.screenVideo===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 18:return e.next=20,VV(r,this._extensionManager);case 20:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(c=this._screenPlayer)||void 0===c||c.playVideo(this._localScreenVideoTrack),null===(u=this._room)||void 0===u||null===(d=u.localScreenStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setPushVideo(!0),null===(h=this._room)||void 0===h||null===(p=h.localScreenStream)||void 0===p||!p.pubVideo){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return P.apply(this,arguments)})},{key:"setAudioSourceType",value:(D=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),VD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),VD(r,"audioSourceType",[el.AUDIO_SOURCE_TYPE_EXTERNAL,el.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===cl.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,FW.print("setVideoSourceType",Om(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==cl.STREAM_INDEX_MAIN){e.next=16;break}if(c=!1,this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL&&(c=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,u=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,c?null===(d=this._room)||void 0===d||null===(l=d.localStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setEnableAudio(!1):null===(p=this._room)||void 0===p||null===(v=p.localStream)||void 0===v||null===(f=v.observer)||void 0===f||f.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==cl.STREAM_INDEX_SCREEN){e.next=24;break}if(y=!1,this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL&&(y=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,y?null===(g=this._room)||void 0===g||null===(S=g.localScreenStream)||void 0===S||null===(b=S.observer)||void 0===b||b.setEnableAudio(!1):null===(E=this._room)||void 0===E||null===(k=E.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setPushAudio(!1),null===(_=this._room)||void 0===_||null===(m=_.localScreenStream)||void 0===m||!m.pubAudio){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return D.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(M=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.print("setExternalAudioTrack()","index: %o, track: %o",t,r),VD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),FD(r),t!==cl.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,LV(r,this._extensionManager);case 8:if(this._localAudioTrack=e.sent,this._localAudioTrack.setVolume(this._localAudioVolume),this._initLocalTrackEvents(this._localAudioTrack),u=null===(n=this._room)||void 0===n?void 0:n._roomConfig.isAutoPublish,null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setPushAudio(!0),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==cl.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,BV(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(d=this._room)||void 0===d||null===(l=d.localScreenStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setPushAudio(!0),null===(p=this._room)||void 0===p||null===(v=p.localScreenStream)||void 0===v||!v.pubAudio){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return M.apply(this,arguments)})},{key:"login",value:(O=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.info("login()","token: %o, userInfo: %o",t,r),zD(t)||UD(t,"token"),XD(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return O.apply(this,arguments)})},{key:"logout",value:(x=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.info("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"updateLoginToken",value:(C=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.info("updateLoginToken()","token: %o",t),zD(t)||UD(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(w=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.info("getPeerOnlineStatus()","userId: %o",t),XD(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(A=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XD(t),QD(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!1,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return A.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(R=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XD(t),jD(r,"message"),QD(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!0,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"setServerParams",value:(I=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.info("setServerParams()","signature: %o, url: %0",t,r),e.abrupt("return",this._rtmClient.setServerParams(t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return I.apply(this,arguments)})},{key:"sendServerMessage",value:(T=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UD(t,"message"),QD(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!1,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(k=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jD(t,"message"),QD(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!0,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new mA(pA.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");FW.info("startCloudProxy()",e),UD(e.logProxy,"logProxy"),UD(e.accessProxy,"accessProxy"),UD(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=OD("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=OD("LOG_SERVER_URL"),this._originConfigServerUrls=OD("CONFIG_REQUEST_DOMAINS"),xD("ICE_CONFIG_REQUEST_URLS",e.accessProxy),xD("LOG_SERVER_URL",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://".concat(e)),"".concat(e,"/video/v1/webrtc_log/")}(e.logProxy)),xD("CONFIG_REQUEST_DOMAINS",[e.configProxy]),ED.clearAccessNode(this._appId),ED.clearAccessUrls(),this._ctx.useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){var e;if(this._room)throw new mA(pA.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");FW.info("stopCloudProxy()"),xD("ICE_CONFIG_REQUEST_URLS",null===(e=this._originIceConfigRequestUrls)||void 0===e?void 0:jm(e).call(e,(function(e){return e.replace("https://","").replace("/dispatch/v1/AccessInfo?Action=GetAccessInfo","")}))),xD("LOG_SERVER_URL",this._originLogServerUrl),xD("CONFIG_REQUEST_DOMAINS",this._originConfigServerUrls),ED.clearAccessNode(this._appId),ED.clearAccessUrls(),this._ctx.useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(E=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),WD(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new mA(pA.REPEAT_PUSH,"repeat push public media stream");case 5:return o=MD(t,"started",r),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.publicStreamControlMessage(o))||void 0===i?void 0:i.then((function(){a._publicStreamIds.set(t,t)})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return E.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(b=Rm(Tm().mark((function e(t,r){var n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),WD(t),this._assertNotInRoom(),i=MD(t,"layoutChanged",r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.publicStreamControlMessage(i));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"stopPushPublicStream",value:(S=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.print("startPushPublicStream()","publicStreamId: %o",t),WD(t),this._assertNotInRoom(),e.abrupt("return",null===(r=this._room)||void 0===r?void 0:r.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){n._publicStreamIds.delete(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"startPlayPublicStream",value:(g=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(WD(t),this._publicStreamManager){e.next=8;break}return this._publicStreamManager=new kW(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.on(wH.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=c._publicStreamAudioPlayer.get(t.streamId);n&&t.audioTrack&&(n.stop(),n.playAudio(null===(r=e.stream)||void 0===r?void 0:r.audioTrack));var i,o=c._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),null===(r=this._publicStreamManager)||void 0===r||r.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,c.safeEmit(Nl.onPublicStreamStats,e)})),null===(n=this._publicStreamManager)||void 0===n||n.on(wH.ON_SEI_MESSAGED_RECEIVED,(function(e){c.safeEmit(Nl.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 KG(this.id,t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===kl.VIDEO_ONLY,isScreen:!1}),this._initPlayerEvents(a,!0),a.playAudio(i.audioTrack),this._publicStreamAudioPlayer.set(t,a));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(y=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publicStreamManager){e.next=2;break}return e.abrupt("return");case 2:this._publicStreamManager.stopPlayPublicStream(t),(r=this._publicStreamAudioPlayer.get(t))&&(r.destroy(),this._publicStreamAudioPlayer.delete(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"setAudioProfile",value:(m=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:FW.info("setAudioProfile()","profile: %o",t),this._shouldUpdateAudioConf("setAudioProfile")&&this._ctx.audioProfileManager.setAudioProfile(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"setAudioEncodeMaxBitrate",value:(_=Rm(Tm().mark((function e(t){var r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.print("setAudioEncodeMaxBitrate()",t),LD(t,"maxBitrate",6,256),this._ctx.audioProfileManager.setCustomMaxBitrate(t),!this._ctx.audioProfileManager.customMaxBitrate){e.next=10;break}if(!zM||!(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubAudio||null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubAudio)){e.next=6;break}throw new mA(pA.NOT_SUPPORTED,"Your browser does not support set audio encode maxBitrate dynamically.");case 6:return e.next=8,null===(a=this._room)||void 0===a?void 0:a.setAudioEncodeMaxBitrate(cl.STREAM_INDEX_MAIN,t);case 8:return e.next=10,null===(s=this._room)||void 0===s?void 0:s.setAudioEncodeMaxBitrate(cl.STREAM_INDEX_SCREEN,t);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i,o;FW.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 zG(this.id,Zd(Zd({},t),{},{userId:e})),this._initPlayerEvents(a,!0),this._publicStreamVideoPlayer.set(e,a);var s=null===(n=this._publicStreamManager)||void 0===n||null===(i=n.remoteStreams)||void 0===i?void 0:i.get(e);null!=s&&s.videoTrack&&(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)!==kl.PLAY_MANUALLY&&a.playVideo(s.videoTrack,s)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(f=Rm(Tm().mark((function e(t,r){var n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Y_((function(e,i){UD(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===cl.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new mA(pA.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new mA(pA.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return f.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===cl.STREAM_INDEX_MAIN?(t=this._dummyMainImage,r=this._videoStreamEncodeConfig[0]):(t=this._dummyScreenImage,r=this._screenStreamEncodeConfig[0]),t){var n,i,o=document.createElement("canvas"),a=o.getContext("2d"),s=LM(r.width),c=LM(r.height);if(!a)throw new mA(pA.UNEXPECTED_ERROR,"Not support canvas");!s||!c||t.width<=s&&t.height<=c?(n=t.width,i=t.height):(n=Math.min(s,t.width*c/t.height),i=Math.min(c,t.height*s/t.width)),o.width=n,o.height=i,a.drawImage(t,0,0,t.width,t.height,0,0,n,i);var u=window.setInterval((function(){t&&a.drawImage(t,0,0,t.width,t.height,0,0,n,i)}),200);e===cl.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=u):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=u);var d,l,h,p,v=o.captureStream(5).getVideoTracks()[0];if(e===cl.STREAM_INDEX_MAIN){if(this._localImgVideoTrack=v,null!==(d=this._localVideoTrack)&&void 0!==d&&d.dummy)null===(l=this._localVideoTrack)||void 0===l||l.setTrack(this._localImgVideoTrack,this._extensionManager)}else if(this._localImgScreenTrack=v,null!==(h=this._localScreenVideoTrack)&&void 0!==h&&h.dummy)null===(p=this._localScreenVideoTrack)||void 0===p||p.setTrack(this._localImgScreenTrack,this._extensionManager)}}},{key:"_addListenExtensionEvent",value:function(e){var t=this;e.on("re-capture-audio",(function(){t._localAudioTrack&&t.stopAudioCapture().then((function(){t.startAudioCapture()}))})),e.on("re-capture-video",(function(){t._localVideoTrack&&!t._localVideoTrack.dummy&&t.stopVideoCapture().then((function(){t.startVideoCapture()}))})),e.on("reset-video-effect",function(){var e=Rm(Tm().mark((function e(r,n){var i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=17;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.prev=2,e.next=5,t._localVideoTrack.generatePreProcessingTrack(t._extensionManager);case 5:e.next=10;break;case 7:e.prev=7,e.t0=e.catch(2),n(e.t0);case 10:if(t._initLocalTrackEvents(t._localVideoTrack),null!==(i=t._videoPlayer)&&void 0!==i&&i.played&&(t._videoPlayer.stop(),t._videoPlayer.playVideo(t._localVideoTrack),t._videoPlayer.mirror(!!t._mirrorType)),t.safeEmit(Nl.onLocalStreamTrackChangedByExtension,{streamIndex:cl.STREAM_INDEX_MAIN,type:"video"}),r(),null===(o=t._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.pubVideo){e.next=17;break}return e.next=17,t._updatePublish();case 17:r();case 18:case"end":return e.stop()}}),e,null,[[2,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"registerExtension",value:(v=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.monitor=this.monitor,e.prev=1,e.next=4,t.isSupported();case 4:if(e.sent){e.next=7;break}throw new Error("This extension is not supported.");case 7:e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(1),new Error("This extension is not supported.");case 12:return e.next=14,t.init({videoCaptureConfig:this._videoStreamConstraints});case 14:this._extensionManager.register(t),this._addListenExtensionEvent(t);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return v.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(Nm(NW.getDefaultValue()))}},{key:"_updatePublish",value:(p=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},FW.info("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:xH.PUB},t=Zd(Zd({},r),t),this._visibility){e.next=6;break}throw new mA(pA.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===uG.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 15:this._videoPlayer&&this._room.localStream&&(this._room.localStream.videoDom=this._videoPlayer.domElement),e.next=25;break;case 18:if(e.prev=18,e.t0=e.catch(12),!(e.t0 instanceof mA)){e.next=24;break}throw e.t0;case 24:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 25:return e.prev=25,n(),e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[12,18,25,28]])}))),function(){return p.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(h=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),UD(t,"filePath"),LD(r,"indicationInterval"),e.next=5,this._audioDeviceManager.startAudioPlaybackDeviceTest(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){FW.info("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(l=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FW.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),LD(t,"indicationInterval"),e.next=4,this._audioDeviceManager.startAudioDeviceRecordTest(t,r,this._localAudioVolume);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){FW.info("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){FW.info("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;FW.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{XD(e),VD(t,"priority",[yl.HIGH,yl.MEDIUM,yl.LOW])}catch(n){return console.warn(n),!1}return this._ctx.userPriority.set(e,t),null===(r=this._room)||void 0===r||r.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(d=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.print("takeLocalSnapshot()","streamIndex: %o",t),VD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),r=t===cl.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new mA(pA.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===cl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",wW(r.getTrack("preprocessing"),(null==n?void 0:n.mirrorType)===hl.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(u=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FW.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),UD(t,"id"),VD(r,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),c=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=gE(i).call(i,(function(e){return e.isScreen===(r===cl.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._publicStreamManager)||void 0===a||null===(s=a.remoteStreams.get(t))||void 0===s?void 0:s.videoTrack)){e.next=6;break}throw new mA(pA.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",wW(c.getTrack(),!1,r===cl.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){FW.info("setSubscribeFallbackOption()","option: %o",e);try{VD(e,"option",[ml.DISABLE,ml.VIDEO_STREAM_LOW,ml.AUDIO_ONLY])}catch(t){return console.warn(t),!1}return!this._room&&(this._ctx.subscribeFallbackOption=e,!0)}},{key:"getLocalStreamTrack",value:function(e,t){var r,n,i,o=this;if(e===cl.STREAM_INDEX_MAIN?(n="video"===t?this.localVideoTrack:this.localAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localStream}):(n="video"===t?this.localScreenVideoTrack:this.localScreenAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localScreenStream}),n){var a=n instanceof HV&&n.mixedAudioTrack?n.mixedAudioTrack:n.getTrack("preprocessing");if(a){var s=i();return this._reportMsTrackEvent(a,(null==s||null===(r=s.stream)||void 0===r?void 0:r.id)||"local"),a}}}},{key:"getRemoteStreamTrack",value:function(e,t,r){var n,i,o=(null===(n=this._room)||void 0===n?void 0:n.remoteStreams.get(e))||[];if(o&&o.length){var a,s,c,u,d;if(t===cl.STREAM_INDEX_MAIN)a=gE(o).call(o,(function(e){return!e.isScreen})),i="video"===r?null===(s=a)||void 0===s?void 0:s.videoTrack:null===(c=a)||void 0===c?void 0:c.audioTrack;else a=gE(o).call(o,(function(e){return e.isScreen})),i="video"===r?null===(u=a)||void 0===u?void 0:u.videoTrack:null===(d=a)||void 0===d?void 0:d.audioTrack;if(i){var l=i.getTrack();if(l&&a){var h=a.streamId;return this._reportMsTrackEvent(l,h),l}}}}},{key:"getPublicStreamTrack",value:function(e,t){if(this._publicStreamManager&&this._publicStreamManager.remoteStreams){var r=this._publicStreamManager.remoteStreams.get(e);if(r){var n="video"===t?r.videoTrack:r.audioTrack;if(n){var i=n.getTrack();if(i){var o=r.streamId;return this._reportMsTrackEvent(i,o),i}}}}}},{key:"setRemoteStreamRenderSync",value:function(e){return!this._room&&(this._ctx.avSync=!!e,!0)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i;(VD(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),t=rP(t,"volume",0,400),e===cl.STREAM_INDEX_SCREEN)?(null===(r=this._localScreenAudioTrack)||void 0===r||r.setVolume(t),this._localScreenAudioVolume=t):(null===(n=this._localAudioTrack)||void 0===n||n.setVolume(t),null===(i=this._audioDeviceManager.audioTrack)||void 0===i||i.setVolume(t),this._localAudioVolume=t)}},{key:"setPlaybackVolume",value:function(e,t,r){var n,i,o;if(XD(e),VD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),r=rP(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)NM("setPlaybackVolume is not supported in Conference mode");else{var a=t===cl.STREAM_INDEX_SCREEN;a?this._remoteScreenAudioVolume.set(e,r):this._remoteAudioVolume.set(e,r),null===(i=this._room)||void 0===i||null===(o=i.remoteStreams.get(e))||void 0===o||o.forEach((function(e){var t;e.isScreen===a&&(null===(t=e.audioTrack)||void 0===t||t.setVolume(r))}))}}},{key:"setPublicStreamVolume",value:function(e,t){var r,n,i;UD(e,"publicStreamId"),t=rP(t,"volume",0,400),this._publicAudioVolume.set(e,t),null===(r=this._publicStreamManager)||void 0===r||null===(n=r.remoteStreams.get(e))||void 0===n||null===(i=n.audioTrack)||void 0===i||i.setVolume(t)}},{key:"startForwardStreamToRooms",value:(c=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){KD(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.startForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"updateForwardStreamToRooms",value:(s=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){KD(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.updateForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"stopForwardStreamToRooms",value:(a=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.stopForwardStream2Rooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"pauseForwardStreamToAllRooms",value:(o=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.pauseForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"resumeForwardStreamToAllRooms",value:(i=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.resumeForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_reportMsTrackEvent",value:function(e,t){var r=this;if(!e.hookStop){e.hookStop=!0;var n=e.stop;e.stop=function(){jO(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:{},FW.info("_updateScreenPublish()"),r={mediaType:void 0,pubState:xH.PUB},t=Zd(Zd({},r),t),e.next=6,this._pubLock.lock();case 6:if(n=e.sent,this._room&&this._room.connectionState===uG.CONNECTED){e.next=10;break}return n(),e.abrupt("return");case 10:return e.prev=10,e.next=13,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 13:this._screenPlayer&&this._room.localScreenStream&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),e.next=23;break;case 16:if(e.prev=16,e.t0=e.catch(10),!(e.t0 instanceof mA)){e.next=22;break}throw e.t0;case 22:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 23:return e.prev=23,n(),e.finish(23);case 26:case"end":return e.stop()}}),e,this,[[10,16,23,26]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){FW.info("_updateAudioPlayerState()");var t,r=e.userId,n=e.isScreen,i=n?this._remoteScreenAudioPlayer:this._remoteAudioPlayer,o=i.get(r);if(e.audioTrack&&e.attributes.audiostream&&e.subAudio){var a,s,c,u=n?null!==(a=this._remoteScreenAudioVolume.get(r))&&void 0!==a?a:100:null!==(s=this._remoteAudioVolume.get(r))&&void 0!==s?s:100;if(e.audioTrack.setVolume(u),!o){var d;o=new KG(this.id,r,{muted:(null===(d=this._config)||void 0===d?void 0:d.autoPlayPolicy)===kl.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN),i.set(r,o);var l=this._audioDeviceManager.getSinkId();l&&o.setPlaybackDevice(l)}(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)!==kl.PLAY_MANUALLY&&o.playAudio(e.audioTrack),KM&&ZM&&(t=this._remoteAudioPlayer,PW&&clearTimeout(PW),PW=setTimeout((function(){var e,r=$T(t);try{for(r.s();!(e=r.n()).done;){var n=eI(e.value,2),i=n[0],o=n[1];null!=i&&hA(i).call(i,"mux")&&o.pause()}}catch(l){r.e(l)}finally{r.f()}var a,s=$T(t);try{for(s.s();!(a=s.n()).done;){var c=eI(a.value,2),u=c[0],d=c[1];null!=u&&hA(u).call(u,"mux")&&d.manuallyPlay()}}catch(l){s.e(l)}finally{s.f()}}),2e3))}else{var h;null===(h=o)||void 0===h||h.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;FW.info("_updateVideoPlayerState()");var r,n,i=e.userId;if(r=e.isScreen?this._remoteScreenPlayer.get(i):this._remoteVideoPlayer.get(i),e.videoTrack)r&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==kl.PLAY_MANUALLY&&r.playVideo(e.videoTrack,e);else if(null!==(t=r)&&void 0!==t&&t.played){var o;null===(o=r)||void 0===o||o.stop()}}},{key:"_onAddStream",value:(r=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.stream).videoDom=null===(r=this._remoteVideoPlayer.get(n.userId))||void 0===r?void 0:r.domElement,i=null==n?void 0:n.attributes,o=i.localaudio,a=i.audiostream,s=i.localvideo,c=i.videostream,u=zV.NONE,a&&(u|=ul.AUDIO),c&&(u|=ul.VIDEO),!u){e.next=12;break}return e.next=9,new Y_((function(e){return setTimeout(e)}));case 9:null!=n&&n.isScreen?this.safeEmit(Nl.onUserPublishScreen,{userId:n.userId,mediaType:u}):(this.safeEmit(Nl.onUserPublishStream,{userId:n.userId,mediaType:u,videoStreamDescriptions:null==n||null===(d=n.attributes)||void 0===d?void 0:d.videoDescriptions}),this._handleAutoSubscribe(n,!0)),this.safeEmit("onAddStream",{userId:n.userId,mediaType:u,isScreen:!(null==n||!n.isScreen)}),null!=n&&n.isScreen||(o&&this.safeEmit(Nl.onUserStartAudioCapture,{userId:n.userId}),s&&this.safeEmit(Nl.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=zV.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=ul.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=ul.VIDEO),i){var o,a;if(t&&wM(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&CM(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=HW[e.reason])&&void 0!==t?t:dl.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?Nl.onUserUnpublishScreen:Nl.onUserUnpublishStream,a=zV.NONE;n.attributes.audiostream&&(a|=ul.AUDIO),n.attributes.videostream&&(a|=ul.VIDEO),a!==zV.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),"function"==typeof e.callback&&e.callback(),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){n.isScreen?(r._remoteScreenPlayer.delete(n.userId),r._remoteScreenAudioPlayer.delete(n.userId)):(r._remoteAudioPlayer.delete(n.userId),r._remoteVideoPlayer.delete(n.userId)),null==e||e.destroy()}))}},{key:"_onUserConnection",value:function(e){var t=this;setTimeout((function(){return t.safeEmit(Nl.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){var t=this,r=e.userInfo;this._getRemotePlayer(r.userId,!0).forEach((function(e){t._remoteScreenAudioPlayer.delete(r.userId),t._remoteScreenPlayer.delete(r.userId),null==e||e.destroy()})),this._getRemotePlayer(r.userId,!1).forEach((function(e){t._remoteAudioPlayer.delete(r.userId),t._remoteVideoPlayer.delete(r.userId),null==e||e.destroy()})),this.safeEmit(Nl.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(Nl.onError,e),null===(t=this._room)||void 0===t||t.destroy(),this._room=void 0}},{key:"_onNetworkQuality",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.safeEmit.apply(this,Om(e=[Nl.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._ctx.useCloudProxy&&e.state===ll.CONNECTION_STATE_CONNECTED&&this.safeEmit(Nl.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(Nl.onConnectionStateChanged,e),e.state===ll.CONNECTION_STATE_RECONNECTING){var t,r=$T(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=eI(t.value,2),i=n[0],o=n[1];null!=i&&hA(i).call(i,"mux")&&o.stop()}}catch(a){r.e(a)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ul.AUDIO_AND_VIDEO,n=(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),i=(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e),o=[];return r&ul.AUDIO&&o.push(n),r&ul.VIDEO&&o.push(i),o}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){e.stream&&(this._getRemotePlayer(e.stream.userId,e.stream.isScreen).forEach((function(e){return null==e?void 0:e.stop()})),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){var t=this;if(e.stream){this._updateAudioPlayerState(e.stream);var r=e.stream;this._getRemotePlayer(r.userId,r.isScreen,e.mediaType).forEach((function(n){e.mediaType&ul.AUDIO&&(r.isScreen?t._remoteScreenAudioPlayer.delete(r.userId):t._remoteAudioPlayer.delete(r.userId)),r.isScreen?e.mediaType&ul.VIDEO&&t._remoteScreenPlayer.delete(r.userId):e.mediaType&ul.VIDEO&&t._remoteVideoPlayer.delete(r.userId),null==n||n.destroy()}))}}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(Nl.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(Nl.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t,r=this,n=e.userId,i=e.isScreen,o=e.mediaType,a=e.pubState,s=e.remoteStream,c={userId:n,mediaType:o};(o&ul.AUDIO&&setTimeout((function(){r._updateAudioPlayerState(s)})),i)?a===xH.PUB?this.safeEmit(Nl.onUserPublishScreen,c):this.safeEmit(Nl.onUserUnpublishScreen,Zd(Zd({},c),{},{reason:dl.STREAM_REMOVE_REASON_UNPUBLISH})):a===xH.PUB?(c.videoStreamDescriptions=null==s||null===(t=s.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(Nl.onUserPublishStream,c),this._handleAutoSubscribe(s,!0)):this.safeEmit(Nl.onUserUnpublishStream,Zd(Zd({},c),{},{reason:dl.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(Nl.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(Nl.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Nl.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Nl.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(Nl.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(Nl.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Nl.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(Nl.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Nl.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Nl.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(Nl.onError,{errorCode:pA.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(Nl.onError,{errorCode:pA.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(Nl.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(Nl.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==uG.CONNECTED)throw new mA(pA.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){VD(e,"mediaType",[ul.AUDIO,ul.VIDEO,ul.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e,t;return(null===(e=this._room)||void 0===e||null===(t=e.roomInfo)||void 0===t?void 0:t.userInfo.userId)||"local_user"}},{key:"_switchTrack",value:(t=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,null!==(r=this._videoPlayer)&&void 0!==r&&r.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(t),this._videoPlayer.mirror(!!this._mirrorType)),null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||!i.pubVideo){e.next=6;break}return e.next=6,this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_shouldUpdateAudioConf",value:function(e){var t,r,n,i=(null===(t=this._room)||void 0===t?void 0:t.hasPublished)||(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n?void 0:n.pubAudio)||this._localAudioTrack&&this._localAudioTrack.sourceType===oV.INTERNAL;if(i){var o="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: ".concat(o)),jO(this.id,e,o)}return!i}},{key:"_getServerConfig",value:function(){var e=this,t=ED.getServerConfig(this.appId);t.rts_report&&wO.setConfig(t.rts_report),this._ctx.joinRoomConfig.setServerConfig(t.web_join_room),GO({engineId:this.id,appId:this.appId,sdkVersion:OD("VERSION"),requestDomains:OD("CONFIG_REQUEST_DOMAINS"),keys:["rts_report","web_join_room","web_rtc_config"],deviceId:OD("DEVICE_ID")}).then((function(t){ED.setServerConfig(e.appId,t),e.safeEmit("__onGetServerConfigFinishHook")}))}}]),ke}(aP);VW([FO()],BW.prototype,"updateToken",1),VW([FO()],BW.prototype,"setVideoCaptureDevice",1),VW([FO()],BW.prototype,"setAudioCaptureDevice",1),VW([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=VO(this.id),r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return null==t||t.set({room_id:i[1],user_id:null===(e=i[2])||void 0===e?void 0:e.userId}),n.apply(this,i)}}},FO()],BW.prototype,"connect",1),VW([FO()],BW.prototype,"joinRoom",1),VW([FO()],BW.prototype,"leaveRoom",1),VW([FO()],BW.prototype,"destroy",1),VW([FO()],BW.prototype,"publishStream",1),VW([FO()],BW.prototype,"unpublishStream",1),VW([FO()],BW.prototype,"publishScreen",1),VW([FO()],BW.prototype,"unpublishScreen",1),VW([FO()],BW.prototype,"subscribeStream",1),VW([FO()],BW.prototype,"unsubscribeStream",1),VW([FO()],BW.prototype,"subscribeScreen",1),VW([FO()],BW.prototype,"unsubscribeScreen",1),VW([FO()],BW.prototype,"setRemoteVideoConfig",1),VW([FO()],BW.prototype,"startVideoCapture",1),VW([FO()],BW.prototype,"stopVideoCapture",1),VW([FO()],BW.prototype,"startAudioCapture",1),VW([FO()],BW.prototype,"stopAudioCapture",1),VW([FO()],BW.prototype,"getAudioMixingManager",1),VW([FO()],BW.prototype,"startScreenCapture",1),VW([FO()],BW.prototype,"stopScreenCapture",1),VW([FO()],BW.prototype,"setLocalVideoPlayer",1),VW([FO()],BW.prototype,"startLiveTranscoding",1),VW([FO()],BW.prototype,"updateLiveTranscoding",1),VW([FO()],BW.prototype,"stopLiveTranscoding",1),VW([FO()],BW.prototype,"startSubtitle",1),VW([FO()],BW.prototype,"stopSubtitle",1),VW([FO()],BW.prototype,"setBusinessId",1),VW([FO()],BW.prototype,"setUserVisibility",1),VW([FO()],BW.prototype,"setRemoteVideoPlayer",1),VW([FO()],BW.prototype,"setLocalVideoMirrorType",1),VW([FO()],BW.prototype,"setAudioPlaybackDevice",1),VW([FO()],BW.prototype,"play",1),VW([FO()],BW.prototype,"pauseAllSubscribedStream",1),VW([FO()],BW.prototype,"resumeAllSubscribedStream",1),VW([FO()],BW.prototype,"sendUserMessage",1),VW([FO()],BW.prototype,"sendUserBinaryMessage",1),VW([FO()],BW.prototype,"sendRoomMessage",1),VW([FO()],BW.prototype,"sendRoomBinaryMessage",1),VW([FO()],BW.prototype,"setAudioCaptureConfig",1),VW([PM("4.51"),FO()],BW.prototype,"setVideoCaptureConfig",1),VW([FO()],BW.prototype,"enableSimulcastMode",1),VW([FO()],BW.prototype,"setVideoEncoderConfig",1),VW([FO()],BW.prototype,"setScreenEncoderConfig",1),VW([FO()],BW.prototype,"sendSEIMessage",1),VW([PM("4.42"),FO()],BW.prototype,"setAudioVolumeIndicationInterval",1),VW([FO()],BW.prototype,"enableAudioPropertiesReport",1),VW([FO()],BW.prototype,"setVideoSourceType",1),VW([FO()],BW.prototype,"setExternalVideoTrack",1),VW([FO()],BW.prototype,"setAudioSourceType",1),VW([FO()],BW.prototype,"setExternalAudioTrack",1),VW([FO()],BW.prototype,"login",1),VW([FO()],BW.prototype,"logout",1),VW([FO()],BW.prototype,"updateLoginToken",1),VW([FO()],BW.prototype,"getPeerOnlineStatus",1),VW([FO()],BW.prototype,"sendUserMessageOutsideRoom",1),VW([FO()],BW.prototype,"sendUserBinaryMessageOutsideRoom",1),VW([FO()],BW.prototype,"setServerParams",1),VW([FO()],BW.prototype,"sendServerMessage",1),VW([FO()],BW.prototype,"sendServerBinaryMessage",1),VW([FO()],BW.prototype,"startCloudProxy",1),VW([FO()],BW.prototype,"stopCloudProxy",1),VW([FO()],BW.prototype,"startPushPublicStream",1),VW([FO()],BW.prototype,"updatePublicStreamParam",1),VW([FO()],BW.prototype,"stopPushPublicStream",1),VW([FO("streamId")],BW.prototype,"startPlayPublicStream",1),VW([FO("streamId")],BW.prototype,"stopPlayPublicStream",1),VW([FO()],BW.prototype,"setAudioProfile",1),VW([FO()],BW.prototype,"setAudioEncodeMaxBitrate",1),VW([FO()],BW.prototype,"setPublicStreamVideoPlayer",1),VW([FO()],BW.prototype,"setDummyCaptureImagePath",1),VW([FO()],BW.prototype,"registerExtension",1),VW([FO()],BW.prototype,"startAudioPlaybackDeviceTest",1),VW([FO()],BW.prototype,"stopAudioPlaybackDeviceTest",1),VW([FO()],BW.prototype,"startAudioDeviceRecordTest",1),VW([FO()],BW.prototype,"stopAudioDeviceRecordAndPlayTest",1),VW([FO()],BW.prototype,"stopAudioDevicePlayTest",1),VW([FO()],BW.prototype,"setRemoteUserPriority",1),VW([FO()],BW.prototype,"takeLocalSnapshot",1),VW([FO()],BW.prototype,"takeRemoteSnapshot",1),VW([FO()],BW.prototype,"setSubscribeFallbackOption",1),VW([FO()],BW.prototype,"getLocalStreamTrack",1),VW([FO()],BW.prototype,"getRemoteStreamTrack",1),VW([FO()],BW.prototype,"getPublicStreamTrack",1),VW([FO()],BW.prototype,"setRemoteStreamRenderSync",1),VW([FO()],BW.prototype,"startForwardStreamToRooms",1),VW([FO()],BW.prototype,"updateForwardStreamToRooms",1),VW([FO()],BW.prototype,"stopForwardStreamToRooms",1),VW([FO()],BW.prototype,"pauseForwardStreamToAllRooms",1),VW([FO()],BW.prototype,"resumeForwardStreamToAllRooms",1);var jW,HW={"client unpublished":dl.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":dl.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":dl.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":dl.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":dl.STREAM_REMOVE_REASON_REPUBLISH};function GW(e){var t=ED.getServerConfig(e).web_rtc_config;return null!=t&&t.web_pc_killswitch?null==t?void 0:t.web_pc_killswitch:{}}function zW(e){var t=ED.getServerConfig(e).web_rtc_config;return"boolean"==typeof(null==t?void 0:t.fallback)?!1!==t.fallback&&(!!Array.isArray(null==t?void 0:t.fallback_ua_reg)&&t.fallback_ua_reg.every((function(e){return"string"==typeof e&&new RegExp(e).test(navigator.userAgent)}))):!!OD("ENABLE_FALLBACK_HANDLER")}function KW(e){var t=ED.getServerConfig(e).web_rtc_config;return"boolean"==typeof(null==t?void 0:t.standard)?!1!==t.standard&&(!!Array.isArray(null==t?void 0:t.standard_ua_reg)&&t.standard_ua_reg.every((function(e){return"string"==typeof e&&new RegExp(e).test(navigator.userAgent)}))):!!OD("ENABLE_STANDARD_HANDLER")}var XW=new Nw("VERTC",0);Ew.storeKey=Om(jW="".concat(Date.now(),"-")).call(jW,ED.getDeviceId()),xO({rtc_sdk_version:CD.VERSION,device_id:ED.getDeviceId(),log_cache_key:Ew.storeKey}),OO(CD.LOG_SERVER_URL);var WW=1,qW=function(e,t){XW.info("createEngine","Invoke VERTC.createEngine"),UD(e,"appId");var r=(WW++).toString();return function(e,t){var r=new TO(e);r.set(Zd(Zd({},t),{},{engine_session_id:_w()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),UO.set(e,r)}(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new BW(e,r,t)},YW=function(e){if(XW.info("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof BW))throw new mA(pA.INVALID_ENGINE,"Invalid engine object");var t;e.destroy(),(t=e.monitor).report("sdk_init_engine",{start:Date.now(),type:"end"}),UO.delete(t.id)},JW=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",qU.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),QW=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:{video:!0,audio:!0},r=t.video,n=t.audio,i={video:!1,audio:!1},!r){e.next=14;break}return e.prev=4,e.next=7,qU.getPermissions({video:!0,force:!0});case 7:o=e.sent,i.video=o.video,o.video||(i.videoExceptionError=o.reason),e.next=14;break;case 12:e.prev=12,e.t0=e.catch(4);case 14:if(!n){e.next=25;break}return e.prev=15,e.next=18,qU.getPermissions({audio:!0,force:!0});case 18:a=e.sent,i.audio=a.audio,a.audio||(i.audioExceptionError=a.reason),e.next=25;break;case 23:e.prev=23,e.t1=e.catch(15);case 25:return e.abrupt("return",i);case 26:case"end":return e.stop()}}),e,null,[[4,12],[15,23]])})));return function(){return e.apply(this,arguments)}}(),ZW=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",qU.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),$W=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",qU.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),eq=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",qU.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),tq=function(){return CD.VERSION},rq=function(){return DO("isSupported",0,""),QN()},nq=function(){return DO("getSupportedCodecs",0,""),eL()},iq=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(Ew.logLevel=t),r&&(Ew.LogfileSize=r)},oq=function(e){Ew.download(e)};function aq(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Nm(jm(t).call(t,(function(e){return e instanceof BW?"[ENGINE]":e})))}function sq(e,t){return function(){DO(t,0,aq.apply(void 0,arguments));var r=e.apply(void 0,arguments);return"function"==typeof(null==r?void 0:r.then)?r.then((function(e){return PO(t,0,aq(e)),e})).catch((function(e){throw PO(t,e.code,e.message),e})):(PO(t,0,aq(r)),r)}}return Zd(Zd(Zd(Zd({},new(Ul((function e(){Vl(this,e),Jd(this,"getSdkVersion",sq(tq,"getSdkVersion")),Jd(this,"createEngine",sq(qW,"createEngine")),Jd(this,"destroyEngine",sq(YW,"destroyEngine")),Jd(this,"enumerateDevices",sq(JW,"enumerateDevices")),Jd(this,"enableDevices",sq(QW,"enableDevices")),Jd(this,"enumerateAudioCaptureDevices",sq(ZW,"enumerateAudioCaptureDevices")),Jd(this,"enumerateVideoCaptureDevices",sq($W,"enumerateVideoCaptureDevices")),Jd(this,"enumerateAudioPlaybackDevices",sq(eq,"enumerateAudioPlaybackDevices")),Jd(this,"getParameter",OD),Jd(this,"setParameter",xD),Jd(this,"isSupported",sq(rq,"isSupported")),Jd(this,"getSupportedCodecs",sq(nq,"getSupportedCodecs")),Jd(this,"events",Nl),Jd(this,"ErrorCode",pA),Jd(this,"platform","BytePlus"),Jd(this,"commitInfo","release_455<1b7f1ca*>"),Jd(this,"downloadLog",sq(oq,"downloadLog")),Jd(this,"setLogConfig",sq(iq,"setLogConfig"))})))),xl),Pl),{},{events:Nl})}));
6
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).BytePlusRTC=t()}(this,(function(){"use strict";function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e){return e&&e.Math==Math&&e},n=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof t&&t)||function(){return this}()||Function("return this")(),i=function(e){try{return!!e()}catch(t){return!0}},o=!i((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),a=o,s=Function.prototype,c=s.apply,u=s.call,d="object"==typeof Reflect&&Reflect.apply||(a?u.bind(c):function(){return u.apply(c,arguments)}),l=o,h=Function.prototype,p=h.call,v=l&&h.bind.bind(p,p),f=l?v:function(e){return function(){return p.apply(e,arguments)}},_=f,m=_({}.toString),y=_("".slice),g=function(e){return y(m(e),8,-1)},S=g,b=f,E=function(e){if("Function"===S(e))return b(e)},k="object"==typeof document&&document.all,T={all:k,IS_HTMLDDA:void 0===k&&void 0!==k},I=T.all,R=T.IS_HTMLDDA?function(e){return"function"==typeof e||e===I}:function(e){return"function"==typeof e},A={},w=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),C=o,x=Function.prototype.call,O=C?x.bind(x):function(){return x.apply(x,arguments)},M={},D={}.propertyIsEnumerable,P=Object.getOwnPropertyDescriptor,N=P&&!D.call({1:2},1);M.f=N?function(e){var t=P(this,e);return!!t&&t.enumerable}:D;var L,U,V=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},F=i,B=g,j=Object,H=E("".split),G=F((function(){return!j("z").propertyIsEnumerable(0)}))?function(e){return"String"==B(e)?H(e,""):j(e)}:j,z=function(e){return null==e},K=z,X=TypeError,W=function(e){if(K(e))throw X("Can't call method on "+e);return e},q=G,Y=W,J=function(e){return q(Y(e))},Q=R,Z=T.all,$=T.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:Q(e)||e===Z}:function(e){return"object"==typeof e?null!==e:Q(e)},ee={},te=ee,re=n,ne=R,ie=function(e){return ne(e)?e:void 0},oe=function(e,t){return arguments.length<2?ie(te[e])||ie(re[e]):te[e]&&te[e][t]||re[e]&&re[e][t]},ae=E({}.isPrototypeOf),se=oe("navigator","userAgent")||"",ce=n,ue=se,de=ce.process,le=ce.Deno,he=de&&de.versions||le&&le.version,pe=he&&he.v8;pe&&(U=(L=pe.split("."))[0]>0&&L[0]<4?1:+(L[0]+L[1])),!U&&ue&&(!(L=ue.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=ue.match(/Chrome\/(\d+)/))&&(U=+L[1]);var ve=U,fe=ve,_e=i,me=!!Object.getOwnPropertySymbols&&!_e((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&fe&&fe<41})),ye=me&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ge=oe,Se=R,be=ae,Ee=Object,ke=ye?function(e){return"symbol"==typeof e}:function(e){var t=ge("Symbol");return Se(t)&&be(t.prototype,Ee(e))},Te=String,Ie=function(e){try{return Te(e)}catch(t){return"Object"}},Re=R,Ae=Ie,we=TypeError,Ce=function(e){if(Re(e))return e;throw we(Ae(e)+" is not a function")},xe=Ce,Oe=z,Me=function(e,t){var r=e[t];return Oe(r)?void 0:xe(r)},De=O,Pe=R,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__",He=n[je]||Be(je,{}),Ge=He;(Ue.exports=function(e,t){return Ge[e]||(Ge[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.0",mode:"pure",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.0/LICENSE",source:"https://github.com/zloirock/core-js"});var ze=W,Ke=Object,Xe=function(e){return Ke(ze(e))},We=Xe,qe=E({}.hasOwnProperty),Ye=Object.hasOwn||function(e,t){return qe(We(e),t)},Je=E,Qe=0,Ze=Math.random(),$e=Je(1..toString),et=function(e){return"Symbol("+(void 0===e?"":e)+")_"+$e(++Qe+Ze,36)},tt=n,rt=Ue.exports,nt=Ye,it=et,ot=me,at=ye,st=rt("wks"),ct=tt.Symbol,ut=ct&&ct.for,dt=at?ct:ct&&ct.withoutSetter||it,lt=function(e){if(!nt(st,e)||!ot&&"string"!=typeof st[e]){var t="Symbol."+e;ot&&nt(ct,e)?st[e]=ct[e]:st[e]=at&&ut?ut(t):dt(t)}return st[e]},ht=O,pt=$,vt=ke,ft=Me,_t=function(e,t){var r,n;if("string"===t&&Pe(r=e.toString)&&!Ne(n=De(r,e)))return n;if(Pe(r=e.valueOf)&&!Ne(n=De(r,e)))return n;if("string"!==t&&Pe(r=e.toString)&&!Ne(n=De(r,e)))return n;throw Le("Can't convert object to primitive value")},mt=TypeError,yt=lt("toPrimitive"),gt=function(e,t){if(!pt(e)||vt(e))return e;var r,n=ft(e,yt);if(n){if(void 0===t&&(t="default"),r=ht(n,e,t),!pt(r)||vt(r))return r;throw mt("Can't convert object to primitive value")}return void 0===t&&(t="number"),_t(e,t)},St=ke,bt=function(e){var t=gt(e,"string");return St(t)?t:t+""},Et=$,kt=n.document,Tt=Et(kt)&&Et(kt.createElement),It=function(e){return Tt?kt.createElement(e):{}},Rt=It,At=!w&&!i((function(){return 7!=Object.defineProperty(Rt("div"),"a",{get:function(){return 7}}).a})),wt=w,Ct=O,xt=M,Ot=V,Mt=J,Dt=bt,Pt=Ye,Nt=At,Lt=Object.getOwnPropertyDescriptor;A.f=wt?Lt:function(e,t){if(e=Mt(e),t=Dt(t),Nt)try{return Lt(e,t)}catch(r){}if(Pt(e,t))return Ot(!Ct(xt.f,e,t),e[t])};var Ut=i,Vt=R,Ft=/#|\.prototype\./,Bt=function(e,t){var r=Ht[jt(e)];return r==zt||r!=Gt&&(Vt(t)?Ut(t):!!t)},jt=Bt.normalize=function(e){return String(e).replace(Ft,".").toLowerCase()},Ht=Bt.data={},Gt=Bt.NATIVE="N",zt=Bt.POLYFILL="P",Kt=Bt,Xt=Ce,Wt=o,qt=E(E.bind),Yt=function(e,t){return Xt(e),void 0===t?e:Wt?qt(e,t):function(){return e.apply(t,arguments)}},Jt={},Qt=w&&i((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Zt=$,$t=String,er=TypeError,tr=function(e){if(Zt(e))return e;throw er($t(e)+" is not an object")},rr=w,nr=At,ir=Qt,or=tr,ar=bt,sr=TypeError,cr=Object.defineProperty,ur=Object.getOwnPropertyDescriptor,dr="enumerable",lr="configurable",hr="writable";Jt.f=rr?ir?function(e,t,r){if(or(e),t=ar(t),or(r),"function"==typeof e&&"prototype"===t&&"value"in r&&hr in r&&!r.writable){var n=ur(e,t);n&&n.writable&&(e[t]=r.value,r={configurable:lr in r?r.configurable:n.configurable,enumerable:dr in r?r.enumerable:n.enumerable,writable:!1})}return cr(e,t,r)}:cr:function(e,t,r){if(or(e),t=ar(t),or(r),nr)try{return cr(e,t,r)}catch(n){}if("get"in r||"set"in r)throw sr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var pr=Jt,vr=V,fr=w?function(e,t,r){return pr.f(e,t,vr(1,r))}:function(e,t,r){return e[t]=r,e},_r=n,mr=d,yr=E,gr=R,Sr=A.f,br=Kt,Er=ee,kr=Yt,Tr=fr,Ir=Ye,Rr=function(e){var t=function(r,n,i){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,i)}return mr(e,this,arguments)};return t.prototype=e.prototype,t},Ar=function(e,t){var r,n,i,o,a,s,c,u,d=e.target,l=e.global,h=e.stat,p=e.proto,v=l?_r:h?_r[d]:(_r[d]||{}).prototype,f=l?Er:Er[d]||Tr(Er,d,{})[d],_=f.prototype;for(i in t)r=!br(l?i:d+(h?".":"#")+i,e.forced)&&v&&Ir(v,i),a=f[i],r&&(s=e.dontCallGetSet?(u=Sr(v,i))&&u.value:v[i]),o=r&&s?s:t[i],r&&typeof a==typeof o||(c=e.bind&&r?kr(o,_r):e.wrap&&r?Rr(o):p&&gr(o)?yr(o):o,(e.sham||o&&o.sham||a&&a.sham)&&Tr(c,"sham",!0),Tr(f,i,c),p&&(Ir(Er,n=d+"Prototype")||Tr(Er,n,{}),Tr(Er[n],i,o),e.real&&_&&!_[i]&&Tr(_,i,o)))},wr=Math.ceil,Cr=Math.floor,xr=Math.trunc||function(e){var t=+e;return(t>0?Cr:wr)(t)},Or=function(e){var t=+e;return t!=t||0===t?0:xr(t)},Mr=Or,Dr=Math.max,Pr=Math.min,Nr=function(e,t){var r=Mr(e);return r<0?Dr(r+t,0):Pr(r,t)},Lr=Or,Ur=Math.min,Vr=function(e){return e>0?Ur(Lr(e),9007199254740991):0},Fr=Vr,Br=function(e){return Fr(e.length)},jr=J,Hr=Nr,Gr=Br,zr=function(e){return function(t,r,n){var i,o=jr(t),a=Gr(o),s=Hr(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},Kr={includes:zr(!0),indexOf:zr(!1)},Xr={},Wr=Ye,qr=J,Yr=Kr.indexOf,Jr=Xr,Qr=E([].push),Zr=function(e,t){var r,n=qr(e),i=0,o=[];for(r in n)!Wr(Jr,r)&&Wr(n,r)&&Qr(o,r);for(;t.length>i;)Wr(n,r=t[i++])&&(~Yr(o,r)||Qr(o,r));return o},$r=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],en=Zr,tn=$r,rn=Object.keys||function(e){return en(e,tn)},nn=Xe,on=rn;Ar({target:"Object",stat:!0,forced:i((function(){on(1)}))},{keys:function(e){return on(nn(e))}});var an=ee.Object.keys,sn={};sn[lt("toStringTag")]="z";var cn="[object z]"===String(sn),un=cn,dn=R,ln=g,hn=lt("toStringTag"),pn=Object,vn="Arguments"==ln(function(){return arguments}()),fn=un?ln:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=pn(e),hn))?r:vn?ln(t):"Object"==(n=ln(t))&&dn(t.callee)?"Arguments":n},_n=fn,mn=String,yn=function(e){if("Symbol"===_n(e))throw TypeError("Cannot convert a Symbol value to a string");return mn(e)},gn={},Sn=w,bn=Qt,En=Jt,kn=tr,Tn=J,In=rn;gn.f=Sn&&!bn?Object.defineProperties:function(e,t){kn(e);for(var r,n=Tn(t),i=In(t),o=i.length,a=0;o>a;)En.f(e,r=i[a++],n[r]);return e};var Rn,An=oe("document","documentElement"),wn=Ue.exports,Cn=et,xn=wn("keys"),On=function(e){return xn[e]||(xn[e]=Cn(e))},Mn=tr,Dn=gn,Pn=$r,Nn=Xr,Ln=An,Un=It,Vn=On("IE_PROTO"),Fn=function(){},Bn=function(e){return"<script>"+e+"</"+"script>"},jn=function(e){e.write(Bn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Hn=function(){try{Rn=new ActiveXObject("htmlfile")}catch(n){}var e,t;Hn="undefined"!=typeof document?document.domain&&Rn?jn(Rn):((t=Un("iframe")).style.display="none",Ln.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Bn("document.F=Object")),e.close(),e.F):jn(Rn);for(var r=Pn.length;r--;)delete Hn.prototype[Pn[r]];return Hn()};Nn[Vn]=!0;var Gn=Object.create||function(e,t){var r;return null!==e?(Fn.prototype=Mn(e),r=new Fn,Fn.prototype=null,r[Vn]=e):r=Hn(),void 0===t?r:Dn.f(r,t)},zn={},Kn=Zr,Xn=$r.concat("length","prototype");zn.f=Object.getOwnPropertyNames||function(e){return Kn(e,Xn)};var Wn={},qn=bt,Yn=Jt,Jn=V,Qn=function(e,t,r){var n=qn(t);n in e?Yn.f(e,n,Jn(0,r)):e[n]=r},Zn=Nr,$n=Br,ei=Qn,ti=Array,ri=Math.max,ni=function(e,t,r){for(var n=$n(e),i=Zn(t,n),o=Zn(void 0===r?n:r,n),a=ti(ri(o-i,0)),s=0;i<o;i++,s++)ei(a,s,e[i]);return a.length=s,a},ii=g,oi=J,ai=zn.f,si=ni,ci="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Wn.f=function(e){return ci&&"Window"==ii(e)?function(e){try{return ai(e)}catch(t){return si(ci)}}(e):ai(oi(e))};var ui={};ui.f=Object.getOwnPropertySymbols;var di=fr,li=function(e,t,r,n){return n&&n.enumerable?e[t]=r:di(e,t,r),e},hi={},pi=lt;hi.f=pi;var vi,fi,_i,mi=ee,yi=Ye,gi=hi,Si=Jt.f,bi=function(e){var t=mi.Symbol||(mi.Symbol={});yi(t,e)||Si(t,e,{value:gi.f(e)})},Ei=O,ki=oe,Ti=lt,Ii=li,Ri=function(){var e=ki("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=Ti("toPrimitive");t&&!t[n]&&Ii(t,n,(function(e){return Ei(r,this)}),{arity:1})},Ai=fn,wi=cn?{}.toString:function(){return"[object "+Ai(this)+"]"},Ci=cn,xi=Jt.f,Oi=fr,Mi=Ye,Di=wi,Pi=lt("toStringTag"),Ni=function(e,t,r,n){if(e){var i=r?e:e.prototype;Mi(i,Pi)||xi(i,Pi,{configurable:!0,value:t}),n&&!Ci&&Oi(i,"toString",Di)}},Li=R,Ui=n.WeakMap,Vi=Li(Ui)&&/native code/.test(String(Ui)),Fi=Vi,Bi=n,ji=$,Hi=fr,Gi=Ye,zi=He,Ki=On,Xi=Xr,Wi="Object already initialized",qi=Bi.TypeError,Yi=Bi.WeakMap;if(Fi||zi.state){var Ji=zi.state||(zi.state=new Yi);Ji.get=Ji.get,Ji.has=Ji.has,Ji.set=Ji.set,vi=function(e,t){if(Ji.has(e))throw qi(Wi);return t.facade=e,Ji.set(e,t),t},fi=function(e){return Ji.get(e)||{}},_i=function(e){return Ji.has(e)}}else{var Qi=Ki("state");Xi[Qi]=!0,vi=function(e,t){if(Gi(e,Qi))throw qi(Wi);return t.facade=e,Hi(e,Qi,t),t},fi=function(e){return Gi(e,Qi)?e[Qi]:{}},_i=function(e){return Gi(e,Qi)}}var Zi={set:vi,get:fi,has:_i,enforce:function(e){return _i(e)?fi(e):vi(e,{})},getterFor:function(e){return function(t){var r;if(!ji(t)||(r=fi(t)).type!==e)throw qi("Incompatible receiver, "+e+" required");return r}}},$i=g,eo=Array.isArray||function(e){return"Array"==$i(e)},to=R,ro=He,no=E(Function.toString);to(ro.inspectSource)||(ro.inspectSource=function(e){return no(e)});var io=ro.inspectSource,oo=E,ao=i,so=R,co=fn,uo=io,lo=function(){},ho=[],po=oe("Reflect","construct"),vo=/^\s*(?:class|function)\b/,fo=oo(vo.exec),_o=!vo.exec(lo),mo=function(e){if(!so(e))return!1;try{return po(lo,ho,e),!0}catch(t){return!1}},yo=function(e){if(!so(e))return!1;switch(co(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return _o||!!fo(vo,uo(e))}catch(t){return!0}};yo.sham=!0;var go=!po||ao((function(){var e;return mo(mo.call)||!mo(Object)||!mo((function(){e=!0}))||e}))?yo:mo,So=eo,bo=go,Eo=$,ko=lt("species"),To=Array,Io=function(e){var t;return So(e)&&(t=e.constructor,(bo(t)&&(t===To||So(t.prototype))||Eo(t)&&null===(t=t[ko]))&&(t=void 0)),void 0===t?To:t},Ro=function(e,t){return new(Io(e))(0===t?0:t)},Ao=Yt,wo=G,Co=Xe,xo=Br,Oo=Ro,Mo=E([].push),Do=function(e){var t=1==e,r=2==e,n=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,d,l){for(var h,p,v=Co(c),f=wo(v),_=Ao(u,d),m=xo(f),y=0,g=l||Oo,S=t?g(c,m):r||a?g(c,0):void 0;m>y;y++)if((s||y in f)&&(p=_(h=f[y],y,v),e))if(t)S[y]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return y;case 2:Mo(S,h)}else switch(e){case 4:return!1;case 7:Mo(S,h)}return o?-1:n||i?i:S}},Po={forEach:Do(0),map:Do(1),filter:Do(2),some:Do(3),every:Do(4),find:Do(5),findIndex:Do(6),filterReject:Do(7)},No=Ar,Lo=n,Uo=O,Vo=E,Fo=w,Bo=me,jo=i,Ho=Ye,Go=ae,zo=tr,Ko=J,Xo=bt,Wo=yn,qo=V,Yo=Gn,Jo=rn,Qo=zn,Zo=Wn,$o=ui,ea=A,ta=Jt,ra=gn,na=M,ia=li,oa=Ue.exports,aa=Xr,sa=et,ca=lt,ua=hi,da=bi,la=Ri,ha=Ni,pa=Zi,va=Po.forEach,fa=On("hidden"),_a="Symbol",ma=pa.set,ya=pa.getterFor(_a),ga=Object.prototype,Sa=Lo.Symbol,ba=Sa&&Sa.prototype,Ea=Lo.TypeError,ka=Lo.QObject,Ta=ea.f,Ia=ta.f,Ra=Zo.f,Aa=na.f,wa=Vo([].push),Ca=oa("symbols"),xa=oa("op-symbols"),Oa=oa("wks"),Ma=!ka||!ka.prototype||!ka.prototype.findChild,Da=Fo&&jo((function(){return 7!=Yo(Ia({},"a",{get:function(){return Ia(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=Ta(ga,t);n&&delete ga[t],Ia(e,t,r),n&&e!==ga&&Ia(ga,t,n)}:Ia,Pa=function(e,t){var r=Ca[e]=Yo(ba);return ma(r,{type:_a,tag:e,description:t}),Fo||(r.description=t),r},Na=function(e,t,r){e===ga&&Na(xa,t,r),zo(e);var n=Xo(t);return zo(r),Ho(Ca,n)?(r.enumerable?(Ho(e,fa)&&e[fa][n]&&(e[fa][n]=!1),r=Yo(r,{enumerable:qo(0,!1)})):(Ho(e,fa)||Ia(e,fa,qo(1,{})),e[fa][n]=!0),Da(e,n,r)):Ia(e,n,r)},La=function(e,t){zo(e);var r=Ko(t),n=Jo(r).concat(Ba(r));return va(n,(function(t){Fo&&!Uo(Ua,r,t)||Na(e,t,r[t])})),e},Ua=function(e){var t=Xo(e),r=Uo(Aa,this,t);return!(this===ga&&Ho(Ca,t)&&!Ho(xa,t))&&(!(r||!Ho(this,t)||!Ho(Ca,t)||Ho(this,fa)&&this[fa][t])||r)},Va=function(e,t){var r=Ko(e),n=Xo(t);if(r!==ga||!Ho(Ca,n)||Ho(xa,n)){var i=Ta(r,n);return!i||!Ho(Ca,n)||Ho(r,fa)&&r[fa][n]||(i.enumerable=!0),i}},Fa=function(e){var t=Ra(Ko(e)),r=[];return va(t,(function(e){Ho(Ca,e)||Ho(aa,e)||wa(r,e)})),r},Ba=function(e){var t=e===ga,r=Ra(t?xa:Ko(e)),n=[];return va(r,(function(e){!Ho(Ca,e)||t&&!Ho(ga,e)||wa(n,Ca[e])})),n};Bo||(Sa=function(){if(Go(ba,this))throw Ea("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Wo(arguments[0]):void 0,t=sa(e),r=function(e){this===ga&&Uo(r,xa,e),Ho(this,fa)&&Ho(this[fa],t)&&(this[fa][t]=!1),Da(this,t,qo(1,e))};return Fo&&Ma&&Da(ga,t,{configurable:!0,set:r}),Pa(t,e)},ia(ba=Sa.prototype,"toString",(function(){return ya(this).tag})),ia(Sa,"withoutSetter",(function(e){return Pa(sa(e),e)})),na.f=Ua,ta.f=Na,ra.f=La,ea.f=Va,Qo.f=Zo.f=Fa,$o.f=Ba,ua.f=function(e){return Pa(ca(e),e)},Fo&&Ia(ba,"description",{configurable:!0,get:function(){return ya(this).description}})),No({global:!0,constructor:!0,wrap:!0,forced:!Bo,sham:!Bo},{Symbol:Sa}),va(Jo(Oa),(function(e){da(e)})),No({target:_a,stat:!0,forced:!Bo},{useSetter:function(){Ma=!0},useSimple:function(){Ma=!1}}),No({target:"Object",stat:!0,forced:!Bo,sham:!Fo},{create:function(e,t){return void 0===t?Yo(e):La(Yo(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,Ha=Ar,Ga=oe,za=Ye,Ka=yn,Xa=Ue.exports,Wa=ja,qa=Xa("string-to-symbol-registry"),Ya=Xa("symbol-to-string-registry");Ha({target:"Symbol",stat:!0,forced:!Wa},{for:function(e){var t=Ka(e);if(za(qa,t))return qa[t];var r=Ga("Symbol")(t);return qa[t]=r,Ya[r]=t,r}});var Ja=Ar,Qa=Ye,Za=ke,$a=Ie,es=ja,ts=(0,Ue.exports)("symbol-to-string-registry");Ja({target:"Symbol",stat:!0,forced:!es},{keyFor:function(e){if(!Za(e))throw TypeError($a(e)+" is not a symbol");if(Qa(ts,e))return ts[e]}});var rs=E([].slice),ns=Ar,is=oe,os=d,as=O,ss=E,cs=i,us=eo,ds=R,ls=$,hs=ke,ps=rs,vs=me,fs=is("JSON","stringify"),_s=ss(/./.exec),ms=ss("".charAt),ys=ss("".charCodeAt),gs=ss("".replace),Ss=ss(1..toString),bs=/[\uD800-\uDFFF]/g,Es=/^[\uD800-\uDBFF]$/,ks=/^[\uDC00-\uDFFF]$/,Ts=!vs||cs((function(){var e=is("Symbol")();return"[null]"!=fs([e])||"{}"!=fs({a:e})||"{}"!=fs(Object(e))})),Is=cs((function(){return'"\\udf06\\ud834"'!==fs("\udf06\ud834")||'"\\udead"'!==fs("\udead")})),Rs=function(e,t){var r=ps(arguments),n=t;if((ls(t)||void 0!==e)&&!hs(e))return us(t)||(t=function(e,t){if(ds(n)&&(t=as(n,this,e,t)),!hs(t))return t}),r[1]=t,os(fs,null,r)},As=function(e,t,r){var n=ms(r,t-1),i=ms(r,t+1);return _s(Es,e)&&!_s(ks,i)||_s(ks,e)&&!_s(Es,n)?"\\u"+Ss(ys(e,0),16):e};fs&&ns({target:"JSON",stat:!0,arity:3,forced:Ts||Is},{stringify:function(e,t,r){var n=ps(arguments),i=os(Ts?Rs:fs,null,n);return Is&&"string"==typeof i?gs(i,bs,As):i}});var ws=ui,Cs=Xe;Ar({target:"Object",stat:!0,forced:!me||i((function(){ws.f(1)}))},{getOwnPropertySymbols:function(e){var t=ws.f;return t?t(Cs(e)):[]}});var xs=ee.Object.getOwnPropertySymbols,Os=i,Ms=ve,Ds=lt("species"),Ps=function(e){return Ms>=51||!Os((function(){var t=[];return(t.constructor={})[Ds]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Ns=Po.filter;Ar({target:"Array",proto:!0,forced:!Ps("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,Hs=function(e){var t=e.filter;return e===js||Fs(js,e)&&t===js.filter?Bs:t},Gs={exports:{}},zs=Ar,Ks=i,Xs=J,Ws=A.f,qs=w,Ys=Ks((function(){Ws(1)}));zs({target:"Object",stat:!0,forced:!qs||Ys,sham:!qs},{getOwnPropertyDescriptor:function(e,t){return Ws(Xs(e),t)}});var Js=ee.Object,Qs=Gs.exports=function(e,t){return Js.getOwnPropertyDescriptor(e,t)};Js.getOwnPropertyDescriptor.sham&&(Qs.sham=!0);var Zs,$s,ec,tc=Gs.exports,rc={},nc=w,ic=Ye,oc=Function.prototype,ac=nc&&Object.getOwnPropertyDescriptor,sc=ic(oc,"name"),cc={EXISTS:sc,PROPER:sc&&"something"===function(){}.name,CONFIGURABLE:sc&&(!nc||nc&&ac(oc,"name").configurable)},uc=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),dc=Ye,lc=R,hc=Xe,pc=uc,vc=On("IE_PROTO"),fc=Object,_c=fc.prototype,mc=pc?fc.getPrototypeOf:function(e){var t=hc(e);if(dc(t,vc))return t[vc];var r=t.constructor;return lc(r)&&t instanceof r?r.prototype:t instanceof fc?_c:null},yc=i,gc=R,Sc=$,bc=Gn,Ec=mc,kc=li,Tc=lt("iterator"),Ic=!1;[].keys&&("next"in(ec=[].keys())?($s=Ec(Ec(ec)))!==Object.prototype&&(Zs=$s):Ic=!0);var Rc=!Sc(Zs)||yc((function(){var e={};return Zs[Tc].call(e)!==e}));gc((Zs=Rc?{}:bc(Zs))[Tc])||kc(Zs,Tc,(function(){return this}));var Ac={IteratorPrototype:Zs,BUGGY_SAFARI_ITERATORS:Ic},wc=Ac.IteratorPrototype,Cc=Gn,xc=V,Oc=Ni,Mc=rc,Dc=function(){return this},Pc=function(e,t,r,n){var i=t+" Iterator";return e.prototype=Cc(wc,{next:xc(+!n,r)}),Oc(e,i,!1,!0),Mc[i]=Dc,e},Nc=R,Lc=String,Uc=TypeError,Vc=E,Fc=tr,Bc=function(e){if("object"==typeof e||Nc(e))return e;throw Uc("Can't set "+Lc(e)+" as a prototype")},jc=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Vc(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return Fc(r),Bc(n),t?e(r,n):r.__proto__=n,r}}():void 0),Hc=Ar,Gc=O,zc=cc,Kc=Pc,Xc=mc,Wc=Ni,qc=li,Yc=rc,Jc=Ac,Qc=zc.PROPER,Zc=Jc.BUGGY_SAFARI_ITERATORS,$c=lt("iterator"),eu="keys",tu="values",ru="entries",nu=function(){return this},iu=function(e,t,r,n,i,o,a){Kc(r,t,n);var s,c,u,d=function(e){if(e===i&&f)return f;if(!Zc&&e in p)return p[e];switch(e){case eu:case tu:case ru:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,p=e.prototype,v=p[$c]||p["@@iterator"]||i&&p[i],f=!Zc&&v||d(i),_="Array"==t&&p.entries||v;if(_&&(s=Xc(_.call(new e)))!==Object.prototype&&s.next&&(Wc(s,l,!0,!0),Yc[l]=nu),Qc&&i==tu&&v&&v.name!==tu&&(h=!0,f=function(){return Gc(v,this)}),i)if(c={values:d(tu),keys:o?f:d(eu),entries:d(ru)},a)for(u in c)(Zc||h||!(u in p))&&qc(p,u,c[u]);else Hc({target:t,proto:!0,forced:Zc||h},c);return a&&p[$c]!==f&&qc(p,$c,f,{name:i}),Yc[t]=f,c},ou=function(e,t){return{value:e,done:t}},au=J,su=function(){},cu=rc,uu=Zi,du=(Jt.f,iu),lu=ou,hu="Array Iterator",pu=uu.set,vu=uu.getterFor(hu);du(Array,"Array",(function(e,t){pu(this,{type:hu,target:au(e),index:0,kind:t})}),(function(){var e=vu(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,lu(void 0,!0)):lu("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values");cu.Arguments=cu.Array;su(),su(),su();var fu={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},_u=n,mu=fn,yu=fr,gu=rc,Su=lt("toStringTag");for(var bu in fu){var Eu=_u[bu],ku=Eu&&Eu.prototype;ku&&mu(ku)!==Su&&yu(ku,Su,bu),gu[bu]=gu.Array}var Tu=i,Iu=function(e,t){var r=[][e];return!!r&&Tu((function(){r.call(null,t||function(){return 1},1)}))},Ru=Po.forEach,Au=Iu("forEach")?[].forEach:function(e){return Ru(this,e,arguments.length>1?arguments[1]:void 0)};Ar({target:"Array",proto:!0,forced:[].forEach!=Au},{forEach:Au});var wu=Us("Array").forEach,Cu=fn,xu=Ye,Ou=ae,Mu=wu,Du=Array.prototype,Pu={DOMTokenList:!0,NodeList:!0},Nu=function(e){var t=e.forEach;return e===Du||Ou(Du,e)&&t===Du.forEach||xu(Pu,Cu(e))?Mu:t},Lu=oe,Uu=zn,Vu=ui,Fu=tr,Bu=E([].concat),ju=Lu("Reflect","ownKeys")||function(e){var t=Uu.f(Fu(e)),r=Vu.f;return r?Bu(t,r(e)):t},Hu=ju,Gu=J,zu=A,Ku=Qn;Ar({target:"Object",stat:!0,sham:!w},{getOwnPropertyDescriptors:function(e){for(var t,r,n=Gu(e),i=zu.f,o=Hu(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&Ku(a,t,r);return a}});var Xu=ee.Object.getOwnPropertyDescriptors,Wu={exports:{}},qu=Ar,Yu=w,Ju=gn.f;qu({target:"Object",stat:!0,forced:Object.defineProperties!==Ju,sham:!Yu},{defineProperties:Ju});var Qu=ee.Object,Zu=Wu.exports=function(e,t){return Qu.defineProperties(e,t)};Qu.defineProperties.sham&&(Zu.sham=!0);var $u=Wu.exports,ed={exports:{}},td=Ar,rd=w,nd=Jt.f;td({target:"Object",stat:!0,forced:Object.defineProperty!==nd,sham:!rd},{defineProperty:nd});var id=ee.Object,od=ed.exports=function(e,t,r){return id.defineProperty(e,t,r)};id.defineProperty.sham&&(od.sham=!0);var ad=ed.exports,sd=TypeError,cd=function(e){if(e>9007199254740991)throw sd("Maximum allowed index exceeded");return e},ud=Ar,dd=i,ld=eo,hd=$,pd=Xe,vd=Br,fd=cd,_d=Qn,md=Ro,yd=Ps,gd=ve,Sd=lt("isConcatSpreadable"),bd=gd>=51||!dd((function(){var e=[];return e[Sd]=!1,e.concat()[0]!==e})),Ed=yd("concat"),kd=function(e){if(!hd(e))return!1;var t=e[Sd];return void 0!==t?!!t:ld(e)};ud({target:"Array",proto:!0,arity:1,forced:!bd||!Ed},{concat:function(e){var t,r,n,i,o,a=pd(this),s=md(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(kd(o=-1===t?a:arguments[t]))for(i=vd(o),fd(c+i),r=0;r<i;r++,c++)r in o&&_d(s,c,o[r]);else fd(c+1),_d(s,c++,o);return s.length=c,s}}),bi("asyncIterator"),bi("hasInstance"),bi("isConcatSpreadable"),bi("iterator"),bi("match"),bi("matchAll"),bi("replace"),bi("search"),bi("species"),bi("split");var Td=Ri;bi("toPrimitive"),Td();var Id=oe,Rd=Ni;bi("toStringTag"),Rd(Id("Symbol"),"Symbol"),bi("unscopables"),Ni(n.JSON,"JSON",!0);var Ad=ee.Symbol;bi("asyncDispose"),bi("dispose"),bi("matcher"),bi("metadataKey"),bi("observable"),bi("metadata"),bi("patternMatch"),bi("replaceAll");var wd=Ad,Cd=E,xd=Or,Od=yn,Md=W,Dd=Cd("".charAt),Pd=Cd("".charCodeAt),Nd=Cd("".slice),Ld=function(e){return function(t,r){var n,i,o=Od(Md(t)),a=xd(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Pd(o,a))<55296||n>56319||a+1===s||(i=Pd(o,a+1))<56320||i>57343?e?Dd(o,a):n:e?Nd(o,a,a+2):i-56320+(n-55296<<10)+65536}},Ud={codeAt:Ld(!1),charAt:Ld(!0)},Vd=Ud.charAt,Fd=yn,Bd=Zi,jd=iu,Hd=ou,Gd="String Iterator",zd=Bd.set,Kd=Bd.getterFor(Gd);jd(String,"String",(function(e){zd(this,{type:Gd,string:Fd(e),index:0})}),(function(){var e,t=Kd(this),r=t.string,n=t.index;return n>=r.length?Hd(void 0,!0):(e=Vd(r,n),t.index+=e.length,Hd(e,!1))}));var Xd=hi.f("iterator");function Wd(e){return(Wd="function"==typeof wd&&"symbol"==typeof Xd?function(e){return typeof e}:function(e){return e&&"function"==typeof wd&&e.constructor===wd&&e!==wd.prototype?"symbol":typeof e})(e)}var qd=hi.f("toPrimitive");function Yd(e){var t=function(e,t){if("object"!==Wd(e)||null===e)return e;var r=e[qd];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==Wd(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Wd(t)?t:String(t)}function Jd(e,t,r){return(t=Yd(t))in e?ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Qd(e,t){var r=an(e);if(xs){var n=xs(e);t&&(n=Hs(n).call(n,(function(t){return tc(e,t).enumerable}))),r.push.apply(r,n)}return r}function Zd(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?Nu(r=Qd(Object(i),!0)).call(r,(function(t){Jd(e,t,i[t])})):Xu?$u(e,Xu(i)):Nu(n=Qd(Object(i))).call(n,(function(t){ad(e,t,tc(i,t))}))}return e}var $d=function(e){return e[e.VIDEO_SOURCE_TYPE_EXTERNAL=0]="VIDEO_SOURCE_TYPE_EXTERNAL",e[e.VIDEO_SOURCE_TYPE_INTERNAL=1]="VIDEO_SOURCE_TYPE_INTERNAL",e}($d||{}),el=function(e){return e[e.AUDIO_SOURCE_TYPE_EXTERNAL=0]="AUDIO_SOURCE_TYPE_EXTERNAL",e[e.AUDIO_SOURCE_TYPE_INTERNAL=1]="AUDIO_SOURCE_TYPE_INTERNAL",e}(el||{}),tl=function(e){return e[e.QUIT=0]="QUIT",e[e.DROPPED=1]="DROPPED",e[e.SWITCH_TO_INVISIBLE=2]="SWITCH_TO_INVISIBLE",e[e.KICKED_BY_ADMIN=3]="KICKED_BY_ADMIN",e}(tl||{}),rl=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(rl||{}),nl=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(nl||{}),il=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(il||{}),ol=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(ol||{}),al=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(al||{}),sl=function(e){return e[e.RENDER_MODE_HIDDEN=0]="RENDER_MODE_HIDDEN",e[e.RENDER_MODE_FIT=1]="RENDER_MODE_FIT",e[e.RENDER_MODE_FILL=2]="RENDER_MODE_FILL",e}(sl||{}),cl=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(cl||{}),ul=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(ul||{}),dl=function(e){return e[e.STREAM_REMOVE_REASON_UNPUBLISH=0]="STREAM_REMOVE_REASON_UNPUBLISH",e[e.STREAM_REMOVE_REASON_PUBLISH_FAILED=1]="STREAM_REMOVE_REASON_PUBLISH_FAILED",e[e.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED=2]="STREAM_REMOVE_REASON_KEEP_LIVE_FAILED",e[e.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED=3]="STREAM_REMOVE_REASON_CLIENT_DISCONNECTED",e[e.STREAM_REMOVE_REASON_REPUBLISH=4]="STREAM_REMOVE_REASON_REPUBLISH",e[e.STREAM_REMOVE_REASON_OTHER=5]="STREAM_REMOVE_REASON_OTHER",e}(dl||{}),ll=function(e){return e[e.CONNECTION_START=0]="CONNECTION_START",e[e.CONNECTION_STATE_DISCONNECTED=1]="CONNECTION_STATE_DISCONNECTED",e[e.CONNECTION_STATE_CONNECTING=2]="CONNECTION_STATE_CONNECTING",e[e.CONNECTION_STATE_CONNECTED=3]="CONNECTION_STATE_CONNECTED",e[e.CONNECTION_STATE_RECONNECTING=4]="CONNECTION_STATE_RECONNECTING",e[e.CONNECTION_STATE_RECONNECTED=5]="CONNECTION_STATE_RECONNECTED",e[e.CONNECTION_STATE_LOST=6]="CONNECTION_STATE_LOST",e}(ll||{}),hl=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(hl||{}),pl=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(pl||{}),vl=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(vl||{}),fl=function(e){return e[e.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",e[e.AUDIO_ONLY=1]="AUDIO_ONLY",e[e.VIDEO_ONLY=2]="VIDEO_ONLY",e}(fl||{}),_l=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(_l||{}),ml=function(e){return e[e.DISABLE=0]="DISABLE",e[e.VIDEO_STREAM_LOW=1]="VIDEO_STREAM_LOW",e[e.AUDIO_ONLY=2]="AUDIO_ONLY",e}(ml||{}),yl=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(yl||{}),gl=function(e){return e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VBAD=5]="VBAD",e[e.DOWN=6]="DOWN",e}(gl||{}),Sl=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(Sl||{}),bl=function(e){return e[e.communication=0]="communication",e[e.chat=5]="chat",e[e.chatRoom=6]="chatRoom",e[e.coHost=9]="coHost",e[e.meeting=16]="meeting",e[e.classRoom=18]="classRoom",e}(bl||{}),El=function(e){return e[e.default=0]="default",e[e.fluent=1]="fluent",e[e.standard=2]="standard",e[e.hd=3]="hd",e[e.standardStereo=4]="standardStereo",e[e.hdMono=5]="hdMono",e}(El||{}),kl=function(e){return e[e.AUTO_PLAY=0]="AUTO_PLAY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.PLAY_MANUALLY=2]="PLAY_MANUALLY",e}(kl||{}),Tl=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(Tl||{}),Il=function(e){return e.H264="H264",e.H265="H265",e}(Il||{}),Rl=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(Rl||{}),Al=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(Al||{}),wl=function(e){return e[e.FORWARD_STREAM_STATE_SUCCESS=0]="FORWARD_STREAM_STATE_SUCCESS",e[e.FORWARD_STREAM_STATE_FAILURE=1]="FORWARD_STREAM_STATE_FAILURE",e}(wl||{}),Cl=function(e){return e[e.FORWARD_STREAM_ERROR_OK=0]="FORWARD_STREAM_ERROR_OK",e[e.FORWARD_STREAM_ERROR_INVALID_TOKEN=1202]="FORWARD_STREAM_ERROR_INVALID_TOKEN",e[e.FORWARD_STREAM_ERROR_RESPONSE=1203]="FORWARD_STREAM_ERROR_RESPONSE",e[e.FORWARD_STREAM_ERROR_REMOTE_KICKED=1204]="FORWARD_STREAM_ERROR_REMOTE_KICKED",e[e.FORWARD_STREAM_ERROR_NOT_SUPPORT=1205]="FORWARD_STREAM_ERROR_NOT_SUPPORT",e}(Cl||{}),xl=Object.freeze(Object.defineProperty({__proto__:null,VideoSourceType:$d,AudioSourceType:el,UserOfflineReason:tl,ChannelProfile:rl,SubscribeMode:nl,SubscribeState:il,PublishState:ol,MirrorMode:al,VideoRenderMode:sl,StreamIndex:cl,MediaType:ul,StreamRemoveReason:dl,ConnectionState:ll,MirrorType:hl,LogChannel:pl,USER_ONLINE_STATUS:vl,PublicStreamType:fl,PublicInterpolationMode:_l,SubscribeFallbackOption:ml,RemoteUserPriority:yl,NetworkQuality:gl,FallbackOrRecoverReason:Sl,RoomProfileType:bl,AudioProfileType:El,RTCAutoPlayPolicy:kl,AAC_PROFILE:Tl,TRANSCODING_VIDEO_CODEC:Il,SUBTITLE_MODE:Rl,SubtitleEventType:Al,ForwardStreamState:wl,ForwardStreamError:Cl},Symbol.toStringTag,{value:"Module"})),Ol=function(e){return e[e.AUTO=0]="AUTO",e[e.MODE_L=1]="MODE_L",e[e.MODE_R=2]="MODE_R",e[e.MODE_MIX=3]="MODE_MIX",e}(Ol||{}),Ml=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(Ml||{}),Dl=function(e){return e[e.AUDIO_MIXING_STATE_PRELOADED=0]="AUDIO_MIXING_STATE_PRELOADED",e[e.AUDIO_MIXING_STATE_PLAYING=1]="AUDIO_MIXING_STATE_PLAYING",e[e.AUDIO_MIXING_STATE_PAUSED=2]="AUDIO_MIXING_STATE_PAUSED",e[e.AUDIO_MIXING_STATE_STOPPED=3]="AUDIO_MIXING_STATE_STOPPED",e[e.AUDIO_MIXING_STATE_FAILED=4]="AUDIO_MIXING_STATE_FAILED",e[e.AUDIO_MIXING_STATE_FINISHED=5]="AUDIO_MIXING_STATE_FINISHED",e[e.AUDIO_MIXING_STATE_PCM_ENABLED=6]="AUDIO_MIXING_STATE_PCM_ENABLED",e[e.AUDIO_MIXING_STATE_PCM_DISABLED=7]="AUDIO_MIXING_STATE_PCM_DISABLED",e}(Dl||{}),Pl=Object.freeze(Object.defineProperty({__proto__:null,AudioMixingDualMonoMode:Ol,AudioMixingType:Ml,AudioMixingState:Dl},Symbol.toStringTag,{value:"Module"})),Nl=function(e){return e.onTrackEnded="onTrackEnded",e.onTrackMute="onTrackMute",e.onTrackUnmute="onTrackUnmute",e.onPlayerEvent="onPlayerEvent",e.onAutoplayFailed="onAutoplayFailed",e.onUserJoined="onUserJoined",e.onUserLeave="onUserLeave",e.onConnectionStateChanged="onConnectionStateChanged",e.onUserPublishStream="onUserPublishStream",e.onUserUnpublishStream="onUserUnpublishStream",e.onUserPublishScreen="onUserPublishScreen",e.onUserUnpublishScreen="onUserUnpublishScreen",e.onRoomMessageReceived="onRoomMessageReceived",e.onRoomBinaryMessageReceived="onRoomBinaryMessageReceived",e.onUserMessageReceived="onUserMessageReceived",e.onUserBinaryMessageReceived="onUserBinaryMessageReceived",e.onVideoFirstFrameRendered="onVideoFirstFrameRendered",e.onVideoFirstFrameDecoded="onVideoFirstFrameDecoded",e.onRemoteVideoFirstFrame="onRemoteVideoFirstFrame",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onRemoteAudioFirstFrame="onRemoteAudioFirstFrame",e.onFirstPublicStreamVideoFrameRendered="onFirstPublicStreamVideoFrameRendered",e.onFirstPublicStreamVideoFrameDecoded="onFirstPublicStreamVideoFrameDecoded",e.onFirstPublicStreamAudioFrameDecoded="onFirstPublicStreamAudioFrameDecoded",e.onVideoDeviceStateChanged="onVideoDeviceStateChanged",e.onAudioDeviceStateChanged="onAudioDeviceStateChanged",e.onRemoteStreamStats="onRemoteStreamStats",e.onPublicStreamStats="onPublicStreamStats",e.onLocalStreamStats="onLocalStreamStats",e.onAudioVolumeIndication="onAudioVolumeIndication",e.onLocalAudioPropertiesReport="onLocalAudioPropertiesReport",e.onRemoteAudioPropertiesReport="onRemoteAudioPropertiesReport",e.onActiveSpeaker="onActiveSpeaker",e.onAudioPlaybackDeviceChanged="onAudioPlaybackDeviceChanged",e.onUserStartVideoCapture="onUserStartVideoCapture",e.onUserStopVideoCapture="onUserStopVideoCapture",e.onUserStartAudioCapture="onUserStartAudioCapture",e.onUserStopAudioCapture="onUserStopAudioCapture",e.onAutoPublishResult="onAutoPublishResult",e.onAutoSubscribeResult="onAutoSubscribeResult",e.onLiveTranscodingResult="onLiveTranscodingResult",e.onStreamMixingEvent="onStreamMixingEvent",e.onAudioPlaybackDeviceTestVolume="onAudioPlaybackDeviceTestVolume",e.onSEIMessageReceived="onSEIMessageReceived",e.onError="onError",e.onAudioMixingStateChanged="onAudioMixingStateChanged",e.onUserMessageReceivedOutsideRoom="onUserMessageReceivedOutsideRoom",e.onUserBinaryMessageReceivedOutsideRoom="onUserBinaryMessageReceivedOutsideRoom",e.onTokenWillExpire="onTokenWillExpire",e.onCloudProxyConnected="onCloudProxyConnected",e.onPushPublicStreamResult="onPushPublicStreamResult",e.onPublicStreamSEIMessageReceived="onPublicStreamSEIMessageReceived",e.onNetworkQuality="onNetworkQuality",e.onSimulcastSubscribeFallback="onSimulcastSubscribeFallback",e.onRemoteVideoSizeChanged="onRemoteVideoSizeChanged",e.onVideoStreamBanned="onVideoStreamBanned",e.onAudioStreamBanned="onAudioStreamBanned",e.onLocalVideoSizeChanged="onLocalVideoSizeChanged",e.onSubtitleStateChanged="onSubtitleStateChanged",e.onSubtitleMessageReceived="onSubtitleMessageReceived",e.onServerParamsSetResult="onServerParamsSetResult",e.onLocalStreamTrackChangedByExtension="onLocalStreamTrackChangedByExtension",e.onVendorConnectionStateChanged="onVendorConnectionStateChanged",e.onForwardStreamError="onForwardStreamError",e.onRejoinWithTcp="onRejoinWithTcp",e.onIceConnectWithTcp="onIceConnectWithTcp",e}(Nl||{});function Ll(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),ad(e,Yd(n.key),n)}}function Ul(e,t,r){return t&&Ll(e.prototype,t),r&&Ll(e,r),ad(e,"prototype",{writable:!1}),e}function Vl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Ar({target:"Object",stat:!0,sham:!w},{create:Gn});var Fl=ee.Object,Bl=function(e,t){return Fl.create(e,t)},jl=Xe,Hl=mc,Gl=uc;Ar({target:"Object",stat:!0,forced:i((function(){Hl(1)})),sham:!Gl},{getPrototypeOf:function(e){return Hl(jl(e))}});var zl=ee.Object.getPrototypeOf;Ar({target:"Object",stat:!0},{setPrototypeOf:jc});var Kl=ee.Object.setPrototypeOf,Xl=Ye,Wl=ju,ql=A,Yl=Jt,Jl=Error,Ql=E("".replace),Zl=String(Jl("zxcasd").stack),$l=/\n\s*at [^:]*:[^\n]*/,eh=$l.test(Zl),th=$,rh=fr,nh=rc,ih=lt("iterator"),oh=Array.prototype,ah=function(e){return void 0!==e&&(nh.Array===e||oh[ih]===e)},sh=fn,ch=Me,uh=z,dh=rc,lh=lt("iterator"),hh=function(e){if(!uh(e))return ch(e,lh)||ch(e,"@@iterator")||dh[sh(e)]},ph=O,vh=Ce,fh=tr,_h=Ie,mh=hh,yh=TypeError,gh=function(e,t){var r=arguments.length<2?mh(e):t;if(vh(r))return fh(ph(r,e));throw yh(_h(e)+" is not iterable")},Sh=O,bh=tr,Eh=Me,kh=function(e,t,r){var n,i;bh(e);try{if(!(n=Eh(e,"return"))){if("throw"===t)throw r;return r}n=Sh(n,e)}catch(o){i=!0,n=o}if("throw"===t)throw r;if(i)throw n;return bh(n),r},Th=Yt,Ih=O,Rh=tr,Ah=Ie,wh=ah,Ch=Br,xh=ae,Oh=gh,Mh=hh,Dh=kh,Ph=TypeError,Nh=function(e,t){this.stopped=e,this.result=t},Lh=Nh.prototype,Uh=function(e,t,r){var n,i,o,a,s,c,u,d=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),v=!(!r||!r.INTERRUPTED),f=Th(t,d),_=function(e){return n&&Dh(n,"normal",e),new Nh(!0,e)},m=function(e){return l?(Rh(e),v?f(e[0],e[1],_):f(e[0],e[1])):v?f(e,_):f(e)};if(h)n=e.iterator;else if(p)n=e;else{if(!(i=Mh(e)))throw Ph(Ah(e)+" is not iterable");if(wh(i)){for(o=0,a=Ch(e);a>o;o++)if((s=m(e[o]))&&xh(Lh,s))return s;return new Nh(!1)}n=Oh(e,i)}for(c=h?e.next:n.next;!(u=Ih(c,n)).done;){try{s=m(u.value)}catch(y){Dh(n,"throw",y)}if("object"==typeof s&&s&&xh(Lh,s))return s}return new Nh(!1)},Vh=yn,Fh=V,Bh=!i((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Fh(1,7)),7!==e.stack)})),jh=Ar,Hh=ae,Gh=mc,zh=jc,Kh=function(e,t,r){for(var n=Wl(t),i=Yl.f,o=ql.f,a=0;a<n.length;a++){var s=n[a];Xl(e,s)||r&&Xl(r,s)||i(e,s,o(t,s))}},Xh=Gn,Wh=fr,qh=V,Yh=function(e,t){if(eh&&"string"==typeof e&&!Jl.prepareStackTrace)for(;t--;)e=Ql(e,$l,"");return e},Jh=function(e,t){th(t)&&"cause"in t&&rh(e,"cause",t.cause)},Qh=Uh,Zh=function(e,t){return void 0===e?arguments.length<2?"":t:Vh(e)},$h=Bh,ep=lt("toStringTag"),tp=Error,rp=[].push,np=function(e,t){var r,n=arguments.length>2?arguments[2]:void 0,i=Hh(ip,this);zh?r=zh(tp(),i?Gh(this):ip):(r=i?this:Xh(ip),Wh(r,ep,"Error")),void 0!==t&&Wh(r,"message",Zh(t)),$h&&Wh(r,"stack",Yh(r.stack,1)),Jh(r,n);var o=[];return Qh(e,rp,{that:o}),Wh(r,"errors",o),r};zh?zh(np,tp):Kh(np,tp,{name:!0});var ip=np.prototype=Xh(tp.prototype,{constructor:qh(1,np),message:qh(1,""),name:qh(1,"AggregateError")});jh({global:!0,constructor:!0,arity:2},{AggregateError:np});var op,ap,sp,cp,up="process"==g(n.process),dp=oe,lp=Jt,hp=w,pp=lt("species"),vp=function(e){var t=dp(e),r=lp.f;hp&&t&&!t[pp]&&r(t,pp,{configurable:!0,get:function(){return this}})},fp=ae,_p=TypeError,mp=function(e,t){if(fp(t,e))return e;throw _p("Incorrect invocation")},yp=go,gp=Ie,Sp=TypeError,bp=function(e){if(yp(e))return e;throw Sp(gp(e)+" is not a constructor")},Ep=tr,kp=bp,Tp=z,Ip=lt("species"),Rp=function(e,t){var r,n=Ep(e).constructor;return void 0===n||Tp(r=Ep(n)[Ip])?t:kp(r)},Ap=TypeError,wp=function(e,t){if(e<t)throw Ap("Not enough arguments");return e},Cp=/(?:ipad|iphone|ipod).*applewebkit/i.test(se),xp=n,Op=d,Mp=Yt,Dp=R,Pp=Ye,Np=i,Lp=An,Up=rs,Vp=It,Fp=wp,Bp=Cp,jp=up,Hp=xp.setImmediate,Gp=xp.clearImmediate,zp=xp.process,Kp=xp.Dispatch,Xp=xp.Function,Wp=xp.MessageChannel,qp=xp.String,Yp=0,Jp={},Qp="onreadystatechange";try{op=xp.location}catch(uq){}var Zp=function(e){if(Pp(Jp,e)){var t=Jp[e];delete Jp[e],t()}},$p=function(e){return function(){Zp(e)}},ev=function(e){Zp(e.data)},tv=function(e){xp.postMessage(qp(e),op.protocol+"//"+op.host)};Hp&&Gp||(Hp=function(e){Fp(arguments.length,1);var t=Dp(e)?e:Xp(e),r=Up(arguments,1);return Jp[++Yp]=function(){Op(t,void 0,r)},ap(Yp),Yp},Gp=function(e){delete Jp[e]},jp?ap=function(e){zp.nextTick($p(e))}:Kp&&Kp.now?ap=function(e){Kp.now($p(e))}:Wp&&!Bp?(cp=(sp=new Wp).port2,sp.port1.onmessage=ev,ap=Mp(cp.postMessage,cp)):xp.addEventListener&&Dp(xp.postMessage)&&!xp.importScripts&&op&&"file:"!==op.protocol&&!Np(tv)?(ap=tv,xp.addEventListener("message",ev,!1)):ap=Qp in Vp("script")?function(e){Lp.appendChild(Vp("script")).onreadystatechange=function(){Lp.removeChild(this),Zp(e)}}:function(e){setTimeout($p(e),0)});var rv,nv,iv,ov,av,sv,cv,uv,dv={set:Hp,clear:Gp},lv=n,hv=/ipad|iphone|ipod/i.test(se)&&void 0!==lv.Pebble,pv=/web0s(?!.*chrome)/i.test(se),vv=n,fv=Yt,_v=A.f,mv=dv.set,yv=Cp,gv=hv,Sv=pv,bv=up,Ev=vv.MutationObserver||vv.WebKitMutationObserver,kv=vv.document,Tv=vv.process,Iv=vv.Promise,Rv=_v(vv,"queueMicrotask"),Av=Rv&&Rv.value;Av||(rv=function(){var e,t;for(bv&&(e=Tv.domain)&&e.exit();nv;){t=nv.fn,nv=nv.next;try{t()}catch(uq){throw nv?ov():iv=void 0,uq}}iv=void 0,e&&e.enter()},yv||bv||Sv||!Ev||!kv?!gv&&Iv&&Iv.resolve?((cv=Iv.resolve(void 0)).constructor=Iv,uv=fv(cv.then,cv),ov=function(){uv(rv)}):bv?ov=function(){Tv.nextTick(rv)}:(mv=fv(mv,vv),ov=function(){mv(rv)}):(av=!0,sv=kv.createTextNode(""),new Ev(rv).observe(sv,{characterData:!0}),ov=function(){sv.data=av=!av}));var wv=Av||function(e){var t={fn:e,next:void 0};iv&&(iv.next=t),nv||(nv=t,ov()),iv=t},Cv=n,xv=function(e){try{return{error:!1,value:e()}}catch(uq){return{error:!0,value:uq}}},Ov=function(){this.head=null,this.tail=null};Ov.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var Mv=Ov,Dv=n.Promise,Pv="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Nv=!Pv&&!up&&"object"==typeof window&&"object"==typeof document,Lv=n,Uv=Dv,Vv=R,Fv=Kt,Bv=io,jv=lt,Hv=Nv,Gv=Pv,zv=ve,Kv=Uv&&Uv.prototype,Xv=jv("species"),Wv=!1,qv=Vv(Lv.PromiseRejectionEvent),Yv={CONSTRUCTOR:Fv("Promise",(function(){var e=Bv(Uv),t=e!==String(Uv);if(!t&&66===zv)return!0;if(!Kv.catch||!Kv.finally)return!0;if(!zv||zv<51||!/native code/.test(e)){var r=new Uv((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[Xv]=n,!(Wv=r.then((function(){}))instanceof n))return!0}return!t&&(Hv||Gv)&&!qv})),REJECTION_EVENT:qv,SUBCLASSING:Wv},Jv={},Qv=Ce,Zv=TypeError,$v=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw Zv("Bad Promise constructor");t=e,r=n})),this.resolve=Qv(t),this.reject=Qv(r)};Jv.f=function(e){return new $v(e)};var ef,tf,rf=Ar,nf=up,of=n,af=O,sf=li,cf=Ni,uf=vp,df=Ce,lf=R,hf=$,pf=mp,vf=Rp,ff=dv.set,_f=wv,mf=function(e,t){var r=Cv.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},yf=xv,gf=Mv,Sf=Zi,bf=Dv,Ef=Yv,kf=Jv,Tf="Promise",If=Ef.CONSTRUCTOR,Rf=Ef.REJECTION_EVENT,Af=Sf.getterFor(Tf),wf=Sf.set,Cf=bf&&bf.prototype,xf=bf,Of=Cf,Mf=of.TypeError,Df=of.document,Pf=of.process,Nf=kf.f,Lf=Nf,Uf=!!(Df&&Df.createEvent&&of.dispatchEvent),Vf="unhandledrejection",Ff=function(e){var t;return!(!hf(e)||!lf(t=e.then))&&t},Bf=function(e,t){var r,n,i,o=t.value,a=1==t.state,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&Kf(t),t.rejection=1),!0===s?r=o:(d&&d.enter(),r=s(o),d&&(d.exit(),i=!0)),r===e.promise?u(Mf("Promise-chain cycle")):(n=Ff(r))?af(n,r,c,u):c(r)):u(o)}catch(uq){d&&!i&&d.exit(),u(uq)}},jf=function(e,t){e.notified||(e.notified=!0,_f((function(){for(var r,n=e.reactions;r=n.get();)Bf(r,e);e.notified=!1,t&&!e.rejection&&Gf(e)})))},Hf=function(e,t,r){var n,i;Uf?((n=Df.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),of.dispatchEvent(n)):n={promise:t,reason:r},!Rf&&(i=of["on"+e])?i(n):e===Vf&&mf("Unhandled promise rejection",r)},Gf=function(e){af(ff,of,(function(){var t,r=e.facade,n=e.value;if(zf(e)&&(t=yf((function(){nf?Pf.emit("unhandledRejection",n,r):Hf(Vf,r,n)})),e.rejection=nf||zf(e)?2:1,t.error))throw t.value}))},zf=function(e){return 1!==e.rejection&&!e.parent},Kf=function(e){af(ff,of,(function(){var t=e.facade;nf?Pf.emit("rejectionHandled",t):Hf("rejectionhandled",t,e.value)}))},Xf=function(e,t,r){return function(n){e(t,n,r)}},Wf=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,jf(e,!0))},qf=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw Mf("Promise can't be resolved itself");var n=Ff(t);n?_f((function(){var r={done:!1};try{af(n,t,Xf(qf,r,e),Xf(Wf,r,e))}catch(uq){Wf(r,uq,e)}})):(e.value=t,e.state=1,jf(e,!1))}catch(uq){Wf({done:!1},uq,e)}}};If&&(Of=(xf=function(e){pf(this,Of),df(e),af(ef,this);var t=Af(this);try{e(Xf(qf,t),Xf(Wf,t))}catch(uq){Wf(t,uq)}}).prototype,(ef=function(e){wf(this,{type:Tf,done:!1,notified:!1,parent:!1,reactions:new gf,rejection:!1,state:0,value:void 0})}).prototype=sf(Of,"then",(function(e,t){var r=Af(this),n=Nf(vf(this,xf));return r.parent=!0,n.ok=!lf(e)||e,n.fail=lf(t)&&t,n.domain=nf?Pf.domain:void 0,0==r.state?r.reactions.add(n):_f((function(){Bf(n,r)})),n.promise})),tf=function(){var e=new ef,t=Af(e);this.promise=e,this.resolve=Xf(qf,t),this.reject=Xf(Wf,t)},kf.f=Nf=function(e){return e===xf||undefined===e?new tf(e):Lf(e)}),rf({global:!0,constructor:!0,wrap:!0,forced:If},{Promise:xf}),cf(xf,Tf,!1,!0),uf(Tf);var Yf=lt("iterator"),Jf=!1;try{var Qf=0,Zf={next:function(){return{done:!!Qf++}},return:function(){Jf=!0}};Zf[Yf]=function(){return this},Array.from(Zf,(function(){throw 2}))}catch(uq){}var $f=function(e,t){if(!t&&!Jf)return!1;var r=!1;try{var n={};n[Yf]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(uq){}return r},e_=Dv,t_=Yv.CONSTRUCTOR||!$f((function(e){e_.all(e).then(void 0,(function(){}))})),r_=O,n_=Ce,i_=Jv,o_=xv,a_=Uh;Ar({target:"Promise",stat:!0,forced:t_},{all:function(e){var t=this,r=i_.f(t),n=r.resolve,i=r.reject,o=o_((function(){var r=n_(t.resolve),o=[],a=0,s=1;a_(e,(function(e){var c=a++,u=!1;s++,r_(r,t,e).then((function(e){u||(u=!0,o[c]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var s_=Ar,c_=Yv.CONSTRUCTOR;Dv&&Dv.prototype,s_({target:"Promise",proto:!0,forced:c_,real:!0},{catch:function(e){return this.then(void 0,e)}});var u_=O,d_=Ce,l_=Jv,h_=xv,p_=Uh;Ar({target:"Promise",stat:!0,forced:t_},{race:function(e){var t=this,r=l_.f(t),n=r.reject,i=h_((function(){var i=d_(t.resolve);p_(e,(function(e){u_(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var v_=O,f_=Jv;Ar({target:"Promise",stat:!0,forced:Yv.CONSTRUCTOR},{reject:function(e){var t=f_.f(this);return v_(t.reject,void 0,e),t.promise}});var __=tr,m_=$,y_=Jv,g_=function(e,t){if(__(e),m_(t)&&t.constructor===e)return t;var r=y_.f(e);return(0,r.resolve)(t),r.promise},S_=Ar,b_=Dv,E_=Yv.CONSTRUCTOR,k_=g_,T_=oe("Promise"),I_=!E_;S_({target:"Promise",stat:!0,forced:true},{resolve:function(e){return k_(I_&&this===T_?b_:this,e)}});var R_=O,A_=Ce,w_=Jv,C_=xv,x_=Uh;Ar({target:"Promise",stat:!0},{allSettled:function(e){var t=this,r=w_.f(t),n=r.resolve,i=r.reject,o=C_((function(){var r=A_(t.resolve),i=[],o=0,a=1;x_(e,(function(e){var s=o++,c=!1;a++,R_(r,t,e).then((function(e){c||(c=!0,i[s]={status:"fulfilled",value:e},--a||n(i))}),(function(e){c||(c=!0,i[s]={status:"rejected",reason:e},--a||n(i))}))})),--a||n(i)}));return o.error&&i(o.value),r.promise}});var O_=O,M_=Ce,D_=oe,P_=Jv,N_=xv,L_=Uh,U_="No one promise resolved";Ar({target:"Promise",stat:!0},{any:function(e){var t=this,r=D_("AggregateError"),n=P_.f(t),i=n.resolve,o=n.reject,a=N_((function(){var n=M_(t.resolve),a=[],s=0,c=1,u=!1;L_(e,(function(e){var d=s++,l=!1;c++,O_(n,t,e).then((function(e){l||u||(u=!0,i(e))}),(function(e){l||u||(l=!0,a[d]=e,--c||o(new r(a,U_)))}))})),--c||o(new r(a,U_))}));return a.error&&o(a.value),n.promise}});var V_=Ar,F_=Dv,B_=i,j_=oe,H_=R,G_=Rp,z_=g_,K_=F_&&F_.prototype;V_({target:"Promise",proto:!0,real:!0,forced:!!F_&&B_((function(){K_.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=G_(this,j_("Promise")),r=H_(e);return this.then(r?function(r){return z_(t,e()).then((function(){return r}))}:e,r?function(r){return z_(t,e()).then((function(){throw r}))}:e)}});var X_=ee.Promise,W_=Jv,q_=xv;Ar({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=W_.f(this),r=q_(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var Y_=X_,J_=Ar,Q_=eo,Z_=E([].reverse),$_=[1,2];J_({target:"Array",proto:!0,forced:String($_)===String($_.reverse())},{reverse:function(){return Q_(this)&&(this.length=this.length),Z_(this)}});var em=Us("Array").reverse,tm=ae,rm=em,nm=Array.prototype,im=function(e){var t=e.reverse;return e===nm||tm(nm,e)&&t===nm.reverse?rm:t},om=Ar,am=eo,sm=go,cm=$,um=Nr,dm=Br,lm=J,hm=Qn,pm=lt,vm=rs,fm=Ps("slice"),_m=pm("species"),mm=Array,ym=Math.max;om({target:"Array",proto:!0,forced:!fm},{slice:function(e,t){var r,n,i,o=lm(this),a=dm(o),s=um(e,a),c=um(void 0===t?a:t,a);if(am(o)&&(r=o.constructor,(sm(r)&&(r===mm||am(r.prototype))||cm(r)&&null===(r=r[_m]))&&(r=void 0),r===mm||void 0===r))return vm(o,s,c);for(n=new(void 0===r?mm:r)(ym(c-s,0)),i=0;s<c;s++,i++)s in o&&hm(n,i,o[s]);return n.length=i,n}});var gm=Us("Array").slice,Sm=ae,bm=gm,Em=Array.prototype,km=function(e){var t=e.slice;return e===Em||Sm(Em,e)&&t===Em.slice?bm:t};function Tm(){Tm=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=ad||function(e,t,r){e[t]=r.value},i="function"==typeof wd?wd:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,r){return ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(A){c=function(e,t,r){return e[t]=r}}function u(e,t,r,i){var o=t&&t.prototype instanceof h?t:h,a=Bl(o.prototype),s=new T(i||[]);return n(a,"_invoke",{value:S(e,r,s)}),a}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(A){return{type:"throw",arg:A}}}e.wrap=u;var l={};function h(){}function p(){}function v(){}var f={};c(f,o,(function(){return this}));var _=zl&&zl(zl(I([])));_&&_!==t&&r.call(_,o)&&(f=_);var m=v.prototype=h.prototype=Bl(f);function y(e){var t;Nu(t=["next","throw","return"]).call(t,(function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){function i(n,o,a,s){var c=d(e[n],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Wd(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return i("throw",e,a,s)}))}s(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function S(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=b(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=d(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function b(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),l;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,l;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],Nu(e).call(e,E,this),this.reset(!0)}function I(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:R}}function R(){return{value:void 0,done:!0}}return p.prototype=v,n(m,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:p,configurable:!0}),p.displayName=c(v,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Kl?Kl(e,v):(e.__proto__=v,c(e,s,"GeneratorFunction")),e.prototype=Bl(m),e},e.awrap=function(e){return{__await:e}},y(g.prototype),c(g.prototype,a,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Y_);var a=new g(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},y(m),c(m,s,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return im(r).call(r),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,T.prototype={constructor:T,reset:function(e){var t;if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,Nu(t=this.tryEntries).call(t,k),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+km(n).call(n,1))&&(this[n]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;k(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function Im(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(uq){return void r(uq)}s.done?t(c):Y_.resolve(c).then(n,i)}function Rm(e){return function(){var t=this,r=arguments;return new Y_((function(n,i){var o=e.apply(t,r);function a(e){Im(o,n,i,a,s,"next",e)}function s(e){Im(o,n,i,a,s,"throw",e)}a(void 0)}))}}var Am=Us("Array").concat,wm=ae,Cm=Am,xm=Array.prototype,Om=function(e){var t=e.concat;return e===xm||wm(xm,e)&&t===xm.concat?Cm:t},Mm=ee,Dm=d;Mm.JSON||(Mm.JSON={stringify:JSON.stringify});var Pm=function(e,t,r){return Dm(Mm.JSON.stringify,null,arguments)},Nm=Pm,Lm=Po.map;Ar({target:"Array",proto:!0,forced:!Ps("map")},{map:function(e){return Lm(this,e,arguments.length>1?arguments[1]:void 0)}});var Um=Us("Array").map,Vm=ae,Fm=Um,Bm=Array.prototype,jm=function(e){var t=e.map;return e===Bm||Vm(Bm,e)&&t===Bm.map?Fm:t},Hm="\t\n\v\f\r                 \u2028\u2029\ufeff",Gm=W,zm=yn,Km=E("".replace),Xm="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Wm=RegExp("^"+Xm+Xm+"*"),qm=RegExp(Xm+Xm+"*$"),Ym=function(e){return function(t){var r=zm(Gm(t));return 1&e&&(r=Km(r,Wm,"")),2&e&&(r=Km(r,qm,"")),r}},Jm={start:Ym(1),end:Ym(2),trim:Ym(3)},Qm=n,Zm=i,$m=E,ey=yn,ty=Jm.trim,ry=Hm,ny=Qm.parseInt,iy=Qm.Symbol,oy=iy&&iy.iterator,ay=/^[+-]?0x/i,sy=$m(ay.exec),cy=8!==ny(ry+"08")||22!==ny(ry+"0x16")||oy&&!Zm((function(){ny(Object(oy))}))?function(e,t){var r=ty(ey(e));return ny(r,t>>>0||(sy(ay,r)?16:10))}:ny;Ar({global:!0,forced:parseInt!=cy},{parseInt:cy});var uy=ee.parseInt,dy={exports:{}},ly=i((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),hy=i,py=$,vy=g,fy=ly,_y=Object.isExtensible,my=hy((function(){_y(1)}))||fy?function(e){return!!py(e)&&((!fy||"ArrayBuffer"!=vy(e))&&(!_y||_y(e)))}:_y,yy=!i((function(){return Object.isExtensible(Object.preventExtensions({}))})),gy=Ar,Sy=E,by=Xr,Ey=$,ky=Ye,Ty=Jt.f,Iy=zn,Ry=Wn,Ay=my,wy=yy,Cy=!1,xy=et("meta"),Oy=0,My=function(e){Ty(e,xy,{value:{objectID:"O"+Oy++,weakData:{}}})},Dy=dy.exports={enable:function(){Dy.enable=function(){},Cy=!0;var e=Iy.f,t=Sy([].splice),r={};r[xy]=1,e(r).length&&(Iy.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===xy){t(n,i,1);break}return n},gy({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Ry.f}))},fastKey:function(e,t){if(!Ey(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!ky(e,xy)){if(!Ay(e))return"F";if(!t)return"E";My(e)}return e[xy].objectID},getWeakData:function(e,t){if(!ky(e,xy)){if(!Ay(e))return!0;if(!t)return!1;My(e)}return e[xy].weakData},onFreeze:function(e){return wy&&Cy&&Ay(e)&&!ky(e,xy)&&My(e),e}};by[xy]=!0;var Py=Ar,Ny=n,Ly=dy.exports,Uy=i,Vy=fr,Fy=Uh,By=mp,jy=R,Hy=$,Gy=Ni,zy=Jt.f,Ky=Po.forEach,Xy=w,Wy=Zi.set,qy=Zi.getterFor,Yy=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=Ny[e],c=s&&s.prototype,u={};if(Xy&&jy(s)&&(o||c.forEach&&!Uy((function(){(new s).entries().next()})))){var d=(n=t((function(t,r){Wy(By(t,d),{type:e,collection:new s}),null!=r&&Fy(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,l=qy(e);Ky(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in c)||o&&"clear"==e||Vy(d,e,(function(r,n){var i=l(this).collection;if(!t&&o&&!Hy(r))return"get"==e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||zy(d,"size",{configurable:!0,get:function(){return l(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Ly.enable();return Gy(n,e,!1,!0),u[e]=n,Py({global:!0,forced:!0},u),o||r.setStrong(n,e,i),n},Jy=li,Qy=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:Jy(e,n,t[n],r);return e},Zy=Jt.f,$y=Gn,eg=Qy,tg=Yt,rg=mp,ng=z,ig=Uh,og=iu,ag=ou,sg=vp,cg=w,ug=dy.exports.fastKey,dg=Zi.set,lg=Zi.getterFor,hg={getConstructor:function(e,t,r,n){var i=e((function(e,i){rg(e,o),dg(e,{type:t,index:$y(null),first:void 0,last:void 0,size:0}),cg||(e.size=0),ng(i)||ig(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=lg(t),s=function(e,t,r){var n,i,o=a(e),s=c(e,t);return s?s.value=r:(o.last=s={index:i=ug(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),cg?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=ug(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return eg(o,{clear:function(){for(var e=a(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,cg?e.size=0:this.size=0},delete:function(e){var t=this,r=a(t),n=c(t,e);if(n){var i=n.next,o=n.previous;delete r.index[n.index],n.removed=!0,o&&(o.next=i),i&&(i.previous=o),r.first==n&&(r.first=i),r.last==n&&(r.last=o),cg?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=tg(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),eg(o,r?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),cg&&Zy(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=lg(t),o=lg(n);og(e,t,(function(e,t){dg(this,{type:n,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?ag("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,ag(void 0,!0))}),r?"entries":"values",!r,!0),sg(t)}};Yy("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hg);var pg=ee.Map,vg=Yt,fg=O,_g=Ce,mg=bp,yg=z,gg=Uh,Sg=[].push,bg=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return mg(this),(t=void 0!==a)&&_g(a),yg(e)?new this:(r=[],t?(n=0,i=vg(a,o>2?arguments[2]:void 0),gg(e,(function(e){fg(Sg,r,i(e,n++))}))):gg(e,Sg,{that:r}),new this(r))};Ar({target:"Map",stat:!0,forced:!0},{from:bg});var Eg=rs,kg=function(){return new this(Eg(arguments))};Ar({target:"Map",stat:!0,forced:!0},{of:kg});var Tg=O,Ig=Ce,Rg=tr,Ag=function(){for(var e,t=Rg(this),r=Ig(t.delete),n=!0,i=0,o=arguments.length;i<o;i++)e=Tg(r,t,arguments[i]),n=n&&e;return!!n};Ar({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:Ag});var wg=O,Cg=Ce,xg=tr,Og=function(e,t){var r,n,i=xg(this),o=Cg(i.get),a=Cg(i.has),s=Cg(i.set);return wg(a,i,e)?(r=wg(o,i,e),"update"in t&&(r=t.update(r,e,i),wg(s,i,e,r)),r):(n=t.insert(e,i),wg(s,i,e,n),n)};Ar({target:"Map",proto:!0,real:!0,forced:!0},{emplace:Og});var Mg=gh,Dg=tr,Pg=Yt,Ng=Mg,Lg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=Dg(this),r=Ng(t),n=Pg(e,arguments.length>1?arguments[1]:void 0);return!Lg(r,(function(e,r,i){if(!n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var Ug=oe,Vg=Yt,Fg=O,Bg=Ce,jg=tr,Hg=Rp,Gg=Mg,zg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=jg(this),r=Gg(t),n=Vg(e,arguments.length>1?arguments[1]:void 0),i=new(Hg(t,Ug("Map"))),o=Bg(i.set);return zg(r,(function(e,r){n(r,e,t)&&Fg(o,i,e,r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var Kg=tr,Xg=Yt,Wg=Mg,qg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=Kg(this),r=Wg(t),n=Xg(e,arguments.length>1?arguments[1]:void 0);return qg(r,(function(e,r,i){if(n(r,e,t))return i(r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var Yg=tr,Jg=Yt,Qg=Mg,Zg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=Yg(this),r=Qg(t),n=Jg(e,arguments.length>1?arguments[1]:void 0);return Zg(r,(function(e,r,i){if(n(r,e,t))return i(e)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $g=Ar,eS=O,tS=Ce,rS=gh,nS=Uh,iS=E([].push);$g({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){tS(t);var r=rS(e),n=new this,i=tS(n.has),o=tS(n.get),a=tS(n.set);return nS(r,(function(e){var r=t(e);eS(i,n,r)?iS(eS(o,n,r),e):eS(a,n,r,[e])}),{IS_ITERATOR:!0}),n}});var oS=tr,aS=Mg,sS=function(e,t){return e===t||e!=e&&t!=t},cS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return cS(aS(oS(this)),(function(t,r,n){if(sS(r,e))return n()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var uS=O,dS=Uh,lS=Ce;Ar({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new this;lS(t);var n=lS(r.set);return dS(e,(function(e){uS(n,r,t(e),e)})),r}});var hS=tr,pS=Mg,vS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){return vS(pS(hS(this)),(function(t,r,n){if(r===e)return n(t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var fS=oe,_S=Yt,mS=O,yS=Ce,gS=tr,SS=Rp,bS=Mg,ES=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=gS(this),r=bS(t),n=_S(e,arguments.length>1?arguments[1]:void 0),i=new(SS(t,fS("Map"))),o=yS(i.set);return ES(r,(function(e,r){mS(o,i,n(r,e,t),r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var kS=oe,TS=Yt,IS=O,RS=Ce,AS=tr,wS=Rp,CS=Mg,xS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=AS(this),r=CS(t),n=TS(e,arguments.length>1?arguments[1]:void 0),i=new(wS(t,kS("Map"))),o=RS(i.set);return xS(r,(function(e,r){IS(o,i,e,n(r,e,t))}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var OS=Ce,MS=tr,DS=Uh;Ar({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=MS(this),r=OS(t.set),n=arguments.length,i=0;i<n;)DS(arguments[i++],r,{that:t,AS_ENTRIES:!0});return t}});var PS=tr,NS=Ce,LS=Mg,US=Uh,VS=TypeError;Ar({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=PS(this),r=LS(t),n=arguments.length<2,i=n?void 0:arguments[1];if(NS(e),US(r,(function(r,o){n?(n=!1,i=o):i=e(i,o,r,t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),n)throw VS("Reduce of empty map with no initial value");return i}});var FS=tr,BS=Yt,jS=Mg,HS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=FS(this),r=jS(t),n=BS(e,arguments.length>1?arguments[1]:void 0);return HS(r,(function(e,r,i){if(n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var GS=O,zS=tr,KS=Ce,XS=TypeError;Ar({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=zS(this),n=KS(r.get),i=KS(r.has),o=KS(r.set),a=arguments.length;KS(t);var s=GS(i,r,e);if(!s&&a<3)throw XS("Updating absent value");var c=s?GS(n,r,e):KS(a>2?arguments[2]:void 0)(e,r);return GS(o,r,e,t(c,e,r)),r}});var WS=O,qS=Ce,YS=R,JS=tr,QS=TypeError,ZS=function(e,t){var r,n=JS(this),i=qS(n.get),o=qS(n.has),a=qS(n.set),s=arguments.length>2?arguments[2]:void 0;if(!YS(t)&&!YS(s))throw QS("At least one callback required");return WS(o,n,e)?(r=WS(i,n,e),YS(t)&&(r=t(r),WS(a,n,e,r))):YS(s)&&(r=s(),WS(a,n,e,r)),r};Ar({target:"Map",proto:!0,real:!0,forced:!0},{upsert:ZS}),Ar({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:ZS});var $S=pg,eb=Ce,tb=Xe,rb=G,nb=Br,ib=TypeError,ob=function(e){return function(t,r,n,i){eb(r);var o=tb(t),a=rb(o),s=nb(o),c=e?s-1:0,u=e?-1:1;if(n<2)for(;;){if(c in a){i=a[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw ib("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in a&&(i=r(i,a[c],c,o));return i}},ab={left:ob(!1),right:ob(!0)}.left,sb=ve,cb=up;Ar({target:"Array",proto:!0,forced:!Iu("reduce")||!cb&&sb>79&&sb<83},{reduce:function(e){var t=arguments.length;return ab(this,e,t,t>1?arguments[1]:void 0)}});var ub=Us("Array").reduce,db=ae,lb=ub,hb=Array.prototype,pb=function(e){var t=e.reduce;return e===hb||db(hb,e)&&t===hb.reduce?lb:t},vb=w,fb=E,_b=O,mb=i,yb=rn,gb=ui,Sb=M,bb=Xe,Eb=G,kb=Object.assign,Tb=Object.defineProperty,Ib=fb([].concat),Rb=!kb||mb((function(){if(vb&&1!==kb({b:1},kb(Tb({},"a",{enumerable:!0,get:function(){Tb(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=kb({},e)[r]||yb(kb({},t)).join("")!=n}))?function(e,t){for(var r=bb(e),n=arguments.length,i=1,o=gb.f,a=Sb.f;n>i;)for(var s,c=Eb(arguments[i++]),u=o?Ib(yb(c),o(c)):yb(c),d=u.length,l=0;d>l;)s=u[l++],vb&&!_b(a,c,s)||(r[s]=c[s]);return r}:kb,Ab=Rb;Ar({target:"Object",stat:!0,arity:2,forced:Object.assign!==Ab},{assign:Ab});var wb=ee.Object.assign,Cb=$,xb=g,Ob=lt("match"),Mb=function(e){var t;return Cb(e)&&(void 0!==(t=e[Ob])?!!t:"RegExp"==xb(e))},Db=TypeError,Pb=function(e){if(Mb(e))throw Db("The method doesn't accept regular expressions");return e},Nb=lt("match"),Lb=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Nb]=!1,"/./"[e](t)}catch(n){}}return!1},Ub=Ar,Vb=E;A.f;var Fb=Vr,Bb=yn,jb=Pb,Hb=W,Gb=Lb,zb=Vb("".endsWith),Kb=Vb("".slice),Xb=Math.min;Ub({target:"String",proto:!0,forced:!Gb("endsWith")},{endsWith:function(e){var t=Bb(Hb(this));jb(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:Xb(Fb(r),n),o=Bb(e);return zb?zb(t,o,i):Kb(t,i-o.length,i)===o}});var Wb=Us("String").endsWith,qb=ae,Yb=Wb,Jb=String.prototype,Qb=function(e){var t=e.endsWith;return"string"==typeof e||e===Jb||qb(Jb,e)&&t===Jb.endsWith?Yb:t},Zb=!0,$b=!0;function eE(e,t,r){var n=e.match(t);return n&&n.length>=r&&uy(n[r],10)}function tE(e,t,r){if(e.RTCPeerConnection){var n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);var o=function(e){var t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new $S),this._eventMap[t].set(n,o),i.apply(this,[e,o])};var o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);var n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===an(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},ad(n,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}}function rE(e){return"boolean"!=typeof e?new Error("Argument type: "+Wd(e)+". Please use a boolean."):(Zb=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function nE(e){return"boolean"!=typeof e?new Error("Argument type: "+Wd(e)+". Please use a boolean."):($b=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function iE(){if("object"===("undefined"==typeof window?"undefined":Wd(window))){if(Zb)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function oE(e,t){$b&&console.warn(e+" is deprecated, please use "+t+" instead.")}function aE(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var r=e.navigator;if(r.mozGetUserMedia)t.browser="firefox",t.version=eE(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=eE(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=eE(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function sE(e){return"[object Object]"===Object.prototype.toString.call(e)}function cE(e){var t;return sE(e)?pb(t=an(e)).call(t,(function(t,r){var n=sE(e[r]),i=n?cE(e[r]):e[r],o=n&&!an(i).length;return void 0===i||o?t:wb(t,Jd({},r,i))}),{}):e}function uE(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),an(t).forEach((function(n){Qb(n).call(n,"Id")?uE(e,e.get(t[n]),r):Qb(n).call(n,"Ids")&&t[n].forEach((function(t){uE(e,e.get(t),r)}))})))}function dE(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new $S;if(null===t)return i;var o=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((function(t){e.forEach((function(r){r.type===n&&r.trackId===t.id&&uE(e,r,i)}))})),i}var lE=Ar,hE=Po.find,pE="find",vE=!0;pE in[]&&Array(1).find((function(){vE=!1})),lE({target:"Array",proto:!0,forced:vE},{find:function(e){return hE(this,e,arguments.length>1?arguments[1]:void 0)}});var fE=Us("Array").find,_E=ae,mE=fE,yE=Array.prototype,gE=function(e){var t=e.find;return e===yE||_E(yE,e)&&t===yE.find?mE:t},SE=Ar,bE=Kr.indexOf,EE=Iu,kE=E([].indexOf),TE=!!kE&&1/kE([1],1,-0)<0,IE=EE("indexOf");SE({target:"Array",proto:!0,forced:TE||!IE},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return TE?kE(this,e,t)||0:bE(this,e,t)}});var RE=Us("Array").indexOf,AE=ae,wE=RE,CE=Array.prototype,xE=function(e){var t=e.indexOf;return e===CE||AE(CE,e)&&t===CE.indexOf?wE:t},OE=w,ME=eo,DE=TypeError,PE=Object.getOwnPropertyDescriptor,NE=OE&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(uq){return uq instanceof TypeError}}(),LE=Ie,UE=TypeError,VE=function(e,t){if(!delete e[t])throw UE("Cannot delete property "+LE(t)+" of "+LE(e))},FE=Ar,BE=Xe,jE=Nr,HE=Or,GE=Br,zE=NE?function(e,t){if(ME(e)&&!PE(e,"length").writable)throw DE("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},KE=cd,XE=Ro,WE=Qn,qE=VE,YE=Ps("splice"),JE=Math.max,QE=Math.min;FE({target:"Array",proto:!0,forced:!YE},{splice:function(e,t){var r,n,i,o,a,s,c=BE(this),u=GE(c),d=jE(e,u),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=u-d):(r=l-2,n=QE(JE(HE(t),0),u-d)),KE(u+r-n),i=XE(c,n),o=0;o<n;o++)(a=d+o)in c&&WE(i,o,c[a]);if(i.length=n,r<n){for(o=d;o<u-n;o++)s=o+r,(a=o+n)in c?c[s]=c[a]:qE(c,s);for(o=u;o>u-n+r;o--)qE(c,o-1)}else if(r>n)for(o=u-n;o>d;o--)s=o+r-1,(a=o+n-1)in c?c[s]=c[a]:qE(c,s);for(o=0;o<r;o++)c[o+d]=arguments[o+2];return zE(c,u-n+r),i}});var ZE=Us("Array").splice,$E=ae,ek=ZE,tk=Array.prototype,rk=function(e){var t=e.splice;return e===tk||$E(tk,e)&&t===tk.splice?ek:t},nk=Kr.includes;Ar({target:"Array",proto:!0,forced:i((function(){return!Array(1).includes()}))},{includes:function(e){return nk(this,e,arguments.length>1?arguments[1]:void 0)}});var ik=Us("Array").includes,ok=Ar,ak=Pb,sk=W,ck=yn,uk=Lb,dk=E("".indexOf);ok({target:"String",proto:!0,forced:!uk("includes")},{includes:function(e){return!!~dk(ck(sk(this)),ck(ak(e)),arguments.length>1?arguments[1]:void 0)}});var lk=Us("String").includes,hk=ae,pk=ik,vk=lk,fk=Array.prototype,_k=String.prototype,mk=function(e){var t=e.includes;return e===fk||hk(fk,e)&&t===fk.includes?pk:"string"==typeof e||e===_k||hk(_k,e)&&t===_k.includes?vk:t},yk=iE;function gk(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==Wd(e)||e.mandatory||e.optional)return e;var t,r={};(an(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===Wd(e[t])?e[t]:{ideal:e[t]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+km(t).call(t,1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){r.optional=r.optional||[];var o={};"number"==typeof n.ideal?(o[i("min",t)]=n.ideal,r.optional.push(o),(o={})[i("max",t)]=n.ideal,r.optional.push(o)):(o[i("",t)]=n.ideal,r.optional.push(o))}void 0!==n.exact&&"number"!=typeof n.exact?(r.mandatory=r.mandatory||{},r.mandatory[i("",t)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(r.mandatory=r.mandatory||{},r.mandatory[i(e,t)]=n[e])}))}})),e.advanced)&&(r.optional=Om(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(Nm(e)))&&"object"===Wd(e.audio)){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};o((e=JSON.parse(Nm(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===Wd(e.video)){var a=e.video.facingMode;a=a&&("object"===Wd(a)?a:{ideal:a});var s,c=t.version<66;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||c))if(delete e.video.facingMode,"environment"===a.exact||"environment"===a.ideal?s=["back","rear"]:"user"!==a.exact&&"user"!==a.ideal||(s=["front"]),s)return r.mediaDevices.enumerateDevices().then((function(t){t=Hs(t).call(t,(function(e){return"videoinput"===e.kind}));var r=gE(t).call(t,(function(e){return s.some((function(t){var r;return mk(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&mk(s).call(s,"back")&&(r=t[t.length-1]),r&&(e.video.deviceId=a.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=n(e.video),yk("chrome: "+Nm(e)),i(e)}));e.video=n(e.video)}return yk("chrome: "+Nm(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};if(r.getUserMedia=function(e,t,n){i(e,(function(e){r.webkitGetUserMedia(e,t,(function(e){n&&n(o(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){var a=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return a(e).then((function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach((function(e){e.stop()})),new DOMException("","NotFoundError");return t}),(function(e){return Y_.reject(o(e))}))}))}}}}function Sk(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function bk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){ad(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",(function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=gE(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.track.id})):i={track:n.track};var a=new Event("track");a.track=n.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)})),t.stream.getTracks().forEach((function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=gE(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.id})):i={track:n};var a=new Event("track");a.track=n,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else tE(e,"track",(function(e){return e.transceiver||ad(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function Ek(e){if("object"===Wd(e)&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){var e;return this._senders=this._senders||[],km(e=this._senders).call(e)};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t;n.apply(this,arguments);var r,i=xE(t=this._senders).call(t,e);-1!==i&&rk(r=this._senders).call(r,i,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((function(e){r._senders.push(t(r,e))}))};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach((function(e){var r,n,i,o=gE(r=t._senders).call(r,(function(t){return t.track===e}));o&&rk(n=t._senders).call(n,xE(i=t._senders).call(i,o),1)}))}}else if("object"===Wd(e)&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},ad(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function kk(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=km(Array.prototype).call(arguments),n=r[0],i=r[1],o=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var a=function(e){var t={};return e.result().forEach((function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){r[t]=e.stat(t)})),t[r.id]=r})),t},s=function(e){var t;return new $S(jm(t=an(e)).call(t,(function(t){return[t,e[t]]})))};if(arguments.length>=2){var c=function(e){i(s(a(e)))};return t.apply(this,[c,n])}return new Y_((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function Tk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return dE(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=n.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),tE(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return dE(t,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t,r,n,o=arguments[0];return this.getSenders().forEach((function(e){e.track===o&&(t?n=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===o&&(r?n=!0:r=e),e.track===o})),n||t&&r?Y_.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Y_.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function Ik(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},jm(e=an(this._shimmedLocalStreams)).call(e,(function(e){return t._shimmedLocalStreams[e][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var n;if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var i=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===xE(n=this._shimmedLocalStreams[r.id]).call(n,i)&&this._shimmedLocalStreams[r.id].push(i):this._shimmedLocalStreams[r.id]=[r,i],i};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t,n,i=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){var t;if(gE(t=i.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var o=this.getSenders();r.apply(this,arguments);var a=Hs(t=this.getSenders()).call(t,(function(e){return-1===xE(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Om(n=[e]).call(n,a)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&an(this._shimmedLocalStreams).forEach((function(r){var n,i,o=xE(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&rk(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function Rk(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Ik(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},jm(t).call(t,(function(t){return e._reverseStreams[t.id]}))};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){var t;if(gE(t=r.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,r){var n,i,o,a=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var s=km([]).call(arguments,1);if(1!==s.length||!gE(n=s[0].getTracks()).call(n,(function(e){return e===t})))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var c=gE(i=this.getSenders()).call(i,(function(e){return e.track===t}));if(c)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var u=this._streams[r.id];if(u)u.addTrack(t),Y_.resolve().then((function(){a.dispatchEvent(new Event("negotiationneeded"))}));else{var d=new e.MediaStream([t]);this._streams[r.id]=d,this._reverseStreams[d.id]=r,this.addStream(d)}return gE(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=s(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then((function(t){return s(e,t)}))}));e.RTCPeerConnection.prototype[t]=n[t]}));var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=c(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var a=tc(e.RTCPeerConnection.prototype,"localDescription");ad(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,r=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{},an(this._streams).forEach((function(n){var i;gE(i=r._streams[n].getTracks()).call(i,(function(t){return e.track===t}))&&(t=r._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function s(e,t){var r=t.sdp;return an(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}function c(e,t){var r=t.sdp;return an(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}}function Ak(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}))}function wk(e,t){tE(e,"negotiationneeded",(function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var Ck=Object.freeze(Object.defineProperty({__proto__:null,shimMediaStream:Sk,shimOnTrack:bk,shimGetSendersWithDtmf:Ek,shimGetStats:kk,shimSenderReceiverGetStats:Tk,shimAddTrackRemoveTrackWithNative:Ik,shimAddTrackRemoveTrack:Rk,shimPeerConnection:Ak,fixNegotiationNeeded:wk,shimGetUserMedia:gk,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then((function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}},Symbol.toStringTag,{value:"Module"}));Ar({target:"Array",stat:!0},{isArray:eo});var xk=ee.Array.isArray;function Ok(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Mk=hh,Dk=tr,Pk=kh,Nk=Yt,Lk=O,Uk=Xe,Vk=function(e,t,r,n){try{return n?t(Dk(r)[0],r[1]):t(r)}catch(uq){Pk(e,"throw",uq)}},Fk=ah,Bk=go,jk=Br,Hk=Qn,Gk=gh,zk=hh,Kk=Array,Xk=function(e){var t=Uk(e),r=Bk(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=Nk(i,n>2?arguments[2]:void 0));var a,s,c,u,d,l,h=zk(t),p=0;if(!h||this===Kk&&Fk(h))for(a=jk(t),s=r?new this(a):Kk(a);a>p;p++)l=o?i(t[p],p):t[p],Hk(s,p,l);else for(d=(u=Gk(t,h)).next,s=r?new this:[];!(c=Lk(d,u)).done;p++)l=o?Vk(u,i,[c.value,p],!0):c.value,Hk(s,p,l);return s.length=p,s},Wk=Xk;Ar({target:"Array",stat:!0,forced:!$f((function(e){Array.from(e)}))},{from:Wk});var qk=ee.Array.from;function Yk(e,t){var r;if(e){if("string"==typeof e)return Ok(e,t);var n=km(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?qk(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ok(e,t):void 0}}function Jk(e){return function(e){if(xk(e))return Ok(e)}(e)||function(e){if(void 0!==wd&&null!=Mk(e)||null!=e["@@iterator"])return qk(e)}(e)||Yk(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Qk=n,Zk=i,$k=yn,eT=Jm.trim,tT=E("".charAt),rT=Qk.parseFloat,nT=Qk.Symbol,iT=nT&&nT.iterator,oT=1/rT("\t\n\v\f\r                 \u2028\u2029\ufeff-0")!=-1/0||iT&&!Zk((function(){rT(Object(iT))}))?function(e){var t=eT($k(e)),r=rT(t);return 0===r&&"-"==tT(t,0)?-0:r}:rT;Ar({global:!0,forced:parseFloat!=oT},{parseFloat:oT});var aT=ee.parseFloat;function sT(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){oE("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},o=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===Wd(e)&&"object"===Wd(e.audio)&&(e=JSON.parse(Nm(e)),i(e.audio,"autoGainControl","mozAutoGainControl"),i(e.audio,"noiseSuppression","mozNoiseSuppression")),o(e)},n&&n.prototype.getSettings){var a=n.prototype.getSettings;n.prototype.getSettings=function(){var e=a.apply(this,arguments);return i(e,"mozAutoGainControl","autoGainControl"),i(e,"mozNoiseSuppression","noiseSuppression"),e}}if(n&&n.prototype.applyConstraints){var s=n.prototype.applyConstraints;n.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===Wd(e)&&(e=JSON.parse(Nm(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function cT(e){"object"===Wd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&ad(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function uT(e,t){if("object"===Wd(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}));var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=km(Array.prototype).call(arguments),i=e[0],o=e[1],a=e[2];return n.apply(this,[i||null]).then((function(e){if(t.version<53&&!o)try{e.forEach((function(e){e.type=r[e.type]||e.type}))}catch(n){if("TypeError"!==n.name)throw n;e.forEach((function(t,n){e.set(n,wb({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function dT(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Y_.resolve(new $S)}}}function lT(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r}),tE(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function hT(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;oE("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&mk(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function pT(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function vT(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]);var r=(e=Jk(e)).length>0;r&&e.forEach((function(e){if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(aT(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(aT(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));var n=t.apply(this,arguments);if(r){var i=n.sender,o=i.getParameters();(!("encodings"in o)||1===o.encodings.length&&0===an(o.encodings[0]).length)&&(o.encodings=e,i.sendEncodings=e,this.setParametersPromises.push(i.setParameters(o).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return n})}}function fT(e){if("object"===Wd(e)&&e.RTCRtpSender){var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e,r=t.apply(this,arguments);"encodings"in r||(r.encodings=Om(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function _T(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Y_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function mT(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Y_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var yT=Object.freeze(Object.defineProperty({__proto__:null,shimOnTrack:cT,shimPeerConnection:uT,shimSenderGetStats:dT,shimReceiverGetStats:lT,shimRemoveStream:hT,shimRTCDataChannel:pT,shimAddTransceiver:vT,shimGetParameters:fT,shimCreateOffer:_T,shimCreateAnswer:mT,shimGetUserMedia:sT,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Y_.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}},Symbol.toStringTag,{value:"Module"}));function gT(e){if("object"===Wd(e)&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r,n=this;this._localStreams||(this._localStreams=[]),mk(r=this._localStreams).call(r,e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(r){return t.call(n,r,e)})),e.getVideoTracks().forEach((function(r){return t.call(n,r,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i&&i.forEach((function(e){var t;r._localStreams?mk(t=r._localStreams).call(t,e)||r._localStreams.push(e):r._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t,r,n=this;this._localStreams||(this._localStreams=[]);var i=xE(t=this._localStreams).call(t,e);if(-1!==i){rk(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){mk(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function ST(e){if("object"===Wd(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){ad(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var t=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach((function(e){var r;if(t._remoteStreams||(t._remoteStreams=[]),!mk(r=t._remoteStreams).call(r,e)){t._remoteStreams.push(e);var n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}}))})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((function(t){var r;if(e._remoteStreams||(e._remoteStreams=[]),!(xE(r=e._remoteStreams).call(r,t)>=0)){e._remoteStreams.push(t);var n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}}))}),t.apply(e,arguments)}}}function bT(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Y_.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Y_.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),Y_.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Y_.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Y_.resolve()):n},t.addIceCandidate=s}}function ET(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(kT(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function kT(e){return e&&void 0!==e.video?wb({},e,{video:cE(e.video)}):e}function TT(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],i=0;i<e.iceServers.length;i++){var o=e.iceServers[i];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(oE("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(Nm(o))).urls=o.url,delete o.url,n.push(o)):n.push(e.iceServers[i])}e.iceServers=n}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&ad(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function IT(e){"object"===Wd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&ad(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function RT(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){var r,n;void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var i=gE(r=this.getTransceivers()).call(r,(function(e){return"audio"===e.receiver.track.kind}));!1===e.offerToReceiveAudio&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveAudio||i||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var o=gE(n=this.getTransceivers()).call(n,(function(e){return"video"===e.receiver.track.kind}));!1===e.offerToReceiveVideo&&o?"sendrecv"===o.direction?o.setDirection?o.setDirection("sendonly"):o.direction="sendonly":"recvonly"===o.direction&&(o.setDirection?o.setDirection("inactive"):o.direction="inactive"):!0!==e.offerToReceiveVideo||o||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function AT(e){"object"!==Wd(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var wT=Object.freeze(Object.defineProperty({__proto__:null,shimLocalStreamsAPI:gT,shimRemoteStreamsAPI:ST,shimCallbacksAPI:bT,shimGetUserMedia:ET,shimConstraints:kT,shimRTCIceServerUrls:TT,shimTrackEventTransceiver:IT,shimCreateOfferLegacy:RT,shimAudioContext:AT},Symbol.toStringTag,{value:"Module"})),CT=cc.PROPER,xT=i,OT=Hm,MT=Jm.trim;Ar({target:"String",proto:!0,forced:function(e){return xT((function(){return!!OT[e]()||"​…᠎"!=="​…᠎"[e]()||CT&&OT[e].name!==e}))}("trim")},{trim:function(){return MT(this)}});var DT,PT,NT=Us("String").trim,LT=ae,UT=NT,VT=String.prototype,FT=function(e){var t=e.trim;return"string"==typeof e||e===VT||LT(VT,e)&&t===VT.trim?UT:t},BT={exports:{}};DT=BT,(PT={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=PT.generateIdentifier(),PT.splitLines=function(e){var t;return jm(t=FT(e).call(e).split("\n")).call(t,(function(e){return FT(e).call(e)}))},PT.splitSections=function(e){var t=e.split("\nm=");return jm(t).call(t,(function(e,t){var r;return FT(r=t>0?"m="+e:e).call(r)+"\r\n"}))},PT.getDescription=function(e){var t=PT.splitSections(e);return t&&t[0]},PT.getMediaSections=function(e){var t=PT.splitSections(e);return t.shift(),t},PT.matchPrefix=function(e,t){var r;return Hs(r=PT.splitLines(e)).call(r,(function(e){return 0===xE(e).call(e,t)}))},PT.parseCandidate=function(e){for(var t,r={foundation:(t=0===xE(e).call(e,"a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:uy(t[3],10),ip:t[4],address:t[4],port:uy(t[5],10),type:t[7]},n=8;n<t.length;n+=2)switch(t[n]){case"raddr":r.relatedAddress=t[n+1];break;case"rport":r.relatedPort=uy(t[n+1],10);break;case"tcptype":r.tcpType=t[n+1];break;case"ufrag":r.ufrag=t[n+1],r.usernameFragment=t[n+1];break;default:void 0===r[t[n]]&&(r[t[n]]=t[n+1])}return r},PT.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(" ")},PT.parseIceOptions=function(e){return e.substr(14).split(" ")},PT.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:uy(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=uy(t[1],10),r.channels=3===t.length?uy(t[2],10):1,r.numChannels=r.channels,r},PT.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"},PT.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:uy(r[0],10),direction:xE(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},PT.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},PT.parseFmtp=function(e){for(var t,r={},n=e.substr(xE(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=FT(o=n[i]).call(o).split("="),r[FT(a=t[0]).call(a)]=t[1]}return r},PT.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},PT.parseRtcpFb=function(e){var t=e.substr(xE(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},PT.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},PT.parseSsrcMedia=function(e){var t=xE(e).call(e," "),r={ssrc:uy(e.substr(7,t-7),10)},n=xE(e).call(e,":",t);return n>-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},PT.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:jm(t).call(t,(function(e){return uy(e,10)}))}},PT.getMid=function(e){var t=PT.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},PT.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},PT.getDtlsParameters=function(e,t){var r=PT.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:jm(r).call(r,PT.parseFingerprint)}},PT.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},PT.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:uy(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:km(t).call(t,3)}},PT.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===Wd(e.keyParams)?PT.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},PT.parseCryptoKeyParams=function(e){if(0!==xE(e).call(e,"inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},PT.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},PT.getCryptoParameters=function(e,t){var r=PT.matchPrefix(e+t,"a=crypto:");return jm(r).call(r,PT.parseCryptoLine)},PT.getIceParameters=function(e,t){var r=PT.matchPrefix(e+t,"a=ice-ufrag:")[0],n=PT.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},PT.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},PT.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=PT.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=PT.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=PT.parseRtpMap(o),c=PT.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=c.length?PT.parseFmtp(c[0]):{},s.rtcpFeedback=jm(a=PT.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,PT.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return PT.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(PT.parseExtmap(e))})),t},PT.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=jm(r=t.codecs).call(r,(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach((function(e){n+=PT.writeRtpMap(e),n+=PT.writeFmtp(e),n+=PT.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+=PT.writeExtmap(e)})),n},PT.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],c=PT.parseRtpParameters(e),u=-1!==xE(t=c.fecMechanisms).call(t,"RED"),d=-1!==xE(r=c.fecMechanisms).call(r,"ULPFEC"),l=Hs(n=jm(i=PT.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return PT.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=l.length>0&&l[0].ssrc,p=jm(o=PT.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return jm(t).call(t,(function(e){return uy(e,10)}))}));p.length>0&&p[0].length>1&&p[0][0]===h&&(a=p[0][1]),c.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:h,codecPayloadType:uy(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),u&&((t=JSON.parse(Nm(t))).fec={ssrc:h,mechanism:d?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var v,f,_=PT.matchPrefix(e,"b=");return _.length&&(_=0===xE(v=_[0]).call(v,"b=TIAS:")?uy(_[0].substr(7),10):0===xE(f=_[0]).call(f,"b=AS:")?1e3*uy(_[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=_}))),s},PT.parseRtcpParameters=function(e){var t,r,n={},i=Hs(t=jm(r=PT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return PT.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=PT.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=PT.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},PT.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},PT.parseMsid=function(e){var t,r,n,i=PT.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=Hs(t=jm(r=PT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return PT.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},PT.parseSctpDescription=function(e){var t,r=PT.parseMLine(e),n=PT.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=uy(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=PT.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:uy(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=PT.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:uy(a[0],10),protocol:a[1],maxMessageSize:t}}},PT.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("")},PT.generateSessionId=function(){return Math.random().toString().substr(2,21)},PT.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||PT.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},PT.getDirection=function(e,t){for(var r=PT.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?PT.getDirection(t):"sendrecv"},PT.getKind=function(e){return PT.splitLines(e)[0].split(" ")[0].substr(2)},PT.isRejected=function(e){return"0"===e.split(" ",2)[1]},PT.parseMLine=function(e){var t=PT.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:uy(t[1],10),protocol:t[2],fmt:km(t).call(t,3).join(" ")}},PT.parseOLine=function(e){var t=PT.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:uy(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},PT.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=PT.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},DT.exports=PT;var jT=BT.exports,HT=e({__proto__:null,default:jT},[BT.exports]);function GT(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===Wd(e)&&e.candidate&&0===xE(r=e.candidate).call(r,"a=")&&((e=JSON.parse(Nm(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=jT.parseCandidate(e.candidate),o=wb(n,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,tE(e,"icecandidate",(function(t){return t.candidate&&ad(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function zT(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||tE(e,"icecandidate",(function(e){if(e.candidate){var t=jT.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function KT(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||ad(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=function(e){if(!e||!e.sdp)return!1;var t=jT.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=jT.parseMLine(e);return r&&"application"===r.kind&&-1!==xE(t=r.protocol).call(t,"SCTP")}))},n=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=uy(t[1],10);return r!=r?-1:r},i=function(e){var r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},o=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=jT.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=uy(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),s=e.sdpSemantics;"plan-b"===s&&ad(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){var c,u=n(arguments[0]),d=i(u),l=o(arguments[0],u);c=0===d&&0===l?Number.POSITIVE_INFINITY:0===d||0===l?Math.max(d,l):Math.min(d,l);var h={};ad(h,"maxMessageSize",{get:function(){return c}}),this._sctp=h}return a.apply(this,arguments)}}}function XT(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return r(e),e},tE(e,"datachannel",(function(e){return r(e.channel,e.target),e}))}function r(e,t){var r=e.send;e.send=function(){return r.apply(e,arguments)}}}function WT(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;ad(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),ad(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((function(e){var r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}}))}}function qT(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71||"safari"===t.browser&&t.version>=605)){var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){var n;if(t&&t.sdp&&-1!==xE(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=Hs(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==FT(e).call(e)})).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:o}):t.sdp=o}return r.apply(this,arguments)}}}function YT(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Y_.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Y_.resolve())})}}function JT(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.setLocalDescription;r&&0!==r.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this,t=arguments[0]||{};if("object"!==Wd(t)||t.type&&t.sdp)return r.apply(this,arguments);if(!(t={type:t.type,sdp:t.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":t.type="offer";break;default:t.type="answer"}if(t.sdp||"offer"!==t.type&&"answer"!==t.type)return r.apply(this,[t]);var n="offer"===t.type?this.createOffer:this.createAnswer;return n.apply(this).then((function(t){return r.apply(e,[t])}))})}}var QT=Object.freeze(Object.defineProperty({__proto__:null,shimRTCIceCandidate:GT,shimRTCIceCandidateRelayProtocol:zT,shimMaxMessageSize:KT,shimSendThrowTypeError:XT,shimConnectionState:WT,removeExtmapAllowMixed:qT,shimAddIceCandidateNullOrEmpty:YT,shimParameterlessSetLocalDescription:JT},Symbol.toStringTag,{value:"Module"}));if(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.window,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=iE,i=aE(t),o={browserDetails:i,commonShim:QT,extractVersion:eE,disableLog:rE,disableWarnings:nE,sdp:HT};switch(i.browser){case"chrome":if(!Ck||!Ak||!r.shimChrome)return n("Chrome shim is not included in this adapter release."),o;if(null===i.version)return n("Chrome shim can not determine version, not shimming."),o;n("adapter.js shimming chrome."),o.browserShim=Ck,YT(t,i),JT(t),gk(t,i),Sk(t),Ak(t,i),bk(t),Rk(t,i),Ek(t),kk(t),Tk(t),wk(t,i),GT(t),zT(t),WT(t),KT(t,i),XT(t),qT(t,i);break;case"firefox":if(!yT||!uT||!r.shimFirefox)return n("Firefox shim is not included in this adapter release."),o;n("adapter.js shimming firefox."),o.browserShim=yT,YT(t,i),JT(t),sT(t,i),uT(t,i),cT(t),hT(t),dT(t),lT(t),pT(t),vT(t),fT(t),_T(t),mT(t),GT(t),WT(t),KT(t,i),XT(t);break;case"safari":if(!wT||!r.shimSafari)return n("Safari shim is not included in this adapter release."),o;n("adapter.js shimming safari."),o.browserShim=wT,YT(t,i),JT(t),TT(t),RT(t),bT(t),gT(t),ST(t),IT(t),ET(t),AT(t),GT(t),zT(t),KT(t,i),XT(t),qT(t,i);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var ZT=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=ZT.call(this);return e.width&&(e.width=Math.floor(e.width)),e.height&&(e.height=Math.floor(e.height)),e.frameRate&&(e.frameRate=Math.floor(e.frameRate)),e}}function $T(e,t){var r=void 0!==wd&&Mk(e)||e["@@iterator"];if(!r){if(xk(e)||(r=Yk(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function eI(e,t){return function(e){if(xk(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==wd&&Mk(e)||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(d){u=!0,i=d}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||Yk(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tI(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var rI=Ye,nI=function(e){return void 0!==e&&(rI(e,"value")||rI(e,"writable"))},iI=O,oI=$,aI=tr,sI=nI,cI=A,uI=mc;Ar({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return aI(t)===o?t[r]:(n=cI.f(t,r))?sI(n)?n.value:void 0===n.get?void 0:iI(n.get,o):oI(i=uI(t))?e(i,r,o):void 0}});var dI=ee.Reflect.get,lI=E,hI=Ce,pI=$,vI=Ye,fI=rs,_I=o,mI=Function,yI=lI([].concat),gI=lI([].join),SI={},bI=function(e,t,r){if(!vI(SI,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";SI[t]=mI("C,a","return new C("+gI(n,",")+")")}return SI[t](e,r)},EI=_I?mI.bind:function(e){var t=hI(this),r=t.prototype,n=fI(arguments,1),i=function(){var r=yI(n,fI(arguments));return this instanceof i?bI(t,r.length,r):t.apply(e,r)};return pI(r)&&(i.prototype=r),i},kI=EI;Ar({target:"Function",proto:!0,forced:Function.bind!==kI},{bind:kI});var TI=Us("Function").bind,II=ae,RI=TI,AI=Function.prototype,wI=function(e){var t=e.bind;return e===AI||II(AI,e)&&t===AI.bind?RI:t};function CI(e){var t;return(CI=Kl?wI(t=zl).call(t):function(e){return e.__proto__||zl(e)})(e)}function xI(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=CI(e)););return e}function OI(){var e;"undefined"!=typeof Reflect&&dI?OI=wI(e=dI).call(e):OI=function(e,t,r){var n=xI(e,t);if(n){var i=tc(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return OI.apply(this,arguments)}function MI(e,t){var r;return(MI=Kl?wI(r=Kl).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function DI(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Bl(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),ad(e,"prototype",{writable:!1}),t&&MI(e,t)}var PI=Ar,NI=d,LI=EI,UI=bp,VI=tr,FI=$,BI=Gn,jI=i,HI=oe("Reflect","construct"),GI=Object.prototype,zI=[].push,KI=jI((function(){function e(){}return!(HI((function(){}),[],e)instanceof e)})),XI=!jI((function(){HI((function(){}))})),WI=KI||XI;PI({target:"Reflect",stat:!0,forced:WI,sham:WI},{construct:function(e,t){UI(e),VI(t);var r=arguments.length<3?e:UI(arguments[2]);if(XI&&!KI)return HI(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 NI(zI,n,t),new(NI(LI,e,n))}var i=r.prototype,o=BI(FI(i)?i:GI),a=NI(e,o,t);return FI(a)?a:o}});var qI=ee.Reflect.construct;function YI(){if("undefined"==typeof Reflect||!qI)return!1;if(qI.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(qI(Boolean,[],(function(){}))),!0}catch(e){return!1}}function JI(e,t){if(t&&("object"===Wd(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return tI(e)}function QI(e){var t=YI();return function(){var r,n=CI(e);if(t){var i=CI(this).constructor;r=qI(n,arguments,i)}else r=n.apply(this,arguments);return JI(this,r)}}var ZI=Us("Array").values,$I=fn,eR=Ye,tR=ae,rR=ZI,nR=Array.prototype,iR={DOMTokenList:!0,NodeList:!0},oR=function(e){var t=e.values;return e===nR||tR(nR,e)&&t===nR.values||eR(iR,$I(e))?rR:t},aR=ni,sR=Math.floor,cR=function(e,t){var r=e.length,n=sR(r/2);return r<8?uR(e,t):dR(e,cR(aR(e,0,n),t),cR(aR(e,n),t),t)},uR=function(e,t){for(var r,n,i=e.length,o=1;o<i;){for(n=o,r=e[o];n&&t(e[n-1],r)>0;)e[n]=e[--n];n!==o++&&(e[n]=r)}return e},dR=function(e,t,r,n){for(var i=t.length,o=r.length,a=0,s=0;a<i||s<o;)e[a+s]=a<i&&s<o?n(t[a],r[s])<=0?t[a++]:r[s++]:a<i?t[a++]:r[s++];return e},lR=cR,hR=se.match(/firefox\/(\d+)/i),pR=!!hR&&+hR[1],vR=/MSIE|Trident/.test(se),fR=se.match(/AppleWebKit\/(\d+)\./),_R=!!fR&&+fR[1],mR=Ar,yR=E,gR=Ce,SR=Xe,bR=Br,ER=VE,kR=yn,TR=i,IR=lR,RR=Iu,AR=pR,wR=vR,CR=ve,xR=_R,OR=[],MR=yR(OR.sort),DR=yR(OR.push),PR=TR((function(){OR.sort(void 0)})),NR=TR((function(){OR.sort(null)})),LR=RR("sort"),UR=!TR((function(){if(CR)return CR<70;if(!(AR&&AR>3)){if(wR)return!0;if(xR)return xR<603;var e,t,r,n,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(n=0;n<47;n++)OR.push({k:t+n,v:r})}for(OR.sort((function(e,t){return t.v-e.v})),n=0;n<OR.length;n++)t=OR[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));mR({target:"Array",proto:!0,forced:PR||!NR||!LR||!UR},{sort:function(e){void 0!==e&&gR(e);var t=SR(this);if(UR)return void 0===e?MR(t):MR(t,e);var r,n,i=[],o=bR(t);for(n=0;n<o;n++)n in t&&DR(i,t[n]);for(IR(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:kR(t)>kR(r)?1:-1}}(e)),r=bR(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)ER(t,n++);return t}});var VR=Us("Array").sort,FR=ae,BR=VR,jR=Array.prototype,HR=function(e){var t=e.sort;return e===jR||FR(jR,e)&&t===jR.sort?BR:t},GR=Ar,zR=Po.findIndex,KR="findIndex",XR=!0;KR in[]&&Array(1).findIndex((function(){XR=!1})),GR({target:"Array",proto:!0,forced:XR},{findIndex:function(e){return zR(this,e,arguments.length>1?arguments[1]:void 0)}});var WR=Us("Array").findIndex,qR=ae,YR=WR,JR=Array.prototype,QR=function(e){var t=e.findIndex;return e===JR||qR(JR,e)&&t===JR.findIndex?YR:t},ZR=Ar,$R=E;A.f;var eA=Vr,tA=yn,rA=Pb,nA=W,iA=Lb,oA=$R("".startsWith),aA=$R("".slice),sA=Math.min;ZR({target:"String",proto:!0,forced:!iA("startsWith")},{startsWith:function(e){var t=tA(nA(this));rA(e);var r=eA(sA(arguments.length>1?arguments[1]:void 0,t.length)),n=tA(e);return oA?oA(t,n,r):aA(t,r,r+n.length)===n}});var cA=Us("String").startsWith,uA=ae,dA=cA,lA=String.prototype,hA=function(e){var t=e.startsWith;return"string"==typeof e||e===lA||uA(lA,e)&&t===lA.startsWith?dA:t},pA=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.EXPIRED_TOKEN="EXPIRED_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_EXCEED_QPS="USER_MESSAGE_EXCEED_QPS",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e.SUBTITLE_ALREADY_ON="SUBTITLE_ALREADY_ON",e.SUBTITLE_NOT_TURNED_ON="SUBTITLE_NOT_TURNED_ON",e.SUBTITLE_ERR_POSTPROCESS="SUBTITLE_ERR_POSTPROCESS",e.SUBTITLE_ERR_CONNECTION_ERROR="SUBTITLE_ERR_CONNECTION_ERROR",e.SUBTITLE_ERR_PROCESS_ERROR="SUBTITLE_ERR_PROCESS_ERROR",e.SUBTITLE_ERR_UNKNOWN="SUBTITLE_ERR_UNKNOWN",e.UNEXPECTED_INVOKE_FORWARD_STREAM="UNEXPECTED_INVOKE_FORWARD_STREAM",e}(pA||{}),vA=function(e){return e[e.AUDIO_MIXING_ERROR_OK=0]="AUDIO_MIXING_ERROR_OK",e[e.AUDIO_MIXING_ERROR_PRELOAD_FAILED=1]="AUDIO_MIXING_ERROR_PRELOAD_FAILED",e[e.AUDIO_MIXING_ERROR_START_FAILED=2]="AUDIO_MIXING_ERROR_START_FAILED",e[e.AUDIO_MIXING_ERROR_ID_NOT_FOUND=3]="AUDIO_MIXING_ERROR_ID_NOT_FOUND",e[e.AUDIO_MIXING_ERROR_SET_POSITION_FAILED=4]="AUDIO_MIXING_ERROR_SET_POSITION_FAILED",e[e.AUDIO_MIXING_ERROR_INVALID_VOLUME=5]="AUDIO_MIXING_ERROR_INVALID_VOLUME",e[e.AUDIO_MIXING_ERROR_LOAD_CONFLICT=6]="AUDIO_MIXING_ERROR_LOAD_CONFLICT",e[e.AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH=7]="AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH",e[e.AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH=8]="AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH",e[e.AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK=9]="AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK",e}(vA||{});function fA(e,t,r){var n;YI()?fA=wI(n=qI).call(n):fA=function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(wI(Function).apply(e,n));return r&&MI(i,r.prototype),i};return fA.apply(null,arguments)}function _A(e){var t="function"==typeof $S?new $S:void 0;return _A=function(e){if(null===e||(r=e,-1===xE(n=Function.toString.call(r)).call(n,"[native code]")))return e;var r,n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return fA(e,arguments,CI(this).constructor)}return i.prototype=Bl(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),MI(i,e)},_A(e)}var mA=function(e){DI(r,e);var t=QI(r);function r(e,n,i){var o;return Vl(this,r),Jd(tI(o=t.call(this,n)),"code",void 0),Jd(tI(o),"message",void 0),Jd(tI(o),"error",void 0),o.code=e,o.message=n,o.error=i,Kl(tI(o),r.prototype),o}return Ul(r,[{key:"toString",value:function(){var e;return Om(e="SDKError: ".concat(this.code," ")).call(e,this.message)}}]),r}(_A(Error)),yA=w,gA=E,SA=rn,bA=J,EA=gA(M.f),kA=gA([].push),TA=function(e){return function(t){for(var r,n=bA(t),i=SA(n),o=i.length,a=0,s=[];o>a;)r=i[a++],yA&&!EA(n,r)||kA(s,e?[r,n[r]]:n[r]);return s}},IA={entries:TA(!0),values:TA(!1)}.entries;Ar({target:"Object",stat:!0},{entries:function(e){return IA(e)}});var RA=ee.Object.entries,AA=Or,wA=yn,CA=W,xA=RangeError,OA=E,MA=Vr,DA=yn,PA=function(e){var t=wA(CA(this)),r="",n=AA(e);if(n<0||n==1/0)throw xA("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},NA=W,LA=OA(PA),UA=OA("".slice),VA=Math.ceil,FA=function(e){return function(t,r,n){var i,o,a=DA(NA(t)),s=MA(r),c=a.length,u=void 0===n?" ":DA(n);return s<=c||""==u?a:((o=LA(u,VA((i=s-c)/u.length))).length>i&&(o=UA(o,0,i)),e?a+o:o+a)}},BA={start:FA(!1),end:FA(!0)},jA=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(se),HA=BA.end;Ar({target:"String",proto:!0,forced:jA},{padEnd:function(e){return HA(this,e,arguments.length>1?arguments[1]:void 0)}});var GA=Us("String").padEnd,zA=ae,KA=GA,XA=String.prototype,WA=function(e){var t=e.padEnd;return"string"==typeof e||e===XA||zA(XA,e)&&t===XA.padEnd?KA:t},qA=cy;Ar({target:"Number",stat:!0,forced:Number.parseInt!=qA},{parseInt:qA});var YA=ee.Number.parseInt,JA=Math.log,QA=Math.LOG10E;Ar({target:"Math",stat:!0},{log10:Math.log10||function(e){return JA(e)*QA}});var ZA,$A=ee.Math.log10,ew=Us("Array").keys,tw=fn,rw=Ye,nw=ae,iw=ew,ow=Array.prototype,aw={DOMTokenList:!0,NodeList:!0},sw=function(e){var t=e.keys;return e===ow||nw(ow,e)&&t===ow.keys||rw(aw,tw(e))?iw:t},cw=new Uint8Array(16);function uw(){if(!ZA&&!(ZA="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ZA(cw)}var dw=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function lw(e){return"string"==typeof e&&dw.test(e)}for(var hw=[],pw=0;pw<256;++pw)hw.push((pw+256).toString(16).substr(1));function vw(e,t,r){var n=(e=e||{}).random||(e.rng||uw)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(hw[e[t+0]]+hw[e[t+1]]+hw[e[t+2]]+hw[e[t+3]]+"-"+hw[e[t+4]]+hw[e[t+5]]+"-"+hw[e[t+6]]+hw[e[t+7]]+"-"+hw[e[t+8]]+hw[e[t+9]]+"-"+hw[e[t+10]]+hw[e[t+11]]+hw[e[t+12]]+hw[e[t+13]]+hw[e[t+14]]+hw[e[t+15]]).toLowerCase();if(!lw(r))throw TypeError("Stringified UUID is invalid");return r}(n)}var fw=function(){return"undefined"==typeof window},_w=function(){return vw()},mw=function(e){return"number"==typeof e},yw=function(e){var t;return mk(t=Function.prototype.toString.call(e)).call(t,"[native code]")},gw="@byted/ve-rtc",Sw="@byted/ve-rtc-cache-size",bw=function(){function e(){Vl(this,e),Jd(this,"storeKey",void 0),Jd(this,"logLevel",void 0),Jd(this,"LogfileSize",void 0),Jd(this,"db",void 0),Jd(this,"logId",void 0),Jd(this,"cacheLog",void 0),Jd(this,"cachedSize",void 0),Jd(this,"preCacheTime",void 0),Jd(this,"timer",void 0),Jd(this,"_getSize",(function(e){return new Blob(e).size/1048576})),this.storeKey="",this.logId=1,this.cacheLog="",this.logLevel="none",this.LogfileSize=100,this._createStore()}return Ul(e,[{key:"_createStore",value:function(){var e=this;if(!fw()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(gw);try{localStorage.removeItem(Sw)}catch(uq){}},t.onerror=function(e){},t.onsuccess=function(){e.db=t.result,e._getCachedSize()}}}},{key:"_getCachedSize",value:function(){var e=this;try{var t=localStorage.getItem(Sw);if(t)this.cachedSize=Number(t);else oR(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(uq){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(Sw,"".concat(this.cachedSize))}catch(uq){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(gw,e).objectStore(gw)}},{key:"set",value:function(e){var t=this;return new Y_((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Om(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,t.timer||(t.timer=setTimeout((function(){t.set("")}),1e3-(t.preCacheTime-Date.now()))),r();clearTimeout(t.timer),t.timer=null;var o=t._getStore("readwrite");if(!o)return n("get store fail");t.cachedSize&&t.cachedSize>t.LogfileSize&&t.keyEarliest().then((function(e){t.get(e).then((function(r){t.del(e).then((function(){t.cachedSize=t.cachedSize-t._getSize(["".concat(r)]),t._setCachedSize()}))}))}));var a=o.get(t.storeKey);a.onsuccess=function(){try{var i,s,c,u,d,l=Om(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Om(s=Om(c="".concat(l?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(Om(u="".concat(l)).call(u,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Om(d="".concat(t.cacheLog)).call(d,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(v){var p;if(!e)return n(v);t.cacheLog+=Om(p="\n\n".concat(t.logId,": ")).call(p,e),t.logId++,n(v)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Om(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new Y_((function(r,n){var i=t._getStore("readonly");if(!i)return n();var o=i.get(e);o.onsuccess=function(){r(o.result)},o.onerror=function(e){n(e)}}))}},{key:"del",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.storeKey;return new Y_((function(r,n){var i=e._getStore("readwrite");if(!i)return n();var o=i.delete(t);o.onsuccess=function(){return r(o.result)},o.onerror=function(e){return n(e)}}))}},{key:"keyEarliest",value:function(){return sw(this).call(this).then((function(e){var t,r=Date.now();return e.forEach((function(e){if(e&&e.length){var n=e.split("-")[0];Number(n)<r&&(r=Number(n),t=e)}})),t}))}},{key:"keys",value:function(){var e=this;return new Y_((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAllKeys){var i=n.getAllKeys();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.key),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"values",value:function(){var e=this;return new Y_((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAll){var i=n.getAll();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.value),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"download",value:function(e){e=e||this.storeKey,this.get(e).then((function(t){var r=document.createElement("a");r.download="".concat(e,".txt"),r.href="data:text/paint;utf-8,".concat(t||""),r.click()}))}}]),e}(),Ew=new bw,kw=BA.start;Ar({target:"String",proto:!0,forced:jA},{padStart:function(e){return kw(this,e,arguments.length>1?arguments[1]:void 0)}});var Tw,Iw,Rw=Us("String").padStart,Aw=ae,ww=Rw,Cw=String.prototype,xw=function(e){var t=e.padStart;return"string"==typeof e||e===Cw||Aw(Cw,e)&&t===Cw.padStart?ww:t},Ow="[VERTC]",Mw="#0050b3",Dw=(Jd(Tw={},"DEBUG","rgba(0, 0, 0, 0)"),Jd(Tw," INFO","rgba(93, 173, 226, 0)"),Jd(Tw," WARN","rgba(255, 119, 0, 0.3)"),Jd(Tw,"ERROR","rgba(255, 0, 0, 0.3)"),Jd(Tw," SUCC","rgba(0, 119, 0, 0.3)"),Tw),Pw="undefined"!=typeof window&&mk(Iw=window.location.search).call(Iw,"_rtc_debug_"),Nw=function(){function e(t,r){Vl(this,e),Jd(this,"indent",void 0),Jd(this,"module",void 0),this.module=t,this.indent=r}return Ul(e,[{key:"log",value:function(e,t){for(var r,n,i,o,a,s,c,u,d=arguments.length,l=new Array(d>2?d-2:0),h=2;h<d;h++)l[h-2]=arguments[h];var p=l.shift();try{var v,f,_,m,y=Om(v=[]).call(v,l),g="".concat(p).replace(/%o/gi,(function(){var e=y.shift();return Nm(e)}));Ew.set(Om(f=Om(_=Om(m="".concat(Ow,"[").concat(this.module,".")).call(m,t,"] ")).call(_,g," ")).call(f,jm(y).call(y,(function(e){return Nm(e)})).join(", ")))}catch(uq){}if(Pw){for(var S="",b=0;b<this.indent;b++)S+=" ";(r=console).log.apply(r,Om(n=[Om(i=Om(o=Om(a=Om(s=Om(c=Om(u="%c".concat(Lw(),"-")).call(u,Ow,"%c[")).call(c,e,"]%c")).call(s,S,"[")).call(a,this.module,".")).call(o,t,"] ")).call(i,p),"color:".concat(Mw,";"),"background-color:".concat(Dw[e],";"),"color:".concat(Mw,";")]).call(n,l))}}},{key:"print",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" INFO",e]).call(t,n))}},{key:"debug",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=["DEBUG",e]).call(t,n))}},{key:"info",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" INFO",e]).call(t,n))}},{key:"warn",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" WARN",e]).call(t,n))}},{key:"error",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=["ERROR",e]).call(t,n))}},{key:"success",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" SUCC",e]).call(t,n))}}]),e}(),Lw=function(){var e,t,r=new Date;return Om(e="".concat(r.toTimeString().split(" ")[0],":")).call(e,xw(t=r.getMilliseconds().toString()).call(t,3,"0"))},Uw={};!function(e){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=km(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==Wd(n))throw new TypeError(n+"must be non-object");for(var i in n)r(n,i)&&(e[i]=n[i])}}return e},e.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){var t,r,n,i,o,a;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),i=0,t=0,r=e.length;t<r;t++)o=e[t],a.set(o,i),i+=o.length;return a}},i={arraySet:function(e,t,r,n,i){for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){return Om([]).apply([],e)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,n)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,i))},e.setTyped(t)}(Uw);var Vw={},Fw={},Bw={},jw=Uw;function Hw(e){for(var t=e.length;--t>=0;)e[t]=0}var Gw=256,zw=286,Kw=30,Xw=15,Ww=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],qw=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Yw=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Jw=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Qw=new Array(576);Hw(Qw);var Zw=new Array(60);Hw(Zw);var $w=new Array(512);Hw($w);var eC=new Array(256);Hw(eC);var tC=new Array(29);Hw(tC);var rC,nC,iC,oC=new Array(Kw);function aC(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function sC(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function cC(e){return e<256?$w[e]:$w[256+(e>>>7)]}function uC(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function dC(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,uC(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function lC(e,t,r){dC(e,r[2*t],r[2*t+1])}function hC(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function pC(e,t,r){var n,i,o=new Array(16),a=0;for(n=1;n<=Xw;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=hC(o[s]++,s))}}function vC(e){var t;for(t=0;t<zw;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Kw;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function fC(e){e.bi_valid>8?uC(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function _C(e,t,r,n){var i=2*t,o=2*r;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]}function mC(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&_C(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!_C(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function yC(e,t,r){var n,i,o,a,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?lC(e,i,t):(lC(e,(o=eC[i])+Gw+1,t),0!==(a=Ww[o])&&dC(e,i-=tC[o],a),lC(e,o=cC(--n),r),0!==(a=qw[o])&&dC(e,n-=oC[o],a))}while(s<e.last_lit);lC(e,256,t)}function gC(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<c;r++)0!==o[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)mC(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],mC(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,mC(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,a,s,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,v=t.stat_desc.max_length,f=0;for(o=0;o<=Xw;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>v&&(o=v,f++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),s=c[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(d[2*n+1]+a)));if(0!==f){do{for(o=v-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[v]--,f-=2}while(f>0);for(o=v;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}}(e,t),pC(o,u,e.bl_count)}function SC(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<c&&i===a||(s<u?e.bl_tree[2*i]+=s:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function bC(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<c&&i===a)){if(s<u)do{lC(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(lC(e,i,e.bl_tree),s--),lC(e,16,e.bl_tree),dC(e,s-3,2)):s<=10?(lC(e,17,e.bl_tree),dC(e,s-3,3)):(lC(e,18,e.bl_tree),dC(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}Hw(oC);var EC=!1;function kC(e,t,r,n){dC(e,0+(n?1:0),3),function(e,t,r,n){fC(e),n&&(uC(e,r),uC(e,~r)),jw.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}Bw._tr_init=function(e){EC||(!function(){var e,t,r,n,i,o=new Array(16);for(r=0,n=0;n<28;n++)for(tC[n]=r,e=0;e<1<<Ww[n];e++)eC[r++]=n;for(eC[r-1]=n,i=0,n=0;n<16;n++)for(oC[n]=i,e=0;e<1<<qw[n];e++)$w[i++]=n;for(i>>=7;n<Kw;n++)for(oC[n]=i<<7,e=0;e<1<<qw[n]-7;e++)$w[256+i++]=n;for(t=0;t<=Xw;t++)o[t]=0;for(e=0;e<=143;)Qw[2*e+1]=8,e++,o[8]++;for(;e<=255;)Qw[2*e+1]=9,e++,o[9]++;for(;e<=279;)Qw[2*e+1]=7,e++,o[7]++;for(;e<=287;)Qw[2*e+1]=8,e++,o[8]++;for(pC(Qw,287,o),e=0;e<Kw;e++)Zw[2*e+1]=5,Zw[2*e]=hC(e,5);rC=new aC(Qw,Ww,257,zw,Xw),nC=new aC(Zw,qw,0,Kw,Xw),iC=new aC(new Array(0),Yw,0,19,7)}(),EC=!0),e.l_desc=new sC(e.dyn_ltree,rC),e.d_desc=new sC(e.dyn_dtree,nC),e.bl_desc=new sC(e.bl_tree,iC),e.bi_buf=0,e.bi_valid=0,vC(e)},Bw._tr_stored_block=kC,Bw._tr_flush_block=function(e,t,r,n){var i,o,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<Gw;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),gC(e,e.l_desc),gC(e,e.d_desc),a=function(e){var t;for(SC(e,e.dyn_ltree,e.l_desc.max_code),SC(e,e.dyn_dtree,e.d_desc.max_code),gC(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Jw[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?kC(e,t,r,n):4===e.strategy||o===i?(dC(e,2+(n?1:0),3),yC(e,Qw,Zw)):(dC(e,4+(n?1:0),3),function(e,t,r,n){var i;for(dC(e,t-257,5),dC(e,r-1,5),dC(e,n-4,4),i=0;i<n;i++)dC(e,e.bl_tree[2*Jw[i]+1],3);bC(e,e.dyn_ltree,t-1),bC(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),yC(e,e.dyn_ltree,e.dyn_dtree)),vC(e),n&&fC(e)},Bw._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(eC[r]+Gw+1)]++,e.dyn_dtree[2*cC(t)]++),e.last_lit===e.lit_bufsize-1},Bw._tr_align=function(e){dC(e,2,3),lC(e,256,Qw),function(e){16===e.bi_valid?(uC(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)};var TC=function(e,t,r,n){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16|0};var IC=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();var RC,AC=function(e,t,r,n){var i=IC,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},wC={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},CC=Uw,xC=Bw,OC=TC,MC=AC,DC=wC,PC=-2,NC=258,LC=262,UC=103,VC=113,FC=666;function BC(e,t){return e.msg=DC[t],t}function jC(e){return(e<<1)-(e>4?9:0)}function HC(e){for(var t=e.length;--t>=0;)e[t]=0}function GC(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(CC.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function zC(e,t){xC._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,GC(e.strm)}function KC(e,t){e.pending_buf[e.pending++]=t}function XC(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function WC(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-LC?e.strstart-(e.w_size-LC):0,u=e.window,d=e.w_mask,l=e.prev,h=e.strstart+NC,p=u[o+a-1],v=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===v&&u[r+a-1]===p&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<h);if(n=NC-(h-o),o=h-NC,n>a){if(e.match_start=t,a=n,n>=s)break;p=u[o+a-1],v=u[o+a]}}}while((t=l[t&d])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function qC(e){var t,r,n,i,o,a,s,c,u,d,l=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=l+(l-LC)){CC.arraySet(e.window,e.window,l,l,0),e.match_start-=l,e.strstart-=l,e.block_start-=l,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=l?n-l:0}while(--r);t=r=l;do{n=e.prev[--t],e.prev[t]=n>=l?n-l:0}while(--r);i+=l}if(0===e.strm.avail_in)break;if(a=e.strm,s=e.window,c=e.strstart+e.lookahead,u=i,d=void 0,(d=a.avail_in)>u&&(d=u),r=0===d?0:(a.avail_in-=d,CC.arraySet(s,a.input,a.next_in,d,c),1===a.state.wrap?a.adler=OC(a.adler,s,d,c):2===a.state.wrap&&(a.adler=MC(a.adler,s,d,c)),a.next_in+=d,a.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+3-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<LC&&0!==e.strm.avail_in)}function YC(e,t){for(var r,n;;){if(e.lookahead<LC){if(qC(e),e.lookahead<LC&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-LC&&(e.match_length=WC(e,r)),e.match_length>=3)if(n=xC._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=xC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}function JC(e,t){for(var r,n,i;;){if(e.lookahead<LC){if(qC(e),e.lookahead<LC&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-LC&&(e.match_length=WC(e,r),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=xC._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(zC(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=xC._tr_tally(e,0,e.window[e.strstart-1]))&&zC(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=xC._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}function QC(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function ZC(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new CC.Buf16(1146),this.dyn_dtree=new CC.Buf16(122),this.bl_tree=new CC.Buf16(78),HC(this.dyn_ltree),HC(this.dyn_dtree),HC(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new CC.Buf16(16),this.heap=new CC.Buf16(573),HC(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new CC.Buf16(573),HC(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function $C(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:VC,e.adler=2===t.wrap?0:1,t.last_flush=0,xC._tr_init(t),0):BC(e,PC)}function ex(e){var t,r=$C(e);return 0===r&&((t=e.state).window_size=2*t.w_size,HC(t.head),t.max_lazy_match=RC[t.level].max_lazy,t.good_match=RC[t.level].good_length,t.nice_match=RC[t.level].nice_length,t.max_chain_length=RC[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),r}function tx(e,t,r,n,i,o){if(!e)return PC;var a=1;if(-1===t&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>9||8!==r||n<8||n>15||t<0||t>9||o<0||o>4)return BC(e,PC);8===n&&(n=9);var s=new ZC;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+3-1)/3),s.window=new CC.Buf8(2*s.w_size),s.head=new CC.Buf16(s.hash_size),s.prev=new CC.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new CC.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=r,ex(e)}RC=[new QC(0,0,0,0,(function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(qC(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,zC(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-LC&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(zC(e,!1),e.strm.avail_out),1)})),new QC(4,4,8,4,YC),new QC(4,5,16,8,YC),new QC(4,6,32,32,YC),new QC(4,4,16,16,JC),new QC(8,16,32,32,JC),new QC(8,16,128,128,JC),new QC(8,32,128,256,JC),new QC(32,128,258,1024,JC),new QC(32,258,258,4096,JC)],Fw.deflateInit=function(e,t){return tx(e,t,8,15,8,0)},Fw.deflateInit2=tx,Fw.deflateReset=ex,Fw.deflateResetKeep=$C,Fw.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?PC:(e.state.gzhead=t,0):PC},Fw.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?BC(e,PC):PC;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===FC&&4!==t)return BC(e,0===e.avail_out?-5:PC);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,KC(n,31),KC(n,139),KC(n,8),n.gzhead?(KC(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),KC(n,255&n.gzhead.time),KC(n,n.gzhead.time>>8&255),KC(n,n.gzhead.time>>16&255),KC(n,n.gzhead.time>>24&255),KC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),KC(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(KC(n,255&n.gzhead.extra.length),KC(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=MC(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(KC(n,0),KC(n,0),KC(n,0),KC(n,0),KC(n,0),KC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),KC(n,3),n.status=VC);else{var a=8+(n.w_bits-8<<4)<<8;a|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=VC,XC(n,a),0!==n.strstart&&(XC(n,e.adler>>>16),XC(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=MC(e.adler,n.pending_buf,n.pending-i,i)),GC(e),i=n.pending,n.pending!==n.pending_buf_size));)KC(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=MC(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=MC(e.adler,n.pending_buf,n.pending-i,i)),GC(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,KC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=MC(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=MC(e.adler,n.pending_buf,n.pending-i,i)),GC(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,KC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=MC(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=UC)}else n.status=UC;if(n.status===UC&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&GC(e),n.pending+2<=n.pending_buf_size&&(KC(n,255&e.adler),KC(n,e.adler>>8&255),e.adler=0,n.status=VC)):n.status=VC),0!==n.pending){if(GC(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&jC(t)<=jC(r)&&4!==t)return BC(e,-5);if(n.status===FC&&0!==e.avail_in)return BC(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==FC){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(qC(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=xC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=NC){if(qC(e),e.lookahead<=NC&&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+NC;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=NC-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=xC._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=xC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}(n,t):RC[n.level].func(n,t);if(3!==s&&4!==s||(n.status=FC),1===s||3===s)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===s&&(1===t?xC._tr_align(n):5!==t&&(xC._tr_stored_block(n,0,0,!1),3===t&&(HC(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),GC(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(KC(n,255&e.adler),KC(n,e.adler>>8&255),KC(n,e.adler>>16&255),KC(n,e.adler>>24&255),KC(n,255&e.total_in),KC(n,e.total_in>>8&255),KC(n,e.total_in>>16&255),KC(n,e.total_in>>24&255)):(XC(n,e.adler>>>16),XC(n,65535&e.adler)),GC(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},Fw.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==UC&&t!==VC&&t!==FC?BC(e,PC):(e.state=null,t===VC?BC(e,-3):0):PC},Fw.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,d=t.length;if(!e||!e.state)return PC;if(2===(o=(r=e.state).wrap)||1===o&&42!==r.status||r.lookahead)return PC;for(1===o&&(e.adler=OC(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(HC(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new CC.Buf8(r.w_size),CC.arraySet(u,t,d-r.w_size,r.w_size,0),t=u,d=r.w_size),a=e.avail_in,s=e.next_in,c=e.input,e.avail_in=d,e.next_in=0,e.input=t,qC(r);r.lookahead>=3;){n=r.strstart,i=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--i);r.strstart=n,r.lookahead=2,qC(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,0},Fw.deflateInfo="pako deflate (from Nodeca project)";var rx={},nx=Uw,ix=!0,ox=!0;try{String.fromCharCode.apply(null,[0])}catch(dq){ix=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(dq){ox=!1}for(var ax=new nx.Buf8(256),sx=0;sx<256;sx++)ax[sx]=sx>=252?6:sx>=248?5:sx>=240?4:sx>=224?3:sx>=192?2:1;function cx(e,t){if(t<65534&&(e.subarray&&ox||!e.subarray&&ix))return String.fromCharCode.apply(null,nx.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}ax[254]=ax[254]=1,rx.string2buf=function(e){var t,r,n,i,o,a=e.length,s=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new nx.Buf8(s),o=0,i=0;o<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},rx.buf2binstring=function(e){return cx(e,e.length)},rx.binstring2buf=function(e){for(var t=new nx.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},rx.buf2string=function(e,t){var r,n,i,o,a=t||e.length,s=new Array(2*a);for(n=0,r=0;r<a;)if((i=e[r++])<128)s[n++]=i;else if((o=ax[i])>4)s[n++]=65533,r+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&r<a;)i=i<<6|63&e[r++],o--;o>1?s[n++]=65533:i<65536?s[n++]=i:(i-=65536,s[n++]=55296|i>>10&1023,s[n++]=56320|1023&i)}return cx(s,n)},rx.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+ax[e[r]]>t?r:t};var ux=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},dx=Fw,lx=Uw,hx=rx,px=wC,vx=ux,fx=Object.prototype.toString;function _x(e){if(!(this instanceof _x))return new _x(e);this.options=lx.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new vx,this.strm.avail_out=0;var r=dx.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==r)throw new Error(px[r]);if(t.header&&dx.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?hx.string2buf(t.dictionary):"[object ArrayBuffer]"===fx.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=dx.deflateSetDictionary(this.strm,n)))throw new Error(px[r]);this._dict_set=!0}}function mx(e,t){var r=new _x(t);if(r.push(e,!0),r.err)throw r.msg||px[r.err];return r.result}_x.prototype.push=function(e,t){var r,n,i=this.strm,o=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=hx.string2buf(e):"[object ArrayBuffer]"===fx.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new lx.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=dx.deflate(i,n))&&0!==r)return this.onEnd(r),this.ended=!0,!1;0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(hx.buf2binstring(lx.shrinkBuf(i.output,i.next_out))):this.onData(lx.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=dx.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==n||(this.onEnd(0),i.avail_out=0,!0)},_x.prototype.onData=function(e){this.chunks.push(e)},_x.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=lx.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},Vw.Deflate=_x,Vw.deflate=mx,Vw.deflateRaw=function(e,t){return(t=t||{}).raw=!0,mx(e,t)},Vw.gzip=function(e,t){return(t=t||{}).gzip=!0,mx(e,t)};var yx={},gx=tr,Sx=O,bx=Ye,Ex=ae,kx=function(){var e=gx(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Tx=RegExp.prototype,Ix=ae,Rx=function(e){var t=e.flags;return void 0!==t||"flags"in Tx||bx(e,"flags")||!Ex(Tx,e)?t:Sx(kx,e)},Ax=RegExp.prototype,wx=function(e){return e===Ax||Ix(Ax,e)?Rx(e):e.flags},Cx={},xx=Uw,Ox=15,Mx=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Dx=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Px=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],Nx=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],Lx=Uw,Ux=TC,Vx=AC,Fx=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,R=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,u=r.wsize,d=r.whave,l=r.wnext,h=r.window,p=r.hold,v=r.bits,f=r.lencode,_=r.distcode,m=(1<<r.lenbits)-1,y=(1<<r.distbits)-1;e:do{v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),g=f[p&m];t:for(;;){if(p>>>=S=g>>>24,v-=S,0===(S=g>>>16&255))R[o++]=65535&g;else{if(!(16&S)){if(0==(64&S)){g=f[(65535&g)+(p&(1<<S)-1)];continue t}if(32&S){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=65535&g,(S&=15)&&(v<S&&(p+=I[n++]<<v,v+=8),b+=p&(1<<S)-1,p>>>=S,v-=S),v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),g=_[p&y];r:for(;;){if(p>>>=S=g>>>24,v-=S,!(16&(S=g>>>16&255))){if(0==(64&S)){g=_[(65535&g)+(p&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(E=65535&g,v<(S&=15)&&(p+=I[n++]<<v,(v+=8)<S&&(p+=I[n++]<<v,v+=8)),(E+=p&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(p>>>=S,v-=S,E>(S=o-a)){if((S=E-S)>d&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(k=0,T=h,0===l){if(k+=u-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}else if(l<S){if(k+=u+l-S,(S-=l)<b){b-=S;do{R[o++]=h[k++]}while(--S);if(k=0,l<b){b-=S=l;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}}else if(k+=l-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}for(;b>2;)R[o++]=T[k++],R[o++]=T[k++],R[o++]=T[k++],b-=3;b&&(R[o++]=T[k++],b>1&&(R[o++]=T[k++]))}else{k=o-E;do{R[o++]=R[k++],R[o++]=R[k++],R[o++]=R[k++],b-=3}while(b>2);b&&(R[o++]=R[k++],b>1&&(R[o++]=R[k++]))}break}}break}}while(n<i&&o<s);n-=b=v>>3,p&=(1<<(v-=b<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<s?s-o+257:257-(o-s),r.hold=p,r.bits=v},Bx=function(e,t,r,n,i,o,a,s){var c,u,d,l,h,p,v,f,_,m=s.bits,y=0,g=0,S=0,b=0,E=0,k=0,T=0,I=0,R=0,A=0,w=null,C=0,x=new xx.Buf16(16),O=new xx.Buf16(16),M=null,D=0;for(y=0;y<=Ox;y++)x[y]=0;for(g=0;g<n;g++)x[t[r+g]]++;for(E=m,b=Ox;b>=1&&0===x[b];b--);if(E>b&&(E=b),0===b)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<b&&0===x[S];S++);for(E<S&&(E=S),I=1,y=1;y<=Ox;y++)if(I<<=1,(I-=x[y])<0)return-1;if(I>0&&(0===e||1!==b))return-1;for(O[1]=0,y=1;y<Ox;y++)O[y+1]=O[y]+x[y];for(g=0;g<n;g++)0!==t[r+g]&&(a[O[t[r+g]]++]=g);if(0===e?(w=M=a,p=19):1===e?(w=Mx,C-=257,M=Dx,D-=257,p=256):(w=Px,M=Nx,p=-1),A=0,g=0,y=S,h=o,k=E,T=0,d=-1,l=(R=1<<E)-1,1===e&&R>852||2===e&&R>592)return 1;for(;;){v=y-T,a[g]<p?(f=0,_=a[g]):a[g]>p?(f=M[D+a[g]],_=w[C+a[g]]):(f=96,_=0),c=1<<y-T,S=u=1<<k;do{i[h+(A>>T)+(u-=c)]=v<<24|f<<16|_|0}while(0!==u);for(c=1<<y-1;A&c;)c>>=1;if(0!==c?(A&=c-1,A+=c):A=0,g++,0==--x[y]){if(y===b)break;y=t[r+a[g]]}if(y>E&&(A&l)!==d){for(0===T&&(T=E),h+=S,I=1<<(k=y-T);k+T<b&&!((I-=x[k+T])<=0);)k++,I<<=1;if(R+=1<<k,1===e&&R>852||2===e&&R>592)return 1;i[d=A&l]=E<<24|k<<16|h-o|0}}return 0!==A&&(i[h+A]=y-T<<24|64<<16|0),s.bits=E,0},jx=-2,Hx=12,Gx=30;function zx(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function Kx(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Lx.Buf16(320),this.work=new Lx.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Xx(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Lx.Buf32(852),t.distcode=t.distdyn=new Lx.Buf32(592),t.sane=1,t.back=-1,0):jx}function Wx(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,Xx(e)):jx}function qx(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?jx:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,Wx(e))):jx}function Yx(e,t){var r,n;return e?(n=new Kx,e.state=n,n.window=null,0!==(r=qx(e,t))&&(e.state=null),r):jx}var Jx,Qx,Zx=!0;function $x(e){if(Zx){var t;for(Jx=new Lx.Buf32(512),Qx=new Lx.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Bx(1,e.lens,0,288,Jx,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Bx(2,e.lens,0,32,Qx,0,e.work,{bits:5}),Zx=!1}e.lencode=Jx,e.lenbits=9,e.distcode=Qx,e.distbits=5}function eO(e,t,r,n){var i,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Lx.Buf8(o.wsize)),n>=o.wsize?(Lx.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((i=o.wsize-o.wnext)>n&&(i=n),Lx.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(Lx.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0}Cx.inflateReset=Wx,Cx.inflateReset2=qx,Cx.inflateResetKeep=Xx,Cx.inflateInit=function(e){return Yx(e,15)},Cx.inflateInit2=Yx,Cx.inflate=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R=0,A=new Lx.Buf8(4),w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return jx;(r=e.state).mode===Hx&&(r.mode=13),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,l=s,h=c,k=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(2&r.wrap&&35615===u){r.check=0,A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0),u=0,d=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=Gx;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=Gx;break}if(d-=4,E=8+(15&(u>>>=4)),0===r.wbits)r.wbits=E;else if(E>r.wbits){e.msg="invalid window size",r.mode=Gx;break}r.dmax=1<<E,e.adler=r.check=1,r.mode=512&u?10:Hx,u=0,d=0;break;case 2:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.flags=u,8!=(255&wx(r))){e.msg="unknown compression method",r.mode=Gx;break}if(57344&wx(r)){e.msg="unknown header flags set",r.mode=Gx;break}r.head&&(r.head.text=u>>8&1),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0)),u=0,d=0,r.mode=3;case 3:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.time=u),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=Vx(r.check,A,4,0)),u=0,d=0,r.mode=4;case 4:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0)),u=0,d=0,r.mode=5;case 5:if(1024&wx(r)){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length=u,r.head&&(r.head.extra_len=u),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&wx(r)&&((p=r.length)>s&&(p=s),p&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),Lx.arraySet(r.head.extra,n,o,p,E)),512&wx(r)&&(r.check=Vx(r.check,n,p,o)),s-=p,o+=p,r.length-=p),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&wx(r)){if(0===s)break e;p=0;do{E=n[o+p++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&p<s);if(512&wx(r)&&(r.check=Vx(r.check,n,p,o)),s-=p,o+=p,E)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&wx(r)){if(0===s)break e;p=0;do{E=n[o+p++],r.head&&E&&r.length<65536&&(r.head.comment+=String.fromCharCode(E))}while(E&&p<s);if(512&wx(r)&&(r.check=Vx(r.check,n,p,o)),s-=p,o+=p,E)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&wx(r)){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=Gx;break}u=0,d=0}r.head&&(r.head.hcrc=wx(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Hx;break;case 10:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}e.adler=r.check=zx(u),u=0,d=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,2;e.adler=r.check=1,r.mode=Hx;case Hx:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&d,d-=7&d,r.mode=27;break}for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}switch(r.last=1&u,d-=1,3&(u>>>=1)){case 0:r.mode=14;break;case 1:if($x(r),r.mode=20,6===t){u>>>=2,d-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=Gx}u>>>=2,d-=2;break;case 14:for(u>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Gx;break}if(r.length=65535&u,u=0,d=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(p=r.length){if(p>s&&(p=s),p>c&&(p=c),0===p)break e;Lx.arraySet(i,n,o,p,a),s-=p,o+=p,c-=p,a+=p,r.length-=p;break}r.mode=Hx;break;case 17:for(;d<14;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.nlen=257+(31&u),u>>>=5,d-=5,r.ndist=1+(31&u),u>>>=5,d-=5,r.ncode=4+(15&u),u>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Gx;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.lens[w[r.have++]]=7&u,u>>>=3,d-=3}for(;r.have<19;)r.lens[w[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,T={bits:r.lenbits},k=Bx(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid code lengths set",r.mode=Gx;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&R,!((_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(y<16)u>>>=_,d-=_,r.lens[r.have++]=y;else{if(16===y){for(I=_+2;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u>>>=_,d-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=Gx;break}E=r.lens[r.have-1],p=3+(3&u),u>>>=2,d-=2}else if(17===y){for(I=_+3;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,E=0,p=3+(7&(u>>>=_)),u>>>=3,d-=3}else{for(I=_+7;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,E=0,p=11+(127&(u>>>=_)),u>>>=7,d-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Gx;break}for(;p--;)r.lens[r.have++]=E}}if(r.mode===Gx)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=Gx;break}if(r.lenbits=9,T={bits:r.lenbits},k=Bx(1,r.lens,0,r.nlen,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid literal/lengths set",r.mode=Gx;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},k=Bx(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,T),r.distbits=T.bits,k){e.msg="invalid distances set",r.mode=Gx;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,Fx(e,h),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,r.mode===Hx&&(r.back=-1);break}for(r.back=0;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&R,!((_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(m&&0==(240&m)){for(g=_,S=m,b=y;m=(R=r.lencode[b+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&R,!(g+(_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=_,d-=_,r.back+=_,r.length=y,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=Hx;break}if(64&m){e.msg="invalid literal/length code",r.mode=Gx;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(R=r.distcode[u&(1<<r.distbits)-1])>>>16&255,y=65535&R,!((_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(0==(240&m)){for(g=_,S=m,b=y;m=(R=r.distcode[b+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&R,!(g+(_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=_,d-=_,r.back+=_,64&m){e.msg="invalid distance code",r.mode=Gx;break}r.offset=y,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Gx;break}r.mode=25;case 25:if(0===c)break e;if(p=h-c,r.offset>p){if((p=r.offset-p)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Gx;break}p>r.wnext?(p-=r.wnext,v=r.wsize-p):v=r.wnext-p,p>r.length&&(p=r.length),f=r.window}else f=i,v=a-r.offset,p=r.length;p>c&&(p=c),c-=p,r.length-=p;do{i[a++]=f[v++]}while(--p);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===s)break e;s--,u|=n[o++]<<d,d+=8}if(h-=c,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=wx(r)?Vx(r.check,i,h,a-h):Ux(r.check,i,h,a-h)),h=c,(wx(r)?u:zx(u))!==r.check){e.msg="incorrect data check",r.mode=Gx;break}u=0,d=0}r.mode=28;case 28:if(r.wrap&&wx(r)){for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=Gx;break}u=0,d=0}r.mode=29;case 29:k=1;break e;case Gx:k=-3;break e;case 31:return-4;default:return jx}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,(r.wsize||h!==e.avail_out&&r.mode<Gx&&(r.mode<27||4!==t))&&eO(e,e.output,e.next_out,h-e.avail_out),l-=e.avail_in,h-=e.avail_out,e.total_in+=l,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=wx(r)?Vx(r.check,i,h,e.next_out-h):Ux(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===Hx?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&0===k&&(k=-5),k},Cx.inflateEnd=function(e){if(!e||!e.state)return jx;var t=e.state;return t.window&&(t.window=null),e.state=null,0},Cx.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?jx:(r.head=t,t.done=!1,0):jx},Cx.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?jx:11===r.mode&&Ux(1,t,n,0)!==r.check?-3:eO(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,0):jx},Cx.inflateInfo="pako inflate (from Nodeca project)";var tO={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};var rO=Cx,nO=Uw,iO=rx,oO=tO,aO=wC,sO=ux,cO=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},uO=Object.prototype.toString;function dO(e){if(!(this instanceof dO))return new dO(e);this.options=nO.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new sO,this.strm.avail_out=0;var r=rO.inflateInit2(this.strm,t.windowBits);if(r!==oO.Z_OK)throw new Error(aO[r]);if(this.header=new cO,rO.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=iO.string2buf(t.dictionary):"[object ArrayBuffer]"===uO.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=rO.inflateSetDictionary(this.strm,t.dictionary))!==oO.Z_OK))throw new Error(aO[r])}function lO(e,t){var r=new dO(t);if(r.push(e,!0),r.err)throw r.msg||aO[r.err];return r.result}dO.prototype.push=function(e,t){var r,n,i,o,a,s=this.strm,c=this.options.chunkSize,u=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?oO.Z_FINISH:oO.Z_NO_FLUSH,"string"==typeof e?s.input=iO.binstring2buf(e):"[object ArrayBuffer]"===uO.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new nO.Buf8(c),s.next_out=0,s.avail_out=c),(r=rO.inflate(s,oO.Z_NO_FLUSH))===oO.Z_NEED_DICT&&u&&(r=rO.inflateSetDictionary(this.strm,u)),r===oO.Z_BUF_ERROR&&!0===d&&(r=oO.Z_OK,d=!1),r!==oO.Z_STREAM_END&&r!==oO.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==oO.Z_STREAM_END&&(0!==s.avail_in||n!==oO.Z_FINISH&&n!==oO.Z_SYNC_FLUSH)||("string"===this.options.to?(i=iO.utf8border(s.output,s.next_out),o=s.next_out-i,a=iO.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&nO.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(nO.shrinkBuf(s.output,s.next_out)))),0===s.avail_in&&0===s.avail_out&&(d=!0)}while((s.avail_in>0||0===s.avail_out)&&r!==oO.Z_STREAM_END);return r===oO.Z_STREAM_END&&(n=oO.Z_FINISH),n===oO.Z_FINISH?(r=rO.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===oO.Z_OK):n!==oO.Z_SYNC_FLUSH||(this.onEnd(oO.Z_OK),s.avail_out=0,!0)},dO.prototype.onData=function(e){this.chunks.push(e)},dO.prototype.onEnd=function(e){e===oO.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=nO.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},yx.Inflate=dO,yx.inflate=lO,yx.inflateRaw=function(e,t){return(t=t||{}).raw=!0,lO(e,t)},yx.ungzip=lO;var hO={};(0,Uw.assign)(hO,Vw,yx,tO);var pO,vO=hO,fO="BytePlusRTC",_O=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},mO=function(){function e(t){Vl(this,e),Jd(this,"storeName",void 0),Jd(this,"pendingList",[]),this.storeName=t,!fw()&&_O()&&this._checkAndCreateStore(t)}var t,r;return Ul(e,[{key:"_checkAndCreateStore",value:function(t,r){var n=this;e.db&&e.db.close();var i=r?_O().open(fO,r):_O().open(fO);i.onupgradeneeded=function(){i.result.createObjectStore(t)},i.onerror=function(e){console.error("IndexedDBInterface error",i.error)},i.onsuccess=function(){var r=i.result;e.db=r;try{e.db.transaction(n.storeName,"readonly"),n.pendingList.forEach(function(){var e=Rm(Tm().mark((function e(t){var r,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.txMode,i=t.resolve,o=t.reject,e.prev=1,e.next=4,n._getStore(r);case 4:a=e.sent,i(a),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o();case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}())}catch(o){n._checkAndCreateStore(t,r.version+1)}}}},{key:"_getStore",value:function(t){var r=this;return new Y_((function(n,i){e.db?n(e.db.transaction(r.storeName,t).objectStore(r.storeName)):r.pendingList.push({txMode:t,resolve:n,reject:i})}))}},{key:"put",value:(r=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readwrite");case 2:return n=e.sent,e.abrupt("return",new Y_((function(e,i){var o=n.put(t,r);o.onsuccess=function(){e()},o.onerror=function(e){i(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"get",value:(t=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readonly");case 2:return r=e.sent,e.abrupt("return",new Y_((function(e,n){var i=r.get(t);i.onsuccess=function(){e(i.result)},i.onerror=function(e){n(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();Jd(mO,"db",void 0),Jd(mO,"state","init");var yO={product_line:"rtc",report_version:"5",os:"web",user_agent:fw()?"":null===(pO=navigator)||void 0===pO?void 0:pO.userAgent,platform:"web",product:"webrtc",app_state:"active"},gO="ReportErrorBuffer",SO=function(){function e(){Vl(this,e),Jd(this,"_buffer",new mO(gO))}var t,r;return Ul(e,[{key:"set",value:(r=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put(t,gO);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"get",value:(t=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.prev=1,e.next=4,this._buffer.get(gO);case 4:t=e.sent,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(1);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(){return t.apply(this,arguments)})}]),e}(),bO=function(){function e(){var t=this;Vl(this,e),Jd(this,"reportCommon",yO),Jd(this,"dataBuffer",[]),Jd(this,"logBuffer",[]),Jd(this,"posting",!1),Jd(this,"sucSendTimer",void 0),Jd(this,"preSucTime",0),Jd(this,"errSendTimer",void 0),Jd(this,"errSendDelay",100),Jd(this,"errSendBuffer",void 0),Jd(this,"_logServerUrl",void 0),Jd(this,"_retryCount",0),fw()||(window.addEventListener("beforeunload",(function(){clearTimeout(t.errSendTimer),clearTimeout(t.sucSendTimer),t.send(void 0,!0)})),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState?t.setCommonStats({app_state:"active"}):"hidden"===document.visibilityState&&t.setCommonStats({app_state:"background"})})))}var t;return Ul(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.reportCommon=wb(this.reportCommon,e)}},{key:"enableErrorBuffer",value:function(){this.errSendBuffer=new SO,this.loadErrorBuffer()}},{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?this.send(e):(this.dataBuffer.push(e),!this.posting&&!this.errSendTimer&&Date.now()-this.preSucTime>2e3&&(clearTimeout(this.sucSendTimer),this.send()))}},{key:"unshift",value:function(e){this.dataBuffer=Om(e).call(e,this.dataBuffer)}},{key:"send",value:function(e,t){var r,n,i=this;if((e||this.dataBuffer.length)&&this._logServerUrl){var o={data:e||rk(r=this.dataBuffer).call(r,0,EO(this.dataBuffer,5e5)),header:Zd(Zd({},this.reportCommon),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},a=new XMLHttpRequest;if(a.timeout=1e4,a.onreadystatechange=function(){if(4===a.readyState){var r,n,s,c;if(e||(i.posting=!1),200===a.status||304===a.status)try{r=JSON.parse(a.responseText)}catch(uq){n=uq}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;NO(Om(e="reportor error, res:".concat(null===(t=r)||void 0===t?void 0:t.toString()," err:")).call(e,n),a.status,n)}),0),e)i.send(e);else i.unshift(o.data),null===(c=i.errSendBuffer)||void 0===c||c.set(Jk(i.dataBuffer)),t?i.send():i.errSend()}},a.open("POST",this._logServerUrl,!0),e||(this.posting=!0),!fw()&&mk(n=location.search).call(n,"_rtc_debug_"))a.send(Nm(o));else{var s=vO.gzip(Nm(o));a.setRequestHeader("Content-Encoding","gzip"),a.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),a.send(s)}}}},{key:"sucSend",value:function(){this.errSendDelay=100,this._retryCount=0,this.preSucTime=Date.now(),this.sucSendTimer=window.setTimeout(this.send.bind(this),2e3)}},{key:"errSend",value:function(){var e=this;this.errSendTimer=window.setTimeout((function(){e.send(),delete e.errSendTimer}),this.errSendDelay),this.errSendDelay*=2,this._retryCount++}},{key:"loadErrorBuffer",value:(t=Rm(Tm().mark((function e(){var t,r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this.errSendBuffer)||void 0===r?void 0:r.get();case 2:if(e.t1=t=e.sent,e.t0=null!==e.t1,!e.t0){e.next=6;break}e.t0=void 0!==t;case 6:if(!e.t0){e.next=10;break}e.t2=t,e.next=11;break;case 10:e.t2=[];case 11:e.t2.forEach((function(e){n.push(e)}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();function EO(e,t){for(var r=0,n=0;n<e.length;n++)if((r+=Nm(e[n]).length)>t)return n-1;return e.length}var kO=new bO,TO=function(){function e(t){Vl(this,e),Jd(this,"report_id",0),Jd(this,"modify_ids",{}),this.id=t}return Ul(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=Zd(Zd(Zd({event_key:e,report_id:this.report_id++,rtc_timestamp:Date.now()},this.modify_ids),t),{},{common_extra_info:Nm(i)});(kO.push(o),fw())||(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.id,o))}},{key:"set",value:function(e){this.modify_ids=wb(this.modify_ids,e)}},{key:"destroy",value:function(){}}]),e}(),IO=new Nw("MessageReportor",1),RO=function(){function e(t){Vl(this,e),Jd(this,"_preTime",Date.now()),Jd(this,"_one2oneNum",0),Jd(this,"_one2manyNum",0),Jd(this,"_one2oneMsgCache",new $S),Jd(this,"_one2manyMsgCache",new $S),Jd(this,"roomId",""),Jd(this,"userId",""),Jd(this,"rtsSessionId",""),this.id=t}return Ul(e,[{key:"needReport",value:function(t){return!!e.config&&(Date.now()-this._preTime>=36e5&&(this._preTime=Date.now(),this._one2oneNum=0,this._one2manyNum=0),"one2one"===t&&this._one2oneNum<e.config.max_one2one_fpt_per_hour&&Math.random()<=e.config.one2one_fpt_ratio/100||"one2many"===t&&this._one2manyNum<e.config.max_one2many_fpt_per_hour&&Math.random()<=e.config.one2many_fpt_ratio/100)}},{key:"cacheP2PMsg",value:function(t){var r;this._one2oneMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateP2PMsg",value:function(e,t){var r=this._one2oneMsgCache.get(e);r&&this._one2oneMsgCache.set(e,Zd(Zd({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateOne2ManyMsg",value:function(e,t){var r=this._one2manyMsgCache.get(e);r&&this._one2manyMsgCache.set(e,Zd(Zd({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(IO.info("reportP2PMsg",r.type,Nm(r)),null===(t=VO(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(IO.info("reportOne2ManyMsg",r.type,Nm(r)),null===(t=VO(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportMsgRecv",value:function(t){var r,n;t.config_version=(null===(r=e.config)||void 0===r?void 0:r.version)||"",IO.info("reportMsgRecv",t.type,Nm(t)),null===(n=VO(this.id))||void 0===n||n.report("rts_message",t)}},{key:"destroy",value:function(){this._one2manyNum=0,this._one2oneNum=0,this._one2manyMsgCache.clear(),this._one2oneMsgCache.clear(),this._preTime=Date.now(),this.roomId="",this.userId="",this.rtsSessionId=""}}]),e}();Jd(RO,"config",void 0);var AO=new $S,wO={_cache:AO,setConfig:function(e){IO.info("setConfig","get config: ".concat(Nm(e))),RO.config=e},setRtsSessionId:function(e,t){var r=AO.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=AO.get(e)||new RO(e);return AO.set(e,t),t},destroyRTSMsgReportor:function(e){var t=AO.get(e);t&&(t.destroy(),AO.delete(e))},setRoomId:function(e,t){var r=AO.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=AO.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=AO.get(e);if(null!=r&&r.needReport("one2one")){var n,i=Om(n="".concat(t.from)).call(n,t.id),o=t.to?"one2one":"one2server";t.enable_report=!0,t.report_msg_id=t.id,r.cacheP2PMsg({rts_session_id:r.rtsSessionId,msg_id:i,node_role:"src_sdk",from:t.from,to:t.to||"server",type:o,rts_room_id:t.room,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""})}return t},updateP2PMsgReq:function(e,t,r){var n,i;t.enable_report&&mw(t.report_msg_id)&&(null===(n=AO.get(e))||void 0===n||n.updateP2PMsg(Om(i="".concat(t.from)).call(i,t.report_msg_id),{send_ts:Date.now(),msg_size:r}))},updateP2PMsgAck:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i,o=AO.get(e);null==o||o.updateP2PMsg(Om(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(Om(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n,i=AO.get(e);null!=i&&i.needReport("one2many")&&(r.enable_report=!0,r.report_msg_id=t,i.cacheCustomMsg({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(r.clientId)).call(n,t),node_role:"src_sdk",from:r.clientId,to:i.roomId,type:"one2many",rts_room_id:i.roomId,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""}));return r},reportP2PMsgRecv:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i=AO.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(t.from)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:o,rts_room_id:t.room,from:t.from,to:t.to||t.room,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:t.to?"":i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},updateOne2ManyMsgAck:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i,o=AO.get(e);if(o)null==o||o.updateOne2ManyMsg(Om(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(Om(i="".concat(t.clientId)).call(i,t.report_msg_id))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i=AO.get(e);if(i)i.updateOne2ManyMsg(Om(n="".concat(t.clientId)).call(n,t.report_msg_id),{send_ts:Date.now(),msg_size:r})}},reportOne2ManyMsgRecv:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i=AO.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(t.clientId)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:"one2many",rts_room_id:t.roomId,from:t.clientId,to:t.roomId,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}}},CO=function(){function e(t){Vl(this,e),Jd(this,"_timer",void 0),Jd(this,"userMessage",{}),Jd(this,"roomMessage",{}),this.id=t,this._setTimer()}return Ul(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(an(this.userMessage).length||an(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e,t,r,n=this;null===(e=VO(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:jm(t=an(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:jm(r=an(this.roomMessage)).call(r,(function(e){return n.roomMessage[e]})),media_server_ip:""})}},{key:"_reset",value:function(){this.userMessage={},this.roomMessage={}}},{key:"_checkInitUserMessage",value:function(e,t){var r,n;this.userMessage[Om(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Om(n="".concat(t,"-")).call(n,e)]={dc_peer_user_id:e,dc_send_total:0,dc_recv_total:0,dc_send_ack:0,dc_send_fail:0,dc_fail_timeout:0,dc_fail_no_receiver:0,dc_fail_no_relay_path:0,dc_cost_time:0,dc_cost_e2s:0,dc_cost_s2s:0,dc_least_time:Number(1/0),dc_most_time:0,dc_cost_peer_s2e:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_message_type:t,dc_send_binary:0})}},{key:"_sendUserMessage",value:function(e,t,r){var n,i;(this._checkInitUserMessage(e,t),this.userMessage[Om(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Om(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Om(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Om(n="".concat(t,"-")).call(n,e)];i&&(i.dc_send_fail++,this._handleUserFail(i,r))}},{key:"_handleUserFail",value:function(e,t){var r;t&&(t.code||t.err)&&(mk(r=["TIME_OUT","USER_MESSAGE_TIMEOUT"]).call(r,t.code)?e.dc_fail_timeout++:3===t.err?e.dc_fail_no_receiver++:4===t.err?e.dc_fail_no_relay_path++:1===t.err&&e.dc_fail_timeout++)}},{key:"_sendUserAck",value:function(e,t,r,n,i){var o,a=this.userMessage[Om(o="".concat(t,"-")).call(o,e)];a&&(a.dc_send_ack++,a.dc_cost_time+=r,a.dc_cost_s2s+=n||0,a.dc_cost_peer_s2e+=i,a.dc_cost_e2s+=r-(n||0)-i,r<=100?(a.dc_send_ack_100++,a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=200?(a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=400?(a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=1e3&&a.dc_send_ack_1s++,r<a.dc_least_time&&(a.dc_least_time=r),r>a.dc_most_time&&(a.dc_most_time=r))}},{key:"sendRoomMessage",value:function(e,t){this.roomMessage[e]||(this.roomMessage[e]={dc_room_id:e,dc_send_total:0,dc_send_ack:0,dc_cost_time:0,dc_least_time:Number(1/0),dc_most_time:0,dc_send_fail:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_send_binary:0}),this.roomMessage[e].dc_send_total++,t&&this.roomMessage[e].dc_send_binary++}},{key:"sendRoomFail",value:function(e){var t=this.roomMessage[e];t&&t.dc_send_fail++}},{key:"sendRoomAck",value:function(e,t){var r=this.roomMessage[e];r&&(r.dc_send_ack++,r.dc_cost_time+=t,t<r.dc_least_time&&(r.dc_least_time=t),t>r.dc_most_time&&(r.dc_most_time=t),t<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=1e3&&r.dc_send_ack_1s++)}},{key:"sendP2PMessage",value:function(e,t){this._sendUserMessage(e,"p2p",t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,"p2p")}},{key:"sendP2PFail",value:function(e,t){this._sendUserFail(e,"p2p",t)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p",t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,"p2p_outside_room",t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,"p2p_outside_room")}},{key:"sendP2POutRoomFail",value:function(e,t){this._sendUserFail(e,"p2p_outside_room",t)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p_outside_room",t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("","p2server",e)}},{key:"sendP2serverFail",value:function(e){this._sendUserFail("","p2server",e)}},{key:"sendP2serveAck",value:function(e,t,r){this._sendUserAck("","p2server",e,t,r)}},{key:"countP2PMessage",value:function(e,t,r,n,i){this.sendP2PMessage(t,r),e?this.sendP2PAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2PFail(t,i)}},{key:"countRoomMessage",value:function(e,t,r,n){this.sendRoomMessage(t,r),e?this.sendRoomAck(t,Date.now()-n):this.sendRoomFail(t)}},{key:"countUserMessageOutsideRoom",value:function(e,t,r,n,i){this.sendP2POutRoomMessage(t,r),e?this.sendP2POutRoomAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2POutRoomFail(t,i)}},{key:"countServerMessage",value:function(e,t,r,n){this.sendP2serverMessage(t),e?(n=n||{},this.sendP2serveAck(Date.now()-r,n.s2s_time||0,n.s2e_time||0)):this.sendP2serverFail(n)}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),xO=function(e){kO.setCommonStats(e)},OO=function(e){kO.setUrl(e)},MO=new TO("global"),DO=function(e,t,r){MO.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},PO=function(e,t,r){MO.report("rtc_sdk_callback",{sdk_callback_name:e,error_code:t,message:r})},NO=function(e,t,r){MO.report("rtc_error",{message:e,error_code:t},r)},LO=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;MO.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)},UO=new $S,VO=function(e){return UO.get(e)};function FO(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r,n){if("function"==typeof n.value){var i=n.value;n.value=function(){for(var e,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];var s,c,u=this.engineId||this.id,d={};(t.forEach((function(e,t){d[e]=o[t]})),"joinRoom"===r)&&(null===(s=VO(u))||void 0===s||s.set({room_id:o[1],user_id:null===(c=o[2])||void 0===c?void 0:c.userId}));null===(e=VO(u))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:Nm(HO(o)),error_code:0},d);var l=i.apply(this,o);return"function"==typeof(null==l?void 0:l.then)?l.then((function(e){return BO(u,r,[e||{}]),e})).catch((function(e){throw BO(u,r,e.message,e.code),e})):(BO(u,r,[l||{}]),l)}}}}var BO=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4?arguments[4]:void 0,a={sdk_callback_name:t,error_code:i,message:Nm(Array.isArray(r)?HO(r):r)};o&&(a.room_id=o),null===(n=VO(e))||void 0===n||n.report("rtc_sdk_callback",a)},jO=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",a=arguments.length>5?arguments[5]:void 0;null===(n=VO(e))||void 0===n||n.report("rtc_invoke_status",{sdk_api_name:t,message:r,error_code:i,stream_id:o,elapse:0},a)};function HO(e){return jm(e).call(e,(function e(t){var r;if(null!=t&&t._reportName)return t._reportName;if(t instanceof HTMLElement)return t.toString();if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){var n,i,o=ArrayBuffer.isView(t)?t.buffer:t,a=o.byteLength,s=[];if(a>10){var c,u,d,l,h=new DataView(o),p=jm(c=qk({length:5})).call(c,(function(e,t){return h.getUint8(t)})),v=jm(u=jm(d=qk({length:5})).call(d,(function(e,t){return a-1-t})).reverse()).call(u,(function(e){return h.getUint8(e)}));s=Om(l=[]).call(l,Jk(p),["..."],Jk(v))}else s=qk(new Uint8Array(o));return Om(n=Om(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return jm(t).call(t,e);if(mk(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var f={};for(var _ in t)f[_]=e(t[_]);return f}return t}))}var GO=function(e){var t,r=VO(e.engineId),n={keys:sw(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId,deviceId:e.deviceId,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0},i=jm(t=e.requestDomains).call(t,(function(e){return"https://".concat(e,"/decision/v1/multi")}));null==r||r.report("rtc_get_config",{error_code:0,message:Nm(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=jm(i).call(i,function(){var e=Rm(Tm().mark((function e(t,r){var i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:Nm(n)}).then((function(e){return e.json()}));case 2:return i=e.sent,e.abrupt("return",{result:i,index:r});case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}());return new Y_((function(e){(function(e){return new Y_((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))})(o).then((function(t){var n=t.result,o=t.index;null==r||r.report("rtc_get_config",{error_code:200,message:Nm(n),elapse:0,host:i[o],type:"response",config_id:"",enable_cloud_proxy:!1}),e(n)})).catch((function(e){var t;null==r||r.report("rtc_get_config",{error_code:500,message:null===(t=e[0])||void 0===t?void 0:t.message,elapse:0,host:"",type:"response",config_id:"",enable_cloud_proxy:!1})}))}))},zO={exports:{}},KO=n;Ar({global:!0,forced:KO.globalThis!==KO},{globalThis:KO});var XO=n,WO={exports:{}};!function(e,r){var n;e.exports=(n=n||function(e,r){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),void 0!==XO&&XO.crypto&&(n=XO.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==t&&t.crypto&&(n=t.crypto),!n)try{n=require("crypto")}catch(_){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(_){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(_){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),a={},s=a.lib={},c=s.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=s.WordArray=c.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=t!=r?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var s=0;s<i;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e,t=c.clone.call(this);return t.words=km(e=this.words).call(e,0),t},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new u.init(t,e)}}),d=a.enc={},l=d.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=uy(e.substr(n,2),16)<<24-n%8*4;return new u.init(r,t/2)}},h=d.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new u.init(r,t)}},p=d.Utf8={stringify:function(e){try{return decodeURIComponent(escape(h.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return h.parse(unescape(encodeURIComponent(e)))}},v=s.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){var t;"string"==typeof e&&(e=p.parse(e)),Om(t=this._data).call(t,e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,s=o/(4*a),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,d=e.min(4*c,o);if(c){for(var l=0;l<c;l+=a)this._doProcessBlock(i,l);r=rk(i).call(i,0,c),n.sigBytes-=d}return new u.init(r,d)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=v.extend({cfg:c.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){v.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new f.HMAC.init(e,r).finalize(t)}}});var f=a.algo={};return a}(Math),n)}(WO),function(e,t){var r;e.exports=(r=WO.exports,function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init,n=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};n.prototype=e}}(),r.lib.WordArray)}(zO);var qO=zO.exports,YO={exports:{}},JO={exports:{}};!function(e,t){var r;e.exports=(r=WO.exports,function(){var e=r,t=e.lib.WordArray;function n(e,r,n){for(var i=[],o=0,a=0;a<r;a++)if(a%4){var s=n[e.charCodeAt(a-1)]<<a%4*2|n[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=s<<24-o%4*8,o++}return t.create(i,o)}e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)i.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<r.length;o++)i[r.charCodeAt(o)]=o}var a=r.charAt(64);if(a){var s=xE(e).call(e,a);-1!==s&&(t=s)}return n(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),r.enc.Base64)}(JO);var QO={exports:{}};!function(e,t){var r;e.exports=(r=WO.exports,function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,a=t.algo,s=[];!function(){for(var t=0;t<64;t++)s[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,a=e[t+0],c=e[t+1],p=e[t+2],v=e[t+3],f=e[t+4],_=e[t+5],m=e[t+6],y=e[t+7],g=e[t+8],S=e[t+9],b=e[t+10],E=e[t+11],k=e[t+12],T=e[t+13],I=e[t+14],R=e[t+15],A=o[0],w=o[1],C=o[2],x=o[3];A=u(A,w,C,x,a,7,s[0]),x=u(x,A,w,C,c,12,s[1]),C=u(C,x,A,w,p,17,s[2]),w=u(w,C,x,A,v,22,s[3]),A=u(A,w,C,x,f,7,s[4]),x=u(x,A,w,C,_,12,s[5]),C=u(C,x,A,w,m,17,s[6]),w=u(w,C,x,A,y,22,s[7]),A=u(A,w,C,x,g,7,s[8]),x=u(x,A,w,C,S,12,s[9]),C=u(C,x,A,w,b,17,s[10]),w=u(w,C,x,A,E,22,s[11]),A=u(A,w,C,x,k,7,s[12]),x=u(x,A,w,C,T,12,s[13]),C=u(C,x,A,w,I,17,s[14]),A=d(A,w=u(w,C,x,A,R,22,s[15]),C,x,c,5,s[16]),x=d(x,A,w,C,m,9,s[17]),C=d(C,x,A,w,E,14,s[18]),w=d(w,C,x,A,a,20,s[19]),A=d(A,w,C,x,_,5,s[20]),x=d(x,A,w,C,b,9,s[21]),C=d(C,x,A,w,R,14,s[22]),w=d(w,C,x,A,f,20,s[23]),A=d(A,w,C,x,S,5,s[24]),x=d(x,A,w,C,I,9,s[25]),C=d(C,x,A,w,v,14,s[26]),w=d(w,C,x,A,g,20,s[27]),A=d(A,w,C,x,T,5,s[28]),x=d(x,A,w,C,p,9,s[29]),C=d(C,x,A,w,y,14,s[30]),A=l(A,w=d(w,C,x,A,k,20,s[31]),C,x,_,4,s[32]),x=l(x,A,w,C,g,11,s[33]),C=l(C,x,A,w,E,16,s[34]),w=l(w,C,x,A,I,23,s[35]),A=l(A,w,C,x,c,4,s[36]),x=l(x,A,w,C,f,11,s[37]),C=l(C,x,A,w,y,16,s[38]),w=l(w,C,x,A,b,23,s[39]),A=l(A,w,C,x,T,4,s[40]),x=l(x,A,w,C,a,11,s[41]),C=l(C,x,A,w,v,16,s[42]),w=l(w,C,x,A,m,23,s[43]),A=l(A,w,C,x,S,4,s[44]),x=l(x,A,w,C,k,11,s[45]),C=l(C,x,A,w,R,16,s[46]),A=h(A,w=l(w,C,x,A,p,23,s[47]),C,x,a,6,s[48]),x=h(x,A,w,C,y,10,s[49]),C=h(C,x,A,w,I,15,s[50]),w=h(w,C,x,A,_,21,s[51]),A=h(A,w,C,x,k,6,s[52]),x=h(x,A,w,C,v,10,s[53]),C=h(C,x,A,w,b,15,s[54]),w=h(w,C,x,A,c,21,s[55]),A=h(A,w,C,x,g,6,s[56]),x=h(x,A,w,C,R,10,s[57]),C=h(C,x,A,w,m,15,s[58]),w=h(w,C,x,A,T,21,s[59]),A=h(A,w,C,x,f,6,s[60]),x=h(x,A,w,C,E,10,s[61]),C=h(C,x,A,w,p,15,s[62]),w=h(w,C,x,A,S,21,s[63]),o[0]=o[0]+A|0,o[1]=o[1]+w|0,o[2]=o[2]+C|0,o[3]=o[3]+x|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,c=s.words,u=0;u<4;u++){var d=c[u];c[u]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+i+a;return(s<<o|s>>>32-o)+t}function d(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+i+a;return(s<<o|s>>>32-o)+t}function l(e,t,r,n,i,o,a){var s=e+(t^r^n)+i+a;return(s<<o|s>>>32-o)+t}function h(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+i+a;return(s<<o|s>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),r.MD5)}(QO);var ZO={exports:{}},$O={exports:{}};!function(e,t){var r,n,i,o,a,s,c,u;e.exports=(n=(r=u=WO.exports).lib,i=n.WordArray,o=n.Hasher,a=r.algo,s=[],c=a.SHA1=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)s[u]=0|e[t+u];else{var d=s[u-3]^s[u-8]^s[u-14]^s[u-16];s[u]=d<<1|d>>>31}var l=(n<<5|n>>>27)+c+s[u];l+=u<20?1518500249+(i&o|~i&a):u<40?1859775393+(i^o^a):u<60?(i&o|i&a|o&a)-1894007588:(i^o^a)-899497514,c=a,a=o,o=i<<30|i>>>2,i=n,n=l}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=o._createHelper(c),r.HmacSHA1=o._createHmacHelper(c),u.SHA1)}($O);var eM={exports:{}};!function(e,t){var r,n,i;e.exports=(n=(r=WO.exports).lib.Base,i=r.enc.Utf8,void(r.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),a=this._iKey=t.clone(),s=o.words,c=a.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;o.sigBytes=a.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t,r=this._hasher,n=r.finalize(e);return r.reset(),r.finalize(Om(t=this._oKey.clone()).call(t,n))}})))}(eM),function(e,t){var r,n,i,o,a,s,c,u;e.exports=(n=(r=u=WO.exports).lib,i=n.Base,o=n.WordArray,a=r.algo,s=a.MD5,c=a.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=o.create(),s=a.words,c=n.keySize,u=n.iterations;s.length<c;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var d=1;d<u;d++)r=i.finalize(r),i.reset();Om(a).call(a,r)}return a.sigBytes=4*c,a}}),r.EvpKDF=function(e,t,r){return c.create(r).compute(e,t)},u.EvpKDF)}(ZO);var tM={exports:{}};!function(e,t){var r;e.exports=void((r=WO.exports).lib.Cipher||function(e){var t=r,n=t.lib,i=n.Base,o=n.WordArray,a=n.BufferedBlockAlgorithm,s=t.enc;s.Utf8;var c=s.Base64,u=t.algo.EvpKDF,d=n.Cipher=a.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?g:m}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()});n.StreamCipher=d.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var l=t.mode={},h=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),p=l.CBC=function(){var t=h.extend();function r(t,r,n){var i,o=this._iv;o?(i=o,this._iv=e):i=this._prevBlock;for(var a=0;a<n;a++)t[r+a]^=i[a]}return t.Encryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize;r.call(this,e,t,i),n.encryptBlock(e,t),this._prevBlock=km(e).call(e,t,t+i)}}),t.Decryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,o=km(e).call(e,t,t+i);n.decryptBlock(e,t),r.call(this,e,t,i),this._prevBlock=o}}),t}(),v=(t.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var c=o.create(a,n);Om(e).call(e,c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};n.BlockCipher=d.extend({cfg:d.cfg.extend({mode:p,padding:v}),reset:function(){var e;d.reset.call(this);var t=this.cfg,r=t.iv,n=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=n.createEncryptor:(e=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(n,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var f=n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),_=(t.format={}).OpenSSL={stringify:function(e){var t,r,n=e.ciphertext,i=e.salt;return(i?Om(t=Om(r=o.create([1398893684,1701076831])).call(r,i)).call(t,n):n).toString(c)},parse:function(e){var t,r=c.parse(e),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(t=o.create(km(n).call(n,2,4)),rk(n).call(n,0,4),r.sigBytes-=16),f.create({ciphertext:r,salt:t})}},m=n.SerializableCipher=i.extend({cfg:i.extend({format:_}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),a=i.cfg;return f.create({ciphertext:o,key:r,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),y=(t.kdf={}).OpenSSL={execute:function(e,t,r,n,i){var a;if(n||(n=o.random(8)),i)s=u.create({keySize:t+r,hasher:i}).compute(e,n);else var s=u.create({keySize:t+r}).compute(e,n);var c=o.create(km(a=s.words).call(a,t),4*r);return s.sigBytes=4*t,f.create({key:s,iv:c,salt:n})}},g=n.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:y}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize,n.salt,n.hasher);n.iv=i.iv;var o=m.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt,n.hasher);return n.iv=i.iv,m.decrypt.call(this,e,t,i.key,n)}})}())}(tM),function(e,t){var r;e.exports=(r=WO.exports,function(){var e=r,t=e.lib.BlockCipher,n=e.algo,i=[],o=[],a=[],s=[],c=[],u=[],d=[],l=[],h=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var v=n^n<<1^n<<2^n<<3^n<<4;v=v>>>8^255&v^99,i[r]=v,o[v]=r;var f=e[r],_=e[f],m=e[_],y=257*e[v]^16843008*v;a[r]=y<<24|y>>>8,s[r]=y<<16|y>>>16,c[r]=y<<8|y>>>24,u[r]=y,y=16843009*m^65537*_^257*f^16843008*r,d[v]=y<<24|y>>>8,l[v]=y<<16|y>>>16,h[v]=y<<8|y>>>24,p[v]=y,r?(r=f^e[e[e[m^f]]],n^=e[e[n]]):r=n=1}}();var v=[0,1,2,4,8,16,32,64,128,27,54],f=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a<n;a++)a<r?o[a]=t[a]:(u=o[a-1],a%r?r>6&&a%r==4&&(u=i[u>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u]):(u=i[(u=u<<8|u>>>24)>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u],u^=v[a/r|0]<<24),o[a]=o[a-r]^u);for(var s=this._invKeySchedule=[],c=0;c<n;c++){if(a=n-c,c%4)var u=o[a];else u=o[a-4];s[c]=c<4||a<=4?u:d[i[u>>>24]]^l[i[u>>>16&255]]^h[i[u>>>8&255]]^p[i[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,c,u,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,d,l,h,p,o),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,a,s){for(var c=this._nRounds,u=e[t]^r[0],d=e[t+1]^r[1],l=e[t+2]^r[2],h=e[t+3]^r[3],p=4,v=1;v<c;v++){var f=n[u>>>24]^i[d>>>16&255]^o[l>>>8&255]^a[255&h]^r[p++],_=n[d>>>24]^i[l>>>16&255]^o[h>>>8&255]^a[255&u]^r[p++],m=n[l>>>24]^i[h>>>16&255]^o[u>>>8&255]^a[255&d]^r[p++],y=n[h>>>24]^i[u>>>16&255]^o[d>>>8&255]^a[255&l]^r[p++];u=f,d=_,l=m,h=y}f=(s[u>>>24]<<24|s[d>>>16&255]<<16|s[l>>>8&255]<<8|s[255&h])^r[p++],_=(s[d>>>24]<<24|s[l>>>16&255]<<16|s[h>>>8&255]<<8|s[255&u])^r[p++],m=(s[l>>>24]<<24|s[h>>>16&255]<<16|s[u>>>8&255]<<8|s[255&d])^r[p++],y=(s[h>>>24]<<24|s[u>>>16&255]<<16|s[d>>>8&255]<<8|s[255&l])^r[p++],e[t]=f,e[t+1]=_,e[t+2]=m,e[t+3]=y},keySize:8});e.AES=t._createHelper(f)}(),r.AES)}(YO);var rM={exports:{}};!function(e,t){e.exports=WO.exports.enc.Hex}(rM);var nM=rM.exports,iM={exports:{}};!function(e,t){var r,n,i;e.exports=((i=WO.exports).mode.CTR=(r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,o=this._counter;i&&(o=this._counter=km(i).call(i,0),this._iv=void 0);var a=km(o).call(o,0);r.encryptBlock(a,0),o[n-1]=o[n-1]+1|0;for(var s=0;s<n;s++)e[t+s]^=a[s]}}),r.Decryptor=n,r),i.mode.CTR)}(iM);var oM=iM.exports,aM={exports:{}};!function(e,t){var r;e.exports=((r=WO.exports).pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)}(aM);var sM=aM.exports,cM=new TextDecoder,uM=new TextEncoder,dM=function(){return vw()},lM=function(){return Date.now()};function hM(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];for(var o=0,a=n;o<a.length;o++){var s=a[o];t+=s.length}for(var c=new e(t),u=0,d=0,l=n;d<l.length;d++){var h=l[d];c.set(h,u),u+=h.length}return c}var pM=function(){function e(){Vl(this,e)}var t,r;return Ul(e,null,[{key:"token2auth",value:function(t,r,n,i){return i?"Bearer ".concat(i):"Basic ".concat(e.createUnsafeToken(t,r,n))}},{key:"createUnsafeToken",value:function(e,t,r){var n;return window.btoa(Hs(n=[e,t,r]).call(n,(function(e){return null!==e})).join(":"))}},{key:"merge",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,i=RA(t);n<i.length;n++){var o=eI(i[n],2),a=o[0],s=o[1];null!==s&&"object"===Wd(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return cM.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 uM.encode(e).buffer}},{key:"ab2b64str",value:(r=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Y_((function(e){var r=new FileReader;r.onload=function(){return e(r.result)},r.readAsDataURL(new Blob([t]))}));case 2:return r=e.sent,e.abrupt("return",r.split(",",2)[1]);case 4:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"b64str2ab",value:(t=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,".concat(t)).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function vM(){for(var e,t,r=Number(WA(e=km(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=WA(r).call(r,28,"1").split(""),i=[];n.length;)i.push(rk(n).call(n,0,7));return jm(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return YA(r+e.join(""),2)}))}var fM=function(){return Math.floor(65535*Math.random())};function _M(e){return"string"==typeof e&&xE(e).call(e,"__web__rtc__rtt__")>-1}var mM,yM,gM,SM,bM,EM,kM,TM,IM=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]&&i[0],(r=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"})).createDataChannel("default"),r.addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),t&&(r.addTransceiver("audio",{direction:"sendonly"}),r.addTransceiver("video",{direction:"sendonly"})),e.next=8,r.createOffer();case 8:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),RM=function(e){return new Y_((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))};function AM(e){return Number(Math.max(-127,10*$A(Math.pow(e/255,2))).toFixed(2))}function wM(e){return(e&ul.AUDIO)===ul.AUDIO}function CM(e){return(e&ul.VIDEO)===ul.VIDEO}function xM(e){var t={};return an(e).forEach((function(r){"object"===Wd(e[r])?t[r]=xM(e[r]):hA(r).call(r,"_")||(t[r]=e[r])})),t}function OM(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 MM(e){return null==e?"undefined | null":"string"==typeof e?e:Nm({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function DM(e){return void 0===e}function PM(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Om(t="[RTC WebSDK]: Api: ".concat(r," has been abandoned from version ")).call(t,e));for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return i.apply(this,o)}}}function NM(e){console.warn("[RTC WebSDK]: ".concat(e))}function LM(e){return"number"==typeof e?e:"number"==typeof(null==e?void 0:e.exact)?e.exact:"number"==typeof(null==e?void 0:e.ideal)?e.ideal:"number"==typeof(null==e?void 0:e.max)?e.max:"number"==typeof(null==e?void 0:e.min)?e.min:1}function UM(e){for(var t=atob(e),r=t.length,n=new Uint8Array(r),i=0;i<r;i++)n[i]=t.charCodeAt(i);return n}function VM(e){for(var t="",r=e.byteLength,n=0;n<r;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function FM(e,t,r){var n=BM(e),i=BM(t),o=BM(r);return function(e){for(var t=e.toString(nM),r=new Uint8Array(t.length/2),n=0;n<t.length;n+=2)r[n/2]=uy(t.substr(n,2),16);return r}(YO.exports.encrypt(n,i,{iv:o,mode:oM,padding:sM}).ciphertext)}function BM(e){for(var t=[],r=0;r<e.length;r+=4)t.push(e[r]<<24|(e[r+1]||0)<<16|(e[r+2]||0)<<8|(e[r+3]||0));return qO.create(t,e.length)}var jM=function(){return"undefined"==typeof window},HM=jM()?"":window.navigator.userAgent;function GM(){var e="none";return jM()||(null!==HM.match("Firefox")?e="mozilla":null!==HM.match("Chrome")?(e="chrome-stable",null!==HM.match("Electron")&&(e="electron")):(null!==HM.match("Safari")||null!==HM.match("AppleWebKit"))&&(e="safari")),e}var zM="mozilla"===GM(),KM="safari"===GM(),XM="chrome-stable"===GM(),WM=!jM()&&/CriOS/i.test(HM),qM=!jM()&&/Edg\//i.test(HM),YM=!jM()&&/EdgA/i.test(HM),JM=!jM()&&/EdgiOS/i.test(HM),QM=qM||YM||JM;!jM()&&/(iPhone|iPod)/i.exec(HM);var ZM=!jM()&&(!!/(iPad)/i.exec(HM)||/Macintosh/i.test(HM)&&"ontouchend"in document),$M=!jM()&&/Macintosh/i.test(HM),eD=!jM()&&/MicroMessenger/i.test(HM),tD=!jM()&&mk(mM=HM.toLowerCase()).call(mM,"mobile");!jM()&&/SM-\w+/i.test(HM);var rD=!jM()&&!!/(iPhone|iPad|iPod)/i.exec(HM),nD=!jM()&&/Android/i.test(HM),iD=!jM()&&/Windows/i.test(HM),oD=0,aD=!jM()&&(null===(yM=HM.match(/version\/(\d+)/i))||void 0===yM?void 0:yM[1]);KM&&aD&&(oD=Number(aD));var sD=!jM()&&(null===(gM=HM.match(/Firefox\/(\d+)/i))||void 0===gM?void 0:gM[1]);zM&&sD&&(oD=Number(sD));var cD=oD,uD=oD,dD=null!==(SM=!jM()&&(null===(bM=HM.match(/ ([\d_]+) like Mac OS X/i))||void 0===bM||null===(EM=bM[1])||void 0===EM?void 0:jm(kM=EM.split("_")).call(kM,(function(e){return uy(e)}))))&&void 0!==SM?SM:[],lD=0,hD=!jM()&&(null===(TM=HM.match(/Chrome\/(\d+)/i))||void 0===TM?void 0:TM[1]);hD&&(lD=Number(hD));var pD=lD,vD="BytePlus",fD="RTC_DEVICE_ID",_D="RTC_ACCESS_NODE",mD="RTC_ACCESS_URLS",yD="ENGINE_WEB_CONFIG",gD="SERVER_CONFIG",SD=function(){function e(){Vl(this,e)}return Ul(e,[{key:"get",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{var r=JSON.parse(t);return r.ttl>0&&Date.now()-r.saveTime>r.ttl?(this.delete(e),null):r.message}catch(n){return null}}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n={ttl:r,saveTime:Date.now(),message:t};try{return localStorage.setItem(e,Nm(n)),!0}catch(i){return!1}}},{key:"getTtl",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{return JSON.parse(t).ttl}catch(r){return null}}},{key:"delete",value:function(e){try{return localStorage.removeItem(e),!0}catch(t){return!1}}}]),e}(),bD=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"_accessVersion","v2"),n}return Ul(r,[{key:"getDeviceId",value:function(){if(jM())return"";var e=this.get(fD);return e&&!/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e)||(e=function(e){for(var t="",r=0;r<e;r++)t+=Math.floor(10*Math.random());return t}(30)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return xO({device_id:e}),this.set(fD,e),e}},{key:"getAccessNode",value:function(e){var t,r;return this.get(Om(t=Om(r="".concat(_D,"_").concat(e,"-")).call(r,vD,"-")).call(t,this._accessVersion))}},{key:"setAccessNode",value:function(e,t,r){var n,i;return this.set(Om(n=Om(i="".concat(_D,"_").concat(e,"-")).call(i,vD,"-")).call(n,this._accessVersion),t,1e3*r)}},{key:"deleteAccessNode",value:function(e,t){var r,n,i=this.getAccessNode(e),o=this.getTtl(Om(r=Om(n="".concat(_D,"_").concat(e,"-")).call(n,vD,"-")).call(r,this._accessVersion));Array.isArray(i)&&i.length>0&&((i=Hs(i).call(i,(function(e){return e.mediaID!==t.mediaID&&e.msgKey!==t.msgKey}))).length>0?this.setAccessNode(e,i,o||0):this.clearAccessNode(e))}},{key:"clearAccessNode",value:function(e){var t,r;this.delete(Om(t=Om(r="".concat(_D,"_").concat(e,"-")).call(r,vD,"-")).call(t,this._accessVersion))}},{key:"getAccessUrls",value:function(){return this.get("".concat(mD,"-").concat(vD))}},{key:"setAccessUrls",value:function(e){var t=jm(e).call(e,(function(e){var t,r=e.host,n=e.path;return Om(t="https://".concat(r)).call(t,n)}));return this.set("".concat(mD,"-").concat(vD),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(mD,"-").concat(vD))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Om(r=Om(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(yD);return(null==a||null===(i=gE(a).call(a,(function(e){return e.key===o})))||void 0===i?void 0:i.config)||{}}},{key:"setEngineWebConfig",value:function(e,t,r){var n,i;if(r){var o=Om(n=Om(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(yD)||[];return(a=Hs(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(yD,km(a).call(a,-5))}}},{key:"getServerConfig",value:function(e){var t,r="".concat(e),n=this.get(gD);return(null==n||null===(t=gE(n).call(n,(function(e){return e.key===r})))||void 0===t?void 0:t.config)||{}}},{key:"setServerConfig",value:function(e,t){if(t){var r="".concat(e),n=this.get(gD)||[];return(n=Hs(n).call(n,(function(e){return e.key!==r}))).push({key:r,config:t}),this.set(gD,km(n).call(n,-5))}}}]),r}(SD),ED=new bD,kD=new Nw("JoinRoomConfig",0),TD=function(){function e(t){var r;Vl(this,e),Jd(this,"_useTcpAfterJoinTimeout",e.DEFAULT_CONF.useTcpAfterJoinTimeout),Jd(this,"_joinWithTcpOnly",e.DEFAULT_CONF.joinWithTcpOnly),Jd(this,"_joinWithTcpOnlyDelay",e.DEFAULT_CONF.joinWithTcpOnlyDelay),Jd(this,"_blackBrowserRegexList",[]),this._engineId=t,xE(r=location.search).call(r,"__rtc_tcp_only__")>-1&&(this._joinWithTcpOnly=!0,this._joinWithTcpOnlyDelay=0),this._report()}return Ul(e,[{key:"useTcpAfterJoinTimeout",get:function(){return this._useTcpAfterJoinTimeout}},{key:"useTcpJoin",get:function(){return this._joinWithTcpOnly}},{key:"useTcpJoinDelay",get:function(){return this._joinWithTcpOnlyDelay}},{key:"isBlackBrower",value:function(){var e;return gE(e=this._blackBrowserRegexList).call(e,(function(e){return new RegExp(e).test(navigator.userAgent)}))}},{key:"setServerConfig",value:function(e){var t,r,n,i,o,a,s=!1;"boolean"==typeof(null==e||null===(t=e.use_tcp_after_join_timeout)||void 0===t?void 0:t.enable)&&(this._useTcpAfterJoinTimeout=null===(i=e.use_tcp_after_join_timeout)||void 0===i?void 0:i.enable,s=!0);"boolean"==typeof(null==e||null===(r=e.join_with_tcp_only)||void 0===r?void 0:r.enable)&&(this._joinWithTcpOnly=null===(o=e.join_with_tcp_only)||void 0===o?void 0:o.enable,s=!0);"number"==typeof(null==e||null===(n=e.join_with_tcp_only)||void 0===n?void 0:n.delay_ms)&&(this._joinWithTcpOnlyDelay=null===(a=e.join_with_tcp_only)||void 0===a?void 0:a.delay_ms,s=!0);e&&Array.isArray(e.black_browser_regex_list)&&(this._blackBrowserRegexList=e.black_browser_regex_list,s=!0),s&&this._report()}},{key:"toString",value:function(){return Nm({use_tcp_after_join_timeout:this._useTcpAfterJoinTimeout,join_with_tcp_only:this._joinWithTcpOnly,join_with_tcp_only_delay:this._joinWithTcpOnlyDelay,black_browser_regex_list:this._blackBrowserRegexList})}},{key:"_report",value:function(){kD.print("_report",this.toString()),jO(this._engineId,"web_join_room_config",this.toString())}}],[{key:"setDefaulConf",value:function(t){var r=t.useTcpAfterJoinTimeout,n=t.joinWithTcpOnly,i=t.joinWithTcpOnlyDelay;return"boolean"==typeof r&&(e.DEFAULT_CONF.useTcpAfterJoinTimeout=r),"boolean"==typeof n&&(e.DEFAULT_CONF.joinWithTcpOnly=n),"number"==typeof i&&(e.DEFAULT_CONF.joinWithTcpOnlyDelay=Math.max(0,i)),e.DEFAULT_CONF}}]),e}();Jd(TD,"DEFAULT_CONF",{useTcpAfterJoinTimeout:!0,joinWithTcpOnly:!1,joinWithTcpOnlyDelay:5e3});var ID="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function RD(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://".concat(e)),"".concat(e,"/dispatch/v1/AccessInfo?Action=GetAccessInfo")}var AD="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",wD="rtc.rtcplus.com".split(","),CD={VERSION:"4.55.15",ICE_CONFIG_REQUEST_URLS_INTERNAL:jm(ID).call(ID,RD),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:AD,CONFIG_REQUEST_DOMAINS:wD,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",FORCE_ENABLED_REPORT_CALLBACKS:[],SKIP_WEB_AUDIO_IN_TRACK:!1,AUDIO_STALL:!0,VIDEO_STALL:!0,STATS_SCALLBACK_SUPPORT:!0,JOIN_ROOM_CONFIG:TD.DEFAULT_CONF,IOS_SAFARI_ORIENTATION:!1,ENABLE_REPORT_ERROR_BUFFER:!1,PUB_SUB_MODE:"recv_and_send",ENABLE_FALLBACK_HANDLER:!1,ENABLE_STANDARD_HANDLER:!1,PC_KILLSWITCH:{}};function xD(e,t){var r;if(DO("setParameter",0,Om(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("JOIN_ROOM_CONFIG"===e)return TD.setDefaulConf(t);if("ICE_CONFIG_REQUEST_URLS"===e)return"string"==typeof t&&(t=[t]),void(CD.ICE_CONFIG_REQUEST_URLS=jm(t).call(t,RD));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(CD.FORCE_ENABLED_REPORT_CALLBACKS=t);if("LOG_SERVER_URL"===e){var n=t===pl.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===pl.domestic?AD:"string"==typeof t?t:void 0;n&&(CD.LOG_SERVER_URL=n,OO(n))}else if("OVERSEA"===e)return xO({extra_is_oversea:t?"1":"0"}),void(CD.OVERSEA=t);"DEVICE_ID"===e&&ED.setDeviceId(t),"ENABLE_REPORT_ERROR_BUFFER"===e&&t&&kO.enableErrorBuffer(),CD[e]=t}else xO({product:t});else xO({platform:t})}}function OD(e){return"DEVICE_ID"===e?ED.getDeviceId():CD[e]}function MD(e,t,r){var n,i,o,a,s,c,u,d,l;return{type:"publicstream",action:t,publicStreamID:e,publicStreamMeta:{audio:{},video:{fps:(null===(n=r.video)||void 0===n?void 0:n.fps)||15,bitrate:1e3*((null===(i=r.video)||void 0===i?void 0:i.kBitRate)||40),width:(null===(o=r.video)||void 0===o?void 0:o.width)||640,height:(null===(a=r.video)||void 0===a?void 0:a.height)||360},layout:{layoutMode:2,interpolationMode:(null===(s=r.layout)||void 0===s?void 0:s.interpolationMode)||_l.PREV_FRAME,canvas:{bgColor:(null===(c=r.layout)||void 0===c?void 0:c.backgroundColor)||"#000000",bgImage:(null===(u=r.layout)||void 0===u?void 0:u.backgroundImage)||""},regions:(null===(d=r.layout)||void 0===d||null===(l=d.regions)||void 0===l?void 0:jm(l).call(l,(function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:!e.alpha||Number(e.alpha)>1||Number(e.alpha)<=0?1:Number(e.alpha),x:!e.x||Number(e.x)>=1||Number(e.x)<0?0:Number(e.x),y:!e.y||Number(e.y)>=1||Number(e.y)<0?0:Number(e.y),w:!e.w||Number(e.w)>1||Number(e.w)<=0?1:Number(e.w),h:!e.h||Number(e.h)>1||Number(e.h)<=0?1:Number(e.h),zorder:!e.zorder||Number(e.zorder)<0||Number(e.zorder)>100?0:Number(e.zorder),renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var DD={width:640,height:480,frameRate:15,maxKbps:600},PD={width:1920,height:1080,frameRate:15,maxKbps:3e3};function ND(e,t){if("boolean"!=typeof e)throw new mA(pA.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function LD(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(e<r||e>n||"number"!=typeof e){var i,o,a=new mA(pA.INVALID_PARAMS,Om(i=Om(o="Invalid ".concat(t,": the value range is [")).call(o,r,", ")).call(i,n,"]. integer only"));throw a}}function UD(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(null==e)throw new mA(pA.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!GD(e,i,o))throw new mA(pA.INVALID_PARAMS,Om(r=Om(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function VD(e,t,r){var n;if(!mk(r).call(r,e))throw new mA(pA.INVALID_PARAMS,Om(n="Invalid ".concat(t,": The value can only be set as ")).call(n,Nm(r)))}function FD(e){if(!(e instanceof MediaStreamTrack))throw new mA(pA.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function BD(e,t){if(zD(e))throw new mA(pA.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function jD(e,t){if(!(e instanceof ArrayBuffer))throw new mA(pA.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function HD(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 GD(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 zD(e){return null==e}function KD(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mA(pA.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function XD(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mA(pA.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function WD(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mA(pA.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function qD(e){BD(e,"userInfo"),XD(e.userId),zD(e.extraInfo)||UD(e.extraInfo,"userInfo.extraInfo",1,200)}function YD(e){BD(e,"roomConfig"),ND(e.isAutoPublish,"roomConfig.isAutoPublish"),ND(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),ND(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),zD(e.roomProfileType)||VD(e.roomProfileType,"roomConfig",[bl.communication,bl.chat,bl.chatRoom,bl.coHost,bl.meeting,bl.classRoom])}function JD(e){BD(e,"videoPlayerOption")}function QD(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64;if(!e||0===(null==e?void 0:e.byteLength))throw new mA(pA.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:pM.str2ab(Nm(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new mA(pA.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function ZD(e){var t,r=OD("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!mk(r).call(r,e))||!mk(t=[Nl.onRemoteStreamStats,Nl.onLocalStreamStats,Nl.onAudioVolumeIndication,Nl.onLocalAudioPropertiesReport,Nl.onRemoteAudioPropertiesReport]).call(t,e)}function $D(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new mA(pA.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function eP(e,t){if("number"!=typeof e||Number.isNaN(e)||!(e>=1)){var r=e;if(!(null!=r&&r.min||null!=r&&r.max||null!=r&&r.exact||null!=r&&r.ideal))throw new mA(pA.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function tP(e){var t,r=$T(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;LD(null==n?void 0:n.maxKbps,"maxKbps"),eP(null==n?void 0:n.width,"width"),eP(null==n?void 0:n.height,"height"),eP(null==n?void 0:n.frameRate,"frameRate")}}catch(i){r.e(i)}finally{r.f()}}function rP(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 LD(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var nP={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?km(n).call(n,1):n);return xs?Om(i).call(i,xs(e)):i},s.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a},s.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,d=this._events[s],l=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),l){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,i),!0;case 5:return d.fn.call(d.context,t,n,i,o),!0;case 6:return d.fn.call(d.context,t,n,i,o,a),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];d.fn.apply(d.context,c)}else{var h,p=d.length;for(u=0;u<p;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),l){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,n);break;case 4:d[u].fn.call(d[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];d[u].fn.apply(d[u].context,c)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var c=0,u=[],d=s.length;c<d;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(nP);var iP=nP.exports,oP=new Nw("VERTC",0),aP=function(e){DI(r,e);var t=QI(r);function r(){return Vl(this,r),t.apply(this,arguments)}return Ul(r,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var n,i,o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return(n=OI(CI(r.prototype),"emit",this)).call.apply(n,Om(i=[this,e]).call(i,a))}catch(uq){return oP.error("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,uq),console.error(uq),Boolean(t)}}}]),r}(nP.exports.EventEmitter),sP=O,cP=tr,uP=$,dP=nI,lP=Jt,hP=A,pP=mc,vP=V;Ar({target:"Reflect",stat:!0,forced:i((function(){var e=function(){},t=lP.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}))},{set:function e(t,r,n){var i,o,a,s=arguments.length<4?t:arguments[3],c=hP.f(cP(t),r);if(!c){if(uP(o=pP(t)))return e(o,r,n,s);c=vP(0)}if(dP(c)){if(!1===c.writable||!uP(s))return!1;if(i=hP.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,lP.f(s,r,i)}else lP.f(s,r,vP(0,n))}else{if(void 0===(a=c.set))return!1;sP(a,s,n)}return!0}});var fP=ee.Reflect.set,_P=hi.f("asyncIterator");function mP(e){var t,r,n,i=2;for(void 0!==wd&&(r=_P,n=Xd);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new yP(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function yP(e){function t(e){if(Object(e)!==e)return Y_.reject(new TypeError(e+" is not an object."));var t=e.done;return Y_.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(yP=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Y_.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Y_.reject(e):t(r.apply(this.s,arguments))}},new yP(e)}var gP=[{maxLayers:3,totalPixels:2073600},{maxLayers:3,totalPixels:921600},{maxLayers:3,totalPixels:518400},{maxLayers:2,totalPixels:230400},{maxLayers:2,totalPixels:129600},{maxLayers:1,totalPixels:57600},{maxLayers:1,totalPixels:0}];Yy("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hg);var SP=ee.Set;Ar({target:"Set",stat:!0,forced:!0},{from:bg}),Ar({target:"Set",stat:!0,forced:!0},{of:kg});var bP=O,EP=Ce,kP=tr,TP=function(){for(var e=kP(this),t=EP(e.add),r=0,n=arguments.length;r<n;r++)bP(t,e,arguments[r]);return e};Ar({target:"Set",proto:!0,real:!0,forced:!0},{addAll:TP}),Ar({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:Ag});var IP=gh,RP=tr,AP=Yt,wP=IP,CP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=RP(this),r=wP(t),n=AP(e,arguments.length>1?arguments[1]:void 0);return!CP(r,(function(e,r){if(!n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var xP=oe,OP=O,MP=Ce,DP=tr,PP=Rp,NP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){var t=DP(this),r=new(PP(t,xP("Set")))(t),n=MP(r.delete);return NP(e,(function(e){OP(n,r,e)})),r}});var LP=oe,UP=O,VP=Ce,FP=tr,BP=Yt,jP=Rp,HP=IP,GP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=FP(this),r=HP(t),n=BP(e,arguments.length>1?arguments[1]:void 0),i=new(jP(t,LP("Set"))),o=VP(i.add);return GP(r,(function(e){n(e,e,t)&&UP(o,i,e)}),{IS_ITERATOR:!0}),i}});var zP=tr,KP=Yt,XP=IP,WP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=zP(this),r=XP(t),n=KP(e,arguments.length>1?arguments[1]:void 0);return WP(r,(function(e,r){if(n(e,e,t))return r(e)}),{IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var qP=oe,YP=O,JP=Ce,QP=tr,ZP=Rp,$P=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){var t=QP(this),r=new(ZP(t,qP("Set"))),n=JP(t.has),i=JP(r.add);return $P(e,(function(e){YP(n,t,e)&&YP(i,r,e)})),r}});var eN=O,tN=Ce,rN=tr,nN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){var t=rN(this),r=tN(t.has);return!nN(e,(function(e,n){if(!0===eN(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var iN=oe,oN=O,aN=Ce,sN=R,cN=tr,uN=gh,dN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){var t=uN(this),r=cN(e),n=r.has;return sN(n)||(r=new(iN("Set"))(e),n=aN(r.has)),!dN(t,(function(e,t){if(!1===oN(n,r,e))return t()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var lN=O,hN=Ce,pN=tr,vN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){var t=pN(this),r=hN(t.has);return!vN(e,(function(e,n){if(!1===lN(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var fN=Ar,_N=tr,mN=yn,yN=IP,gN=Uh,SN=E([].join),bN=[].push;fN({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=_N(this),r=yN(t),n=void 0===e?",":mN(e),i=[];return gN(r,bN,{that:i,IS_ITERATOR:!0}),SN(i,n)}});var EN=oe,kN=Yt,TN=O,IN=Ce,RN=tr,AN=Rp,wN=IP,CN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=RN(this),r=wN(t),n=kN(e,arguments.length>1?arguments[1]:void 0),i=new(AN(t,EN("Set"))),o=IN(i.add);return CN(r,(function(e){TN(o,i,n(e,e,t))}),{IS_ITERATOR:!0}),i}});var xN=Ce,ON=tr,MN=IP,DN=Uh,PN=TypeError;Ar({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=ON(this),r=MN(t),n=arguments.length<2,i=n?void 0:arguments[1];if(xN(e),DN(r,(function(r){n?(n=!1,i=r):i=e(i,r,r,t)}),{IS_ITERATOR:!0}),n)throw PN("Reduce of empty set with no initial value");return i}});var NN=tr,LN=Yt,UN=IP,VN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=NN(this),r=UN(t),n=LN(e,arguments.length>1?arguments[1]:void 0);return VN(r,(function(e,r){if(n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var FN=oe,BN=O,jN=Ce,HN=tr,GN=Rp,zN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){var t=HN(this),r=new(GN(t,FN("Set")))(t),n=jN(r.delete),i=jN(r.add);return zN(e,(function(e){BN(n,r,e)||BN(i,r,e)})),r}});var KN=oe,XN=Ce,WN=tr,qN=Rp,YN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){var t=WN(this),r=new(qN(t,KN("Set")))(t);return YN(e,XN(r.add),{that:r}),r}});var JN=SP,QN=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!jM()&&window.RTCPeerConnection&&window.RTCPeerConnection.prototype.addTransceiver&&window.RTCPeerConnection.prototype.createDataChannel){e.next=3;break}return e.abrupt("return",!1);case 3:return e.next=5,cL();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,sL();case 9:e.t0=e.sent;case 10:return e.abrupt("return",e.t0);case 13:return e.prev=13,e.t1=e.catch(0),e.abrupt("return",!1);case 16:case"end":return e.stop()}}),e,null,[[0,13]])})));return function(){return e.apply(this,arguments)}}(),ZN=function(){var e=Rm(Tm().mark((function e(t){var r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t||"recv_and_send",n=[],e.next=4,cL();case 4:return i=e.sent,e.next=7,sL();case 7:return o=e.sent,e.next=10,dL();case 10:return a=e.sent,e.next=13,uL();case 13:return s=e.sent,"send_only"===r&&(o&&n.push("H264"),s&&n.push("vp8")),"recv_only"===r&&(i&&n.push("H264"),a&&n.push("vp8")),"recv_and_send"===r&&(o&&i&&n.push("H264"),s&&a&&n.push("vp8")),e.abrupt("return",n);case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),$N=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Nm(rL));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),eL=function(){var e=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ZN();case 2:return t=e.sent,e.abrupt("return",jm(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),tL={},rL={};function nL(e){var t,r=!1,n=$T(e.split("\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value;if(mk(i).call(i,"level-asymmetry-allowed=1")&&mk(i).call(i,"packetization-mode=1")&&mk(i).call(i,"profile-level-id=42e0")){r=!0;break}}}catch(d){n.e(d)}finally{n.f()}if(r){for(var o=navigator.userAgent.toLowerCase(),a=!1,s=0,c=["miuibrowser"];s<c.length;s++){var u=c[s];mk(o).call(o,u)&&(a=!0)}return!a}return!1}var iL=function(){var e=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("video",{direction:t}),e.next=4,r.createOffer();case 4:return n=e.sent,r.close(),e.abrupt("return",n.sdp.toLowerCase());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),oL=function(){var e=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,iL("sendonly");case 2:if(r=e.sent,!mk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,iL("sendonly");case 6:r=e.sent;case 7:return tL.h264encode=nL(r),rL.h264encode=r,tL.vp8encode=xE(r).call(r,"vp8")>-1,rL.vp8encode="same as h264encode",e.abrupt("return",tL);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),aL=function(){var e=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,iL("recvonly");case 2:if(r=e.sent,!mk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,iL("recvonly");case 6:r=e.sent;case 7:return tL.h264decode=nL(r),rL.h264decode=r,tL.vp8decode=xE(r).call(r,"vp8")>-1,rL.vp8decode="same as h264decode",e.abrupt("return",tL);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),sL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==tL.h264encode){e.next=10;break}return e.prev=1,e.next=4,oL();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),rL.h264encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",tL.h264encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),cL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==tL.h264decode){e.next=10;break}return e.prev=1,e.next=4,aL();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),rL.h264decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",tL.h264decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),uL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==tL.vp8encode){e.next=10;break}return e.prev=1,e.next=4,oL();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),rL.vp8encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",tL.vp8encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),dL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==tL.vp8decode){e.next=10;break}return e.prev=1,e.next=4,aL();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),rL.vp8decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",tL.vp8decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),lL=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},hL=function(){return $M?XM&&pD>=70||zM&&uD>=80||KM&&cD>=14:iD?XM&&pD>=70||zM&&uD>=80:rD?dD[0]>=14:!!nD&&(XM&&pD>=86)},pL=XM&&pD<=114,vL=!zM||uD>=96,fL=!(KM&&cD<=14);nD&&XM||rD&&(17===dD[0]||dD[0]);var _L=new $S,mL=function(){var e=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Y_((function(e,r){var n=OD("STATS_SCALLBACK_SUPPORT");if(XM&&void 0===window.InstallTrigger&&pL&&n)try{t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!mk(bL).call(bL,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(Zd(Zd({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return Hs(r).call(r,(function(t){return"ssrc"!==t.type||t.googTrackId===e}))}})}))}catch(uq){r(uq)}else e({all:[],getTrackStats:function(){return[]}})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),yL=function(){var e=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getStats();case 2:return n=e.sent,i={all:[]},o=new $S,n.forEach((function(e){var t=o.get(e.type)||new $S;t.set(e.id,e),o.set(e.type,t),i.all.push(e)})),a=function(e,t){e.forEach((function(e){var r,n,i,a,s,c,u=e.codecId,d=e.transportId,l=e.trackId,h=e.playoutId;if(null===(r=o.get(SL.codec))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=o.get(SL.transport))||void 0===n||n.forEach((function(e){e.id===d&&(s=e,t.add(e))})),null===(i=o.get(SL.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(a=o.get(SL.mediaPlayout))||void 0===a||a.forEach((function(e){e.id===h&&t.add(e)})),s){var p,v,f=s,_=f.localCertificateId,m=f.remoteCertificateId,y=f.selectedCandidatePairId;null===(p=o.get(SL.certificate))||void 0===p||p.forEach((function(e){(e.id===_||e.id===m)&&t.add(e)})),null===(v=o.get(SL.candidatePair))||void 0===v||v.forEach((function(e){e.id===y&&(c=e,t.add(e))}))}if(c){var g,S,b=c,E=b.localCandidateId,k=b.remoteCandidateId;null===(g=o.get(SL.localCandidate))||void 0===g||g.forEach((function(e){e.id===E&&t.add(e)})),null===(S=o.get(SL.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===k&&t.add(e)}))}}))},o.get(SL.mediaSource)?null===(s=o.get(SL.mediaSource))||void 0===s||s.forEach((function(e){var t,r=new JN;r.add(e);var n=[];null===(t=o.get(SL.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=o.get(SL.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=qk(r)})):o.get(SL.track)&&(null===(c=o.get(SL.track))||void 0===c||c.forEach((function(e){var t,r=new JN;r.add(e);var n=[];null===(t=o.get(SL.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.trackId===e.id&&(r.add(t),n.push(t),null===(i=o.get(SL.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=qk(r)}))),null===(r=o.get(SL.inboundRtp))||void 0===r||r.forEach((function(e){var t,r=new JN;r.add(e),null===(t=o.get(SL.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),a([e],r);var n,s=e.trackIdentifier;s||(null===(n=o.get(SL.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(s=t.trackIdentifier)})));i[s]=qk(r)})),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),gL=function(){var e=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!zM&&!KM){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=_L.get(t))||Date.now()-a.timestamp>150)&&(a={timestamp:Date.now(),statsPromise:yL(t),extraStatsPromise:mL(t)},_L.set(t,a)),e.next=14,a.statsPromise;case 14:if(s=e.sent,c=(i?s[i]:s.all)||[],n){e.next=21;break}return e.next=19,a.extraStatsPromise;case 19:u=e.sent,c=Om(c).call(c,(i?u.getTrackStats(i):u.all)||[]);case 21:return e.abrupt("return",c);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),SL=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}(SL||{}),bL=["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"],EL={},kL={},TL={exports:{}},IL=TL.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(IL).forEach((function(e){IL[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=TL.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t,o={},a=[],s=o;return Hs(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=km(e).call(e,2);"m"===t&&(a.push({rtp:[],fmtp:[]}),s=a[a.length-1]);for(var o=0;o<(n[t]||[]).length;o+=1){var c=n[t][o];if(c.reg.test(i))return r(c,s,i)}})),o.media=a,o};var o=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){var t;return pb(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return jm(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=jm(r=e.split(" ")).call(r,t),o=0;o<i.length;o+=3)n.push({component:i[o],ip:i[o+1],port:i[o+2]});return n},e.parseImageAttributes=function(e){var t;return jm(t=e.split(" ")).call(t,(function(e){var t;return pb(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return jm(r=e.split(";")).call(r,(function(e){var r;return jm(r=e.split(",")).call(r,(function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(kL);var RL=TL.exports,AL=/%[sdv%]/g,wL=function(e){var t=1,r=arguments,n=r.length;return e.replace(AL,(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""}}))},CL=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 wL.apply(null,n)},xL=["v","o","s","i","u","e","p","c","b","t","r","z","a"],OL=["i","c","b","a"],ML=kL,DL=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||xL,n=t.innerOrder||OL,i=[];return r.forEach((function(t){RL[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(CL(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(CL(t,r,e))}))}))})),e.media.forEach((function(e){i.push(CL("m",RL.m[0],e)),n.forEach((function(t){RL[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(CL(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(CL(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};EL.write=DL,EL.parse=ML.parse,EL.parseParams=ML.parseParams,EL.parseFmtpConfig=ML.parseFmtpConfig,EL.parsePayloads=ML.parsePayloads,EL.parseRemoteCandidates=ML.parseRemoteCandidates,EL.parseImageAttributes=ML.parseImageAttributes,EL.parseSimulcastStreamList=ML.parseSimulcastStreamList;var PL=Xe,NL=Nr,LL=Br,UL=function(e){for(var t=PL(this),r=LL(t),n=arguments.length,i=NL(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:NL(o,r);a>i;)t[i++]=e;return t};Ar({target:"Array",proto:!0},{fill:UL});var VL=Us("Array").fill,FL=ae,BL=VL,jL=Array.prototype,HL=function(e){var t=e.fill;return e===jL||FL(jL,e)&&t===jL.fill?BL:t},GL=new Nw("FirefoxHandler",3),zL=Math.pow(2,32),KL="kp34Za0H+aVf862l",XL="o/i14u9pJrxRKAsu";function WL(e){return e>zL-18?(GL.warn("generateAllSsrc","reset start id",e),WL(e=e-zL+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var qL=function(e,t,r){var n,i,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:XL;return[{id:r,attribute:"cname",value:a},{id:r,attribute:"msid",value:Om(n=Om(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Om(o="".concat(e,"-")).call(o,t)}]},YL=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.video,o=t.videoRtx,a=t.videoFec,s=[i,o],c=n.cname,u=n.flexfec;u&&s.push(a);var d,l=pb(s).call(s,(function(t,r){return Om(t).call(t,qL(e,"video",r,c))}),[]),h=[{semantics:"FID",ssrcs:Om(r="".concat(i," ")).call(r,o)}];u&&h.push({semantics:"FEC-FR",ssrcs:Om(d="".concat(i," ")).call(d,a)});return{ssrcs:l,ssrcGroups:h}};function JL(e){return e.direction="inactive",e.port=0,delete e.ext,delete e.ssrcs,delete e.ssrcGroups,delete e.simulcast,delete e.simulcast_03,delete e.rids,delete e.extmapAllowMixed,delete e.msid,delete e.bundleOnly,e}var QL=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=Zd(Zd({},e),{},{media:[]});return n&&(i.invalid=[{value:"realx-exts:rscp"}]),t&&i.media.push(t),r&&i.media.push(r),delete i.groups,delete i.msidSemantic,EL.write(i)};function ZL(e){return $L.apply(this,arguments)}function $L(){return($L=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},n=t.publicIPs,i=t.certFingerprint,o=t.iceParams,a=t.iceConfig,r.fingerprint={type:"sha-256",hash:i},r.icePwd=o.serverIcePwd,e.next=6,tU(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=eU(n,a),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function eU(e,t){if(!Array.isArray(e))return[];var r=0,n=2130706431,i=[];return e.forEach((function(e){var o={component:1,ip:e.ip,type:"host",generation:e.generation};e.udpPorts&&!t.tcpOnly&&e.udpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var tU=function(){var e=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new TextEncoder,n=r.encode("PREC"),e.t0=Uint8Array,e.next=5,pM.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=hM(Uint8Array,n,i,o,a),e.next=15,pM.ab2b64str(s.buffer);case 15:return c=e.sent,e.abrupt("return",c);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),rU=function(e){return e[e.kICEConfigTypeSrtpDtlsType=0]="kICEConfigTypeSrtpDtlsType",e[e.kICEConfigTypeRenominationType=1]="kICEConfigTypeRenominationType",e[e.kICEConfigTypeTcpType=2]="kICEConfigTypeTcpType",e[e.kICEConfigTypeMultiSendType=3]="kICEConfigTypeMultiSendType",e[e.kICEConfigTypeKcpType=4]="kICEConfigTypeKcpType",e[e.kICEConfigTypeSrtpSdesType=5]="kICEConfigTypeSrtpSdesType",e}(rU||{});function nU(e){var t,r=e.random,n=e.serverUfrag,i=e.serverPwd,o=e.clientPwd,a=e.options,s=(new TextEncoder).encode("WPRE");r||(r=new Uint8Array(4),crypto.getRandomValues(r));var c=UM(n);c.byteLength;var u=FM(UM(o),UM(i).subarray(0,16),UM(n).subarray(0,16));u.byteLength;var d=new Uint8Array(pb(t=an(a)).call(t,(function(e,t){var r=Number(t);return e.push(r),e.push(a[r]?1:0),e}),[]));d.byteLength;var l,h=hM(Uint8Array,s,r,[c.byteLength],c,[u.byteLength],u,d);h.byteLength%3!=0&&(h=hM(Uint8Array,h,HL(l=new Uint8Array(3-h.byteLength%3)).call(l,255)));return[VM(h),VM(hM(Uint8Array,r,c.subarray(0,20)))]}var iU=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=$T(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(mk(o=c.config).call(o,"level-asymmetry-allowed=1")&&mk(a=c.config).call(a,"packetization-mode=1")&&mk(s=c.config).call(s,"profile-level-id=42e0")){r=c.payload;break}}}catch(v){i.e(v)}finally{i.f()}for(var u=0;u<e.rtp.length;u++){var d=e.rtp[u];if("H264"===t){if(d.payload===r){var l;e.rtp.unshift(rk(l=e.rtp).call(l,u,1)[0]);break}}else if(d.codec===t){var h;e.rtp.unshift(rk(h=e.rtp).call(h,u,1)[0]);break}}var p=[];e.rtp.forEach((function(e){return p.push(e.payload)})),e.payloads=p.join(" ")}},oU=new Nw("BasicHandler",3),aU=function(e){DI(n,e);var t,r=QI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this)),"_peerConnection",void 0),Jd(tI(i),"_dataChannel",void 0),Jd(tI(i),"_context",void 0),Jd(tI(i),"peerConnectionMode",0),Jd(tI(i),"peerConnectionId",""),Jd(tI(i),"id",void 0),Jd(tI(i),"_monitor",void 0),Jd(tI(i),"_nextSsrc",Math.floor(Math.random()*zL+1e4)),Jd(tI(i),"_aSendonlyAnswerTpl",void 0),Jd(tI(i),"_vSendonlyAnswerTpl",void 0),Jd(tI(i),"_enableSubFlexfec",!1),Jd(tI(i),"audioTrack4ff",void 0),Jd(tI(i),"setLocalDescription",void 0),Jd(tI(i),"setRemoteDescription",void 0),i.peer=t,i.id=e.id,i._monitor=VO(i.id),i._peerConnection=t.getOriginRTCPeerConnection(),i._dataChannel=t.getOriginRTCDataChannel(),i.setLocalDescription=t.setLocalDescription.bind(t),i.setRemoteDescription=t.setRemoteDescription.bind(t),i._context=e,i.peer.on("ontrack",(function(e){i.emit("ontrack",e)})),i}return Ul(n,[{key:"destroy",value:function(){oU.info("destroy",this.peerConnectionId||""),OI(CI(n.prototype),"removeAllListeners",this).call(this)}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"getConnectionState",value:function(){return this._peerConnection.connectionState}},{key:"_simulcast",value:function(e,t,r,n,i){var o,a,s,c=[];1===e.videoEncodeConfig.length?(c=function(e,t){var r=[];if(t<=1)return r;var n=Math.min(e.width,e.height)/90;return r.push({scaleResolutionDownBy:n,width:Math.floor(e.width/n),height:Math.floor(e.height/n),maxkbps:100,frameRate:10}),t<=2||r.unshift({scaleResolutionDownBy:2,width:Math.floor(e.width/2),height:Math.floor(e.height/2),maxkbps:Math.floor(e.maxKbps/2),frameRate:e.frameRate>=30?Math.floor(e.frameRate/2):e.frameRate}),r}(t,i),oU.info("simulcast() ","simulcastLayers: %o",c)):(c=jm(o=km(a=km(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){var r=LM(e.width),n=t.width/r;return{width:r,height:Math.floor(t.height/n),scaleResolutionDownBy:n,frameRate:LM(e.frameRate)||15,maxkbps:e.maxKbps||600}})),oU.info("simulcast() ","simulcastLayers2: %o",c));var u=[!0];c.forEach((function(e,t){var i,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:e.scaleResolutionDownBy,rid:"".concat(t+1),maxFramerate:e.frameRate};null===(i=r.sendEncodings)||void 0===i||i.unshift(o),n.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)}),u.push(!0)})),this._context&&(this._context.activeSimStreams=u)}},{key:"internalPublish",value:function(e){var t=e.stream,r=e.videoTrack,n=e.audioTrack,i=e.enableSimulcast,o=e.pubAudio,a=e.pubVideo,s={direction:"sendonly",streams:[t]},c={direction:"sendonly",streams:[t]},u=[],d=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var l=null==r?void 0:r.getTrack(),h=Zd({},DD);if(l){var p=null==l?void 0:l.getSettings();h={width:Math.floor(p.width),height:Math.floor(p.height),frameRate:Math.floor(p.frameRate)}}"number"!=typeof h.frameRate&&(h.frameRate=30);var v=null==e?void 0:e.videoEncodeConfig[0],f={maxBitrate:1e3*v.maxKbps,rid:"0"};if(e.prevBitrate=v.maxKbps,c.sendEncodings=[f],u.push({width:h.width,height:h.height,framerate:h.frameRate,maxkbps:v.maxKbps,rid:"0"}),!zM&&i){var _,m,y=function(e){for(var t=0,r=e.width*e.height,n=0;n<gP.length;n++)if(r>=gP[n].totalPixels){t=n;break}if(0===t)return gP[t].maxLayers;var i=gP[t-1].totalPixels;return(i-r)/(i-gP[t].totalPixels)<.1?gP[t-1].maxLayers:gP[t].maxLayers}(h);if(oU.info("simulcast() ","maxLayers: %o",y),y>1)this._simulcast(e,Zd(Zd({},h),{},{maxKbps:v.maxKbps}),c,u,y),null!==(_=this._context)&&void 0!==_&&null!==(m=_.serverConfig)&&void 0!==m&&m.simulcastOnDemand&&(d=jm(u).call(u,(function(e,t){return Zd(Zd({},e),{},{video_index:t,sub_index:t})})))}}oU.info("publish videoTransceiverInit videoDescriptions","",c,u);var g=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==Ml.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(g=null==n?void 0:n.mixedAudioTrack),g=o&&g?g:"audio";var S=null==r?void 0:r.getTrack("preprocessing");S=a&&S?S:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",Nm({aTrack:MM(g),vTrack:MM(S),audioTransceiverInit:s,videoTransceiverInit:c}))}catch(uq){}return{semantics:"unified-plan",videoDescriptions:u,subVideoDescriptions:d,audioTransceiverInit:{track:g,init:s},videoTransceiverInit:{track:S,init:c}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;oU.info("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.getTrack(),a=e.videoTransceiver;if(o&&e.pubVideo&&a){var s=null===(r=e.videoEncodeConfig)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.maxKbps;if(s){if(s===e.prevBitrate)return void oU.warn("updateMaxBitrate()","no change");e.prevBitrate=s}var c=null===(i=a.sender)||void 0===i?void 0:i.getParameters();if(c){var u;c.encodings=null==c||null===(u=c.encodings)||void 0===u?void 0:jm(u).call(u,(function(t){var r,n=Number(t.rid)||0,i=null===(r=e.videoEncodeConfig[n])||void 0===r?void 0:r.maxKbps;return"number"==typeof i&&(t.maxBitrate=1e3*i),t})),null==a||a.sender.setParameters(c);try{this._reportRtcInvokeStatus("Handler.updateScaleResolutionDownBy",Nm(c.encodings))}catch(uq){}}}else oU.warn("updateMaxBitrate()","no pub")}},{key:"getStats",value:function(e,t){return gL(this._peerConnection,e,t)}},{key:"setCurrentDescription",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineAnswerTpl",value:function(e){var t=this;EL.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:gE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:gE(i=e.fmtp).call(i,(function(e){return e.payload===n.payload}));o&&t._context&&(o.config+=";stereo=1;sprop-stereo=1")}t._aSendonlyAnswerTpl=e}}else"video"===e.type&&("sendonly"===e.direction&&(t._vSendonlyAnswerTpl=e),Array.isArray(e.rtp)&&e.rtp.forEach((function(e){var r;null!==(r=e.codec)&&void 0!==r&&mk(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))}))}},{key:"pc",get:function(){return this._peerConnection}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n,i=r.codec,o=r.payload;if(mk(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=gE(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=Om(s=[]).call(s,Jk(c.config.split(";")),["x-google-min-bitrate=100","x-google-start-bitrate=".concat(t)]).join(";");else e.fmtp.push({payload:o,config:"x-google-min-bitrate=100;x-google-start-bitrate=".concat(t)})}}))}},{key:"_report",value:function(e,t,r){var n;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this.peer.getConnectionId(),group_connection_id:this.peer.getGroupConnectionId()}),r)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}]),n}(nP.exports.EventEmitter),sU=E,cU=Qy,uU=dy.exports.getWeakData,dU=mp,lU=tr,hU=z,pU=$,vU=Uh,fU=Ye,_U=Zi.set,mU=Zi.getterFor,yU=Po.find,gU=Po.findIndex,SU=sU([].splice),bU=0,EU=function(e){return e.frozen||(e.frozen=new kU)},kU=function(){this.entries=[]},TU=function(e,t){return yU(e.entries,(function(e){return e[0]===t}))};kU.prototype={get:function(e){var t=TU(this,e);if(t)return t[1]},has:function(e){return!!TU(this,e)},set:function(e,t){var r=TU(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=gU(this.entries,(function(t){return t[0]===e}));return~t&&SU(this.entries,t,1),!!~t}};var IU,RU={getConstructor:function(e,t,r,n){var i=e((function(e,i){dU(e,o),_U(e,{type:t,id:bU++,frozen:void 0}),hU(i)||vU(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=mU(t),s=function(e,t,r){var n=a(e),i=uU(lU(t),!0);return!0===i?EU(n).set(t,r):i[n.id]=r,e};return cU(o,{delete:function(e){var t=a(this);if(!pU(e))return!1;var r=uU(e);return!0===r?EU(t).delete(e):r&&fU(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!pU(e))return!1;var r=uU(e);return!0===r?EU(t).has(e):r&&fU(r,t.id)}}),cU(o,r?{get:function(e){var t=a(this);if(pU(e)){var r=uU(e);return!0===r?EU(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}},AU=n,wU=E,CU=Qy,xU=dy.exports,OU=Yy,MU=RU,DU=$,PU=my,NU=Zi.enforce,LU=Vi,UU=!AU.ActiveXObject&&"ActiveXObject"in AU,VU=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},FU=OU("WeakMap",VU,MU);if(LU&&UU){IU=MU.getConstructor(VU,"WeakMap",!0),xU.enable();var BU=FU.prototype,jU=wU(BU.delete),HU=wU(BU.has),GU=wU(BU.get),zU=wU(BU.set);CU(BU,{delete:function(e){if(DU(e)&&!PU(e)){var t=NU(this);return t.frozen||(t.frozen=new IU),jU(this,e)||t.frozen.delete(e)}return jU(this,e)},has:function(e){if(DU(e)&&!PU(e)){var t=NU(this);return t.frozen||(t.frozen=new IU),HU(this,e)||t.frozen.has(e)}return HU(this,e)},get:function(e){if(DU(e)&&!PU(e)){var t=NU(this);return t.frozen||(t.frozen=new IU),HU(this,e)?GU(this,e):t.frozen.get(e)}return GU(this,e)},set:function(e,t){if(DU(e)&&!PU(e)){var r=NU(this);r.frozen||(r.frozen=new IU),HU(this,e)?zU(this,e,t):r.frozen.set(e,t)}else zU(this,e,t);return this}})}var KU=ee.WeakMap;Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{emplace:Og}),Ar({target:"WeakMap",stat:!0,forced:!0},{from:bg}),Ar({target:"WeakMap",stat:!0,forced:!0},{of:kg}),Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{deleteAll:Ag}),Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{upsert:ZS});var XU=KU,WU=function(e){DI(p,e);var t,r,n,i,o,a,s,c,u,d,l,h=QI(p);function p(){var e,t,r;return Vl(this,p),Jd(tI(r=h.call(this)),"inited",!1),Jd(tI(r),"deviceMap",{audioinput:new $S,audiooutput:new $S,videoinput:new $S}),Jd(tI(r),"checkDeviceChangeTimer",null),Jd(tI(r),"isSupportedPermissionsQuery",!1),Jd(tI(r),"isGrantedMicrophonePermission",!1),Jd(tI(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!jM()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(tI(r)),!jM()&&r.refreshDevices(),r}return Ul(p,[{key:"refreshDevices",value:(l=Rm(Tm().mark((function e(){var t,r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices){e.next=2;break}return e.abrupt("return");case 2:if(t=void 0,!zM){e.next=12;break}return e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:!0});case 7:t=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:return e.next=14,navigator.mediaDevices.enumerateDevices();case 14:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),r.forEach((function(e){var t;e.deviceId&&(null===(t=n.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))})),this.inited||this.initListener(),this.inited=!0;case 19:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return l.apply(this,arguments)})},{key:"initListener",value:(d=Rm(Tm().mark((function e(){var t,r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.ondevicechange)&&"function"==typeof(null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)?navigator.mediaDevices.addEventListener("devicechange",(function(){o._handleDeviceChange(),setTimeout((function(){o._handleDeviceChange()}),300)})):this.checkDeviceChangeTimer=window.setInterval((function(){o._handleDeviceChange()}),3e3),!this.isSupportedPermissionsQuery){e.next=22;break}return e.prev=2,e.next=5,navigator.permissions.query({name:"microphone"});case 5:n=e.sent,this.isGrantedMicrophonePermission="granted"===n.state,n.addEventListener("change",(function(){o.isGrantedMicrophonePermission="granted"===n.state})),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.prev=12,e.next=15,navigator.permissions.query({name:"camera"});case 15:i=e.sent,this.isGrantedCameraPermission="granted"===i.state,i.addEventListener("change",(function(){o.isGrantedCameraPermission="granted"===i.state})),e.next=22;break;case 20:e.prev=20,e.t1=e.catch(12);case 22:case"end":return e.stop()}}),e,this,[[2,10],[12,20]])}))),function(){return d.apply(this,arguments)})},{key:"_handleDeviceChange",value:(u=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=void 0,!zM){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=Hs(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=qk(Om(t=[]).call(t,Jk(oR(r=this.deviceMap.audioinput).call(r)),Jk(oR(n=this.deviceMap.videoinput).call(n)),Jk(oR(i=this.deviceMap.audiooutput).call(i)))),(tD||ZM)&&!s.length&&a.length&&a.forEach((function(e){var t;null===(t=c.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e)})),a.forEach((function(e){var t,r,n=c.deviceMap[e.kind].get(e.deviceId);c.deviceMap[e.kind].set(e.deviceId,e),n||(mk(t=e.kind).call(t,"video")?c.emit(Nl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):mk(r=e.kind).call(r,"audio")&&c.emit(Nl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;gE(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),mk(t=e.kind).call(t,"video")?c.emit(Nl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):mk(r=e.kind).call(r,"audio")&&c.emit(Nl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 14:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getUserMedia",value:(c=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia(t);case 2:return r=e.sent,null!=t&&t.audio&&(this.isGrantedMicrophonePermission=!0),null!=t&&t.video&&(this.isGrantedCameraPermission=!0),this.refreshDevices(),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(s=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={audio:!1,video:!1},navigator.mediaDevices){e.next=3;break}return e.abrupt("return",t);case 3:return e.next=5,navigator.mediaDevices.enumerateDevices();case 5:return r=e.sent,t.audio=Hs(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=Hs(r).call(r,(function(e){return"videoinput"===e.kind&&e.label&&e.deviceId})).length>0,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"getPermissions",value:(a=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=l.length>0&&void 0!==l[0]?l[0]:{},n=r.audio,i=r.video,o=r.force,n||i||(n=!0,i=!0),a={audio:!1,video:!1,reason:void 0},o){e.next=30;break}if(!this.isSupportedPermissionsQuery){e.next=20;break}if(!n||!i){e.next=14;break}if(!this.isGrantedMicrophonePermission||!this.isGrantedCameraPermission){e.next=12;break}return a.audio=!0,a.video=!0,e.abrupt("return",a);case 12:e.next=18;break;case 14:if(!(n&&this.isGrantedMicrophonePermission||i&&this.isGrantedCameraPermission)){e.next=18;break}return a.audio=this.isGrantedMicrophonePermission,a.video=this.isGrantedCameraPermission,e.abrupt("return",a);case 18:e.next=30;break;case 20:return e.next=22,this.checkPermissionsByDevices();case 22:if(s=e.sent,!n||!i){e.next=28;break}if(!s.audio||!s.video){e.next=26;break}return e.abrupt("return",s);case 26:e.next=30;break;case 28:if(!(n&&s.audio||i&&s.video)){e.next=30;break}return e.abrupt("return",s);case 30:if(null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=70;break}return e.prev=31,e.next=34,navigator.mediaDevices.getUserMedia({audio:n,video:i});case 34:(c=e.sent)&&(c.getTracks().forEach((function(e){return e.stop()})),n&&(a.audio=!0,this.isGrantedMicrophonePermission=!0),i&&(a.video=!0,this.isGrantedCameraPermission=!0)),e.next=70;break;case 38:if(e.prev=38,e.t0=e.catch(31),a.reason=e.t0,!this.isSupportedPermissionsQuery){e.next=70;break}if(!n){e.next=56;break}return e.next=45,navigator.permissions.query({name:"microphone"}).catch((function(){}));case 45:if(e.t2=u=e.sent,e.t1=null===e.t2,e.t1){e.next=49;break}e.t1=void 0===u;case 49:if(!e.t1){e.next=53;break}e.t3=void 0,e.next=54;break;case 53:e.t3=u.state;case 54:e.t4=e.t3,a.audio="granted"===e.t4;case 56:if(!i){e.next=70;break}return e.next=59,navigator.permissions.query({name:"camera"}).catch((function(){}));case 59:if(e.t6=d=e.sent,e.t5=null===e.t6,e.t5){e.next=63;break}e.t5=void 0===d;case 63:if(!e.t5){e.next=67;break}e.t7=void 0,e.next=68;break;case 67:e.t7=d.state;case 68:e.t8=e.t7,a.video="granted"===e.t8;case 70:return e.next=72,this.refreshDevices();case 72:return e.abrupt("return",a);case 73:case"end":return e.stop()}}),e,this,[[31,38]])}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions();case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(Om(t=[]).call(t,Jk(oR(r=this.deviceMap.audioinput).call(r)),Jk(oR(n=this.deviceMap.videoinput).call(n)),Jk(oR(i=this.deviceMap.audiooutput).call(i)))));case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"enumerateAudioCaptureDevices",value:(i=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(oR(t=this.deviceMap.audioinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"enumerateVideoCaptureDevices",value:(n=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({video:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(oR(t=this.deviceMap.videoinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"enumerateAudioPlaybackDevices",value:(r=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(oR(t=this.deviceMap.audiooutput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getDeviceById",value:(t=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateDevices();case 2:return r=e.sent,e.abrupt("return",gE(r).call(r,(function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),p}(aP),qU=new WU;!jM()&&(window.__rtc_dd__=qU);var YU=new Nw("InternalEventBus",1),JU=function(e){return e.ON_IOS_INTERRUPTION_START="ON_IOS_INTERRUPTION_START",e.ON_IOS_INTERRUPTION_END="ON_IOS_INTERRUPTION_END",e.ON_IOS_LOCAL_TRACK_MUTE="ON_IOS_LOCAL_TRACK_MUTE",e.ON_IOS_LOCAL_TRACK_UNMUTE="ON_IOS_LOCAL_TRACK_UNMUTE",e}(JU||{}),QU=function(e){DI(r,e);var t=QI(r);function r(){return Vl(this,r),t.apply(this,arguments)}return Ul(r,[{key:"emit",value:function(e){var t,n;YU.info(e);for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return(t=OI(CI(r.prototype),"emit",this)).call.apply(t,Om(n=[this,e]).call(n,o))}}]),r}(nP.exports.EventEmitter),ZU=new QU,$U=new Nw("AudioContext",1),eV=function(){function e(){var t=this;Vl(this,e),Jd(this,"_audioContextInstance",void 0),Jd(this,"_previousState",""),Jd(this,"_currentState",""),Jd(this,"_contextStuckAt",0);var r=0;jM()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,$U.info("currentTime resume"),LO("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,$U.warn("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),LO("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return Ul(e,[{key:"getAudioContextInstance",value:function(){var e=this;if(!this._audioContextInstance){var t=window.AudioContext||window.webkitAudioContext;this._audioContextInstance=new t,this._audioContextInstance.onstatechange=function(){var t,r,n;$U.warn("state change",null===(t=e._audioContextInstance)||void 0===t?void 0:t.state),e._previousState=e._currentState,e._currentState=(null===(r=e._audioContextInstance)||void 0===r?void 0:r.state)||"","interrupted"===(null===(n=e._audioContextInstance)||void 0===n?void 0:n.state)&&e._audioContextInstance.resume(),(rD||ZM)&&("running"===e._previousState&&"interrupted"===e._currentState&&ZU.emit(JU.ON_IOS_INTERRUPTION_START),"interrupted"===e._previousState&&"running"===e._currentState&&ZU.emit(JU.ON_IOS_INTERRUPTION_END))}}return this._audioContextInstance}}]),e}(),tV=function(){function e(t){Vl(this,e),Jd(this,"_ctx",void 0),Jd(this,"_analyserNode",void 0),Jd(this,"_audioSource",void 0);var r=rV.getAudioContextInstance();if(t instanceof MediaStreamTrack){var n=new MediaStream;n.addTrack(t),this._audioSource=r.createMediaStreamSource(n)}else this._audioSource=r.createMediaElementSource(t),this._audioSource.connect(r.destination);var i=r.createAnalyser();this._audioSource.connect(i),this._analyserNode=i,this._ctx=r}var t;return Ul(e,[{key:"getAudioLevel",value:function(){var e;"suspended"===(null===(e=this._ctx)||void 0===e?void 0:e.state)&&this._ctx.resume();var t=new Uint8Array(2048);this._analyserNode.getByteTimeDomainData(t);var r=0;t.forEach((function(e){return r=Math.max(r,Math.abs(e-128))}));var n=r/128*255;return n>2?n:0}},{key:"resume",value:(t=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._ctx)||void 0===t?void 0:t.resume();case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._audioSource.disconnect(),this._analyserNode.disconnect()}}]),e}(),rV=new eV,nV=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}(nV||{}),iV=function(){function e(t){Vl(this,e),Jd(this,"_plugins",new $S),this.id=t}var t;return Ul(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(QR(t).call(t,(function(t){return t.name===e.name}))>-1)throw new Error("Failed to register ".concat(e.name,": name is repeated."));t.push(e),this._plugins.set(e.type,t)}},{key:"getPluginsByType",value:function(e){return this._plugins.get(e)||[]}},{key:"getPluginByName",value:function(e,t){var r;return gE(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.getTrack(),i=$T(r),e.prev=3,i.s();case 5:if((o=i.n()).done){e.next=12;break}return a=o.value,e.next=9,a.effect(t,n);case 9:n=e.sent;case 10:e.next=5;break;case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(3),i.e(e.t0);case 17:return e.prev=17,i.f(),e.finish(17);case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,this,[[3,14,17,20]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._plugins.forEach((function(e){e.forEach((function(e){return e.destroy()}))})),this._plugins.clear()}}]),e}(),oV=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(oV||{}),aV=new Nw("VERTC",0),sV=new XU,cV=function(e){DI(r,e);var t=QI(r);function r(e,n){var i;return Vl(this,r),Jd(tI(i=t.call(this)),"sourceType",1),Jd(tI(i),"mediaType",void 0),Jd(tI(i),"_trackId",void 0),Jd(tI(i),"_ac",void 0),Jd(tI(i),"_sourceNode",void 0),Jd(tI(i),"_gainNode",void 0),Jd(tI(i),"_destNode",void 0),Jd(tI(i),"_channelCount",void 0),i._trackId=e,i.mediaType=n,"audio"===n&&hL()&&!OD("SKIP_WEB_AUDIO_IN_TRACK")&&(i._ac=rV.getAudioContextInstance(),i._gainNode=i._ac.createGain(),i._destNode=i._ac.createMediaStreamDestination(),i._gainNode.connect(i._destNode)),i}return Ul(r,[{key:"getId",value:function(){return this._trackId}},{key:"setVolume",value:function(e){this._gainNode&&(this._gainNode.gain.value=e/100)}},{key:"getVolume",value:function(){return this._gainNode?Math.round(100*this._gainNode.gain.value):-1}},{key:"channelCount",get:function(){var e;return null!==(e=this._channelCount)&&void 0!==e?e:0}},{key:"connectAudioTrack",value:function(e){var t;if(this._channelCount=e.getSettings().channelCount,!hL()||OD("SKIP_WEB_AUDIO_IN_TRACK"))return e;this._sourceNode&&(this._sourceNode.mediaStream.getTracks().forEach((function(e){e.stop()})),delete this._sourceNode);var r,n=new MediaStream;(n.addTrack(e),this._sourceNode=null===(t=this._ac)||void 0===t?void 0:t.createMediaStreamSource(n),this._gainNode)&&(null===(r=this._sourceNode)||void 0===r||r.connect(this._gainNode));return this._destNode.stream.getTracks()[0]}},{key:"destroy",value:function(){var e,t,r,n;(null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),13!==cD)&&(null===(n=this._destNode)||void 0===n||n.stream.getTracks().forEach((function(e){e.stop()})));null===(t=this._sourceNode)||void 0===t||t.disconnect(),null===(r=this._gainNode)||void 0===r||r.disconnect(),delete this._sourceNode,delete this._gainNode,delete this._destNode}}]),r}(aP),uV=function(e){DI(n,e);var t,r=QI(n);function n(e,t,i){var o;return Vl(this,n),Jd(tI(o=r.call(this,t,i)),"_mediaTrack",void 0),Jd(tI(o),"_preProcessingTrack",void 0),Jd(tI(o),"_originTrack",void 0),Jd(tI(o),"captureSessionId",""),Jd(tI(o),"handleTrackEnded",(function(){o.emit("track-ended",tI(o)),o.close()})),Jd(tI(o),"handleMute",(function(){o.emit("track-mute",tI(o))})),Jd(tI(o),"handleUnmute",(function(){o.emit("track-unmute",tI(o))})),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o._initListeners(),o}return Ul(n,[{key:"getTrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"origin";return"origin"===e?this._mediaTrack:this._preProcessingTrack||this._mediaTrack}},{key:"setTrack",value:function(e,t){this._mediaTrack="audio"===this.mediaType?this.connectAudioTrack(e):e,this._originTrack=e,t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._preProcessingTrack=void 0,e.prev=1,e.next=4,t.getPreProcessingTrack(this);case 4:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e){return t.apply(this,arguments)})},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){var e,t,r,n,i;return this._mediaTrack.onended=null,this._mediaTrack.onmute=null,this._mediaTrack.onunmute=null,null===(e=this._originTrack)||void 0===e||e.removeEventListener("ended",this.handleTrackEnded),null===(t=this._originTrack)||void 0===t||t.removeEventListener("mute",this.handleMute),null===(r=this._originTrack)||void 0===r||r.removeEventListener("unmute",this.handleUnmute),null===(n=this._preProcessingTrack)||void 0===n||n.stop(),"audio"===this.mediaType?this.destroy():null===(i=this._mediaTrack)||void 0===i?void 0:i.stop()}},{key:"_initListeners",value:function(){this._originTrack instanceof MediaStreamTrack&&(this._originTrack.addEventListener("ended",this.handleTrackEnded),this._originTrack.addEventListener("mute",this.handleMute),this._originTrack.addEventListener("unmute",this.handleUnmute))}}]),n}(cV),dV=function(e){DI(r,e);var t=QI(r);function r(e,n,i){var o;return Vl(this,r),Jd(tI(o=t.call(this,n,i)),"_mediaTrack",void 0),Jd(tI(o),"_originTrack",void 0),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o}return Ul(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){return this.destroy()}}]),r}(cV),lV=function(e){DI(n,e);var t,r=QI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this,e,t,"video")),"resolution",void 0),Jd(tI(i),"dummy",!1),i.resolution={width:0,height:0},i}return Ul(n,[{key:"updateVideoCaptureConfig",value:(t=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return aV.info("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=Zd({},t)).contentHint,zM&&this.streamIndex===cl.STREAM_INDEX_MAIN&&(r.frameRate={ideal:30,max:30}),e.next=8,this.getTrack().applyConstraints(r);case 8:((n=this.getTrack().getSettings()).width&&n.width!==this.resolution.width||n.height&&n.height!==this.resolution.height)&&(this.resolution={width:n.width,height:n.height},this.emit("resolution-change",this.resolution));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){var t;this._mediaTrack&&"contentHint"in this._mediaTrack&&mk(t=["text","motion","detail"]).call(t,e)&&(this._mediaTrack.contentHint=e)}}]),n}(uV),hV=function(e){DI(n,e);var t,r=QI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),Jd(tI(i),"_audioLevelFetcher",void 0),Jd(tI(i),"mixedAudioTrack",void 0),Jd(tI(i),"mixType",Ml.PLAYOUT_AND_PUBLISH),i}return Ul(n,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new tV(this.getTrack("preprocessing"))),this._audioLevelFetcher.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.audioCaptureConfig){e.next=2;break}return e.abrupt("return");case 2:return aV.info("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,null===(t=this.getOrgTrack())||void 0===t?void 0:t.applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(uV),pV=function(e){DI(r,e);var t=QI(r);function r(e,n){return Vl(this,r),t.call(this,e,n,"video")}return Ul(r)}(dV),vV=function(e){DI(r,e);var t=QI(r);function r(e,n){var i;return Vl(this,r),Jd(tI(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return Ul(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new tV(this.getOrgTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(dV),fV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),n}return Ul(r)}(hV),_V=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),n}return Ul(r)}(lV),mV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(lV),yV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(hV),gV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),n}return Ul(r)}(lV),SV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),n}return Ul(r)}(hV),bV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(lV),EV=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(hV);function kV(e,t){return TV.apply(this,arguments)}function TV(){return(TV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new _V(t,dM())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function IV(e,t){return RV.apply(this,arguments)}function RV(){return(RV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new gV(t,dM())).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 AV(e,t){return wV.apply(this,arguments)}function wV(){return(wV=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=VO(r.id),s=dM(),e.prev=3,aV.info("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o,capture_session_id:s}),c=lM(),zM&&(t.frameRate={ideal:30,max:30}),e.next=10,qU.getUserMedia({video:t});case 10:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:lM()-c,capture_session_id:s}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(3),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:s}),new mA(pA.GET_VIDEO_TRACK_FAILED,Om(u="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(u,e.t0.message||"unknown message","."),e.t0);case 18:return d=i.getVideoTracks()[0],sV.set(d,i),(l=new _V(d,dM())).captureSessionId=s,e.next=24,l.generatePreProcessingTrack(r);case 24:return e.abrupt("return",l);case 25:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function CV(e,t){return xV.apply(this,arguments)}function xV(){return(xV=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return aV.info("createMicrophoneAudioTrack","constraints:",t),o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=VO(r.id),s=dM(),e.prev=4,null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_begin",media_device_id:o,event_session_id:s}),u=lM(),(d=r.getPluginByName(nV.PRE_PROCESSING,"RTCAIAnsExtension"))&&(d.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=11,qU.getUserMedia({audio:t});case 11:i=e.sent,null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_result",media_device_id:o,media_device_name:(null===(c=i.getAudioTracks()[0])||void 0===c?void 0:c.label)||"",reason:"success",elapse:lM()-u,event_session_id:s}),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(4),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_end",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message,event_session_id:s}),new mA(pA.GET_AUDIO_TRACK_FAILED,Om(l="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(l,e.t0.message||"unknown message","."),e.t0);case 19:return h=i.getAudioTracks()[0],sV.set(h,i),(p=new fV(h,dM())).captureSessionId=s,e.next=25,p.generatePreProcessingTrack(r);case 25:return e.abrupt("return",p);case 26:case"end":return e.stop()}}),e,null,[[4,15]])})))).apply(this,arguments)}function OV(){return MV.apply(this,arguments)}function MV(){return MV=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=h.length>0&&void 0!==h[0]&&h[0],r=h.length>1?h[1]:void 0,n=h.length>2?h[2]:void 0,aV.info("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=VO(r.id),a=dM(),e.prev=6,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen",capture_session_id:a}),s=lM(),e.next=11,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!KM||16!==cD))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!0,autoGainControl:!1}});case 11:i=e.sent,null==o||o.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",reason:"success",elapse:lM()-s,capture_session_id:a}),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(6),null==o||o.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:"screen",error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:a}),new mA(pA.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 19:return c=i.getVideoTracks()[0],u=new gV(c,dM()),e.next=23,u.generatePreProcessingTrack(r);case 23:if(!(d=i.getAudioTracks()[0])){e.next=29;break}return l=new SV(d,dM()),e.next=28,l.generatePreProcessingTrack(r);case 28:return e.abrupt("return",[u,l]);case 29:return e.abrupt("return",[u,void 0]);case 30:case"end":return e.stop()}}),e,null,[[6,15]])}))),MV.apply(this,arguments)}function DV(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dM();return new vV(e,t)}function PV(e,t){return NV.apply(this,arguments)}function NV(){return(NV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new mV(t,dM()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function LV(e,t){return UV.apply(this,arguments)}function UV(){return(UV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new yV(t,dM()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function VV(e,t){return FV.apply(this,arguments)}function FV(){return(FV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new bV(t,dM()),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 BV(e,t){return jV.apply(this,arguments)}function jV(){return(jV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new EV(t,dM()),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 HV=hV,GV=vV,zV=function(e){return e[e.NONE=0]="NONE",e}(zV||{}),KV={getNalunits:function(e){if(e.length-e.position<4)return[];var t=e.position;return 1===e.getInt32(t)||0===e.getInt16(t)&&1===e.getInt8(t+2)?KV.getAnnexbNals(e):KV.getAvccNals(e)},getAnnexbNals:function(e){for(var t=[],r=KV.getHeaderPositionAnnexB(e),n=r.pos,i=n;n<e.length-4;){var o,a,s=new Uint8Array(km(o=e.buffer).call(o,n,n+r.headerLength));r.pos===e.position&&e.skip(r.headerLength),i=(r=KV.getHeaderPositionAnnexB(e)).pos;var c={header:s,body:new Uint8Array(km(a=e.buffer).call(a,n+s.byteLength,i)),type:-1};KV.analyseNal(c),c.type<=9&&0!==c.type&&t.push(c),e.skip(i-e.position),n=i}return t},getAvccNals:function(e){for(var t=[];e.position<e.length-4;){var r=e.getInt32(e.position);if(!(e.length-e.position>=r))break;var n,i,o=new Uint8Array(km(n=e.buffer).call(n,e.position,e.position+4));e.skip(4);var a=new Uint8Array(km(i=e.buffer).call(i,e.position,e.position+r));e.skip(r);var s={header:o,body:a,type:-1};KV.analyseNal(s),s.type<=9&&0!==s.type&&t.push(s)}return t},analyseNal:function(e){var t=31&e.body[0];switch(e.type=t,t){case 1:e.ndr=!0;break;case 5:e.idr=!0;break;case 6:e.sei=!0;break;case 7:e.sps=!0;break;case 8:e.pps=!0}},getHeaderPositionAnnexB:function(e){for(var t=e.position,r=0,n=e.length;3!==r&&4!==r&&t<n-4;)0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:1===e.getInt8(t+2)?r=3:t++:t++;return t===n-4&&(0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:t=n:(t++,0===e.getInt16(t)&&1===e.getInt8(t)?r=3:t=n)),{pos:t,headerLength:r}}},XV=function(){function e(t){Vl(this,e),Jd(this,"_position",0),Jd(this,"_dataview",void 0),this._dataview=new DataView(t)}return Ul(e,[{key:"length",get:function(){return this.buffer.byteLength}},{key:"buffer",get:function(){return this._dataview.buffer}},{key:"position",get:function(){return this._position},set:function(e){this._position=e}},{key:"back",value:function(e){this.position-=e}},{key:"getUint8",value:function(e){return this._dataview.getUint8(e)}},{key:"getInt8",value:function(e){return this._dataview.getInt8(e)}},{key:"getInt16",value:function(e){return this._dataview.getInt16(e)}},{key:"getUint16",value:function(e){return this._dataview.getUint16(e)}},{key:"getUint32",value:function(e){return this._dataview.getUint32(e)}},{key:"getInt32",value:function(e){return this._dataview.getInt32(e)}},{key:"skip",value:function(t){for(var r=Math.floor(t/4),n=t%4,i=0;i<r;i++)e.readByte(this,4);n>0&&e.readByte(this,n)}},{key:"readUint8",value:function(){return e.readByte(this,1)}},{key:"readUint16",value:function(){return e.readByte(this,2)}},{key:"readUint24",value:function(){return e.readByte(this,3)}},{key:"readUint32",value:function(){return e.readByte(this,4)}},{key:"readUint64",value:function(){return e.readByte(this,8)}},{key:"readInt8",value:function(){return e.readByte(this,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}}],[{key:"readByte",value:function(e,t,r){var n;switch(t){case 1:n=r?e.getInt8(e.position):e.getUint8(e.position);break;case 2:n=r?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(r)throw new Error("not supported for readByte 3");n=e.getUint8(e.position)<<16,n|=e.getUint8(e.position+1)<<8,n|=e.getUint8(e.position+2);break;case 4:n=r?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(r)throw new Error("not supported for readBody 8");n=e.getUint32(e.position)<<32,n|=e.getUint32(e.position+4);break;default:n=""}return e.position+=t,n}}]),e}(),WV=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(WV||{}),qV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),YV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]),JV=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 QV(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function ZV(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 $V=function(){function e(){Vl(this,e)}return Ul(e,null,[{key:"generateSEI",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new Uint8Array([0,0,0,1]),i=new Uint8Array([6]),o=new Uint8Array([5]),a=r?qV:YV,s=QV(e.byteLength+a.byteLength),c=JV(e);return new Uint8Array(Om(t=[]).call(t,Jk(n),Jk(i),Jk(o),Jk(s),Jk(a),Jk(c),[128]))}},{key:"decodeSeiBody",value:function(e){var t=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]||t.push(e[r]);return new Uint8Array(t)}(e=km(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=eI(ZV(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=YV.byteLength&&i>=YV.byteLength&&km(t).call(t,r,r+YV.byteLength).toString()===YV.toString()?(r+=YV.byteLength,o=1):t.byteLength>=YV.byteLength&&i>=YV.byteLength&&km(t).call(t,r,r+qV.byteLength).toString()===qV.toString()&&(r+=qV.byteLength,o=0),{type:o,payload:km(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new $S,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=eI(ZV(e.payload,r),2),i=n[0];r=n[1];var o,a=eI(ZV(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,km(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=$T(e);try{for(n.s();!(t=n.n()).done;){var i=eI(t.value,2),o=i[0],a=i[1],s=QV(o),c=QV(a.byteLength);r.push(s,c,a)}}catch(l){n.e(l)}finally{n.f()}var u=pb(r).call(r,(function(e,t){return e+t.byteLength}),0),d=new Uint8Array(u);return pb(r).call(r,(function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),eF=new Nw("Stats",3),tF=function(){function e(t){Vl(this,e),Jd(this,"player",void 0),Jd(this,"_timer",void 0),Jd(this,"handler",void 0),Jd(this,"_monitor",void 0),Jd(this,"_destroyed",!1),this._context=t,this._monitor=VO(t.id)}return Ul(e,[{key:"setVar",value:function(e){this.handler=e}},{key:"stopReport",value:function(e){var t;this._timer&&(eF.info("stopReport","invoke"),clearTimeout(this._timer),delete this._timer,jO(this._context.id,"del_media_statistics_timer",Om(t="reason: ".concat(e,", stack: ")).call(t,(new Error).stack),0,this._stream.streamId||""))}},{key:"filterIllegal",value:function(e){var t={};return an(e).forEach((function(r){null===e[r]||void 0===e[r]||Number.isNaN(e[r])||(t[r]=e[r])})),t}},{key:"destroy",value:function(){eF.info("destroy","invoke"),jO(this._context.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.stopReport("destroy"),this._destroyed=!0}}]),e}(),rF=function(e){DI(i,e);var t,r,n=QI(i);function i(e,t){var r;return Vl(this,i),(r=n.call(this,e))._stream=t,r}return Ul(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t){var r,n,i,o=this;if(!this._timer){eF.info("setLocalStreamStatsEvtInterval","invoke"),this.setVar(t),this._destroyed=!1;var a={audio:{},video:{}},s=this._stream,c=null===(r=s.audioTrack)||void 0===r?void 0:r.getTrack("preprocessing"),u=null===(n=s.videoTrack)||void 0===n?void 0:n.getTrack("preprocessing");this.getAudioStats(c,a,null===(i=s.audioTrack)||void 0===i?void 0:i.getAudioLevel()),this.getVideoStats(u,a);var d=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=s.audioTrack)||void 0===t?void 0:t.getTrack("preprocessing"),c=null===(r=s.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,o.getAudioStats(i,a,null===(n=s.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return u=e.sent,e.next=7,o.getVideoStats(c,a);case 7:return d=e.sent,e.abrupt("return",{audioStats:u,videoStats:d,isScreen:s.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),l=function(){var t=Rm(Tm().mark((function t(){var r;return Tm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,d();case 2:r=t.sent,e(r),o._destroyed||(o._timer=setTimeout(l,2e3));case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();this._timer=setTimeout(l,2e3)}}},{key:"getAudioStats",value:(r=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,y;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s={},c={timestamp:Date.now()},u=this._stream,d=u.streamId,l=u.audioMid,h=u.isScreen,p=u.pubAttributes,v=u.pubAudio,f=u.audioTrack,_={media_type:"audio",is_screen:!!h,direction:"up",stream_id:d,vid:l,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:p.localaudio?"capture_state_on":"capture_state_off",mute_state:v?"mute_state_off":"mute_state_on"},f&&(_.playback_volume=f.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",s);case 7:return e.next=9,this.handler.getStats(t);case 9:if((m=e.sent).length){e.next=12;break}return e.abrupt("return",s);case 12:if(m.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,o=e.clockRate,a=e.roundTripTime,u=e.channels,d=e.audioLevel;e.googRtt;var l=e.mimeType,h=e.availableIncomingBitrate,p=e.availableOutgoingBitrate,v=e.bytesReceived,f=e.nominated,m=e.id,y=e.currentRoundTripTime,g=e.state,S=e.writable,b=e.requestsReceived,E=e.responsesReceived,k=e.requestsSent,T=e.consentRequestsSent,I=e.responsesSent,R=e.jitter,A=e.candidateType,w=e.ip,C=e.address,x=e.networkType,O=e.port,M=e.protocol,D=e.nackCount,P=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?(c.packetsSent=r,c.bytesSent=i,_.bytes=i,_.packetsSent=r,_.nackCount=D,_.ssrc=U,_.retransmitted_bytes_sent=P,_.retransmitted_packets_sent=N,c.retransmittedBytesSent=P,c.retransmittedPacketsSent=N):"remote-inbound-rtp"===t?(c.packetsLost=n,_.packetsLost=n,_.net_jitter=1e3*R,s.rtt=1e3*a,_.rtt=s.rtt,s._fractionLost=j||0):"codec"===t?(s.recordSampleRate=o,s.numChannels=u,_.codecName=l):"media-source"===t&&void 0!==d?(_.audio_level=d?-10*$A(Math.pow(d,2)):d,_.volume=255*d,_.total_audio_energy=V,_.totalInputDuration=F):"ssrc"===t&&"audio"===B?_.send_level=L:"candidate-pair"===t?(_.ice_available_incoming_bitrate=h,_.ice_available_outgoing_bitrate=p,_.ice_bytes_received=v,_.ice_bytes_sent=i,_.ice_nominated=Number(f),_.ice_pair_id=m,_.ice_pair_rtt=y,_.ice_pair_state=g,_.ice_pair_writable=S,_.recv_ping_requests=b,_.recv_ping_responses=E,_.sent_ping_requests_before_first_response=k,_.sent_ping_requests_total=k+(T||0),_.sent_ping_responses=I):"local-candidate"===t?(_.local_candidate_type=A,_.local_ip=w||C,_.local_network_type=x,_.local_port=O,_.protocol=M):"remote-candidate"===t&&(_.remote_candidate_type=A,_.remote_ip=w||C,_.remote_port=O);var H=OD("STATS_SCALLBACK_SUPPORT");pL&&H||"media-source"===t&&(_.send_level=d)})),void 0===_.volume&&void 0!==n&&(_.volume=n,_.audio_level=n?-10*$A(Math.pow(n/255,2)):n),(y=r.audio).timestamp){e.next=18;break}return r.audio=c,e.abrupt("return",this.filterIllegal(s));case 18:return void 0!==c.packetsLost&&(s.audioLossRate=(c.packetsLost-y.packetsLost)/(c.packetsSent-y.packetsSent),s.audioLossRate=Number.isNaN(s.audioLossRate)?0:s.audioLossRate,_.fraction_lost=s.audioLossRate),s.statsInterval=c.timestamp-y.timestamp,_.stats_interval=s.statsInterval,s.sendKBitrate=(c.bytesSent-y.bytesSent||0)/s.statsInterval*8,_.mediaBitratebps=Math.round(1e3*s.sendKBitrate),_.bandwidth=Math.round(_.mediaBitratebps/1024),void 0!==c.retransmittedBytesSent&&(_.retransmitBitratebps=(c.retransmittedBytesSent-y.retransmittedBytesSent||0)/s.statsInterval),r.audio=c,_.vendor_mode=(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,_.pc_session_id=null===(o=this.handler)||void 0===o?void 0:o.peerConnectionId,null===(a=this._monitor)||void 0===a||a.report("rtc_media_statistics",_),s._retransmittedRate=(c.retransmittedPacketsSent-y.retransmittedPacketsSent)/(c.packetsSent-y.packetsSent),void 0===s.audioLossRate&&(s.audioLossRate=s._retransmittedRate,_.fraction_lost=s.audioLossRate),s._fractionLost=Math.max(s._fractionLost,s.audioLossRate),e.abrupt("return",this.filterIllegal(s));case 33:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},i={timestamp:Date.now(),simulcast:{}},o=this._stream,a=o.streamId,s=o.videoMid,c=o.isScreen,u=o.pubAttributes,d=o.enableSimulcast,l=o.pubVideo,e.t0=Zd,e.t1={media_type:"video",is_screen:!!c,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:u.localvideo?"capture_state_on":"capture_state_off",mute_state:l?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,h=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",n);case 11:return h.cap_frame_width=t.getSettings().width,h.cap_frame_height=t.getSettings().height,h.frameRateSent=t.getSettings().frameRate,n.isScreen=c,e.next=17,this.handler.getStats(t);case 17:if((p=e.sent).length){e.next=20;break}return e.abrupt("return",n);case 20:if(v=0,p.forEach((function(e){var t=e.type,o=e.framesEncoded,a=e.packetsLost,s=e.bytesSent,c=e.framesSent,u=e.retransmittedBytesSent,l=e.totalPacketSendDelay,p=e.totalEncodeTime,f=e.firCount,_=e.targetBitrate,m=e.roundTripTime,y=e.mimeType,g=e.frameWidth,S=e.frameHeight,b=e.packetsSent,E=e.googActualEncBitrate,k=e.googAvailableReceiveBandwidth,T=e.googAvailableSendBandwidth,I=e.googAvgEncodeMs,R=e.googBucketDelay,A=e.googEncodeUsagePercent,w=e.googFrameRateInput,C=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,O=e.bytesReceived,M=e.nominated,D=e.id,P=e.currentRoundTripTime,N=e.state,L=e.writable,U=e.candidateType,V=e.ip,F=e.address,B=e.networkType,j=e.port,H=e.nackCount,G=e.pliCount,z=e.protocol,K=e.qpSum,X=e.requestsReceived,W=e.responsesReceived,q=e.googRetransmitBitrate,Y=e.requestsSent,J=e.consentRequestsSent,Q=e.responsesSent,Z=e.ssrc,$=e.googTargetEncBitrate,ee=e.googTransmitBitrate,te=e.retransmittedPacketsSent,re=e.encoderImplementation,ne=e.jitter,ie=e.rid,oe=e.fractionLost,ae=e.googAdaptationChanges,se=e.qualityLimitationReason,ce=e.qualityLimitationDurations,ue=e.googFirsReceived,de=e.googFrameRateSent,le=e.keyFramesEncoded,he=e.scalabilityMode,pe=e.framesPerSecond,ve=e.frames;"outbound-rtp"===t?(d&&(ie?i.simulcast[ie]=e:i.simulcast[v]=e,v++),i.framesEncoded=o||i.framesEncoded||0,h.key_frames_encoded=le||0,i.bytesSent=s||i.bytesSent||0,i.framesSent=c||i.framesSent,h.bytes=s||h.bytes||0,i.packetsSent=b||i.packetsSent||0,h.packetsSent=b||h.packetsSent||0,h.nackCount=H||h.nackCount||0,h.pli_count=G||h.pli_count||0,h.qp_sum=K||h.qp_sum||0,h.ssrc=Z||h.ssrc||0,h.retransmitted_packets_sent=te,i.retransmittedPacketsSent=te,i.retransmittedBytesSent=u,h.encoder_implementation=re,h.qualityLimitationReason=se,h.qualityLimitationDurations=ce,h.scalabilityMode=he,void 0!==g&&((!n.encodedFrameWidth||g>n.encodedFrameWidth)&&(n.encodedFrameWidth=g),(!n.encodedFrameHeight||S>n.encodedFrameHeight)&&(n.encodedFrameHeight=S),h.frame_size_height=S,h.frame_size_width=g)):"track"===t?(n.encodedFrameWidth=g,n.encodedFrameHeight=S,h.frame_size_height=S,h.frame_size_width=g):"remote-inbound-rtp"===t?(i.packetsLost=a,n.rtt=1e3*m,h.rtt=n.rtt,h.jitter=1e3*ne,h.packetsLost=a,n._fractionLost=oe||0):"codec"===t?(n.codecType=y,h.codecName=y):"candidate-pair"===t?(h.ice_available_incoming_bitrate=C,h.ice_available_outgoing_bitrate=x,h.ice_bytes_received=O,h.ice_bytes_sent=s,h.ice_nominated=Number(M),h.ice_pair_id=D,h.ice_pair_rtt=P,h.ice_pair_state=N,h.ice_pair_writable=L,h.recv_ping_requests=X,h.recv_ping_responses=W,h.sent_ping_requests_before_first_response=Y,h.sent_ping_requests_total=Y+J,h.sent_ping_responses=Q):"local-candidate"===t?(h.local_candidate_type=U,h.local_ip=V||F,h.local_network_type=B,h.local_port=j,h.protocol=z):"remote-candidate"===t?(h.remote_candidate_type=U,h.remote_ip=V||F,h.remote_port=j):"VideoBwe"===t?(h.encBitratebps=E,h.available_receive_bandwidth=k,h.available_send_bandwidth=T,h.bucket_delay=R,h.retransmitBitratebps=q,h.targetEncBitratebps=$,h.transmit_bitrate=ee,n._sendBandWidth=Number(T)):"ssrc"===t&&(h.avg_encode_ms=I,h.encodeUsage=A,h.frame_rate_input=w,h.orignal_input_Framerate=Number(w),h.ddaptationChanges=ae,h.firsReceived=ue,h.frameRateSent=de);var fe=OD("STATS_SCALLBACK_SUPPORT");if(!pL||!fe){var _e=r.video,me=i.timestamp-_e.timestamp;if("outbound-rtp"===t){var ye=s-_e.bytesSent,ge=u-_e.retransmittedBytesSent;h.encBitratebps=Math.round(8e3*(ye-ge)/me),h.bucket_delay=l/b,h.retransmitBitratebps=Math.round(8e3*ge/me),h.targetEncBitratebps=_,h.transmit_bitrate=Math.round(1e3*(s-_e.bytesSent)*8/me),h.avg_encode_ms=1e3*p/o,h.firsReceived=f+G}else"candidate-pair"===t?(h.available_send_bandwidth=x,n._sendBandWidth=x):"media-source"===t&&(h.frame_rate_input=pe,h.orignal_input_Framerate=Number(pe),h.frame_input=ve)}})),(f=r.video).timestamp){e.next=26;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 26:return n.statsInterval=i.timestamp-f.timestamp,h.stats_interval=n.statsInterval,_=an(i.simulcast),d?(h.sim_enc_width=[],h.sim_enc_height=[],h.sim_enc_bps=[],h.sim_enc_framerate=[],h.sim_enc_key_frames=[],h.sim_rids=[],h.sim_enc_bandwidth=[],h.sim_sent_framerate=[],h.sim_fraction_lost=[],h.sim_keyencoded=[],h.active_sim_streams=(null===(m=this._context)||void 0===m?void 0:m.activeSimStreams)||[],h.sim_retransmittedRate=[],b=!1,HR(_).call(_,(function(e,t){return Number(e)-Number(t)})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,p=t.qualityLimitationDurations,v=t.qualityLimitationResolutionChanges,_=t.retransmittedPacketsSent,m=t.pliCount,y=t.keyFramesEncoded;void 0!==l&&(h.sim_qualityLimitationReason||(h.sim_qualityLimitationReason=[],h.sim_qualityLimitationDurations=[],h.sim_qualityLimitationResolutionChanges=[]),h.sim_qualityLimitationReason.push(l),h.sim_qualityLimitationDurations.push(p),h.sim_qualityLimitationResolutionChanges.push(v));var g=f.simulcast[e];if(h.sim_enc_width.push(r||0),h.sim_enc_height.push(o||0),h.sim_enc_key_frames.push(y||0),g){var S=(a-g.bytesSent||0)/n.statsInterval;h.sim_enc_bps.push(Math.round(8e3*S)),h.sim_enc_bandwidth.push(Math.round(8e3*S/1024));var E=1e3*(s-g.framesEncoded)/n.statsInterval;h.sim_enc_framerate.push(Math.round(E)),h.sim_rids.push(e);var k=void 0!==c?c-g.framesSent:s-g.framesEncoded,T=1e3*k/n.statsInterval;h.sim_sent_framerate.push(Math.round(T));var I=(u-g.packetsLost)/(d-g.packetsSent);n._retransmittedRate=(_-g.retransmittedPacketsSent)/(d-g.packetsSent),I=Number.isNaN(I)?0:I,h.sim_fraction_lost.push(I),h.sim_keyencoded.push(m-g.pliCount>0),h.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!b&&(n.sentKBitrate=8*S,n.encoderOutputFrameRate=E,n.encodedFrameCount=k,n.sentFrameRate=T,n.videoLossRate=I,b=!0)}})),h.vendor_mode=(null===(y=this._stream)||void 0===y?void 0:y.vendorCode)||0,h.pc_session_id=null===(g=this.handler)||void 0===g?void 0:g.peerConnectionId,null===(S=this._monitor)||void 0===S||S.report("rtc_media_statistics",h)):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-f.framesSent:i.framesEncoded-f.framesEncoded,n.sentKBitrate=(i.bytesSent-f.bytesSent||0)/n.statsInterval*8,h.bitrate=Math.round(1e3*n.sentKBitrate),h.bandwidth=Math.round(h.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-f.framesEncoded)/n.statsInterval,h.frame_rate_encoded=Math.round(n.encoderOutputFrameRate),n.sentFrameRate=1e3*n.encodedFrameCount/n.statsInterval,h.frame_rate_sent=Math.round(n.sentFrameRate),n.videoLossRate=(i.packetsLost-f.packetsLost)/(i.packetsSent-f.packetsSent),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,h.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-f.retransmittedPacketsSent)/(i.packetsSent-f.packetsSent),h.vendor_mode=(null===(E=this._stream)||void 0===E?void 0:E.vendorCode)||0,h.pc_session_id=null===(k=this.handler)||void 0===k?void 0:k.peerConnectionId,null===(T=this._monitor)||void 0===T||T.report("rtc_media_statistics",h)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 33:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(tF),nF=function(e){DI(o,e);var t,r,n,i=QI(o);function o(e,t){var r;return Vl(this,o),Jd(tI(r=i.call(this,e)),"isPaused",void 0),Jd(tI(r),"pauseStart",void 0),Jd(tI(r),"pauseDuration",void 0),Jd(tI(r),"_audioStallCount",void 0),Jd(tI(r),"_setAudioStallCount",void 0),Jd(tI(r),"_audioStallTimer",void 0),Jd(tI(r),"_audioStallInterval",void 0),Jd(tI(r),"_audioStallRatio",void 0),Jd(tI(r),"_videoInWaiting",void 0),r._stream=t,r._videoInWaiting=!1,r.pauseDuration=0,r}return Ul(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=Rm(Tm().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,p,v,f,_,m,y,g=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._timer){e.next=2;break}return e.abrupt("return");case 2:return eF.info("setRemoteStreamStatsEvtInterval","invoke"),this.setVar(r),this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,s={audio:{},video:{}},this._destroyed=!1,c=this._stream,u=null===(n=c.audioTrack)||void 0===n?void 0:n.getOrgTrack(),d=null===(i=c.videoTrack)||void 0===i?void 0:i.getTrack(),this.getRemoteVideoStats(d,s),e.next=14,this.getRemoteAudioStats(u,s,null===(a=this._stream.audioTrack)||void 0===a?void 0:a.getAudioLevel());case 14:this._stopAudioStallTimer(),l=0,h=0,v=[],f=0,_=lM(),this._setAudioStallCount=function(){if(CD.AUDIO_STALL&&g._audioStallInterval>0&&void 0!==s.audio.concealedSamples){var e=s.audio.concealedSamples,t=s.audio.totalSamplesReceived;_=lM();var r={isStall:!1,counted:!1,diff:0},n=.5*g._audioStallInterval;g._audioStallCount=Rm(Tm().mark((function i(){var o,a,s,u,d,p,m,y,S,b,E,k,T,I,R,A,w,C,x,O;return Tm().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=c.hasAudio,s=c.subAudio,u=c.virtual,d=c.virtualOccupy,!c.removeTrack){i.next=4;break}return clearTimeout(g._audioStallTimer),i.abrupt("return");case 4:if(a&&s){i.next=10;break}return r.isStall=!1,r.counted=!1,v.push({reason:Om(p="hasAudio: ".concat(a,", subAudio: ")).call(p,s)}),_=lM(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 10:if(!u||d){i.next=16;break}return r.isStall=!1,r.counted=!1,v.push({reason:Om(m="virtual: ".concat(u,", virtualOccupy: ")).call(m,d)}),_=lM(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 16:return y=null===(o=c.audioTrack)||void 0===o?void 0:o.getOrgTrack(),S=Date.now(),i.next=20,g.handler.getStats(y,!0);case 20:if(b=i.sent,E=Date.now(),k=lM(),!((T=k-_)<n)){i.next=27;break}return v.push({diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:Om(I="diff(".concat(T,") < minInterval(")).call(I,n,")")}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 27:if(R=b.length,A=gE(b).call(b,(function(e){return"inbound-rtp"===e.type}))){i.next=32;break}return v.push({diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:R?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 32:return w=A.concealedSamples,C=A.totalSamplesReceived,O=C-t,(x=w-e)>=0&&O>=0&&x>=g._audioStallRatio*O?(v.push({concealed:x,received:O,diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,is_stall:!0}),r.isStall?(r.counted?h+=T:(h=h+r.diff+T,l++),r.counted=!0):T>=200?(h+=T,l++,r.counted=!0):(r.counted=!1,r.diff=T),r.isStall=!0):(v.push({concealed:x,received:O,diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E}),r.isStall=!1,r.counted=!1),e=w,t=C,_=k,f++,i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 41:case"end":return i.stop()}}),i)}))),p=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!g._audioStallCount&&g._setAudioStallCount&&g._setAudioStallCount(),!g._audioStallCount){e.next=6;break}return e.next=4,g._audioStallCount();case 4:g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval)}},this._setAudioStallCount(),m=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i,o,a,u;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=c.audioTrack)||void 0===t?void 0:t.getOrgTrack(),o=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,g.getRemoteAudioStats(i,s,null===(n=g._stream.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return a=e.sent,l=0,h=0,v=[],f=0,e.next=11,g.getRemoteVideoStats(o,s);case 11:return u=e.sent,e.abrupt("return",{audioStats:a,videoStats:u,isScreen:c.isScreen,userId:c.userId,streamId:c.streamId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y=function(){var e=Rm(Tm().mark((function e(){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m();case 2:r=e.sent,t(r),p&&(_=lM(),g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval)),g._timer&&clearTimeout(g._timer),g._destroyed||(g._timer=setTimeout(y,2e3));case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(y,2e3);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_stopAudioStallTimer",value:function(){clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){eF.info("unsubscribe","invoke"),OI(CI(o.prototype),"stopReport",this).call(this,"unsubscribe"),this._stopAudioStallTimer(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d={},l={},h=this._stream,p=h.streamId,v=h.userId,f=h.isScreen,_=h.audioMid,m=h.subMediaType,y=h._attributes,g=h.virtual,S=h.audioTrack,b={media_type:"audio",is_screen:!!f,direction:"down",stream_id:p,stream_user_id:v,vid:_,audio_mux:g,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:wM(m)?"mute_state_off":"mute_state_on",remote_user_capture_state:y.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:y.localaudio&&y.audiostream?"mute_state_off":"mute_state_on"},S&&(b.playback_volume=S.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",d);case 7:return e.next=9,this.handler.getStats(t);case 9:if((E=e.sent).length){e.next=12;break}return e.abrupt("return",d);case 12:if(E.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,o=e.bytesReceived,a=e.jitterBufferDelay,s=e.jitterBufferEmittedCount,c=e.clockRate,u=e.channels,h=e.totalSamplesReceived,v=e.concealedSamples,f=e.silentConcealedSamples,_=e.concealmentEvents,m=e.totalRoundTripTime,y=e.packetsDiscarded,g=e.state,S=e.currentRoundTripTime,E=e.audioLevel,k=e.totalAudioEnergy,T=e.totalSamplesDuration,I=e.mimeType,R=e.googDecodingNormal,A=e.googDecodingMuted,w=e.availableIncomingBitrate,C=e.availableOutgoingBitrate,O=e.bytesSent,M=e.nominated,D=e.id,P=e.writable,N=e.jitter,L=e.candidateType,U=e.ip,V=e.address,F=e.networkType,B=e.port,j=e.protocol,H=e.audioOutputLevel,G=e.requestsReceived,z=e.responsesReceived,K=e.requestsSent,X=e.consentRequestsSent,W=e.responsesSent,q=e.ssrc;e.kind;var Y=e.nackCount,J=e.lastPacketReceivedTimestamp,Q=e.concealmentevents,Z=e.fecPacketsReceived;if("inbound-rtp"===t)l.packetsLost=r,l.packetsReceived=i,b.packetsLost=r,b.packetsReceived=i,b.packetsDiscarded=y,b.nackCount=Y,b.lastPacketReceivedTimestamp=J,b.concealmentevents=Q,l.bytesReceived=o,void 0!==a&&(d.jitterBufferDelay=a/s*1e3,b.average_jitter_buffer_delay_ms=d.jitterBufferDelay),void 0!==h&&(l.totalSamplesReceived=h,d.concealedSamples=v,l.concealedSamples=v,l.silentConcealedSamples=f,b.concealedSamples=v,d.concealmentEvents=_,b.totalSamplesReceived=h),void 0!==Z&&(b.fec_packets_received=Z,l.fecPacketsReceived=Z),b.jitter=1e3*N,b.ssrc=q,void 0!==E&&0!==E?(b.audio_level=E?-10*$A(Math.pow(E,2)):E,b.volume=255*E):(b.volume=null!=n?n:255*E,b.audio_level=n?-10*$A(Math.pow(n/255,2)):n),void 0!==k&&(b.total_audio_energy=k),void 0!==T&&(b.totalAudioDuration=T);else if("codec"===t)d.recordSampleRate=c,u&&(d.numChannels=u),b.codecName=I;else if("candidate-pair"===t){var $,ee,te;b.ice_available_incoming_bitrate=w,b.ice_available_outgoing_bitrate=C,b.ice_bytes_received=o,b.ice_bytes_sent=O,b.ice_nominated=Number(M),b.ice_pair_id=D,b.ice_pair_rtt=S,b.rtt=1e3*S,b.rtt&&null!==($=x._context)&&void 0!==$&&null!==(ee=$.streamRTT)&&void 0!==ee&&null!==(te=ee[p])&&void 0!==te&&te.audio&&(b.total_rtt_ms=Math.round(b.rtt+x._context.streamRTT[p].audio)),b.ice_pair_state=g,b.ice_pair_writable=P,b.recv_ping_requests=G,b.recv_ping_responses=z,b.sent_ping_requests_before_first_response=K,b.sent_ping_requests_total=K+(X||0),b.sent_ping_responses=W,"succeeded"===g&&(d.rtt=1e3*S,d.total_rtt=1e3*m)}else"track"===t&&void 0!==E?(0===E&&0!==n?(b.volume=n,b.audio_level=n?-10*$A(Math.pow(n/255,2)):n):(b.audio_level=E?-10*$A(Math.pow(E,2)):E,b.volume=255*E),b.total_audio_energy=k,b.totalAudioDuration=T):"ssrc"===t?(b.decodingNormal=R,b.recvAudioLevel=H,b.decodingMuted=A):"local-candidate"===t?(b.local_candidate_type=L,b.local_ip=U||V,b.local_network_type=F,b.local_port=B,b.protocol=j):"remote-candidate"===t&&(b.remote_candidate_type=L,b.remote_ip=U||V,b.remote_port=B)})),(k=r.audio).timestamp){e.next=18;break}return l.timestamp=Date.now(),r.audio=l,e.abrupt("return",this.filterIllegal(d));case 18:if(T={},void 0!==l.concealedSamples&&(b.interval_concealed_samples=l.concealedSamples-k.concealedSamples,b.interval_samples_received=l.totalSamplesReceived-k.totalSamplesReceived,b.interval_silent_concealed_samples=l.silentConcealedSamples-k.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==k.concealedSamples)){e.next=36;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=36;break}return e.next=26,this._audioStallCount();case 26:I=e.sent,R=I.stall_count,A=I.stall_duration,w=I.stall_list,C=I.stats_count,T.stall_list=w,T.stats_count=C,b.concealedSamples===b.interval_concealed_samples&&b.totalSamplesReceived===b.interval_samples_received?(b.stall_count=0,b.stall_duration=0):(b.stall_count=R,b.stall_duration=A),d.stallCount=b.stall_count,d.stallDuration=b.stall_duration;case 36:return l.timestamp=Date.now(),d.audioLossRate=(l.packetsLost-k.packetsLost)/(l.packetsReceived-k.packetsReceived+(l.packetsLost-k.packetsLost)),d.audioLossRate=Number.isNaN(d.audioLossRate)?0:d.audioLossRate,b.fraction_lost=d.audioLossRate,d.statsInterval=l.timestamp-k.timestamp,b.stats_interval=d.statsInterval,d.receivedKBitrate=(l.bytesReceived-k.bytesReceived||0)/d.statsInterval*8,b.bandwidth=Math.round(1e3*d.receivedKBitrate/1024),void 0!==l.concealedSamples&&(d.receivedSampleRate=1e3*b.interval_samples_received/d.statsInterval),void 0!==l.fecPacketsReceived&&(b.fecBitratebps=(l.fecPacketsReceived-k.fecPacketsReceived||0)/d.statsInterval),b.average_jitter_buffer_delay_ms&&b.total_rtt_ms&&(d.e2eDelay=b.average_jitter_buffer_delay_ms+b.total_rtt_ms),null!==(i=this._context)&&void 0!==i&&null!==(o=i.streamRTT)&&void 0!==o&&null!==(a=o[p])&&void 0!==a&&a.audio&&(d.totalRtt=(b.rtt?b.rtt:0)+this._context.streamRTT[p].audio),r.audio=l,b.vendor_mode=(null===(s=this._stream)||void 0===s?void 0:s.vendorCode)||0,b.pc_session_id=null===(c=this.handler)||void 0===c?void 0:c.peerConnectionId,null===(u=this._monitor)||void 0===u||u.report("rtc_media_statistics",b,T),e.abrupt("return",this.filterIllegal(d));case 53:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u={},d={timestamp:Date.now()},l=this._stream,h=l.streamId,p=l.userId,v=l.isScreen,f=l.subMediaType,_=l._attributes,e.t0=Zd,e.t1={media_type:"video",is_screen:!!v,direction:"down",stream_id:h,stream_user_id:p,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:CM(f)?"mute_state_off":"mute_state_on",remote_user_capture_state:_.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:_.localvideo&&_.videostream?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,m=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",u);case 11:return u.isScreen=v,e.next=14,this.handler.getStats(t);case 14:if((y=e.sent).length){e.next=17;break}return e.abrupt("return",u);case 17:if(y.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,i=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,s=e.framesDecoded,c=e.jitterBufferDelay,l=e.jitterBufferEmittedCount,p=e.mimeType,v=e.firCount,f=e.availableIncomingBitrate,_=e.availableOutgoingBitrate,y=e.bytesSent,g=e.nominated,S=e.id,E=e.currentRoundTripTime,k=e.state,T=e.writable,I=e.candidateType,R=e.ip,A=e.address,w=e.networkType,C=e.port,x=e.nackCount,O=e.pliCount,M=e.protocol,D=e.requestsReceived,P=e.responsesReceived,N=e.requestsSent,L=e.consentRequestsSent,U=e.responsesSent,V=e.ssrc,F=e.jitter,B=e.framesReceived,j=e.keyFramesDecoded,H=e.totalDecodeTime,G=e.decoderImplementation,z=e.lastPacketReceivedTimestamp,K=e.framesDropped;if("inbound-rtp"===t)d.packetsLost=i,m.packetsLost=i,d.packetsReceived=o,m.packetsReceived=o,d.bytesReceived=a,m.bytes=a,d.framesDecoded=s,d.totalDecodeTime=H,void 0!==c&&(d.jitterBufferDelay=c/l*1e3,m.average_jitter_buffer_delay_ms=d.jitterBufferDelay),m.fir_count=v,m.nackCount=x,d.nackCount=x,m.pli_count=O,m.ssrc=V,m.framesDropped=K,m.jitter=1e3*F,m.framesReceived=B,d.framesReceived=B,m.framesDecoded=s,m.key_frames_decoded=j,m.decoder_name=G,m.last_packet_received_timestamp=z,void 0!==n&&(u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r);else if("track"===t&&void 0!==n)u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r,void 0!==B&&(m.framesReceived=B,d.framesReceived=B);else if("codec"===t)m.codecName=p;else if("candidate-pair"===t){var X,W,q;m.ice_available_incoming_bitrate=f,m.ice_available_outgoing_bitrate=_,m.ice_bytes_received=a,m.ice_bytes_sent=y,m.ice_nominated=Number(g),m.ice_pair_id=S,m.ice_pair_rtt=E,m.rtt=1e3*E,m.rtt&&null!==(X=b._context)&&void 0!==X&&null!==(W=X.streamRTT)&&void 0!==W&&null!==(q=W[h])&&void 0!==q&&q.video&&(m.total_rtt_ms=Math.round(m.rtt+b._context.streamRTT[h].video)),u.rtt=m.rtt,m.ice_pair_state=k,m.ice_pair_writable=T,m.recv_ping_requests=D,m.recv_ping_responses=P,m.sent_ping_requests_before_first_response=N,m.sent_ping_requests_total=N+(L||0),m.sent_ping_responses=U}else"local-candidate"===t?(m.local_candidate_type=I,m.local_ip=R||A,m.local_network_type=w,m.local_port=C,m.protocol=M):"remote-candidate"===t&&(m.remote_candidate_type=I,m.remote_ip=R||A,m.remote_port=C)})),(g=r.video).timestamp){e.next=22;break}return r.video=d,e.abrupt("return",this.filterIllegal(u));case 22:return u.videoLossRate=(d.packetsLost-g.packetsLost)/(d.packetsReceived-g.packetsReceived+(d.packetsLost-g.packetsLost)),g.totalDecodeTime&&g.framesDecoded&&d.framesDecoded!==g.framesDecoded&&(m.decode_elapse_per_frame=Number(((d.totalDecodeTime-g.totalDecodeTime)/(d.framesDecoded-g.framesDecoded)*1e3).toFixed(2))),u._retransmittedRate=(d.nackCount-g.nackCount)/(d.packetsReceived-g.packetsReceived+(d.packetsLost-g.packetsLost)),u.videoLossRate=Number.isNaN(u.videoLossRate)?0:u.videoLossRate,m.fraction_lost=u.videoLossRate,u.statsInterval=d.timestamp-g.timestamp,m.stats_interval=u.statsInterval,u.receivedKBitrate=(d.bytesReceived-g.bytesReceived||0)/u.statsInterval*8,m.bitrate=Math.round(1e3*u.receivedKBitrate),m.bandwidth=Math.round(m.bitrate/1024),u.decoderOutputFrameRate=1e3*(d.framesDecoded-g.framesDecoded)/u.statsInterval,u.receivedFrameRate=1e3*(d.framesReceived-g.framesReceived)/u.statsInterval,m.frame_rate_decoded=Math.round(u.decoderOutputFrameRate),m.frame_rate_received=Math.round(u.receivedFrameRate),m.average_jitter_buffer_delay_ms&&m.total_rtt_ms&&(u.e2eDelay=m.average_jitter_buffer_delay_ms+m.total_rtt_ms),null!==(n=this._context)&&void 0!==n&&null!==(i=n.streamRTT)&&void 0!==i&&null!==(o=i[h])&&void 0!==o&&o.video&&(u.totalRtt=(m.rtt?m.rtt:0)+this._context.streamRTT[h].video),r.video=d,this.processStall(this._stream,m,u,v),this.isPaused?(S=d.timestamp-(this.pauseStart||0),m.pause_duration=this.pauseDuration+(S>500?S:0),this.pauseStart=d.timestamp):m.pause_duration=this.pauseDuration,m.pause_duration=Math.min(m.stall_duration||m.stuck_length||0,m.pause_duration),this.pauseDuration=0,m.vendor_mode=(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,m.pc_session_id=null===(s=this.handler)||void 0===s?void 0:s.peerConnectionId,null===(c=this._monitor)||void 0===c||c.report("rtc_media_statistics",m),e.abrupt("return",this.filterIllegal(u));case 47:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"processStall",value:function(e,t,r,n){var i=0,o=0,a=0;if(e.recordedVideoFrames&&this.player&&this.player.played){e.recordedVideoFrames.forEach((function(e){e.isStall&&(i+=e.stallCount,o+=e.stallDuration),a=e.playTime})),e.recordedVideoFrames.length||(o=2e3,i=this._videoInWaiting?0:1,this._videoInWaiting=!0);var s=e.recordedVideoFrames.pop();s&&(s.isStall?this._videoInWaiting=!0:this._videoInWaiting=!1),e.recordedVideoFrames=[]}t.stall_count=i,n?(t.stuck_length=Math.min(o,t.stats_interval),t.stall_duration=void 0):(t.stall_duration=Math.min(o,t.stats_interval),t.stuck_length=void 0),t.play_time=a,r.stallCount=i,r.stallDuration=o}},{key:"destroy",value:function(){OI(CI(o.prototype),"destroy",this).call(this),OI(CI(o.prototype),"stopReport",this).call(this,"destroy"),this._stopAudioStallTimer(),this._videoInWaiting=!1}}],[{key:"audioStallConfig",set:function(e){o.audioStallInterval=((null==e?void 0:e.audio_stall_interval)||200)/2,o.audioStallRatio=null==e?void 0:e.audio_stall_ratio}}]),o}(tF);Jd(nF,"audioStallInterval",void 0),Jd(nF,"audioStallRatio",void 0);var iF,oF,aF=new Nw("Stream",0),sF=function(e){DI(r,e);var t=QI(r);function r(e){var n;return Vl(this,r),Jd(tI(n=t.call(this)),"videoDom",void 0),Jd(tI(n),"audioMid",void 0),Jd(tI(n),"videoMid",void 0),Jd(tI(n),"videoTransceiver",void 0),Jd(tI(n),"audioTransceiver",void 0),Jd(tI(n),"vendorHandler",void 0),Jd(tI(n),"vendorCode",0),Jd(tI(n),"engineId",void 0),Jd(tI(n),"__seiHelper",$V),n._ctx=e,n.engineId=e.id,n}return Ul(r,[{key:"requestVideoFrameCallback",value:function(){var e=this;return new Y_((function(t){var r,n=null===(r=e.videoDom)||void 0===r?void 0:r.requestVideoFrameCallback;if("function"==typeof n){var i=function(e,r){var n={};an(r).forEach((function(e){var t=e.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return Om(t="".concat(e[0],"_")).call(t,e[1].toLowerCase())}));n["video_".concat(t)]=r[e]})),clearInterval(o),t(n)};n.call(e.videoDom,i);var o=setTimeout((function(){var r;null===(r=e.videoDom)||void 0===r||r.cancelVideoFrameCallback(i),t({})}),500)}else t({})}))}},{key:"stopReport",value:function(e){this.statsReport.stopReport(e)}},{key:"destroy",value:function(){var e,t;delete this.audioMid,delete this.videoMid,this.statsReport.destroy(),null===(e=this.observer)||void 0===e||e.reset(),delete this.videoTransceiver,delete this.audioTransceiver,null===(t=this.vendorHandler)||void 0===t||t.destroy(),this.vendorCode=0,delete this.vendorHandler}}]),r}(aP),cF=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(cF||{}),uF=function(e){DI(r,e);var t=QI(r);function r(e){var n;return Vl(this,r),Jd(tI(n=t.call(this,e)),"isScreen",!1),Jd(tI(n),"stream",void 0),Jd(tI(n),"streamId",void 0),Jd(tI(n),"seiList",[]),Jd(tI(n),"videoTrack",void 0),Jd(tI(n),"audioTrack",void 0),Jd(tI(n),"videoEncodeConfig",[DD]),Jd(tI(n),"subVideoDescriptions",[]),Jd(tI(n),"enableSimulcast",!1),Jd(tI(n),"observer",void 0),Jd(tI(n),"statsReport",void 0),Jd(tI(n),"prevBitrate",0),Jd(tI(n),"pubAudio",!1),Jd(tI(n),"pubVideo",!1),Jd(tI(n),"pubAttributes",void 0),Jd(tI(n),"pcSessionId",void 0),n.stream=new MediaStream,n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},n.statsReport=new rF(e,tI(n)),n}return Ul(r,[{key:"audioHasCapture",get:function(){return this.pubAttributes.localaudio}},{key:"audioHasPublish",get:function(){return this.pubAttributes.audiostream}},{key:"videoHasCapture",get:function(){return this.pubAttributes.localvideo}},{key:"videoHasPublish",get:function(){return this.pubAttributes.videostream}},{key:"hasPublished",get:function(){return!!this.audioMid&&!!this.videoMid}},{key:"isEmptyStream",get:function(){return!this.audioTrack&&!this.videoTrack}},{key:"initStreamId",get:function(){return this.stream.id}},{key:"startReport",value:function(e,t){this.statsReport.setLocalStreamStatsEvtInterval(e,t)}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add&&lL()){var r=t.createEncodedStreams(),n=r.readable,i=r.writable,o=new TransformStream({transform:function(t,r){var n=e.seiList[0];if(n){var i,o=$V.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)rk(i=e.seiList).call(i,0,1);n.repeatCount--,a.set(new Uint8Array(t.data)),a.set(o,t.data.byteLength),t.data=a.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else aF.warn("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender)if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add){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 aF.warn("initAudioEncodedTransform","legacy EncodedTransform is not supported");else aF.warn("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){jO(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),OI(CI(r.prototype),"destroy",this).call(this),this.prevBitrate=0,this.subVideoDescriptions=[]}},{key:"switchTrackEnableState",value:function(e,t){var r,n;"audio"===e?n=this.audioTrack:"video"===e&&(n=this.videoTrack);var i=null===(r=n)||void 0===r?void 0:r.getTrack();return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}}]),r}(sF),dF=function(e){DI(r,e);var t=QI(r);function r(e,n,i,o,a,s){var c;return Vl(this,r),Jd(tI(c=t.call(this,e)),"streamId",void 0),Jd(tI(c),"userId",void 0),Jd(tI(c),"isScreen",void 0),Jd(tI(c),"isPublic",void 0),Jd(tI(c),"hasVideo",void 0),Jd(tI(c),"hasAudio",void 0),Jd(tI(c),"_attributes",void 0),Jd(tI(c),"streamState",void 0),Jd(tI(c),"removeTrack",!1),Jd(tI(c),"observer",void 0),Jd(tI(c),"statsReport",void 0),Jd(tI(c),"subVideo",void 0),Jd(tI(c),"subAudio",void 0),Jd(tI(c),"subMediaType",void 0),Jd(tI(c),"subLayer",void 0),Jd(tI(c),"_sequenceId",void 0),Jd(tI(c),"stream",void 0),Jd(tI(c),"videoTrack",void 0),Jd(tI(c),"audioTrack",void 0),Jd(tI(c),"recordedVideoFrames",void 0),Jd(tI(c),"stillExist",void 0),Jd(tI(c),"originalMediaType",void 0),Jd(tI(c),"priority",void 0),Jd(tI(c),"originalStreamIndex",0),Jd(tI(c),"virtual",void 0),Jd(tI(c),"pcSessionId",void 0),Jd(tI(c),"_virtualOccupy",void 0),c.virtual=!1,c._virtualOccupy=!1,c.userId=n,c.isScreen=o,c.isPublic=a,c.streamId=i,c.hasAudio=s.audiostream&&s.localaudio,c.hasVideo=s.videostream&&s.localvideo,c._attributes=s,c.vendorCode=(null==s?void 0:s.vendorCode)||0,c.subVideo=!1,c.subAudio=!1,c._sequenceId=0,c.subMediaType=zV.NONE,c.subLayer={spatialLayer:0,spatialSubLayer:-1},c.streamState=0,c.statsReport=new nF(e,tI(c)),c.enableVendorMode&&(c.pcSessionId=_w()),c}return Ul(r,[{key:"vendor",get:function(){return this._attributes.vendorCode}},{key:"audioHasCapture",get:function(){return this._attributes.localaudio}},{key:"audioHasPublish",get:function(){return this._attributes.audiostream}},{key:"videoHasCapture",get:function(){return this._attributes.localvideo}},{key:"videoHasPublish",get:function(){return this._attributes.videostream}},{key:"sequenceId",get:function(){return this._sequenceId||-1},set:function(e){"number"==typeof e&&(this._sequenceId=e)}},{key:"enableVendorMode",get:function(){return"number"==typeof this.attributes.vendorCode&&0!==this.attributes.vendorCode}},{key:"hasSubscribed",get:function(){return 2===this.streamState}},{key:"attributes",get:function(){return this._attributes},set:function(e){this.hasVideo=e.localvideo&&e.videostream,this.hasAudio=e.localaudio&&e.audiostream,this._attributes=e,this.vendorCode=e.vendorCode||0}},{key:"virtualOccupy",get:function(){return this._virtualOccupy},set:function(e){var t;if(this._virtualOccupy&&!e)null===(t=this.observer)||void 0===t||t.setPushTrack(!1);else if(!this._virtualOccupy&&e){var r;null===(r=this.observer)||void 0===r||r.setPushTrack(!0)}this._virtualOccupy=e}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver)if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){KV.getNalunits(new XV(t.data)).forEach((function(t){if(t.sei){var r=$V.decodeSeiBody(t.body);r&&r.type!==WV.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else aF.warn("initAudioEncodedTransform","legacy EncodedTransform is not supported");else aF.warn("no receiver found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.receiver)if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add){var e=this.audioTransceiver.receiver.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){e.data.byteLength<=1e3?t.enqueue(e):aF.print("too large audio frame",e.data.byteLength)}})).pipeTo(r)}else aF.warn("legacy EncodedTransform is not supported");else aF.warn("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n,i,o,a;try{var s;jO(this.engineId,"Stream.ontrack",Nm({uid:this.userId,streamId:this.streamId,streams:pb(s=e.streams).call(s,(function(e,t){return e+(null==(r=t)?"undefined | null":"string"==typeof r?r:Nm({id:r.id,active:r.active}));var r}),""),transceiver:(i=e.transceiver,null==i?"undefined | null":"string"==typeof i?i:Nm({currentDirection:i.currentDirection,direction:i.direction,mid:i.mid,stopped:i.stopped,receiver:(a=i.receiver,null==a?"undefined | null":"string"==typeof a?a:Nm({track:MM(a.track)})),sender:(o=i.sender,null==o?"undefined | null":"string"==typeof o?o:Nm({track:MM(o.track)}))})),track:MM(e.track)}),0,this.streamId||"")}catch(uq){}if(this.enableVendorMode||null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&mk(n).call(n,this.streamId)){var c,u=e.track;"video"===(null==u?void 0:u.kind)?this._setVideoTrack(u):"audio"===(null===(c=e.track)||void 0===c?void 0:c.kind)&&this._setAudioTrack(u),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e,t;aF.info("clean",Om(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),jO(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),OI(CI(r.prototype),"destroy",this).call(this),this.subAudio=!1,this.subVideo=!1,this.sequenceId=0,this.videoTrack=void 0,null===(t=this.audioTrack)||void 0===t||t.close(),this.audioTrack=void 0,this.stream=void 0,this.recordedVideoFrames=void 0,delete this.priority}},{key:"destroy",value:function(){this.clean(),this.attributes={audiostream:!1,localaudio:!1,localvideo:!1,videostream:!1,extvideo:!1,extaudio:!1,videoDescriptions:[]}}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{key:"_setStream",value:function(e){var t=this;this.stream=e,e.onaddtrack=function(e){"video"===e.track.kind?t._setVideoTrack(e.track):"audio"===e.track.kind&&t._setAudioTrack(e.track)}}},{key:"_setAudioTrack",value:function(e){var t,r;(null===(t=this.audioTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.audioTrack=DV(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]:dM();return new pV(e,t)}(e),this.emit("ontrack",this.videoTrack))}}]),r}(sF),lF=new Nw("queue",4),hF=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(hF||{}),pF=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(pF||{}),vF=(Jd(iF={},"publish","unpublish"),Jd(iF,"subscribe","unsubscribe"),Jd(iF,"pushtrack","removetrack"),iF),fF=(Jd(oF={},"publish",0),Jd(oF,"subscribe",0),Jd(oF,"pushtrack",0),Jd(oF,"unpublish",1),Jd(oF,"unsubscribe",1),Jd(oF,"removetrack",1),oF),_F=function(e){DI(r,e);var t=QI(r);function r(){var e;return Vl(this,r),Jd(tI(e=t.call(this)),"_queue",void 0),e._queue=[],e}return Ul(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t,r=this._queue.length,n="";return this._queue=Hs(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==vF[t.action]||(n=t.streamId,lF.info("offsetStreamId",n),!1)})),this._queue.length===r&&this._queue.push(e),this.emit("start"),n}},{key:"dequeue",value:function(){var e;if(!this._queue.length)return null;var t=this._queue.length;XM&&pD>=86&&pD<=92&&(t=Math.min(this._queue.length,5));for(var r=fF[this._queue[0].action],n=1;n<t;n++){var i;if(fF[this._queue[n].action]!==r)return{sdpStrategy:r,items:rk(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:rk(e=this._queue).call(e,0,t)}}}]),r}(iP),mF="object"==typeof global&&global&&global.Object===Object&&global,yF="object"==typeof self&&self&&self.Object===Object&&self,gF=mF||yF||Function("return this")(),SF=gF.Symbol,bF=Object.prototype,EF=bF.hasOwnProperty,kF=bF.toString,TF=SF?SF.toStringTag:void 0;var IF=Object.prototype.toString;var RF=SF?SF.toStringTag:void 0;function AF(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":RF&&RF 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 OF(e){return e}function MF(e){if(!xF(e))return!1;var t=AF(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var DF,PF=gF["__core-js_shared__"],NF=(DF=/[^.]+$/.exec(PF&&PF.keys&&PF.keys.IE_PROTO||""))?"Symbol(src)_1."+DF:"";var LF=Function.prototype.toString;function UF(e){if(null!=e){try{return LF.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var VF=/^\[object .+?Constructor\]$/,FF=Function.prototype,BF=Object.prototype,jF=FF.toString,HF=BF.hasOwnProperty,GF=RegExp("^"+jF.call(HF).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function zF(e){return!(!xF(e)||(t=e,NF&&NF in t))&&(MF(e)?GF:VF).test(UF(e));var t}function KF(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return zF(r)?r:void 0}var XF=KF(gF,"WeakMap"),WF=Object.create,qF=function(){function e(){}return function(t){if(!xF(t))return{};if(WF)return WF(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();function YF(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 JF=Date.now;var QF,ZF,$F,eB=function(){try{var e=KF(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),tB=eB,rB=tB?function(e,t){return tB(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:OF,nB=(QF=rB,ZF=0,$F=0,function(){var e=JF(),t=16-(e-$F);if($F=e,t>0){if(++ZF>=800)return arguments[0]}else ZF=0;return QF.apply(void 0,arguments)}),iB=nB;var oB=/^(?:0|[1-9]\d*)$/;function aB(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&oB.test(e))&&e>-1&&e%1==0&&e<t}function sB(e,t,r){"__proto__"==t&&tB?tB(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function cB(e,t){return e===t||e!=e&&t!=t}var uB=Object.prototype.hasOwnProperty;function dB(e,t,r){var n=e[t];uB.call(e,t)&&cB(n,r)&&(void 0!==r||t in e)||sB(e,t,r)}function lB(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?sB(r,s,c):dB(r,s,c)}return r}var hB=Math.max;function pB(e,t){return iB(function(e,t,r){return t=hB(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=hB(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),YF(e,this,s)}}(e,t,OF),e+"")}function vB(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function fB(e){return null!=e&&vB(e.length)&&!MF(e)}var _B=Object.prototype;function mB(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||_B)}function yB(e){return wF(e)&&"[object Arguments]"==AF(e)}var gB=Object.prototype,SB=gB.hasOwnProperty,bB=gB.propertyIsEnumerable,EB=yB(function(){return arguments}())?yB:function(e){return wF(e)&&SB.call(e,"callee")&&!bB.call(e,"callee")},kB=EB;var TB="object"==typeof exports&&exports&&!exports.nodeType&&exports,IB=TB&&"object"==typeof module&&module&&!module.nodeType&&module,RB=IB&&IB.exports===TB?gF.Buffer:void 0,AB=(RB?RB.isBuffer:void 0)||function(){return!1},wB={};function CB(e){return function(t){return e(t)}}wB["[object Float32Array]"]=wB["[object Float64Array]"]=wB["[object Int8Array]"]=wB["[object Int16Array]"]=wB["[object Int32Array]"]=wB["[object Uint8Array]"]=wB["[object Uint8ClampedArray]"]=wB["[object Uint16Array]"]=wB["[object Uint32Array]"]=!0,wB["[object Arguments]"]=wB["[object Array]"]=wB["[object ArrayBuffer]"]=wB["[object Boolean]"]=wB["[object DataView]"]=wB["[object Date]"]=wB["[object Error]"]=wB["[object Function]"]=wB["[object Map]"]=wB["[object Number]"]=wB["[object Object]"]=wB["[object RegExp]"]=wB["[object Set]"]=wB["[object String]"]=wB["[object WeakMap]"]=!1;var xB="object"==typeof exports&&exports&&!exports.nodeType&&exports,OB=xB&&"object"==typeof module&&module&&!module.nodeType&&module,MB=OB&&OB.exports===xB&&mF.process,DB=function(){try{var e=OB&&OB.require&&OB.require("util").types;return e||MB&&MB.binding&&MB.binding("util")}catch(t){}}(),PB=DB&&DB.isTypedArray,NB=PB?CB(PB):function(e){return wF(e)&&vB(e.length)&&!!wB[AF(e)]},LB=Object.prototype.hasOwnProperty;function UB(e,t){var r=CF(e),n=!r&&kB(e),i=!r&&!n&&AB(e),o=!r&&!n&&!i&&NB(e),a=r||n||i||o,s=a?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=s.length;for(var u in e)!t&&!LB.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||aB(u,c))||s.push(u);return s}function VB(e,t){return function(r){return e(t(r))}}var FB=VB(Object.keys,Object),BB=Object.prototype.hasOwnProperty;function jB(e){return fB(e)?UB(e):function(e){if(!mB(e))return FB(e);var t=[];for(var r in Object(e))BB.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var HB=Object.prototype.hasOwnProperty;function GB(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=mB(e),r=[];for(var n in e)("constructor"!=n||!t&&HB.call(e,n))&&r.push(n);return r}function zB(e){return fB(e)?UB(e,!0):GB(e)}var KB,XB=(KB=function(e,t){lB(t,zB(t),e)},pB((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=KB.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?fB(r)&&aB(t,r.length):"string"==n&&t in r)&&cB(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&&KB(e,a,r,i)}return e}))),WB=KF(Object,"create");var qB=Object.prototype.hasOwnProperty;var YB=Object.prototype.hasOwnProperty;function JB(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function QB(e,t){for(var r=e.length;r--;)if(cB(e[r][0],t))return r;return-1}JB.prototype.clear=function(){this.__data__=WB?WB(null):{},this.size=0},JB.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},JB.prototype.get=function(e){var t=this.__data__;if(WB){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return qB.call(t,e)?t[e]:void 0},JB.prototype.has=function(e){var t=this.__data__;return WB?void 0!==t[e]:YB.call(t,e)},JB.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=WB&&void 0===t?"__lodash_hash_undefined__":t,this};var ZB=Array.prototype.splice;function $B(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}$B.prototype.clear=function(){this.__data__=[],this.size=0},$B.prototype.delete=function(e){var t=this.__data__,r=QB(t,e);return!(r<0)&&(r==t.length-1?t.pop():ZB.call(t,r,1),--this.size,!0)},$B.prototype.get=function(e){var t=this.__data__,r=QB(t,e);return r<0?void 0:t[r][1]},$B.prototype.has=function(e){return QB(this.__data__,e)>-1},$B.prototype.set=function(e,t){var r=this.__data__,n=QB(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var ej=KF(gF,"Map");function tj(e,t){var r,n,i=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof t?"string":"hash"]:i.map}function rj(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function nj(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}rj.prototype.clear=function(){this.size=0,this.__data__={hash:new JB,map:new(ej||$B),string:new JB}},rj.prototype.delete=function(e){var t=tj(this,e).delete(e);return this.size-=t?1:0,t},rj.prototype.get=function(e){return tj(this,e).get(e)},rj.prototype.has=function(e){return tj(this,e).has(e)},rj.prototype.set=function(e,t){var r=tj(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};var ij=VB(Object.getPrototypeOf,Object);function oj(e){var t=this.__data__=new $B(e);this.size=t.size}oj.prototype.clear=function(){this.__data__=new $B,this.size=0},oj.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},oj.prototype.get=function(e){return this.__data__.get(e)},oj.prototype.has=function(e){return this.__data__.has(e)},oj.prototype.set=function(e,t){var r=this.__data__;if(r instanceof $B){var n=r.__data__;if(!ej||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new rj(n)}return r.set(e,t),this.size=r.size,this};var aj="object"==typeof exports&&exports&&!exports.nodeType&&exports,sj=aj&&"object"==typeof module&&module&&!module.nodeType&&module,cj=sj&&sj.exports===aj?gF.Buffer:void 0,uj=cj?cj.allocUnsafe:void 0;function dj(){return[]}var lj=Object.prototype.propertyIsEnumerable,hj=Object.getOwnPropertySymbols,pj=hj?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,o=[];++r<n;){var a=e[r];t(a,r,e)&&(o[i++]=a)}return o}(hj(e),(function(t){return lj.call(e,t)})))}:dj;var vj=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)nj(t,pj(e)),e=ij(e);return t}:dj;function fj(e,t,r){var n=t(e);return CF(e)?n:nj(n,r(e))}function _j(e){return fj(e,jB,pj)}function mj(e){return fj(e,zB,vj)}var yj=KF(gF,"DataView"),gj=KF(gF,"Promise"),Sj=KF(gF,"Set"),bj="[object Map]",Ej="[object Promise]",kj="[object Set]",Tj="[object WeakMap]",Ij="[object DataView]",Rj=UF(yj),Aj=UF(ej),wj=UF(gj),Cj=UF(Sj),xj=UF(XF),Oj=AF;(yj&&Oj(new yj(new ArrayBuffer(1)))!=Ij||ej&&Oj(new ej)!=bj||gj&&Oj(gj.resolve())!=Ej||Sj&&Oj(new Sj)!=kj||XF&&Oj(new XF)!=Tj)&&(Oj=function(e){var t=AF(e),r="[object Object]"==t?e.constructor:void 0,n=r?UF(r):"";if(n)switch(n){case Rj:return Ij;case Aj:return bj;case wj:return Ej;case Cj:return kj;case xj:return Tj}return t});var Mj=Oj,Dj=Object.prototype.hasOwnProperty;var Pj=gF.Uint8Array;function Nj(e){var t=new e.constructor(e.byteLength);return new Pj(t).set(new Pj(e)),t}var Lj=/\w*$/;var Uj=SF?SF.prototype:void 0,Vj=Uj?Uj.valueOf:void 0;function Fj(e,t,r){var n,i,o,a=e.constructor;switch(t){case"[object ArrayBuffer]":return Nj(e);case"[object Boolean]":case"[object Date]":return new a(+e);case"[object DataView]":return function(e,t){var r=t?Nj(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(e,t){var r=t?Nj(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,r);case"[object Map]":case"[object Set]":return new a;case"[object Number]":case"[object String]":return new a(e);case"[object RegExp]":return(o=new(i=e).constructor(i.source,Lj.exec(i))).lastIndex=i.lastIndex,o;case"[object Symbol]":return n=e,Vj?Object(Vj.call(n)):{}}}var Bj=DB&&DB.isMap,jj=Bj?CB(Bj):function(e){return wF(e)&&"[object Map]"==Mj(e)};var Hj=DB&&DB.isSet,Gj=Hj?CB(Hj):function(e){return wF(e)&&"[object Set]"==Mj(e)},zj="[object Arguments]",Kj="[object Function]",Xj="[object Object]",Wj={};function qj(e,t,r,n,i,o){var a,s=1&t,c=2&t,u=4&t;if(r&&(a=i?r(e,n,i,o):r(e)),void 0!==a)return a;if(!xF(e))return e;var d=CF(e);if(d){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&Dj.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!s)return function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}(e,a)}else{var l=Mj(e),h=l==Kj||"[object GeneratorFunction]"==l;if(AB(e))return function(e,t){if(t)return e.slice();var r=e.length,n=uj?uj(r):new e.constructor(r);return e.copy(n),n}(e,s);if(l==Xj||l==zj||h&&!i){if(a=c||h?{}:function(e){return"function"!=typeof e.constructor||mB(e)?{}:qF(ij(e))}(e),!s)return c?function(e,t){return lB(e,vj(e),t)}(e,function(e,t){return e&&lB(t,zB(t),e)}(a,e)):function(e,t){return lB(e,pj(e),t)}(e,function(e,t){return e&&lB(t,jB(t),e)}(a,e))}else{if(!Wj[l])return i?e:{};a=Fj(e,l,s)}}o||(o=new oj);var p=o.get(e);if(p)return p;o.set(e,a),Gj(e)?e.forEach((function(n){a.add(qj(n,t,r,n,e,o))})):jj(e)&&e.forEach((function(n,i){a.set(i,qj(n,t,r,i,e,o))}));var v=d?void 0:(u?c?mj:_j:c?zB:jB)(e);return function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););}(v||e,(function(n,i){v&&(n=e[i=n]),dB(a,i,qj(n,t,r,i,e,o))})),a}Wj[zj]=Wj["[object Array]"]=Wj["[object ArrayBuffer]"]=Wj["[object DataView]"]=Wj["[object Boolean]"]=Wj["[object Date]"]=Wj["[object Float32Array]"]=Wj["[object Float64Array]"]=Wj["[object Int8Array]"]=Wj["[object Int16Array]"]=Wj["[object Int32Array]"]=Wj["[object Map]"]=Wj["[object Number]"]=Wj[Xj]=Wj["[object RegExp]"]=Wj["[object Set]"]=Wj["[object String]"]=Wj["[object Symbol]"]=Wj["[object Uint8Array]"]=Wj["[object Uint8ClampedArray]"]=Wj["[object Uint16Array]"]=Wj["[object Uint32Array]"]=!0,Wj["[object Error]"]=Wj[Kj]=Wj["[object WeakMap]"]=!1;function Yj(e){return qj(e,5)}function Jj(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 Qj(e){return null==e?[]:Jj(e,jB(e))}var Zj=new Nw("ChromeHandler",3),$j=lL(),eH=function(e){DI(u,e);var t,r,n,i,o,a,s,c=QI(u);function u(e,t){var r;return Vl(this,u),Jd(tI(r=c.call(this,e,t)),"name","chrome"),Jd(tI(r),"_queueBusy",!1),Jd(tI(r),"_sdpQueue",void 0),Jd(tI(r),"_aSendonlyOfferTpl",void 0),Jd(tI(r),"_vSendonlyOfferTpl",void 0),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),Jd(tI(r),"_vRecvonlyOfferTpl",void 0),Jd(tI(r),"_mid",10),Jd(tI(r),"_inactiveMlineIndex",[]),Jd(tI(r),"_mlinesCache",{}),Jd(tI(r),"setDescription",void 0),r.setDescription=t.setDescription.bind(t),r._sdpQueue=new _F,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(Zj.info("dequeue start"),r.dequeue())})),r}return Ul(u,[{key:"destroy",value:function(){OI(CI(u.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(s=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D,P,N,L,U,V,F;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d=t.stream,l=t.enableSimulcast,h=OI(CI(u.prototype),"internalPublish",this).call(this,t),p=h.videoDescriptions,v=h.subVideoDescriptions,f=h.audioTransceiverInit,_=h.videoTransceiverInit,m=WL(this._nextSsrc),this._nextSsrc=m.next,y="".concat(this._mid++),g="".concat(this._mid++),S=Zd(Zd(Zd({},this._aSendonlyOfferTpl),this.peer._offerIce),{},{mid:y,msid:Om(r="".concat(d.id," ")).call(r,d.id,"-audio"),ssrcs:qL(d.id,"audio",m.audio,KL)}),b=Zd(Zd(Zd({},this._vSendonlyOfferTpl),this.peer._offerIce),{},{mid:g,msid:Om(n="".concat(d.id," ")).call(n,d.id,"-video")}),l?(Zj.info("subVideoDesc","desc: %o ",v),delete b.ssrcGroups,delete b.ssrcs,E=[],b.rids=jm(p).call(p,(function(e){var t=e.rid;return E.unshift(t),{id:t,direction:"send"}})),b.simulcast={dir1:"send",list1:E.join(";")}):(k=YL(d.id,m,{cname:KL}),T=k.ssrcs,I=k.ssrcGroups,b.ssrcs=T,b.ssrcGroups=I),null!==(i=this._context)&&void 0!==i&&null!==(o=i.serverConfig)&&void 0!==o&&o.audioRed&&Array.isArray(S.rtp)&&(-1!==(A=QR(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(C=rk(w=S.rtp).call(w,A,1),x=eI(C,1),O=x[0],S.rtp.unshift(O)),M=[],S.rtp.forEach((function(e){return M.push(e.payload)})),S.payloads=M.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&iU(b,null===(D=this._context)||void 0===D||null===(P=D.serverConfig)||void 0===P?void 0:P.videoCodec),!OD("IOS_SAFARI_ORIENTATION")&&(KM||rD)&&Array.isArray(b.ext)&&(b.ext=Hs(N=b.ext).call(N,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&mk(t).call(t,"video-orientation"))}))),(L=null==S?void 0:gE(c=S.rtp).call(c,(function(e){return"opus"===e.codec})))&&S.fmtp&&(F=gE(U=S.fmtp).call(U,(function(e){return e.payload===L.payload})))&&null!==(V=this._context)&&void 0!==V&&V.audioProfileManager&&(F.config=this._context.audioProfileManager.getOpusConfigStr(F.config)),l||KM||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:QL(this.peer._offerSession,S,b),audioMid:y,videoMid:g,type:"incroffer",semantics:"unified-plan",videoDescriptions:p,subVideoDescriptions:v,audioTransceiverInit:f,videoTransceiverInit:_,peerConnectionMode:this.peerConnectionMode});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"subscribe",value:(a=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D,P,N,L,U,V=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Zj.info("subscribe"),a="incroffer",s="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return c=e.sent,e.next=9,this.createAVMlineOfferTpl(c);case 9:if(u="",d="",l=!1,h=!1,p=void 0,v=void 0,this._mlinesCache[t.streamId]=[p,v],t.virtual?(u="".concat(this._mid++),l=!0):r.multiChatMode?(u="".concat(this._mid++),d="".concat(this._mid++),h=!0):(l=!0,h=!0,u="".concat(this._mid++),d="".concat(this._mid++)),u&&(p=Zd(Zd({},Yj(this._aRecvonlyOfferTpl)),{},{mid:u})),l&&(this._mlinesCache[t.streamId][0]=p,f={track:"audio",init:{direction:"recvonly"}}),d&&(v=Zd(Zd({},Yj(this._vRecvonlyOfferTpl)),{},{mid:d})),h&&(this._mlinesCache[t.streamId][1]=v,_={track:"video",init:{direction:"recvonly"}}),m=QL(this.peer._offerSession,p,v),y=void 0,t.enableVendorMode||r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl){e.next=32;break}return y=WL(this._nextSsrc),this._nextSsrc=y.next,R=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Om(g=Om(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(g,t.streamId,"-audio"),ssrcs:qL(t.streamId,"audio",y.audio)}),A=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:d,msid:Om(E=Om(k="".concat(t.streamId)).call(k,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},YL(t.streamId,y,{flexfec:this._enableSubFlexfec})),w=new Y_((function(e){V._sdpQueue.enqueue({action:pF.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:f,videoTransceiverInit:_,signalingAck:{sdp:EL.write(Zd(Zd({},V.peer._answerSession),{},{media:[R,A]})),sequenceId:t.sequenceId?++t.sequenceId:0},stream:t,sdp:m,onSuccess:function(){Zj.info("subscribe()","sub success"),e(0)}})})),e.next=31,w;case 31:null===(I=y)||void 0===I||delete I.next;case 32:return(C=null===(n=p)||void 0===n?void 0:gE(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=p)&&void 0!==o&&o.fmtp&&(M=null===(x=p)||void 0===x?void 0:gE(O=x.fmtp).call(O,(function(e){return e.payload===C.payload})))&&this._context&&(M.config+=";stereo=1;sprop-stereo=1"),t.isPublic&&pD>=86&&null!=(L=null===(D=v)||void 0===D?void 0:Hs(P=D.rtp).call(P,(function(e){return"H264"===e.codec})))&&L.length&&null!==(N=v)&&void 0!==N&&N.fmtp&&(null===(U=v)||void 0===U||U.fmtp.forEach((function(e){gE(L).call(L,(function(t){return t.payload===e.payload}))&&(e.config+=";sps-pps-idr-in-keyframe=1")}))),e.abrupt("return",{partialSdp:m,audioMid:u,videoMid:d,type:a,semantics:s,audioTransceiverInit:f,videoTransceiverInit:_,allSsrc:y,peerConnectionMode:this.peerConnectionMode});case 36:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handleAck",value:(o=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Zj.info("handleAck()","item: %o",t),!t.generatorSsrc){e.next=4;break}return Zj.warn("already set remote"),e.abrupt("return","");case 4:return e.abrupt("return",this._sdpQueue.enqueue(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"dequeue",value:(i=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),Zj.info("dequeue()","ret: %o",t),t){e.next=6;break}return this._queueBusy=!1,e.abrupt("return");case 6:if(e.prev=6,r=t.items,n=t.sdpStrategy,i=[],o=[],a=[],n!==hF.ADD){e.next=15;break}return e.delegateYield(Tm().mark((function e(){var t,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=Zd({},_.peer._answerIce)).candidates,s=!1,c=!1,e.prev=4,d=mP(r);case 6:return e.next=8,d.next();case 8:if(!(s=!(l=e.sent).done)){e.next=16;break}if(n=l.value,"break"!==function(){var e=n.audioMid,r=n.videoMid,s=n.action,c=n.audioTransceiverInit,u=n.videoTransceiverInit,d=n.signalingAck,l=n.stream,h=l instanceof dF;if(n.onSuccess&&a.push(n.onSuccess),h&&(null==d?void 0:d.sequenceId)<l.sequenceId)return"break";var p,v={},f={},m=EL.parse(d.sdp);Array.isArray(m.media)&&HR(p=m.media).call(p,(function(e,t){var r;return null==e||null===(r=e.type)||void 0===r?void 0:r.localeCompare(null==t?void 0:t.type)})).forEach((function(n){"audio"===(n=Zd(Zd({},n),t)).type?(v=n).mid=e:(f=n).mid=r}));var y,g=l.streamId;if(s===pF.publish&&(g=null===(y=l.stream)||void 0===y?void 0:y.id),!_._mlinesCache[g])return"break";var S=eI(_._mlinesCache[g],2),b=S[0],E=S[1];if(c&&b){l.audioTransceiver=_._peerConnection.addTransceiver(c.track,c.init),_._reportRtcInvokeStatus("chromeHandler.addTrack",Nm({audioStreamTrack:MM(c.track)}));var k=_._inactiveMlineIndex.shift();k||(k=_.peer._offerMlines.length),_.peer._offerMlines[k]=Zd({},b),_.peer._answerMlines[k]=v,$j&&l.initAudioEncodedTransform()}if(u&&E){var T,I;l.videoTransceiver=_._peerConnection.addTransceiver(u.track,u.init),_._reportRtcInvokeStatus("chromeHandler.addTrack",Nm({videoStreamTrack:MM(u.track)}));var R,A,w=_._inactiveMlineIndex.shift();w||(w=_.peer._offerMlines.length),_.peer._offerMlines[w]=Zd({},E),s===pF.publish&&null!==(T=_._context)&&void 0!==T&&null!==(I=T.serverConfig)&&void 0!==I&&I.videoCodec&&iU(f,null===(R=_._context)||void 0===R||null===(A=R.serverConfig)||void 0===A?void 0:A.videoCodec),_.peer._answerMlines[w]=f,$j&&l.initVideoEncodedTransform()}i.push(l.streamId||""),o.push(h?l.userId:"local"),h&&(l.sequenceId=null==d?void 0:d.sequenceId),delete _._mlinesCache[g]}()){e.next=13;break}return e.abrupt("break",16);case 13:s=!1,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),c=!0,u=e.t0;case 22:if(e.prev=22,e.prev=23,!s||null==d.return){e.next=27;break}return e.next=27,d.return();case 27:if(e.prev=27,!c){e.next=30;break}throw u;case 30:return e.finish(27);case 31:return e.finish(22);case 32:case"end":return e.stop()}}),e,null,[[4,18,22,32],[23,,27,31]])}))(),"t0",13);case 13:e.next=20;break;case 15:f={},r.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;f[t]=t,n!==pF.removetrack&&(f[r]=r),f[t]=t})),this.peer._offerMlines=jm(h=this.peer._offerMlines).call(h,(function(e,t){return f[e.mid]&&(e=JL(e),_._inactiveMlineIndex.push(t)),e})),HR(p=this._inactiveMlineIndex).call(p,(function(e,t){return e-t})),this.peer._answerMlines=jm(v=this.peer._answerMlines).call(v,(function(e){return f[e.mid]&&(e=JL(e)),e}));case 20:return e.next=22,this.peer.getOriginRTCPeerConnection().createOffer();case 22:return e.next=24,this.setDescription(i.length?{streamId:i.join(","),streamUserId:o.join(",")}:void 0);case 24:try{a.forEach((function(e){return e()}))}catch(uq){}Zj.info("dequeue","loop"),e.next=31;break;case 28:e.prev=28,e.t1=e.catch(6),Zj.error("dequeue","unknown error: %o",e.t1);case 31:return e.prev=31,this.dequeue(),e.finish(31);case 34:case"end":return e.stop()}}),e,this,[[6,28,31,34]])}))),function(){return i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._genOfferSdp();case 2:return r=e.sent,this.createAVMlineOfferTpl(r),n=EL.parse(r),i=[],n.media=Hs(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=Hs(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),i.push("".concat(e.mid)),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:EL.write(n),semantics:"unified-plan",type:"incroffer"});case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"rollback",value:(r=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete this._mlinesCache[t];case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;EL.parse(e).media.forEach((function(e){if(e.icePwd=t.peer._offerIce.icePwd,e.iceUfrag=t.peer._offerIce.iceUfrag,"audio"===e.type)if("sendonly"===e.direction)t._aSendonlyOfferTpl=e;else{var r;if(Array.isArray(e.ext))e.ext=Hs(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=Hs(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}}))}},{key:"_genOfferSdp",value:(t=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,IM(!0);case 3:if(t=e.sent){e.next=6;break}throw"pc.createOffer() return empty.";case 6:e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),r="Get offer Error. ".concat(e.t0.message|e.t0),new mA(pA.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return t.apply(this,arguments)})}]),u}(aU),tH=new Nw("FirefoxHandler",3),rH=function(e){DI(d,e);var t,r,n,i,o,a,s,c,u=QI(d);function d(){var e,t;Vl(this,d);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return Jd(tI(t=u.call.apply(u,Om(e=[this]).call(e,n))),"name","firefox"),Jd(tI(t),"_aRecvonlyOfferTpl",void 0),t}return Ul(d,[{key:"publish",value:(c=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,f,_,m=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=OI(CI(d.prototype),"internalPublish",this).call(this,t),o=i.videoDescriptions,a=i.subVideoDescriptions,s=i.audioTransceiverInit,c=i.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(s.track,s.init),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),u=lM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=7,this._peerConnection.createOffer();case 7:return l=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:lM()-u}),(h=EL.parse(l.sdp)).media=null===(r=h.media)||void 0===r?void 0:jm(r).call(r,(function(e){return Zd(Zd({},e),m.peer._offerIce)})),e.next=13,this.setLocalDescription(EL.write(h));case 13:return p=t.audioTransceiver.mid,v=t.videoTransceiver.mid,f=null,_=null,h.media=null===(n=h.media)||void 0===n?void 0:jm(n).call(n,(function(e){if("".concat(e.mid)===p){var t,r,n=null===(t=f=e)||void 0===t?void 0:gE(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&f.fmtp){var i,o,a=gE(i=f.fmtp).call(i,(function(e){return e.payload===n.payload}));a&&null!==(o=m._context)&&void 0!==o&&o.audioProfileManager&&(a.config=m._context.audioProfileManager.getOpusConfigStr(a.config))}}else if("".concat(e.mid)===v){var s,c,u,d;null!==(s=m._context)&&void 0!==s&&null!==(c=s.serverConfig)&&void 0!==c&&c.videoCodec&&iU(e,null===(u=m._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec),_=e}return e})),this.addBitrateLimit(_,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(EL.write(h));case 21:return e.abrupt("return",{partialSdp:QL(h,f,_,!1),audioMid:p,videoMid:v,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:c,peerConnectionMode:this.peerConnectionMode});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tH.info("subscribe()"),c="",u="",d=!1,l=!1,h=void 0,p=void 0,t.virtual?d=!0:(r.multiChatMode||(d=!0),l=!0),d&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),l&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),v=lM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return f=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:lM()-v}),(_=EL.parse(f.sdp)).media=null===(n=_.media)||void 0===n?void 0:jm(n).call(n,(function(e){return Zd(Zd({},e),A.peer._offerIce)})),jm(i=_.media).call(i,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=21,this.setLocalDescription(EL.write(_),{streamId:t.streamId||"",streamUserId:t.userId});case 21:if(c=null===(o=t.audioTransceiver)||void 0===o?void 0:o.mid,u=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid,null===(s=_.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===c?h=e:"".concat(e.mid)===u&&(p=e)})),c&&h||(c="audio_".concat(u),h=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:c})),t.audioMid=c,t.videoMid=u,m=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=36;break}return m=WL(this._nextSsrc),this._nextSsrc=m.next,I=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:c,msid:Om(y=Om(g="".concat(t.streamId)).call(g,null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:qL(t.streamId,"audio",m.audio)}),R=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Om(b=Om(E="".concat(t.streamId)).call(E,null!==(k=this._context)&&void 0!==k&&k.avSync?"":"-video"," ")).call(b,t.streamId,"-video")},YL(t.streamId,m,{flexfec:this._enableSubFlexfec})),e.next=35,this._internalSetRemoteDescription([I,R],t);case 35:null===(T=m)||void 0===T||delete T.next;case 36:return e.abrupt("return",{partialSdp:QL(_,h,p,!1),audioMid:c,videoMid:u,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:m,peerConnectionMode:this.peerConnectionMode});case 37:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==pF.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==pF.unpublish&&i!==pF.unsubscribe){e.next=7;break}return e.next=6,this.close(n);case 6:return e.abrupt("return",n.streamId||"");case 7:if(!t.generatorSsrc){e.next=10;break}return tH.warn("already set remote"),e.abrupt("return","");case 10:return o=EL.parse(null==r?void 0:r.sdp),e.next=13,this._internalSetRemoteDescription(o.media,n);case 13:return e.abrupt("return","");case 14:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=EL.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){if("audio"===(e=Zd(Zd({},e),l.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type){if(r instanceof uF&&uD<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=Hs(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=Hs(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=Hs(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=Hs(o=e.fmtp).call(o,(function(e){return!a[e.payload]})))}r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e}})),u=EL.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=jm(o=u.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,jm(a=c.media).call(a,(function(e){var t,r,n;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type})),uD>=138&&(e.ext=null===(n=e.ext)||void 0===n?void 0:Hs(n).call(n,(function(e){var t;return!mk(t=e.uri).call(t,"sdes:mid")}))))})),e.next=11,this.setRemoteDescription(EL.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=EL.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Hs(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:EL.write(i),semantics:"unified-plan",type:"incroffer"});case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tH.warn("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tH.info("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=EL.parse(null==c?void 0:c.sdp)).media=jm(n=u.media).call(n,(function(e){return a[e.mid]&&(e=JL(e)),"inactive"!==e.direction&&s.push(e.mid),Zd(Zd({},e),h.peer._offerIce)})),d=EL.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=jm(o=u.media).call(o,(function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(EL.write(u));case 17:return e.next=19,this.setRemoteDescription(EL.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;EL.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(aU),nH=new Nw("FallbackHandler",3),iH=function(e){DI(d,e);var t,r,n,i,o,a,s,c,u=QI(d);function d(e,t){var r;return Vl(this,d),Jd(tI(r=u.call(this,e,t)),"name","fallback"),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),nH.warn("ctor","using fallback handler"),r._report("rtc_error",{message:"using fallback handler",error_code:-1}),r}return Ul(d,[{key:"publish",value:(c=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,f;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=OI(CI(d.prototype),"internalPublish",this).call(this,t),i=n.videoDescriptions,o=n.subVideoDescriptions,a=n.audioTransceiverInit,s=n.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(a.track,a.init),t.videoTransceiver=this._peerConnection.addTransceiver(s.track,s.init),c=lM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=7,this._peerConnection.createOffer();case 7:return u=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:lM()-c}),l=EL.parse(u.sdp),e.next=12,this.setLocalDescription(u.sdp);case 12:return h=t.audioTransceiver.mid,p=t.videoTransceiver.mid,v=null,f=null,l.media=null===(r=l.media)||void 0===r?void 0:jm(r).call(r,(function(e){return"".concat(e.mid)===h?v=e:"".concat(e.mid)===p&&(f=e),e})),lL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:QL(l,v,f,!1),audioMid:h,videoMid:p,type:"incroffer",semantics:"unified-plan",videoDescriptions:i,subVideoDescriptions:o,audioTransceiverInit:a,videoTransceiverInit:s,peerConnectionMode:this.peerConnectionMode});case 19:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nH.info("subscribe()"),a="",s="",c=!1,u=!1,d=void 0,l=void 0,t.virtual?c=!0:(r.multiChatMode||(c=!0),u=!0),c&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),u&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),h=lM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return p=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:lM()-h}),v=EL.parse(p.sdp),e.next=19,this.setLocalDescription(p.sdp,{streamId:t.streamId||"",streamUserId:t.userId});case 19:if(a=null===(n=t.audioTransceiver)||void 0===n?void 0:n.mid,s=null===(i=t.videoTransceiver)||void 0===i?void 0:i.mid,null===(o=v.media)||void 0===o||o.forEach((function(e){"".concat(e.mid)===a?d=e:"".concat(e.mid)===s&&(l=e)})),a&&d||(a="audio_".concat(s),d=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:a})),t.audioMid=a,t.videoMid=s,f=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=34;break}return f=WL(this._nextSsrc),this._nextSsrc=f.next,k=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:a,msid:Om(_=Om(m="".concat(t.streamId)).call(m,null!==(y=this._context)&&void 0!==y&&y.avSync?"":"-audio"," ")).call(_,t.streamId,"-audio"),ssrcs:qL(t.streamId,"audio",f.audio)}),T=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:s,msid:Om(g=Om(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-video"," ")).call(g,t.streamId,"-video")},YL(t.streamId,f,{flexfec:this._enableSubFlexfec})),e.next=33,this._internalSetRemoteDescription([k,T],t);case 33:null===(E=f)||void 0===E||delete E.next;case 34:return lL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:QL(v,d,l,!1),audioMid:a,videoMid:s,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:f,peerConnectionMode:this.peerConnectionMode});case 36:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==pF.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==pF.unpublish&&i!==pF.unsubscribe){e.next=7;break}return e.next=6,this.close(n);case 6:return e.abrupt("return",n.streamId||"");case 7:if(!t.generatorSsrc){e.next=10;break}return nH.warn("already set remote"),e.abrupt("return","");case 10:return o=EL.parse(null==r?void 0:r.sdp),e.next=13,this._internalSetRemoteDescription(o.media,n);case 13:return e.abrupt("return","");case 14:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=EL.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){"audio"===(e=Zd(Zd({},e),l.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e)})),u=EL.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=jm(o=u.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,jm(a=c.media).call(a,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(EL.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=EL.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Hs(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:EL.write(i),semantics:"unified-plan",type:"incroffer"});case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nH.warn("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nH.info("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=EL.parse(null==c?void 0:c.sdp)).media=jm(n=u.media).call(n,(function(e){return a[e.mid]&&(e=JL(e)),"inactive"!==e.direction&&s.push(e.mid),Zd(Zd({},e),h.peer._offerIce)})),d=EL.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=jm(o=u.media).call(o,(function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(null==c?void 0:c.sdp);case 17:return e.next=19,this.setRemoteDescription(EL.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;EL.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(aU);function oH(e,t){var r=(new Error).stack;NO("[DCHECK FAILED] ".concat(t),-1,{stack:r})}var aH=ad,sH=tc,cH=function(e,t,r,n){for(var i,o=n>1?void 0:n?sH(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&&aH(t,r,o),o},uH=function(){function e(t){Vl(this,e),Jd(this,"_queue",[]),Jd(this,"_runningTask",[]),Jd(this,"executor",void 0),Jd(this,"busy",!1),this.executor=t}var t;return Ul(e,[{key:"add",value:function(e){var t=vH(),r=t.promise,n=t.resolve,i=t.reject;return this._queue.push({item:e,resolve:n,reject:i}),this.busy||this._emit(),r}},{key:"destroy",value:function(){var e;Om(e=[]).call(e,Jk(this._queue),Jk(this._runningTask)).forEach((function(e){(0,e.reject)(new mA(pA.OPERATION_CANCEL,"queue close"))})),this.busy=!1,this._queue=[]}},{key:"_emit",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._queue,this._runningTask=t,this._queue=[],0!==t.length){e.next=6;break}return this.busy=!1,e.abrupt("return");case 6:return r=jm(t).call(t,(function(e){return e.item})),n=jm(t).call(t,(function(e){return e.resolve})),i=jm(t).call(t,(function(e){return e.reject})),e.prev=9,this.busy=!0,e.next=13,this.executor(r);case 13:o=e.sent,n.forEach((function(e){return e(o)})),e.next=20;break;case 17:e.prev=17,e.t0=e.catch(9),i.forEach((function(t){return t(e.t0)}));case 20:return this._runningTask=[],setTimeout((function(){a._emit()})),e.abrupt("return");case 23:case"end":return e.stop()}}),e,this,[[9,17]])}))),function(){return t.apply(this,arguments)})}]),e}(),dH=new Nw("StandardHandler",3),lH=function(e){DI(h,e);var t,r,n,i,o,a,s,c,u,d,l=QI(h);function h(e,t){var r;return Vl(this,h),Jd(tI(r=l.call(this,e,t)),"name","standard"),Jd(tI(r),"_applyQueue",new uH(r.apply.bind(tI(r)))),Jd(tI(r),"_createQueue",new uH(r.create.bind(tI(r)))),Jd(tI(r),"_pqueue",new pH),Jd(tI(r),"_midMap",new $S),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),dH.warn("ctor","using standard handler"),r}return Ul(h,[{key:"publish",value:(d=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,p,v,f,_;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.info("publish()","streamId: ".concat(t.streamId)),n=OI(CI(h.prototype),"internalPublish",this).call(this,t),i=n.videoDescriptions,o=n.subVideoDescriptions,a=n.audioTransceiverInit,s=n.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(a.track,Zd(Zd({},a.init),{},{direction:"sendonly"})),Array.isArray(s.init.sendEncodings)&&1===s.init.sendEncodings.length&&(s.init.sendEncodings=jm(c=s.init.sendEncodings).call(c,(function(e){return delete e.rid,e}))),t.videoTransceiver=this._peerConnection.addTransceiver(s.track,Zd(Zd({},s.init),{},{direction:"sendonly"})),u=lM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=9,this._createQueue.add();case 9:return d=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:lM()-u}),l=t.audioTransceiver.mid,p=t.videoTransceiver.mid,oH(0,"Transceiver not return MID after setLocalDescription"),t.audioMid=l,t.videoMid=p,v=null,f=null,(_=EL.parse(d)).media=null===(r=_.media)||void 0===r?void 0:jm(r).call(r,(function(e){return"".concat(e.mid)===l?v=e:"".concat(e.mid)===p&&(f=e),e})),lL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:QL(_,v,f,!1),audioMid:l,videoMid:p,type:"incroffer",semantics:"unified-plan",videoDescriptions:i,subVideoDescriptions:o,audioTransceiverInit:a,videoTransceiverInit:s,peerConnectionMode:this.peerConnectionMode});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"subscribe",value:(u=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.info("subscribe()","streamId: ".concat(t.streamId)),c=!1,u=!1,d=void 0,l=void 0,t.virtual?c=!0:(r.multiChatMode||(c=!0),u=!0),c&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),u&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),h=lM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=12,this._createQueue.add();case 12:if(p=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:lM()-h}),v=null!==(n=null===(i=t.audioTransceiver)||void 0===i?void 0:i.mid)&&void 0!==n?n:void 0,f=null!==(o=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid)&&void 0!==o?o:void 0,_=EL.parse(p),null===(s=_.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===v?d=e:"".concat(e.mid)===f&&(l=e)})),v&&d||(v="audio_".concat(f),d=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:v})),t.audioMid=v,t.videoMid=f,m=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=29;break}return m=this._generateAllSsrc(),I=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:v,msid:Om(y=Om(g="".concat(t.streamId)).call(g,null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:qL(t.streamId,"audio",m.audio)}),R=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:f,msid:Om(b=Om(E="".concat(t.streamId)).call(E,null!==(k=this._context)&&void 0!==k&&k.avSync?"":"-video"," ")).call(b,t.streamId,"-video")},YL(t.streamId,m,{flexfec:this._enableSubFlexfec})),e.next=28,this._internalSetRemoteDescription([I,R],t);case 28:null===(T=m)||void 0===T||delete T.next;case 29:return lL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:QL(_,d,l,!1),audioMid:v,videoMid:f||"",type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:m,peerConnectionMode:this.peerConnectionMode});case 31:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"handleAck",value:(c=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==pF.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==pF.unpublish&&i!==pF.unsubscribe){e.next=7;break}return e.next=6,this.close(n);case 6:return e.abrupt("return",n.streamId||"");case 7:if(!t.generatorSsrc){e.next=10;break}return dH.warn("already set remote"),e.abrupt("return","");case 10:return o=EL.parse(null==r?void 0:r.sdp),e.next=13,this._internalSetRemoteDescription(o.media,n);case 13:return e.abrupt("return","");case 14:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(s=Rm(Tm().mark((function e(t,r){var n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){"audio"===(e=Zd(Zd({},e),n.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,n._midMap.set(r.audioMid,e)):n._midMap.set(e.mid,e)),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,n._midMap.set(r.videoMid,e)):n._midMap.set(e.mid,e))})),r instanceof uF?this.handlePublishAction({stream:r}):this.handleSubscribeAction({stream:r}),e.next=7,this._applyQueue.add();case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handlePublishAction",value:function(e){var t,r,n,i,o,a,s,c,u=e.stream,d=u.audioMid?this._midMap.get(u.audioMid):void 0,l=u.videoMid?this._midMap.get(u.videoMid):void 0;null!==(t=this._context)&&void 0!==t&&t.pcKillSwitch.sld_rtcpfb_rrtr_add&&fL&&(hH.addRRTR(d),hH.addRRTR(l));var h,p=null!==(r=this._context)&&void 0!==r&&null!==(n=r.serverConfig)&&void 0!==n&&n.audioRed?"RED":"OPUS";("OPUS"!==p&&d&&function(e,t){if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){for(var r=0;r<e.rtp.length;r++)if(e.rtp[r].codec.toUpperCase()===t.toUpperCase()){var n;e.rtp.unshift(rk(n=e.rtp).call(n,r,1)[0]);break}var i=[];e.rtp.forEach((function(e){return i.push(e.payload)})),e.payloads=i.join(" ")}}(d,p),null!==(i=this._context)&&void 0!==i&&i.pcKillSwitch.sld_fmtp_opus_add)&&hH.decorateOpusConfig(d,null===(h=this._context)||void 0===h?void 0:h.audioProfileManager);zM&&uD<=87&&hH.removeRtxInMLine(l);var v=null===(o=this._context)||void 0===o||null===(a=o.serverConfig)||void 0===a?void 0:a.videoCodec;v&&l&&iU(l,v),null!==(s=this._context)&&void 0!==s&&s.pcKillSwitch.sld_ext_sdesmid_remove&&zM&&uD>=138&&hH.removeExtSdesMid(l),null!==(c=this._context)&&void 0!==c&&c.pcKillSwitch.sld_fmtp_bitrate_add&&(u.enableSimulcast||KM||!l||this.addBitrateLimit(l,u.videoEncodeConfig[0].maxKbps)),zM&&hH.selectCC(l,vL?"tcc":"remb"),u.audioMid&&d&&this._midMap.set(u.audioMid,d),u.videoMid&&l&&this._midMap.set(u.videoMid,l)}},{key:"handleSubscribeAction",value:function(e){var t,r,n,i=e.stream,o=i.audioMid?this._midMap.get(i.audioMid):void 0,a=i.videoMid?this._midMap.get(i.videoMid):void 0;zM||(hH.removeRtpStreamId(o),hH.removeRtpStreamId(a)),null!==(t=this._context)&&void 0!==t&&t.pcKillSwitch.sld_rtcpfb_rrtr_add&&fL&&(hH.addRRTR(o),hH.addRRTR(a)),null!==(r=this._context)&&void 0!==r&&r.pcKillSwitch.sld_fmtp_opus_add&&hH.decorateOpusConfig(o),OD("IOS_SAFARI_ORIENTATION")||!KM&&!rD||hH.removeExtVideoOrientation(a),null!==(n=this._context)&&void 0!==n&&n.pcKillSwitch.sld_fmtp_sps_add&&i.isPublic&&XM&&pD>=86&&hH.decorateSpsPpsIdrInKeyframe(a),i.audioMid&&o&&this._midMap.set(i.audioMid,o),i.videoMid&&a&&this._midMap.set(i.videoMid,a)}},{key:"getDefaultSdp",value:(a=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=EL.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Hs(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),fL&&i.media.forEach((function(e){"audio"!==e.type&&"video"!==e.type||e.rtp.forEach((function(t){var r;e.rtcpFb||(e.rtcpFb=[]),gE(r=e.rtcpFb).call(r,(function(e){return e.payload===t.payload&&"rrtr"===e.type}))||e.rtcpFb.push({payload:t.payload,type:"rrtr"})}))})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:EL.write(i),semantics:"unified-plan",type:"incroffer"});case 14:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"rollback",value:(o=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.warn("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return o.apply(this,arguments)})},{key:"close",value:(i=Rm(Tm().mark((function e(t,r,n){var i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(dH.info("close()"),i=t.audioMid||r,o=t.videoMid||n,t.audioTransceiver&&i)try{t.audioTransceiver.stop(),delete t.audioTransceiver}catch(c){}if(t.videoTransceiver&&o)try{t.videoTransceiver.stop(),delete t.videoTransceiver}catch(u){}return a=i?this._midMap.get(i):void 0,s=o?this._midMap.get(o):void 0,a&&JL(a),s&&JL(s),i&&a&&this._midMap.set(i,a),o&&s&&this._midMap.set(o,s),e.next=13,this._applyQueue.add();case 13:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return i.apply(this,arguments)})},{key:"setCurrentDescription",value:(n=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._applyQueue.add();case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;EL.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}},{key:"_generateAllSsrc",value:function(){var e=WL(this._nextSsrc);return this._nextSsrc=e.next,e}},{key:"create",value:(r=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.info("RTCPeerConnection create"),e.next=3,this._peerConnection.createOffer();case 3:return t=e.sent,r=t.sdp,oH(0,"RTCPeerConnection not return SDP"),e.next=8,this.peer.setLocalDescription(r);case 8:return e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"apply",value:(t=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.info("RTCPeerConnection apply"),e.next=3,this._peerConnection.createOffer();case 3:return t=e.sent,r=t.sdp,oH(0,"RTCPeerConnection not return SDP"),n=EL.parse(r),r=this.generateOffer(n,r),i=this.generateAnswer(n),e.next=11,this.setLocalDescription(r);case 11:return e.next=13,this.setRemoteDescription(i);case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"generateOffer",value:function(e,t){var r,n,i,o,a,s=this,c=!1;"v1"===this.peer.getIceVersion()&&zM&&(e.media=jm(i=e.media).call(i,(function(e){return Zd(Zd({},e),s.peer._offerIce)})),c=!0);null!==(r=this._context)&&void 0!==r&&r.pcKillSwitch.sld_fmtp_opus_add&&(e.media=jm(o=e.media).call(o,(function(e){if("audio"===e.type){var t,r="sendonly"===e.direction;hH.decorateOpusConfig(e,r?null===(t=s._context)||void 0===t?void 0:t.audioProfileManager:void 0)}return e})),c=!0);null!==(n=this._context)&&void 0!==n&&n.pcKillSwitch.sld_rtcpfb_rrtr_add&&(e.media=jm(a=e.media).call(a,(function(e){return!fL||"audio"!==e.type&&"video"!==e.type||hH.addRRTR(e),e})),c=!0);return c?EL.write(e):t}},{key:"generateAnswer",value:function(e){var t=this,r=[];return e.media.forEach((function(e){if("application"===e.type){oH(e.mid,"should always have mid in mline");var n=t._midMap.get(e.mid);return n||(n=t.generateDCAnswer(e),t._midMap.set(e.mid,n)),void r.push(Zd({},n))}var i="".concat(e.mid);oH(0,"No MID in offer m-line: ".concat(e));var o=t._midMap.get(i);o||(dH.info("generateInactiveAnswerMLine","mid: %o, mLine: %o",e.mid,e),o=t.generateInactiveAnswerMLine(e)),r.push(o)})),this.peer.createAnswerSdp(r,e.groups)}},{key:"generateInactiveAnswerMLine",value:function(e){return Zd(Zd(Zd({},e),this.peer._answerIce),{},{direction:"inactive"})}},{key:"generateDCAnswer",value:function(e){var t=Zd(Zd(Zd({},e),this.peer._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}});return zM&&(delete t.bundleOnly,t.port=9),t}},{key:"destroy",value:function(){OI(CI(h.prototype),"destroy",this).call(this),this._pqueue.destroy(),this._applyQueue.destroy(),this._createQueue.destroy()}}]),h}(aU);cH([function(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.info("SDP Lock","pending task %o",t),e.next=3,this._pqueue.enqueue(0);case 3:for(r=e.sent,dH.info("SDP Lock","running task %o",t),e.prev=5,i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=9,null==n?void 0:n.apply(this,o);case 9:return e.abrupt("return",e.sent);case 10:return e.prev=10,dH.info("SDP Lock","unlocking by task %o",t),r(),e.finish(10);case 14:case"end":return e.stop()}}),e,this,[[5,,10,14]])}))),r}],lH.prototype,"create",1),cH([function(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dH.info("SDP Lock","pending task %o",t),e.next=3,this._pqueue.enqueue(1);case 3:for(r=e.sent,dH.info("SDP Lock","running task %o",t),e.prev=5,i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=9,null==n?void 0:n.apply(this,o);case 9:return e.abrupt("return",e.sent);case 10:return e.prev=10,dH.info("SDP Lock","unlocking by task %o",t),r(),e.finish(10);case 14:case"end":return e.stop()}}),e,this,[[5,,10,14]])}))),r}],lH.prototype,"apply",1);var hH={decorateOpusConfig:function(e,t){var r,n;if(e){var i=null==e?void 0:gE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(i&&e.fmtp){var o=gE(n=e.fmtp).call(n,(function(e){return e.payload===i.payload}));o&&(t&&(o.config=t.getOpusConfigStr(o.config)),o.config=mH(o.config))}}},removeRtxInMLine:function(e){var t,r,n,i;if(e){var o=[];e.rtp=Hs(t=e.rtp).call(t,(function(e){return"rtx"===e.codec&&o.push(e.payload),"rtx"!==e.codec})),e.fmtp=Hs(r=e.fmtp).call(r,(function(e){return mk(o).call(o,e.payload)})),e.payloads=null===(n=e.payloads)||void 0===n?void 0:Hs(i=n.split(" ")).call(i,(function(e){return!mk(o).call(o,uy(e))})).join(" ")}},removeExtSdesMid:function(e){var t;e&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return!mk(t=e.uri).call(t,"sdes:mid")})))},selectCC:function(e,t){var r,n;if(e)if("tcc"===t)e.ext=null===(r=e.ext)||void 0===r?void 0:Hs(r).call(r,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:Hs(n).call(n,(function(e){return"goog-remb"!==e.type}));else if("remb"===t){var i,o;e.rtcpFb=null===(i=e.rtcpFb)||void 0===i?void 0:Hs(i).call(i,(function(e){return"transport-cc"!==e.type})),e.ext=null===(o=e.ext)||void 0===o?void 0:Hs(o).call(o,(function(e){var t;return-1===xE(t=e.uri).call(t,"transport")}))}},addRRTR:function(e){e&&e.rtp.forEach((function(t){var r;e.rtcpFb||(e.rtcpFb=[]),gE(r=e.rtcpFb).call(r,(function(e){return e.payload===t.payload&&"rrtr"===e.type}))||e.rtcpFb.push({payload:t.payload,type:"rrtr"})}))},removeRtpStreamId:function(e){var t;e&&(Array.isArray(e.ext)&&(e.ext=Hs(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))))},decorateSpsPpsIdrInKeyframe:function(e){var t;if(e){var r=Hs(t=e.rtp).call(t,(function(e){return"H264"===e.codec}));r.length&&e.fmtp&&e.fmtp.forEach((function(e){gE(r).call(r,(function(t){return t.payload===e.payload}))&&(e.config+=";sps-pps-idr-in-keyframe=1")}))}},removeExtVideoOrientation:function(e){var t;e&&(Array.isArray(e.ext)&&(e.ext=Hs(t=e.ext).call(t,(function(e){var t;return!mk(t=e.uri).call(t,"video-orientation")}))))},removeExtFramemarking:function(e){var t;e&&(Array.isArray(e.ext)&&(e.ext=Hs(t=e.ext).call(t,(function(e){var t;return!mk(t=e.uri).call(t,"framemarking")}))))}},pH=function(){function e(){Vl(this,e),Jd(this,"queue",[]),Jd(this,"processing",!1)}var t;return Ul(e,[{key:"enqueue",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u=this,d=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=d.length>0&&void 0!==d[0]?d[0]:0,n=vH(),i=n.promise,o=n.resolve,a={priority:r,resolve:o},-1===(s=QR(t=this.queue).call(t,(function(e){return e.priority>r})))?this.queue.push(a):rk(c=this.queue).call(c,s,0,a),this.tryProcess(),e.next=8,i;case 8:return this.processing=!0,e.abrupt("return",(function(){u.processing=!1,u.tryProcess()}));case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this.queue.forEach((function(e){(0,e.resolve)()})),this.queue=[],this.processing=!1}},{key:"tryProcess",value:function(){if(!this.processing){var e=this.queue.shift();e&&e.resolve()}}}]),e}();function vH(){var e=void 0,t=void 0,r=new Y_((function(r,n){e=r,t=n}));if(!e||!t)throw Error("Broken Implement of Promise");return{promise:r,resolve:e,reject:t}}var fH,_H,mH=function(e){var t,r={};return e.split(";").forEach((function(e){var t=eI(e.split("="),2),n=t[0],i=t[1];n&&i&&(r[n]=i)})),r["sprop-stereo"]=1,r.stereo=1,jm(t=an(r)).call(t,(function(e){var t;return Om(t="".concat(e,"=")).call(t,r[e])})).join(";")},yH=function(e,t){return e.enableFallbackHandler?new iH(e,t):e.enableStandardHandler?new lH(e,t):zM?new rH(e,t):new eH(e,t)},gH=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}(gH||{}),SH=function(e){return e.PushLimitWarn="PushLimitWarn",e}(SH||{}),bH=function(e){return e.ON_ADD_STREAM="onAddStream",e.ON_ADD_STREAM_LIST="onAddStreamList",e.ON_REMOVE_STREAM="onRemoveStream",e.ON_REMOVE_STREAM_LIST="onRemoveStreamList",e.USER_DISCONNECTION="userDisconnection",e.USER_DISCONNECTION_LIST="userDisconnectionList",e.USER_CONNECTION="userConnection",e.USER_CONNECTION_LIST="userConnectionList",e.ON_UPDATE_STREAM_ATTRIBUTES="onUpdateStreamAttributes",e.ON_UPDATE_ROOM_ATTRIBUTES="onUpdateRoomAttributes",e.ON_UPDATE_USER_ATTRIBUTES="onUpdateUserAttributes",e.ON_PUSH_TRACK="onPushTrack",e.ON_REMOVE_TRACK="onRemoveTrack",e.ON_CUSTOM_MESSAGE="onCustomMessage",e.NODE_CHANGE="nodeChange",e.USER_MESSAGE_RECEIVED="userMessageReceived",e.USER_BINARY_MESSAGE_RECEIVED="userBinaryMessageReceived",e.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM="userMessageReceivedOutsideRoom",e.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM="userBinaryMessageReceivedOutsideRoom",e.POST_PROCESSING_MESSAGE="postProcessingMessage",e.ON_USER_TOKEN_WILL_EXPIRE="onUserTokenWillExpire",e.STREAM_CONTROL_MESSAGE="streamControlMessage",e.ON_SPEAKER_CHANGE="onSpeakerChange",e.ON_STREAM_FAILED="streamFailed",e.ON_NOTIFY_RECONNECT="notifyReconnect",e.ON_FORWARD_DST_ROOM_USER_KICK="onForwardDstRoomUserKick",e}(bH||{}),EH=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(EH||{}),kH=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ON_VENDOR_CONNECTION_STATE_CHANGE="onVendorConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(kH||{}),TH=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(TH||{}),IH=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(IH||{}),RH=new Nw("Locker",2),AH=1,wH=function(){function e(t){var r;Vl(this,e),Jd(this,"lockingPromise",Y_.resolve()),Jd(this,"locks",0),Jd(this,"name",""),Jd(this,"lockId",void 0),this.lockId=AH++,t&&(this.name=t),RH.info(Om(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return Ul(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,RH.info(Om(e=Om(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new Y_((function(e){r=function(){var t,r;n.locks-=1,RH.info(Om(t=Om(r="[lock-".concat(n.name,"-")).call(r,n.lockId,"] unlocked, current queue ")).call(t,n.locks,".")),e()}})),o=this.lockingPromise.then((function(){return r}));return this.lockingPromise=this.lockingPromise.then((function(){return i})),o}}]),e}(),CH=function(e){return e.RESUBSCRIBE="resubscribe",e.STREAM_FAILED="stream_failed",e.SUBSCRIBE_PUSH_TRACK="subscribe_push_track",e.REMOVE_PUSH_TRACK="remove_push_track",e.VIDEO_FIRST_FRAME="video_first_frame",e.ON_USER_PUBLISH_STATE_CHANGE="on_user_publish_state_change",e.ON_USER_START_AUDIO_CAPTURE="on_user_start_audio_capture",e.ON_USER_STOP_AUDIO_CAPTURE="on_user_stop_audio_capture",e.ON_USER_START_VIDEO_CAPTURE="on_user_start_video_capture",e.ON_USER_STOP_VIDEO_CAPTURE="on_user_stop_video_capture",e.ON_SEI_MESSAGED_RECEIVED="on_sei_messaged_received",e.ON_PUBLISH_RESULT="on_publish_result",e.ON_UPDATE_TOKEN_SUCCESS="on_update_token_success",e.ON_REMOTE_STREAM_STATS="ON_REMOTE_STREAM_STATS",e.ON_LOCAL_STREAM_STATS="ON_LOCAL_STREAM_STATS",e.ON_USER_LEAVE="on_user_leave",e.ON_ROOM_ERROR="on_room_error",e.ON_NETWORK_QUALITY="on_network_quality",e.ON_SIMULCAST_SUBSCRIBE_FALLBACK="on_simulcast_subscribe_fallback",e.ON_REMOTE_VIDEO_SIZE_CHANGED="on_remote_video_size_changed",e.RECONNECT_FAILED="reconnect_failed",e.ON_SUBTITLE_STATE_CHANGED="ON_SUBTITLE_STATE_CHANGED",e.ON_SUBTITLE_MESSAGE_RECEIVED="ON_SUBTITLE_MESSAGE_RECEIVED",e.ON_VIDEO_STREAM_BANNED="ON_VIDEO_STREAM_BANNED",e.ON_AUDIO_STREAM_BANNED="ON_AUDIO_STREAM_BANNED",e.ON_FORWARD_STREAM_ERROR="ON_FORWARD_STREAM_ERROR",e.ON_REJOIN_WITH_TCP="ON_REJOIN_WITH_TCP",e.ON_ICE_CONNECT_WITH_TCP="ON_ICE_CONNECT_WITH_TCP",e}(CH||{}),xH=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}(xH||{}),OH=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(OH||{}),MH=function(e){return e[e.SUB=0]="SUB",e[e.UNSUB=1]="UNSUB",e}(MH||{}),DH=(Jd(fH={},bl.communication,[0]),Jd(fH,bl.chat,[0]),Jd(fH,bl.chatRoom,[1,"IES_chatroom"]),Jd(fH,bl.coHost,[1,"IES_PK"]),Jd(fH,bl.meeting,[16]),Jd(fH,bl.classRoom,[0]),fH),PH=lL(),NH=function(e){DI(s,e);var t,r,n,i,o,a=QI(s);function s(e,t){var r;return Vl(this,s),Jd(tI(r=a.call(this,e,t)),"peerConnectionId",dM()),Jd(tI(r),"peerConnectionMode",1),Jd(tI(r),"name","vendor"),Jd(tI(r),"direction","up"),Jd(tI(r),"stream",void 0),t.on("ice_state",(function(e){r._report("rtc_ice_state",{pc_session_id:r.peerConnectionId,direction:r.direction,error_code:0,ice_state:e.toUpperCase(),message:"",peer_connection_id:r.peerConnectionId,stream_id:"",stream_user_id:""})})),r}return Ul(s,[{key:"publish",value:(o=Rm(Tm().mark((function e(t){var r,n,i,o,a,c,u,d,l,h,p=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.enableSimulcast=!1,this.stream=t,r=OI(CI(s.prototype),"internalPublish",this).call(this,t),n=r.videoDescriptions,i=r.subVideoDescriptions,o=r.audioTransceiverInit,a=r.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(o.track,o.init),t.videoTransceiver=this._peerConnection.addTransceiver(a.track,a.init),PH&&(t.initAudioEncodedTransform(),t.initVideoEncodedTransform()),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:(null==t?void 0:t.vendorCode)||0}),e.next=9,this._peerConnection.createOffer();case 9:return c=e.sent,u=lM(),d=EL.parse(c.sdp),Array.isArray(d.media)&&(d.media=jm(l=d.media).call(l,(function(e){var r,n,i,o,a;if("video"===e.type)null!==(r=p._context)&&void 0!==r&&null!==(n=r.serverConfig)&&void 0!==n&&n.videoCodec&&iU(e,null===(i=p._context)||void 0===i||null===(o=i.serverConfig)||void 0===o?void 0:o.videoCodec),(KM||rD)&&Array.isArray(e.ext)&&(e.ext=Hs(a=e.ext).call(a,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&mk(t).call(t,"video-orientation"))}))),KM||p.addBitrateLimit(e,t.videoEncodeConfig[0].maxKbps);else if("audio"===e.type){var s,c=null==e?void 0:gE(s=e.rtp).call(s,(function(e){return"opus"===e.codec}));if(c&&e.fmtp){var u,d,l=gE(u=e.fmtp).call(u,(function(e){return e.payload===c.payload}));l&&null!==(d=p._context)&&void 0!==d&&d.audioProfileManager&&(l.config=p._context.audioProfileManager.getOpusConfigStr(l.config))}}return e}))),h=new RTCSessionDescription({type:"offer",sdp:EL.write(d)}),e.prev=14,e.next=17,this._peerConnection.setLocalDescription(h);case 17:this._report("rtc_set_description",{error_code:0,message:h.sdp||"",is_local:"1",direction:"up",stream_id:"",stream_user_id:"",elapse:lM()-u},{type:"offer"}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(14),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+h.sdp,is_local:"1",direction:"up",stream_id:"",stream_user_id:"",elapse:lM()-u},{type:"offer"}),e.t0;case 24:return e.abrupt("return",{partialSdp:h.sdp||"",audioMid:"0",videoMid:"1",type:"offer",semantics:"unified-plan",videoDescriptions:n,subVideoDescriptions:i,audioTransceiverInit:o,videoTransceiverInit:a,peerConnectionMode:this.peerConnectionMode,peerConnectionId:this.peerConnectionId});case 25:case"end":return e.stop()}}),e,this,[[14,20]])}))),function(e){return o.apply(this,arguments)})},{key:"subscribe",value:(i=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stream=t,this.direction="down",t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"}),PH&&(t.initAudioEncodedTransform(),t.initVideoEncodedTransform()),this._report("rtc_begin_create_offer",{direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:t.vendorCode||0}),e.next=8,this._peerConnection.createOffer();case 8:return r=e.sent,n=lM(),i=EL.parse(r.sdp),Array.isArray(i.media)&&(i.media=jm(o=i.media).call(o,(function(e){if("audio"===e.type){var t,r=null==e?void 0:gE(t=e.rtp).call(t,(function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n,i=null==e?void 0:gE(n=e.fmtp).call(n,(function(e){return e.payload===r.payload}));i&&s._context&&(i.config+=";stereo=1;sprop-stereo=1")}}return e}))),a=new RTCSessionDescription({type:"offer",sdp:EL.write(i)}),e.prev=13,e.next=16,this._peerConnection.setLocalDescription(a);case 16:this._report("rtc_set_description",{error_code:0,message:a.sdp||"",is_local:"1",direction:"down",stream_id:t.streamId,stream_user_id:t.userId,elapse:lM()-n},{type:"offer"}),e.next=23;break;case 19:throw e.prev=19,e.t0=e.catch(13),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+a.sdp,is_local:"1",direction:"down",stream_id:t.streamId,stream_user_id:t.userId,elapse:lM()-n},{type:"offer"}),e.t0;case 23:return e.abrupt("return",{partialSdp:a.sdp||"",audioMid:"0",videoMid:"1",type:"offer",semantics:"unified-plan",peerConnectionMode:this.peerConnectionMode,peerConnectionId:this.peerConnectionId});case 24:case"end":return e.stop()}}),e,this,[[13,19]])}))),function(e){return i.apply(this,arguments)})},{key:"handleAck",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.action!==pF.publish&&t.action!==pF.subscribe){e.next=16;break}return n=new RTCSessionDescription({sdp:null===(r=t.signalingAck)||void 0===r?void 0:r.sdp,type:"answer"}),i=lM(),e.prev=3,e.next=6,this._peerConnection.setRemoteDescription(n);case 6:this._report("rtc_set_description",{error_code:0,message:n.sdp||"",is_local:"1",direction:"down",stream_id:null===(o=t.stream)||void 0===o?void 0:o.userId,stream_user_id:(null===(a=t.stream)||void 0===a?void 0:a.streamId)||"",elapse:lM()-i},{type:"answer"}),e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(3),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+n.sdp,is_local:"1",direction:"down",stream_id:null===(s=t.stream)||void 0===s?void 0:s.userId,stream_user_id:(null===(c=t.stream)||void 0===c?void 0:c.streamId)||"",elapse:lM()-i},{type:"offer"}),e.t0;case 13:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=17;break;case 16:t.action!==pF.unpublish&&t.action!==pF.unsubscribe||this.destroy();case 17:return e.abrupt("return","");case 18:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e){return n.apply(this,arguments)})},{key:"destroy",value:function(){this.peer.destroy(),OI(CI(s.prototype),"destroy",this).call(this)}},{key:"getDefaultSdp",value:(r=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{sdp:"",type:"offer",semantics:""});case 1:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)})},{key:"connect",value:function(){throw new Error("Method not implemented.")}},{key:"rollback",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{this._peerConnection.close()}catch(t){}case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),s}(aU),LH=function(e){return e[e.AUTOPLAY_FAILED=-1e3]="AUTOPLAY_FAILED",e[e.TRACK_ERROR=-1001]="TRACK_ERROR",e[e.Fetch_MODIFY=-1002]="Fetch_MODIFY",e[e.BLACK_BROWSER=-1003]="BLACK_BROWSER",e[e.DC_SEND_ERROR=-1004]="DC_SEND_ERROR",e}(LH||{}),UH={start_interval:100,multiplier:2,max_interval:3e4},VH=function(){function e(){Vl(this,e),Jd(this,"_times",0),Jd(this,"_config",UH),Jd(this,"initTs",lM())}return Ul(e,[{key:"getRetryDelay",value:function(){return Math.min(this._config.max_interval,Math.pow(this._config.multiplier,this._times++)*this._config.start_interval)}},{key:"setConfig",value:function(e){this._config=e}},{key:"reset",value:function(){this._times=0}}]),e}(),FH=new Nw("ICERequest",4),BH=function(){function e(t){Vl(this,e),Jd(this,"_reconnectTimer",void 0),Jd(this,"_abortControllers",[]),Jd(this,"_monitor",void 0),Jd(this,"_groupConfigId",dM()),Jd(this,"_retryLimiter",new VH),Jd(this,"_timer",void 0),this._ctx=t,this._monitor=VO(t.id)}var t,r,n,i,o;return Ul(e,[{key:"getICENode",value:(o=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FH.info("getICENode","invoke"),e.prev=1,e.next=4,this._getAccessWithRetry(t);case 4:if(0!==(r=e.sent).length){e.next=7;break}throw"server return empty nodes.";case 7:e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(1),this._reportRtcInvokeStatus("es.join.getNodeFailed",e.t0),new mA(pA.ICE_SERVER_WRONG,"get ICE config failed: ".concat(e.t0),e.t0);case 13:return FH.success("getICENode","success"),this._reportRtcInvokeStatus("es.join.getNodeSuccess",r),e.abrupt("return",r);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return o.apply(this,arguments)})},{key:"_getAccessWithRetry",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 0!==r&&FH.info("_getAccessWithRetry()","invoke feedbackInfo: %o, 201count: %o",e,r),new Y_((function(n,i){t._getAccessNode(e).then((function(e){t._retryLimiter.reset(),n(e)})).catch((function(o){if(Array.isArray(o)&&o.length>0){if(QR(o).call(o,(function(e){return 400<=e.code&&e.code<500}))>-1)return t._retryLimiter.reset(),i("HTTP request failed(4xx)");if(o.every((function(e){var t;return 201===e.code||201===(null===(t=e.error)||void 0===t?void 0:t.code)}))&&r++,3===r)return t._retryLimiter.reset(),i("HTTP request failed(201)")}var a=t._retryLimiter.getRetryDelay();FH.warn("_getAccessWithRetry()","_getAccessWithRetry error, will retry after ".concat(a,"ms"),o),t._reconnectTimer=self.setTimeout((function(){t._getAccessWithRetry(e,r).then(n).catch(i)}),a)}))}))}},{key:"_getAccessNode",value:(i=Rm(Tm().mark((function e(t){var r=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Y_((function(e,n){var i=ED.getAccessNode(r._ctx.appId);i?(FH.info("getAccessNode","use cache node."),e(Array.isArray(i)?i:[i]),r._timer=window.setTimeout((function(){r._getAccessNodeFromServer(t),r._reportRtcInvokeStatus("es.R.node.cache",i),delete r._timer}),0)):r._getAccessNodeFromServer(t).then(e).catch(n)})));case 1:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"_getAccessNodeFromServer",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this._getAccessUrls(),n=r.urls,i=r.needFallback,e.abrupt("return",this.getICEConfigFromServer(n,t).then((function(e){var t=e.nodes;return!o._ctx.useCloudProxy&&ED.setAccessNode(o._ctx.appId,t,e.ttl||11200),e.dispatchDomains&&!o._ctx.useCloudProxy&&ED.setAccessUrls(e.dispatchDomains),t})).catch((function(e){if(i)return o._reportRtcInvokeStatus("es.R.req.fallback",""),ED.clearAccessUrls(),o._getAccessNodeFromServer(t);throw e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_getAccessUrls",value:function(){var e=ED.getAccessUrls()||[],t=!0;return this._reportRtcInvokeStatus("es.R.req.cache.urls",e),0===e.length&&(e=CD.ICE_CONFIG_REQUEST_URLS,t=!1,this._reportRtcInvokeStatus("es.R.req.external.urls",e)),0===e.length&&(e=CD.ICE_CONFIG_REQUEST_URLS_INTERNAL,t=!1,this._reportRtcInvokeStatus("es.R.req.internal.urls",e)),{urls:e,needFallback:t}}},{key:"getICEConfigFromServer",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={appID:this._ctx.appId,deviceID:ED.getDeviceId(),os:"web",sdkVersion:CD.VERSION,isOversea:CD.OVERSEA,expectedAddr:OD("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC,accessParams:Nm({requireICEUfragV2:!0}),userAgent:navigator.userAgent},r&&(n.feedbackInfo=r,"ICE_FAILED"!==(null===(i=r[0])||void 0===i||null===(o=i.feedbackReason)||void 0===o?void 0:o.type)&&delete n.expectedAddr),a=jm(t).call(t,(function(e){return s._httpRequest(e,n)})),e.abrupt("return",RM(a));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_httpRequest",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=dM(),r.connectSessionID=i,o=Date.now(),null===(n=this._monitor)||void 0===n||n.report("rtc_get_access",{error_code:0,message:Nm(r),elapse:0,type:"request",host:t,config_id:i,group_config_id:this._groupConfigId}),a=new AbortController,this._abortControllers.push(a),e.prev=6,e.prev=7,e.next=10,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:Nm(r),signal:a.signal});case 10:s=e.sent,e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),yw(fetch)||null===(d=this._monitor)||void 0===d||d.report("rtc_error",{error_code:LH.Fetch_MODIFY,message:"get access failed, possibly due to modifying the browser's Fetch API."},{origin_error:e.t0}),e.t0;case 17:if(this._abortControllers=Hs(c=this._abortControllers).call(c,(function(e){return e!==a})),200===s.status){e.next=20;break}throw{message:s.statusText,code:s.status};case 20:return e.next=22,s.json();case 22:if(200===(l=e.sent).code){e.next=25;break}throw l;case 25:return null===(u=this._monitor)||void 0===u||u.report("rtc_get_access",{error_code:200,message:Nm(l),elapse:Date.now()-o,type:"response",host:t,config_id:i,group_config_id:this._groupConfigId}),e.abrupt("return",l);case 29:throw e.prev=29,e.t1=e.catch(6),null===(h=this._monitor)||void 0===h||h.report("rtc_get_access",{error_code:Number((null===e.t1||void 0===e.t1?void 0:e.t1.code)||(null===e.t1||void 0===e.t1?void 0:e.t1.server_code)),message:null===e.t1||void 0===e.t1?void 0:e.t1.message,elapse:Date.now()-o,type:"response",host:t,config_id:i,group_config_id:this._groupConfigId},{error:Nm(e.t1)}),e.t1;case 33:case"end":return e.stop()}}),e,this,[[6,29],[7,13]])}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._abortControllers.forEach((function(e){return e.abort()})),this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer),this._timer&&(window.clearTimeout(this._timer),delete this._timer)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0;null===(r=this._monitor)||void 0===r||r.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:n,stream_id:"",elapse:0,group_config_id:this._groupConfigId},i)}}]),e}(),jH=lL(),HH={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"},GH=function(e){return e[e.DC_ERROR=0]="DC_ERROR",e[e.DC_CLOSE=1]="DC_CLOSE",e[e.ICE_FAILED=2]="ICE_FAILED",e[e.DESTROY=3]="DESTROY",e[e.TIMEOUT=4]="TIMEOUT",e}(GH||{}),zH=0,KH=function(e){DI(c,e);var t,r,n,i,o,a,s=QI(c);function c(e,t){var r;return Vl(this,c),Jd(tI(r=s.call(this)),"uuid",(zH++).toString()),Jd(tI(r),"_peerConnectionId",""),Jd(tI(r),"audioTrack4ff",void 0),Jd(tI(r),"_pc",void 0),Jd(tI(r),"_dc",void 0),Jd(tI(r),"_iceNode",void 0),Jd(tI(r),"_initSctpEvents",!1),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_offerIce",{}),Jd(tI(r),"_answerIce",{}),Jd(tI(r),"_offerSession",void 0),Jd(tI(r),"_answerSession",void 0),Jd(tI(r),"_offerMlines",[]),Jd(tI(r),"_answerMlines",[]),Jd(tI(r),"_connectReject",void 0),Jd(tI(r),"_logger",new Nw("PeerConnection_".concat(r.uuid),4)),Jd(tI(r),"_peerConfig",void 0),r._ctx=e,r._groupConnectionId=t,r._monitor=VO(e.id),r._ctx.enableFallbackHandler&&r._logger.warn("ctor","PeerConnection running in fallback mode"),r._peerConfig=XH(e),r._pc=new RTCPeerConnection(r._peerConfig),r._pc.ontrack=function(e){var t,n,i,o,a=null===(t=e.streams)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.id;r._print("pc.ontrack",Om(i=Om(o="".concat(e.track.kind," ")).call(o,e.track.id," ")).call(i,a)),"ff-stream"===a&&(r.audioTrack4ff=e.track),r.emit("ontrack",e)},r._pc.onconnectionstatechange=function(e){var t;r._print("onconnectionstatechange",Om(t="".concat(r._pc.connectionState,". ice -> ")).call(t,r._pc.iceConnectionState)),"failed"!==r._pc.iceConnectionState&&"closed"!==r._pc.iceConnectionState&&"failed"!==r._pc.connectionState||r.emit("disconnect","ice failed")},r._pc.oniceconnectionstatechange=function(){var e=r._pc.iceConnectionState;r._report("rtc_pre_ice_state",{message:e,ice_state:e.toUpperCase()}),r.emit("ice_state",e)},r}return Ul(c,[{key:"getOriginRTCPeerConnection",value:function(){return this._pc}},{key:"getOriginRTCDataChannel",value:function(){return this._dc}},{key:"getConnectionId",value:function(){return this._peerConnectionId}},{key:"getGroupConnectionId",value:function(){return this._groupConnectionId}},{key:"connect",value:(a=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._ctx.enableStandardHandler){e.next=2;break}return e.abrupt("return",this.startIceConnectStandard(t));case 2:return this._print("connect","invoke. %o",t),this._iceNode=t,this._dc=this._pc.createDataChannel("signaling",{negotiated:!0,id:100}),this._dc.binaryType="arraybuffer",e.next=8,this._genIceInfo(t);case 8:return r=e.sent,n=r.offerIce,i=r.answerIce,this._offerIce=n,this._answerIce=i,zM&&uD<138&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=16,this._pc.createOffer();case 16:if((o=e.sent).sdp){e.next=19;break}throw new mA(pA.NOT_SUPPORTED,"create offer sdp failed.");case 19:if(a=EL.parse(o.sdp),this._peerConnectionId=i.iceUfrag||"",(s=!n.iceUfrag&&!n.icePwd)&&((l="renomination"===(null===(c=a.media[0])||void 0===c?void 0:c.iceOptions))||(delete n.iceOptions,delete i.iceOptions),delete n.iceUfrag,delete n.icePwd,h=nU({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(u=a.media[0])||void 0===u?void 0:u.icePwd,options:(d={},Jd(d,rU.kICEConfigTypeSrtpDtlsType,!0),Jd(d,rU.kICEConfigTypeRenominationType,l),d)}),p=eI(h,2),v=p[0],f=p[1],this._peerConnectionId=f,i.iceUfrag=v,this._logger.info("use serverUfrag v2",Nm({dtls:!0,renomination:l}))),_=eI(a.media,1),m=_[0],this._offerIce.fingerprint=a.fingerprint||m.fingerprint,!zM&&!this._ctx.enableFallbackHandler){e.next=41;break}if(a.media=jm(y=a.media).call(y,(function(e){var t,r,n=Zd(Zd({},e),b._offerIce);return"video"===n.type&&(n.ext=null===(t=n.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),n.rtcpFb=null===(r=n.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type}))),n})),(S=Zd({},a)).fingerprint=this._answerIce.fingerprint,S.media=jm(g=S.media).call(g,(function(e){return delete(e=Zd(Zd({},e),b._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),!this._ctx.enableFallbackHandler){e.next=35;break}return e.next=33,this.setLocalDescription(o.sdp);case 33:e.next=37;break;case 35:return e.next=37,this.setLocalDescription(EL.write(a));case 37:return e.next=39,this.setRemoteDescription(EL.write(S));case 39:e.next=50;break;case 41:delete a.media,this._offerSession=Zd({},a),this._answerSession=Zd({},a),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),s&&(this._offerIce.iceUfrag=m.iceUfrag,this._offerIce.icePwd=m.icePwd),this._offerMlines=[Zd(Zd(Zd({},m),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[Zd(Zd(Zd({},m),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription();case 50:return e.next=52,new Y_((function(e,t){b._connectReject=t,b._dc.onopen=function(){b._print("connect","dataChannel open"),b._reportRtcInvokeStatus("es.dc.open",""),e(""),delete b._connectReject},b._dc.onerror=function(e){var t,r;b._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),b._reportRtcInvokeStatus("es.dc.error",""),null===(t=b._connectReject)||void 0===t||t.call(b,{message:"dc.onerror, ".concat(null===(r=e.error)||void 0===r?void 0:r.errorDetail),code:0}),b.emit("disconnect","dc onerror"),delete b._connectReject},b._dc.onclose=function(e){var t;b._reportRtcInvokeStatus("es.dc.close",""),null===(t=b._connectReject)||void 0===t||t.call(b,{message:"dc.onclose",code:1}),b.emit("disconnect","dc onclose"),delete b._connectReject},b._pc.addEventListener("connectionstatechange",(function(e){var t,r;"failed"!==b._pc.iceConnectionState&&"closed"!==b._pc.iceConnectionState&&"failed"!==b._pc.connectionState||(null===(t=b._connectReject)||void 0===t||t.call(b,{message:Om(r="pc.connectionstatechange -> ".concat(b._pc.connectionState,", ice -> ")).call(r,b._pc.iceConnectionState),code:2}),delete b._connectReject)})),setTimeout((function(){var e;null===(e=b._connectReject)||void 0===e||e.call(b,{code:4,message:"connect timeout"}),delete b._connectReject}),8e3)}));case 52:return this._print("connect","dataChannel establish success"),e.abrupt("return",this._dc);case 54:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"startIceConnectStandard",value:(o=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("connect","standard invoke. %o",t),this._iceNode=t,(i=this._pc.createDataChannel("signaling",{negotiated:!0,id:100})).binaryType="arraybuffer",this._dc=i,e.next=7,this._genIceInfo(t);case 7:return o=e.sent,a=o.offerIce,s=o.answerIce,this._offerIce=a,this._answerIce=s,zM&&uD<138&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=15,this._pc.createOffer();case 15:if(c=e.sent,u=c.sdp){e.next=19;break}throw new mA(pA.NOT_SUPPORTED,"create offer sdp failed.");case 19:if(d=EL.parse(u),this._answerSession=Zd({},d),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),l=gE(r=d.media).call(r,(function(e){return"application"===e.type})),this._peerConnectionId=s.iceUfrag||"",!a.iceUfrag&&!a.icePwd&&((p="renomination"===(null==l?void 0:l.iceOptions))||(delete a.iceOptions,delete s.iceOptions),delete a.iceUfrag,delete a.icePwd,v=nU({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null==l?void 0:l.icePwd,options:(h={},Jd(h,rU.kICEConfigTypeSrtpDtlsType,!0),Jd(h,rU.kICEConfigTypeRenominationType,p),h)}),f=eI(v,2),_=f[0],m=f[1],this._peerConnectionId=m,s.iceUfrag=_,this._logger.info("use serverUfrag v2",Nm({dtls:!0,renomination:p}))),this._offerIce.fingerprint=d.fingerprint||(null==l?void 0:l.fingerprint),(y=Zd({},d)).fingerprint=this._answerIce.fingerprint,y.media=jm(n=y.media).call(n,(function(e){if("application"===(e=Zd(Zd({},e),S._answerIce)).type&&(e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}),zM)if(delete e.bundleOnly,e.port=9,"audio"===e.type)e.msid="ff-stream ff-stream-audio",e.direction="sendonly";else if("video"===e.type){var t,r,n,i;vL?(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type}))):(e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:Hs(n).call(n,(function(e){return"transport-cc"!==e.type})),e.ext=null===(i=e.ext)||void 0===i?void 0:Hs(i).call(i,(function(e){var t;return-1===xE(t=e.uri).call(t,"transport")}))),e.direction="sendonly"}return e})),"v1"!==this.getIceVersion()){e.next=36;break}return d.media=jm(g=d.media).call(g,(function(e){return e=Zd(Zd({},e),S._offerIce)})),e.next=34,this.setLocalDescription(EL.write(d));case 34:e.next=38;break;case 36:return e.next=38,this.setLocalDescription(u);case 38:return e.next=40,this.setRemoteDescription(EL.write(y));case 40:return e.next=42,new Y_((function(e,t){S._connectReject=t,i.onopen=function(){S._print("connect","dataChannel open"),S._reportRtcInvokeStatus("es.dc.open",""),e(""),delete S._connectReject},i.onerror=function(e){var t,r,n,i;S._report("rtc_signaling_msg_error",{error_code:null==e||null===(t=e.error)||void 0===t?void 0:t.sdpLineNumber,message:null==e||null===(r=e.error)||void 0===r?void 0:r.errorDetail,reason:"invalid data"}),S._reportRtcInvokeStatus("es.dc.error",""),null===(n=S._connectReject)||void 0===n||n.call(S,{message:"dc.onerror, ".concat(null===(i=e.error)||void 0===i?void 0:i.errorDetail),code:0}),S.emit("disconnect","dc onerror"),delete S._connectReject},i.onclose=function(){var e;S._reportRtcInvokeStatus("es.dc.close",""),null===(e=S._connectReject)||void 0===e||e.call(S,{message:"dc.onclose",code:1}),S.emit("disconnect","dc onclose"),delete S._connectReject},S._pc.addEventListener("connectionstatechange",(function(){var e,t;"failed"!==S._pc.iceConnectionState&&"closed"!==S._pc.iceConnectionState&&"failed"!==S._pc.connectionState||(null===(e=S._connectReject)||void 0===e||e.call(S,{message:Om(t="pc.connectionstatechange -> ".concat(S._pc.connectionState,", ice -> ")).call(t,S._pc.iceConnectionState),code:2}),delete S._connectReject)})),setTimeout((function(){var e;null===(e=S._connectReject)||void 0===e||e.call(S,{code:4,message:"connect timeout"}),delete S._connectReject}),8e3)}));case 42:return this._print("connect","dataChannel establish success"),e.abrupt("return",i);case 44:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setDescription",value:(i=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("setDescription","invoke."),this._offerSession.media=this._offerMlines,this._answerSession.media=this._answerMlines,r=[],this._offerMlines.forEach((function(e){"inactive"!==e.direction&&r.push(e.mid)})),this._offerSession.groups&&this._answerSession.groups&&(this._offerSession.groups[0].mids=r.join(" "),this._answerSession.groups[0].mids=r.join(" ")),n=lM(),t&&this._report("rtc_begin_create_offer",{direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,pc_session_id:this._peerConnectionId,vendor_mode:0}),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:lM()-n}),e.next=11,this.setLocalDescription(EL.write(this._offerSession),t);case 11:return e.next=13,this.setRemoteDescription(EL.write(this._answerSession),t);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setLocalDescription",value:(n=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=lM(),e.prev=1,e.next=4,this._pc.setLocalDescription({type:"offer",sdp:t});case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:lM()-n},{type:"offer"}),this._initSctpEvents||(this._initSctpEvents=!0,(o=null===(i=this._pc)||void 0===i?void 0:i.sctp)&&(o.onstatechange=function(){a._reportRtcInvokeStatus("sctp","sctp state change TO: ".concat(o.state))},o.transport&&(o.transport.onstatechange=function(){var e;a._reportRtcInvokeStatus("dtls","dtls state change TO: ".concat(null==o||null===(e=o.transport)||void 0===e?void 0:e.state))}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:"",stream_user_id:"",elapse:lM()-n},{type:"offer"});case 12:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(r=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=lM(),e.prev=1,e.next=4,this._pc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:t}));case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:lM()-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:lM()-n},{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"disconnect",value:function(){var e,t;null===(e=this._connectReject)||void 0===e||e.call(this,{code:3,message:"invoke destroy()"}),delete this._connectReject,this._pc.close(),null===(t=this._dc)||void 0===t||t.close(),this._pc.ontrack=null}},{key:"getIceVersion",value:function(){var e,t;return null!==(e=this._iceNode)&&void 0!==e&&e.iceParams.clientIceUfrag||null!==(t=this._iceNode)&&void 0!==t&&t.iceParams.clientIcePwd?"v1":"v2"}},{key:"createAnswerSdp",value:function(e,t){oH(this._answerSession,"_answerSession should be existed");var r=Zd({},this._answerSession);return r.media=e,r.groups=t,EL.write(r)}},{key:"destroy",value:function(){this._print("destroy",this._peerConnectionId),OI(CI(c.prototype),"removeAllListeners",this).call(this),this.disconnect()}},{key:"_genIceInfo",value:(t=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=3,ZL(t);case 3:return o=e.sent,e.abrupt("return",{offerIce:i,answerIce:o});case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"_print",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];(t=this._logger).info.apply(t,Om(r=["".concat(e)]).call(r,i))}},{key:"_report",value:function(e,t,r){var n,i,o,a;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this._peerConnectionId,group_connection_id:this._groupConnectionId}),Zd(Zd({},r),{},{tcp_only:null===(i=this._iceNode)||void 0===i?void 0:i.iceConfig.tcpOnly,ms_addr:Nm((null===(o=this._iceNode)||void 0===o?void 0:jm(a=o.publicIPs).call(a,(function(e){return{ip:e.ip,tcp:e.tcpPorts,udp:e.udpPorts}})))||[])}))}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}],[{key:"checkSupported",value:function(){if(!RTCPeerConnection)throw new mA(pA.NOT_SUPPORTED,"missing RTCPeerConnection API.");["addTransceiver","createDataChannel","createOffer","setLocalDescription","setRemoteDescription"].forEach((function(e){var t,r;if(null===(t=RTCPeerConnection)||void 0===t||null===(r=t.prototype)||void 0===r||!r[e])throw new mA(pA.NOT_SUPPORTED,"missing peer.".concat(e," API."))}))}}]),c}(aP),XH=function(e){var t=Zd({},HH);return e.pcKillSwitch.ctor_sdpsemantics_add&&(t.sdpSemantics="unified-plan"),e.pcKillSwitch.ctor_encodedinsetablestream_add&&jH&&(t.encodedInsertableStreams=!0),t};function WH(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=an(e);for(n=0;n<o.length;n++)r=o[n],xE(t).call(t,r)>=0||(i[r]=e[r]);return i}(e,t);if(xs){var o=xs(e);for(n=0;n<o.length;n++)r=o[n],xE(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var qH=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(qH||{}),YH=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}(YH||{}),JH=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}(JH||{}),QH=(Jd(_H={},0,[0,"success"]),Jd(_H,1,[pA.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),Jd(_H,2,[pA.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),Jd(_H,3,[pA.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),Jd(_H,4,[pA.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),Jd(_H,5,[pA.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),Jd(_H,17,[pA.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),Jd(_H,18,[pA.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),Jd(_H,100,[pA.USER_MESSAGE_NOT_JOIN,"not join room"]),Jd(_H,105,[pA.USER_MESSAGE_NOT_LOGIN,"not login."]),Jd(_H,106,[pA.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),Jd(_H,1e3,[pA.USER_MESSAGE_UNKNOWN,"unknown."]),_H),ZH=["msg"],$H=new Nw("DataChannelSignaling",3),eG=[],tG=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}(tG||{}),rG=function(e){DI(a,e);var t,r,n,i,o=QI(a);function a(e,t){var r;return Vl(this,a),Jd(tI(r=o.call(this)),"_singlingCache",new $S),Jd(tI(r),"_p2pCache",new $S),Jd(tI(r),"_rttIds",{}),Jd(tI(r),"_p2pMessageId",1),Jd(tI(r),"_clearDataChannelListener",void 0),Jd(tI(r),"_monitor",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=VO(e),r}return Ul(a,[{key:"destroy",value:function(){var e=this;this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.forEach((function(t,r){t.error(new mA(pA.OPERATION_CANCEL,"disconnect")),e._singlingCache.delete(r)})),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=1,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n,i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:6e4;return null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:Nm(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new Y_((function(n,a){var s,c=i._genHeader(r);c.id=vM();var u=c.id.join("-"),d="customMessage"===e;d&&wO.samplingOne2ManyMsg(i.id,Number(c.id.join("")),t);var l=setTimeout((function(){i._singlingCache.delete(u),a(new mA(pA.TIME_OUT,"".concat(e," message time out"))),d&&wO.updateOne2ManyMsgAck(i.id,t,999)}),o);i._singlingCache.set(u,{signalingType:e,success:function(e){clearTimeout(l),n(e),d&&wO.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(l),a(e),d&&wO.updateOne2ManyMsgAck(i.id,t,e.code)}}),$H.info("Signal",Om(s=">>>>>> [".concat(e,"][")).call(s,u,"]"),t),i._sendMessage(e,c,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=Rm(Tm().mark((function e(t,r){var n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=WH(t,ZH),o=n instanceof ArrayBuffer,e.t0=this,e.t1=wO,e.t2=this.id,e.t3=Zd,e.t4=Zd({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:qH.SEND,type:YH.P2P,err:JH.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,pM.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 _M(e.msg)?this._rttIds[e.id]=e.id:e.dir===qH.SEND&&$H.info("_sendP2PMessage [DC Signaling p2p >>]",Nm(e)),new Y_((function(n,i){var o=t._genHeader(Zd(Zd({needAck:!0,functionType:1},r),{},{id:vM()}));if(e.dir===qH.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new mA(pA.USER_MESSAGE_TIMEOUT,"P2P message timeout")),wO.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),wO.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),wO.updateP2PMsgAck(t.id,e,r.err);var o=eI(QH[r.err]||[pA.USER_MESSAGE_UNKNOWN,Om(n="err: ".concat(r.err,", msg: ")).call(n,r.msg)],2),s=o[0],c=o[1];i({err:r.err,code:s,message:r.msg||c})}})}try{t._sendMessage("p2p",o,e)}catch(s){throw s.code===pA.NOT_CONNECTED_YET&&(s.code=pA.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new mA(pA.NOT_CONNECTED_YET,"DataChannel not open");var i=t.version+(Number(t.zip)<<5)+(Number(t.encrypt)<<6),o=Number(t.needAck)+(Number(t.direction)<<1)+(Number(t.functionType)<<2)+(Number(t.binary)<<6),a=pM.str2ab(Nm([e,r])),s=hM(Uint8Array,Om(n=[i,o]).call(n,Jk(t.id||[])),new Uint8Array(a));try{this._dataChannel.send(s.buffer)}catch(u){var c;throw null===(c=this._monitor)||void 0===c||c.report("rtc_error",{message:"datachannel send error: ".concat(u.message),error_code:LH.DC_SEND_ERROR}),u}"p2p"===e?wO.updateP2PMsgReq(this.id,r,s.buffer.byteLength):"customMessage"===e&&wO.updateOne2ManyMsgReq(this.id,r,s.buffer.byteLength)}},{key:"_dispartData",value:function(e){var t=new Uint8Array(e),r=0,n=t[r++],i=t[r++],o={version:15&n,zip:16==(16&n),encrypt:32==(32&n),needAck:1==(1&i),direction:(2&i)>>1,functionType:(60&i)>>2,binary:64==(64&i)};if(o.needAck||1===o.direction){for(;r<=6;r++)if(128!=(128&t[r])){r++;break}o.id=qk(km(t).call(t,2,r))}return{header:o,data:km(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:jm(n=e.split("-")).call(n,(function(e){return Number(e)}))});mk(eG).call(eG,t)||$H.info("Signal",Om(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=Date.now(),n=t.byteLength,i=this._dispartData(t),o=i.data,(a=i.header).zip&&((s=new vO.Inflate).push(o,!0),o=s.result),c=pM.ab2str(o),u=[],e.prev=8,u=JSON.parse(c),e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(8),e.t0 instanceof Error&&(null===(d=this._monitor)||void 0===d||d.report("rtc_signaling_msg_error",{error_code:-1,message:e.t0.message,reason:"message parse failed"})),e.abrupt("return");case 16:e.t1=a.functionType,e.next=0===e.t1?19:1===e.t1?21:2===e.t1?23:25;break;case 19:return this.C2S(a,u,c,n,r),e.abrupt("break",26);case 21:return this.C2C(u,n,r),e.abrupt("break",26);case 23:return this.C2GW(a,u,c),e.abrupt("break",26);case 25:return e.abrupt("break",26);case 26:case"end":return e.stop()}}),e,this,[[8,12]])}))),function(e){return n.apply(this,arguments)})},{key:"C2S",value:(r=Rm(Tm().mark((function e(t,r,n,i,o){var a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=(null===(a=t.id)||void 0===a?void 0:a.join("-"))||"",1!==t.direction){e.next=5;break}this._handleAckMessage(s,r[0]||{},n),e.next=18;break;case 5:if(!Array.isArray(r)){e.next=18;break}if(u=r[0],r=r[1],mk(eG).call(eG,u)||$H.info("Signal","<<<<<< ".concat(u),r,s),this._feedbackSignaling(s,u,u===bH.ON_CUSTOM_MESSAGE?Zd(Zd({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,pM.b64str2ab(r.message);case 13:r.message=e.sent;case 14:d=Date.now(),this.emit(u,Zd({},r)),u===bH.ON_CUSTOM_MESSAGE&&wO.reportOne2ManyMsgRecv(this.id,r,{msg_size:i,recv_msg_ts:o,fwd_msg_ts:d}),null===(c=this._monitor)||void 0===c||c.report("rtc_signaling",{error_code:0,message:n,signaling_event:"on-".concat(u),signaling_type:"Recv",stream_id:r.streamId,stream_user_id:r.clientId,direction:"down"});case 18:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"C2C",value:(t=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Array.isArray(t)&&(t=t[1]),c=null===(i=t)||void 0===i?void 0:i.id,this._rttIds[c]||(null===(o=t)||void 0===o?void 0:o.dir)===qH.FEEDBACK||_M(null===(a=t)||void 0===a?void 0:a.msg)?delete this._rttIds[c]:$H.info("Signal","<<<<<< p2p response",t),e.t0=t.dir,e.next=e.t0===qH.SEND?6:e.t0===qH.FEEDBACK?46:48;break;case 6:if(u=Date.now(),_M(null===(s=t)||void 0===s?void 0:s.msg)){e.next=43;break}if(l=(d=t).binary,h=d.msg,p=d.room,v=d.to,f=d.from,_=""===p?l?bH.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:bH.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:l?bH.USER_BINARY_MESSAGE_RECEIVED:bH.USER_MESSAGE_RECEIVED,v){e.next=27;break}if(e.t1=this,e.t2=bH.ON_CUSTOM_MESSAGE,e.t3=f,e.t4=l,!l){e.next=21;break}return e.next=18,pM.b64str2ab(h);case 18:e.t5=e.sent,e.next=22;break;case 21:e.t5=h;case 22:e.t6=e.t5,e.t7={clientId:e.t3,binary:e.t4,message:e.t6},e.t1.emit.call(e.t1,e.t2,e.t7),e.next=43;break;case 27:if(e.t8=this,e.t9=_,e.t10=Zd,e.t11=Zd({},t),e.t12={},!l){e.next=38;break}return e.next=35,pM.b64str2ab(h);case 35:e.t13=e.sent,e.next=39;break;case 38:e.t13=h;case 39:e.t14=e.t13,e.t15={msg:e.t14},e.t16=(0,e.t10)(e.t11,e.t12,e.t15),e.t8.emit.call(e.t8,e.t9,e.t16);case 43:return this._sendP2PMessage(Zd(Zd({},t),{},{dir:qH.FEEDBACK,msg:""})),wO.reportP2PMsgRecv(this.id,t,{msg_size:r,recv_msg_ts:n,fwd_msg_ts:u}),e.abrupt("break",49);case 46:return this._handleP2PMsgFeedback(t),e.abrupt("break",49);case 48:return e.abrupt("break",49);case 49:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"C2GW",value:function(e,t,r){if(1===e.direction){var n,i=(null===(n=e.id)||void 0===n?void 0:n.join("-"))||"";this._handleAckMessage(i,t[0]||{},r)}else{var o=eI(t,2),a=o[0],s=o[1],c=void 0===s?{}:s;if("RXMediaMsg"===a){var u,d=c.type,l=c.data;switch(null===(u=this._monitor)||void 0===u||u.report("rtc_signaling",{error_code:0,message:r,signaling_event:"on-".concat(d),signaling_type:"Recv",stream_id:"",stream_user_id:"",direction:"down"}),d){case"RSCP":try{var h=JSON.parse(l);Array.isArray(h)&&this.emit(d,h)}catch(f){}break;case"RTT":try{var p=JSON.parse(l);p.length&&this.emit(d,p[0])}catch(f){}break;case"SSC":try{var v=JSON.parse(l);v.length&&this.emit(d,v[0])}catch(f){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(e){$H.warn("_handleHandler","dataChannel close",e)},r=function(e){$H.error("_handleHandler","dataChannel error",e)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Zd({version:2,zip:!1,encrypt:!1,needAck:!0,direction:0,functionType:0,binary:!1},e)}},{key:"_handleAckMessage",value:function(e,t,r){var n,i,o=this._singlingCache.get(e);o&&(this._singlingCache.delete(e),200===t.code?o.success(t):o.error(t),$H.info("Signal",Om(i="<<<<<< [".concat(o.signalingType,"-ack] ")).call(i,e),t));null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:r,signaling_event:null==o?void 0:o.signalingType,signaling_type:"Ack",stream_id:"",stream_user_id:"",direction:"down"})}},{key:"_handleP2PMsgFeedback",value:function(e){var t=this._p2pCache.get(e.id);t&&(this._p2pCache.delete(e.id),e.err===JH.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(nP.exports.EventEmitter),nG=new Nw("ConnectionManager",3),iG=function(e){DI(o,e);var t,r,n,i=QI(o);function o(e){var t;return Vl(this,o),Jd(tI(t=i.call(this)),"id",void 0),Jd(tI(t),"_monitor",void 0),Jd(tI(t),"_getAccessManager",void 0),Jd(tI(t),"_connectionPool",new $S),Jd(tI(t),"_curConnection",void 0),Jd(tI(t),"_hasReportBrowerWarning",!1),Jd(tI(t),"_reconnectTimer",void 0),Jd(tI(t),"_connecting",!1),Jd(tI(t),"_isFirstTimeConnected",!0),Jd(tI(t),"_feedbackNodes",[]),Jd(tI(t),"_preIceStartTime",-1),Jd(tI(t),"_tcpOnlyTimer",void 0),Jd(tI(t),"_destroyed",!1),t._ctx=e,nG.info("constructor","invoke"),t.id=e.id,t._monitor=VO(t.id),t._getAccessManager=new BH(e),t}return Ul(o,[{key:"connect",value:function(){var e=this;nG.info("connect","invoke");try{KH.checkSupported()}catch(t){this.safeEmit("disconnected",t)}this._connecting||(this._onConnectStart("init"),Y_.resolve().then((function(){return e.emit("__onGetIceConfigHook")})),this._getAccess())}},{key:"reconnectByNodeChange",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:nG.info("reconnectByNodeChange","invoke %o",t),o=t.nodes,a=t.reason,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:Nm(t),reason:Nm(a)}),ED.clearAccessNode(this._ctx.appId),s=(null===(n=this._curConnection)||void 0===n||null===(i=n.node.publicIPs[0])||void 0===i?void 0:i.ip)||"",this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart("node change"),Array.isArray(o)&&o.length>0?this._startIceConnect(o):this._getAccess([{feedbackIP:s,feedbackReason:{type:"NODE_CHANGED",reason:a}}]);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"reconnect",value:(r=Rm(Tm().mark((function e(t){var r,n=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],nG.info("reconnect","invoke. ".concat(r?"ICE over TCP":"")),this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart(t),this._getAccess(void 0,r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){nG.info("destroy","invoke"),this._destroyed=!0,this.safeEmit("disconnected",new mA(pA.OPERATION_CANCEL,"destroy")),OI(CI(o.prototype),"removeAllListeners",this).call(this),this._clearReconnectTimer(),this._clearConnectionPool(),this._getAccessManager.destroy(),this._closeCurrentConnection()}},{key:"_getAccess",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._getAccessManager.getICENode(e).then((function(e){t.emit("__onGetIceSuccessHook",e),t._startIceConnect(e,r)})).catch((function(e){t.safeEmit("disconnected",e)})).finally((function(){t._feedbackNodes=[]}))}},{key:"_startIceConnect",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this._destroyed){nG.info("_startIceConnect","invoke");var n=_w();this._preIceStartTime=lM();var i=this._ctx.joinRoomConfig.useTcpJoin,o=this._ctx.joinRoomConfig.useTcpJoinDelay,a=function(){var e=Rm(Tm().mark((function e(i){var o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r&&((i=Yj(i)).iceConfig.tcpOnly=!0),o={node:i},e.prev=2,a=new KH(t._ctx,n),o.pc=a,t._connectionPool.set(a.uuid,o),e.next=8,a.connect(i);case 8:return s=e.sent,c=new rG(t.id,s),o.signaling=c,e.next=13,c.sendPingSignaling();case 13:t._onConnectSuccess({node:i,pc:a,signaling:c,dc:s}),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(2),t._onConnectionFailed(o,e.t0);case 19:case"end":return e.stop()}}),e,null,[[2,16]])})));return function(t){return e.apply(this,arguments)}}();this.emit("__onIceConnectStartHook"),e.forEach(a),i&&!r&&(nG.info("_startIceConnect","tcp-only will try after ".concat(o,"ms")),this._tcpOnlyTimer=window.setTimeout((function(){t.emit("connectWidthTcp"),e.forEach((function(e){(e=Yj(e)).iceConfig.tcpOnly=!0,a(e)})),delete t._tcpOnlyTimer}),o))}}},{key:"_onConnectSuccess",value:function(e){var t,r,n,i=this;(nG.info("connect","peer_%s connect success.",e.pc.uuid),this.emit("__onIceConnectSuccessHook",e),this._curConnection)?(e.pc.destroy(),null===(t=e.signaling)||void 0===t||t.destroy(),this._connectionPool.delete(e.pc.uuid)):(this._curConnection=e,this._addConnectionHandler(e.pc,e.dc),null===(r=this._monitor)||void 0===r||r.set({connection_id:e.pc.getConnectionId(),rtc_vid:(null===(n=e.node.iceConfig)||void 0===n?void 0:n._abtest_vid)||""}),this._connectionPool.delete(e.pc.uuid),this._feedbackNodes.forEach((function(e){return i._feedbackBySignaling(e)})),this._feedbackNodes=[],this._onConnectEnded(e))}},{key:"_onConnectionFailed",value:function(e,t){var r,n,i=this;(nG.info("connect","peer_%s connect failed. %s",(null===(r=e.pc)||void 0===r?void 0:r.uuid)||"",t.message),this.emit("__onIceConnectFailedHook",e),t.code!==GH.DESTROY&&t.code!==pA.OPERATION_CANCEL)&&(this._curConnection?this._feedbackBySignaling(e.node):this._feedbackNodes.push(e.node),nG.info("connect","remove cache node"),ED.deleteAccessNode(this._ctx.appId,e.node),e.pc&&(this._connectionPool.delete(e.pc.uuid),e.pc.destroy()),null===(n=e.signaling)||void 0===n||n.destroy());0!==this._connectionPool.size||this._curConnection||this._destroyed||(nG.error("connect","establish peerConnection failed"),this._checkBrowserUA(),lM()-this._preIceStartTime<1e3?(this._clearReconnectTimer(),this._reconnectTimer=window.setTimeout((function(){delete i._reconnectTimer,i._reconnectWithIceFailed(i._feedbackNodes)}),1e3)):this._reconnectWithIceFailed(this._feedbackNodes))}},{key:"_feedbackBySignaling",value:function(e){var t;null===(t=this._curConnection)||void 0===t||t.signaling.sendSignaling("scheduleMessage",{type:"feedback",body:{feedbackIP:e.publicIPs[0].ip,feedbackReason:{type:"ICE_FAILED",reason:{}}}})}},{key:"_reconnectWithIceFailed",value:(t=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._onConnectStart("ice failed"),nG.warn("reconnect","because of ice failed"),this._getAccess(jm(t).call(t,(function(e){return{feedbackIP:e.publicIPs[0].ip,feedbackReason:{type:"ICE_FAILED",reason:{}}}})));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_checkBrowserUA",value:function(){var e;!this._hasReportBrowerWarning&&this._ctx.joinRoomConfig.isBlackBrower()&&(this._hasReportBrowerWarning=!0,null===(e=this._monitor)||void 0===e||e.report("rtc_error",{error_code:LH.BLACK_BROWSER,message:"failed to establish data-channel, and the current browser is on the browser blacklist."}))}},{key:"_onConnectStart",value:function(e){var t;nG.info("_onConnectStart","invoke, reason: ".concat(e)),this._connecting=!0,this.safeEmit(this._isFirstTimeConnected?"connecting":"reconnecting");var r,n=_w();(null===(t=this._monitor)||void 0===t||t.set({connect_session_id:n}),this._isFirstTimeConnected)||(null===(r=this._monitor)||void 0===r||r.report("rtc_reconnect",{error_code:1002,message:"peerconnection reconnecting",reconnect_id:n,reconnect_type:"peerconnection"},{reason:e}))}},{key:"_onConnectEnded",value:function(e){var t;(nG.info("_onConnectEnded","invoke"),this._connecting=!1,this._isFirstTimeConnected=!1,this.safeEmit("connected",e),this._isFirstTimeConnected)||(null===(t=this._monitor)||void 0===t||t.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"}));e.node.iceConfig.tcpOnly&&(nG.info("_onConnectEnded","use tcp only"),jO(this._ctx.id,"connected_with_tcp_only",Nm(e.node))),this._tcpOnlyTimer&&(window.clearTimeout(this._tcpOnlyTimer),delete this._tcpOnlyTimer),this._clearConnectionPool()}},{key:"_addConnectionHandler",value:function(e,t){var r=this;e.on("disconnect",(function(e){r._closeCurrentConnection(),r._clearReconnectTimer(),navigator.onLine?r.reconnect(e):r._reconnectTimer=window.setTimeout((function(){return r.reconnect(e)}),3e3)}))}},{key:"_closeCurrentConnection",value:function(){var e,t;null===(e=this._curConnection)||void 0===e||e.pc.destroy(),null===(t=this._curConnection)||void 0===t||t.signaling.destroy(),delete this._curConnection}},{key:"_clearConnectionPool",value:function(){var e=this;this._connectionPool.forEach((function(t,r){var n,i;null===(n=t.pc)||void 0===n||n.destroy(),null===(i=t.signaling)||void 0===i||i.destroy(),e._connectionPool.delete(r)}))}},{key:"_clearReconnectTimer",value:function(){this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer)}}]),o}(aP),oG=ad,aG=tc,sG=function(e,t,r,n){for(var i,o=n>1?void 0:n?aG(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&&oG(t,r,o),o},cG=new Nw("MediaServerClient",2),uG=6e4,dG=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(dG||{}),lG=function(e,t){cG.info(e,"userId: %o, subAudio: %o, subVideo: %o, audioMid: %o, videoMid: %o, sequenceId: %o",t.userId,t.subAudio,t.subVideo,t.audioMid,t.videoMid,t.sequenceId)},hG=function(e){DI(T,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k=QI(T);function T(e){var t;return Vl(this,T),Jd(tI(t=k.call(this)),"id",void 0),Jd(tI(t),"_token",void 0),Jd(tI(t),"_roomId",void 0),Jd(tI(t),"_roomAttributes",void 0),Jd(tI(t),"_vendorConfig",{enableMultiVendor:!1,vendorCode:0}),Jd(tI(t),"_clientId",void 0),Jd(tI(t),"_businessId",void 0),Jd(tI(t),"_userInfo",void 0),Jd(tI(t),"_authorization",void 0),Jd(tI(t),"_sessionId",""),Jd(tI(t),"_liveControlMessage",void 0),Jd(tI(t),"isReconnecting",!1),Jd(tI(t),"_ontrackCallbackMap",new $S),Jd(tI(t),"_subResolves",{}),Jd(tI(t),"supportConcurrent",!1),Jd(tI(t),"_handler",void 0),Jd(tI(t),"_pubSubLock",void 0),Jd(tI(t),"_joinLeaveLock",void 0),Jd(tI(t),"_state",void 0),Jd(tI(t),"_dataChannelSignal",void 0),Jd(tI(t),"_joinRoomStartTs",void 0),Jd(tI(t),"_subConfig",{}),Jd(tI(t),"_monitor",void 0),Jd(tI(t),"_roomProfile",bl.communication),Jd(tI(t),"_context",void 0),Jd(tI(t),"_subStreamQueue",{}),Jd(tI(t),"_connectionManager",void 0),Jd(tI(t),"_joinRoom5xxTimer",void 0),Jd(tI(t),"_joinResolve",void 0),Jd(tI(t),"_joinReject",void 0),cG.info("constructor","invoke"),t.id=e.id,t._monitor=VO(t.id),t._pubSubLock=new wH("pubSubLock"),t._joinLeaveLock=new wH("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._context=e,t.on("SUB_END",(function(e){return t._handleSubStreamQueue(e)})),t._connectionManager=new iG(e),t._addConnectHandler(),t}return Ul(T,[{key:"_addSignalEventHandler",value:function(){var e,t,r=this;[bH.ON_ADD_STREAM,bH.ON_ADD_STREAM_LIST,bH.ON_REMOVE_STREAM,bH.ON_REMOVE_STREAM_LIST,bH.USER_CONNECTION,bH.USER_CONNECTION_LIST,bH.USER_DISCONNECTION,bH.USER_DISCONNECTION_LIST,bH.ON_UPDATE_STREAM_ATTRIBUTES,bH.ON_UPDATE_ROOM_ATTRIBUTES,bH.ON_PUSH_TRACK,bH.ON_REMOVE_TRACK,bH.ON_CUSTOM_MESSAGE,bH.USER_MESSAGE_RECEIVED,bH.USER_BINARY_MESSAGE_RECEIVED,bH.POST_PROCESSING_MESSAGE,bH.ON_USER_TOKEN_WILL_EXPIRE,bH.STREAM_CONTROL_MESSAGE,bH.ON_UPDATE_USER_ATTRIBUTES,bH.ON_SPEAKER_CHANGE,EH.RSCP,EH.RTT,bH.ON_STREAM_FAILED,bH.ON_NOTIFY_RECONNECT,EH.SSC,bH.ON_FORWARD_DST_ROOM_USER_KICK].forEach((function(e){var t;null===(t=r._dataChannelSignal)||void 0===t||t.on(e,(function(t){r.safeEmit(e,t)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.on(bH.NODE_CHANGE,(function(e){r._connectionManager.reconnectByNodeChange(e)})),null===(t=this._dataChannelSignal)||void 0===t||t.on(bH.ON_NOTIFY_RECONNECT,(function(){r._connectionManager.reconnect("recv notifyReconnect signaling")}))}},{key:"_removeSignalEventHandler",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.removeAllListeners(),null===(t=this._handler)||void 0===t||t.removeAllListeners()}},{key:"connectionState",get:function(){return this._state},set:function(e){this._state!==e&&(this.safeEmit(kH.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"businessId",set:function(e){this._businessId=e}},{key:"setLiveControlMessage",value:function(e){this._liveControlMessage=e}},{key:"connect",value:function(){var e=this;return new Y_((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"join",value:(E=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return cG.info("join()","info: %o",t),this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._roomProfile=t.roomProfile,this._reportJoinRoomStart(),e.next=10,new Y_((function(e,t){n._joinResolve=e,n._joinReject=t,(n._handler?Y_.resolve():n.connect()).then((function(){n._callJoinRoom()})).catch((function(e){var t=Array.isArray(e)&&e.length>0?e[0]:e;n._joinRoomFailed(t.message)}))}));case 10:return r=e.sent,e.abrupt("return",r);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"_callJoinRoom",value:(b=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m=this,y=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=y.length>0&&void 0!==y[0]&&y[0],cG.info("_callJoinRoom","invoke"),e.t0=pM.token2auth(this._context.appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId,e.t2=Date.now(),e.t3=this._liveControlMessage,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=9,null===(t=this._handler)||void 0===t?void 0:t.getDefaultSdp();case 9:return e.t5=e.sent,e.next=12,ZN(OD("PUB_SUB_MODE"));case 12:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=CD.VERSION,e.t9=ED.getDeviceId(),e.t10=this._context.appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._context.useCloudProxy,e.t15=DH[this._roomProfile]?"".concat(DH[this._roomProfile][0]):"0",e.t16={supportedCodecs:e.t6,deviceType:"web",userAgent:e.t7,sdkVersion:e.t8,deviceId:e.t9,appId:e.t10,roomId:e.t11,userId:e.t12,businessId:e.t13,enableCloudProxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0,supportMultiVendor:!0},e.t18=Nm({requireICEUfragV2:!0}),n={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17,accessParams:e.t18},e.prev=26,e.t19=jO,e.t20=this.id,e.t21=Nm,e.next=32,$N();case 32:e.t22=e.sent,e.t23=OD("PUB_SUB_MODE")||"recv_and_send",e.t24={supportedCodecsSdpOffer:e.t22,pubSubMode:e.t23},e.t25=(0,e.t21)(e.t24),(0,e.t19)(e.t20,"MediaClient.internalGetSupportedCodecsSdpOffer",e.t25),e.next=41;break;case 39:e.prev=39,e.t26=e.catch(26);case 41:return Y_.resolve().then((function(){return m.emit("onSendingJoinMessageHook")})),e.prev=42,o=r?"reconnected":"joinRoom",e.next=46,this._joinRoomWithRetry(o,n);case 46:a=e.sent,cG.success("join","send join message success"),s=a.config||{},c=s.engine_WEB,this.connectionState="connected",this._authorization=n.Authorization,ED.setEngineWebConfig(this._context.appId,this._roomId,c),this._context&&(this._context.serverConfig={videoCodec:(null==c?void 0:c.video_codec)||"H264",audioRed:!(null==c||!c.pub_audio_red),muteReplaceUnsub:!(null===(u=a.config)||void 0===u||!u.mute_replace_unsub),simulcastOnDemand:!(zM||!1===(null===(d=a.config)||void 0===d||null===(l=d.engine_VPM)||void 0===l||null===(h=l.ondemand)||void 0===h?void 0:h.enable)),forceUniHandler:1===(null==a||null===(p=a.config)||void 0===p||null===(v=p.vendor_param)||void 0===v?void 0:v.vendor_stream_sub_mode)},"boolean"==typeof(null==c?void 0:c.av_sync)&&(this._context.avSync=c.av_sync)),a.vendorConfig&&(this._vendorConfig=a.vendorConfig),nF.audioStallConfig=c,null!=a&&null!==(i=a.relayMessage)&&void 0!==i&&i.sdp&&(null===(f=this._handler)||void 0===f||f.createAVMlineAnswerTpl(a.relayMessage.sdp)),this.emit("joinSuccess",{joinRes:a,reconnect:r}),this._joinRoomSuccess(a),e.next=63;break;case 60:e.prev=60,e.t27=e.catch(42),(null===e.t27||void 0===e.t27?void 0:e.t27.code)>=700&&(null===e.t27||void 0===e.t27?void 0:e.t27.code)<800?this._joinRoomFailed("token_error",pA.INVALID_TOKEN):(null===e.t27||void 0===e.t27?void 0:e.t27.code)===pA.TIME_OUT&&this._context.joinRoomConfig.useTcpAfterJoinTimeout?(_="joinRoom timeout, retry with tcp only",cG.error("join",_),this.safeEmit(CH.ON_REJOIN_WITH_TCP),this._connectionManager.reconnect(_,!0)):e.t27.code===pA.OPERATION_CANCEL&&"connecting"===this.connectionState||this._joinRoomFailed((null===e.t27||void 0===e.t27?void 0:e.t27.message)||"signaling_error");case 63:case"end":return e.stop()}}),e,this,[[26,39],[42,60]])}))),function(){return b.apply(this,arguments)})},{key:"publish",value:(S=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D,P,N=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(cG.info("publish()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,i=lM(),o="",a="",s=this._handler,e.prev=7,!this._vendorConfig.enableMultiVendor){e.next=20;break}return T=new KH(this._context,""),t.vendorHandler=new NH(this._context,T),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),e.next=14,t.vendorHandler.publish(t);case 14:k=e.sent,(s=t.vendorHandler).on("ice_state",(function(e){N.emit(kH.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:ll.CONNECTION_STATE_CONNECTING,connected:ll.CONNECTION_STATE_CONNECTED,disconnected:ll.CONNECTION_STATE_RECONNECTING}[e],userId:N._clientId})})),T.once("disconnect",Rm(Tm().mark((function e(){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=s)||void 0===r||r.removeAllListeners(),"connected"===(null===(n=N._handler)||void 0===n||null===(i=n.pc)||void 0===i?void 0:i.iceConnectionState)){e.next=4;break}return cG.error("vendor ice failed",t.streamId),e.abrupt("return");case 4:t.clean(),N.unpublish(t),N.publish(t);case 7:case"end":return e.stop()}}),e)})))),e.next=23;break;case 20:return e.next=22,null===(I=this._handler)||void 0===I?void 0:I.publish(t);case 22:k=e.sent;case 23:if(null===(c=t.observer)||void 0===c||c.setHandler(s),k){e.next=26;break}throw new mA(pA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 26:if("H264"!==(null===(u=this._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec)){e.next=32;break}return e.next=29,sL();case 29:if(e.sent){e.next=32;break}throw new mA(pA.PUBLISH_FAILED,"h264 is not supported");case 32:return o=k.audioMid,a=k.videoMid,t.pubAttributes={localaudio:!!n,localvideo:!!r,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(r instanceof mV),extaudio:!!(n instanceof yV)},R={attributes:Zd({videoDescriptions:k.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:o,videoMid:a,sdpInfo:{msid:t.stream.id,type:k.type,sdp:k.partialSdp,semantics:k.semantics},peerConnectionMode:null===(l=k)||void 0===l?void 0:l.peerConnectionMode,supportMultiVendor:!0},(A=!this._vendorConfig.enableMultiVendor&&t.enableSimulcast&&(null===(h=this._context)||void 0===h||null===(p=h.serverConfig)||void 0===p?void 0:p.simulcastOnDemand)&&(null===(v=k.subVideoDescriptions)||void 0===v?void 0:v.length))&&(R.attributes.subVideoDescriptions=k.subVideoDescriptions),null!==(f=k)&&void 0!==f&&f.peerConnectionId&&(R.peerConnectionId=k.peerConnectionId),e.next=41,null===(_=this._dataChannelSignal)||void 0===_?void 0:_.sendSignaling("publish",R);case 41:if(200===(null==(w=e.sent)?void 0:w.code)){e.next=44;break}throw new mA(pA.PUBLISH_FAILED,(null==w?void 0:w.message)||"publish failed");case 44:if(null===(m=this._monitor)||void 0===m||m.report("rtc_recv_answer",{error_code:0,answer_type:null==w?void 0:w.relayMessage.type,sequence_id:(null==w||null===(y=w.relayMessage)||void 0===y?void 0:y.sequenceId)||0,message:null==w||null===(g=w.relayMessage)||void 0===g?void 0:g.sdp,direction:"up",stream_id:"",stream_user_id:"",pc_session_id:(null===(S=s)||void 0===S?void 0:S.peerConnectionId)||""}),C=new Y_((function(e,r){var n,i,c,u,d,l;null===(n=s)||void 0===n||n.handleAck({action:pF.publish,streamId:w.streamId,audioMid:o,videoMid:a,audioTransceiverInit:null===(i=k)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(c=k)||void 0===c?void 0:c.videoTransceiverInit,signalingAck:{sdp:null==w||null===(u=w.relayMessage)||void 0===u?void 0:u.sdp,sequenceId:null==w||null===(d=w.relayMessage)||void 0===d?void 0:d.sequenceId},sdp:null===(l=k)||void 0===l?void 0:l.sdp,stream:t,onSuccess:function(){cG.info("publish()","publish success"),e(0)}})})),"chrome"!==(null===(b=this.handler)||void 0===b?void 0:b.name)){e.next=49;break}return e.next=49,C;case 49:return A&&this.emit(EH.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}],!0),t.streamId=w.streamId,t.videoMid=a,t.audioMid=o,t.subVideoDescriptions=k.subVideoDescriptions,null===(E=this._monitor)||void 0===E||E.report("rtc_publish_stat",{result:"success",is_screen:"0",start:i,message:"unknown"}),e.abrupt("return");case 58:return e.prev=58,e.t0=e.catch(7),e.t0 instanceof Error?null===(O=this._monitor)||void 0===O||O.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:Om(M="".concat(e.t0.name,": ")).call(M,e.t0.message)}):e.t0 instanceof mA&&(null===(D=this._monitor)||void 0===D||D.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:Om(P="".concat(e.t0.code,": ")).call(P,e.t0.message)})),e.next=63,null===(x=s)||void 0===x?void 0:x.rollback(t.stream.id,t);case 63:throw e.t0;case 64:case"end":return e.stop()}}),e,this,[[7,58]])}))),function(e){return S.apply(this,arguments)})},{key:"updatePubTrack",value:(g=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(cG.info("updatePubTrack()","localStream: %o",t),i=t.videoTrack,o=t.audioTrack,a=t.pubAudio,s=t.pubVideo,c=t.vendorHandler||this.handler,u=null==o?void 0:o.getTrack("preprocessing"),d=null==i?void 0:i.getTrack("preprocessing"),!s||!d){e.next=10;break}return e.next=8,null===(l=t.videoTransceiver)||void 0===l?void 0:l.sender.replaceTrack(d);case 8:e.next=12;break;case 10:return e.next=12,null===(h=t.videoTransceiver)||void 0===h?void 0:h.sender.replaceTrack(null);case 12:if(null==c||c.updateMaxBitrate(t),!a||!u){e.next=20;break}return v=o.mixType,(f=o.mixedAudioTrack)&&v!==Ml.PLAYOUT&&u.enabled&&(u=f),e.next=18,null===(p=t.audioTransceiver)||void 0===p?void 0:p.sender.replaceTrack(u);case 18:e.next=23;break;case 20:return e.next=22,null===(_=t.audioTransceiver)||void 0===_?void 0:_.sender.replaceTrack(null);case 22:jO(this.id,"MediaClient.updatePubTrack(audio)","null");case 23:try{jO(this.id,"MediaClient.updatePubTrack",Nm({audioStreamTrack:MM(u),videoStreamTrack:MM(d)}))}catch(uq){}for(y={},g=0,S=RA(m={localaudio:!!o,localvideo:!!i,videostream:s,audiostream:a,extvideo:!!(i instanceof mV),extaudio:!!(o instanceof yV)});g<S.length;g++)b=eI(S[g],2),E=b[0],(k=b[1])!==dI(t.pubAttributes,E)&&fP(y,E,k);if(an(y).length){e.next=29;break}return e.abrupt("return");case 29:return t.observer&&(T=t.observer,I=y.audiostream,R=y.videostream,A=y.localaudio,w=y.localvideo,C=y.extaudio,x=y.extvideo,void 0!==w?void 0!==x?T.setPushVideo(x):T.setEnableVideo(w):void 0!==R&&T.setUnmuteVideo(R),void 0!==A?void 0!==C?T.setPushAudio(C):T.setEnableAudio(A):void 0!==I&&T.setUnmuteAudio(I)),t.pubAttributes=m,O={roomId:this._roomId,streamId:t.streamId,attributes:y},e.next=34,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateStreamAttributes",O);case 34:if(200===(null==(M=e.sent)?void 0:M.code)){e.next=37;break}throw new mA(pA.UPDATE_TRACK_FAILED,(null==M?void 0:M.message)||"update track failed");case 37:if("chrome"===(null===(n=this.handler)||void 0===n?void 0:n.name)){e.next=40;break}return e.next=40,null==c?void 0:c.setCurrentDescription();case 40:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"updateToken",value:(y=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(cG.info("updateToken()","newToken: %o",t),this._token=t,this._context.appId&&null!==(r=this._userInfo)&&void 0!==r&&r.userId&&this._roomId){e.next=4;break}return e.abrupt("return");case 4:return i={roomId:this._roomId,userId:null===(n=this._userInfo)||void 0===n?void 0:n.userId,appId:this._context.appId,token:"Bearer ".concat(t)},e.prev=5,e.next=8,null===(o=this._dataChannelSignal)||void 0===o?void 0:o.sendSignaling("updateToken",i);case 8:if(200===(null==(a=e.sent)?void 0:a.code)){e.next=11;break}throw new mA(pA.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 11:e.next=16;break;case 13:throw e.prev=13,e.t0=e.catch(5),new mA(pA.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 16:case"end":return e.stop()}}),e,this,[[5,13]])}))),function(e){return y.apply(this,arguments)})},{key:"unpublish",value:(m=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return cG.info("unpublish()","localStream: %o",t),n={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",n),i=t.vendorHandler||this._handler,e.next=6,null==i?void 0:i.handleAck({action:pF.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 6:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"subscribe",value:(_=Rm(Tm().mark((function e(t,r,n){var i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Y_(function(){var e=Rm(Tm().mark((function e(o,a){var s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D,P,N,L,U,V,F,B,j,H,G,z,K,X,W,q,Y,J,Q,Z,$;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.streamState!==cF.SUB_ED){e.next=2;break}return e.abrupt("return",i._updateSubTrack(t,r,MH.SUB).then(o,a));case 2:if(t.streamState!==cF.SUB_ING){e.next=7;break}return i._subStreamQueue[t.streamId]||(i._subStreamQueue[t.streamId]=[]),cG.info("_subStreamQueue","streamId: %o, enqueue",t.streamId),i._subStreamQueue[t.streamId].push({fn:i.subscribe,args:[t,r,n],resolve:o,reject:a}),e.abrupt("return");case 7:if(cG.info("subscribe()","mediaType: %o",r),lG("subscribe()",t),t.streamState=cF.SUB_ING,c=!1,u=!1,wM(r)&&(u=!0),CM(r)&&(c=!0),c||!i.multiChatMode()){e.next=17;break}return t.streamState=cF.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",o(null));case 17:if(d=lM(),l=t.subVideo,h=[],p=!i.multiChatMode(),i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),h.push(new Y_((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),uG);t.on("ontrack",(function r(i){"video"===i.mediaType&&(cG.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p&&h.push(new Y_((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),uG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(cG.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v=function(e){t.ontrack(e)},null===(s=i._handler)||void 0===s||s.on("ontrack",v),i._ontrackCallbackMap.set(t,v),f=i._handler,e.prev=28,null!==(_=i._context.serverConfig)&&void 0!==_&&_.forceUniHandler||!t.enableVendorMode){e.next=42;break}return V=new KH(i._context,""),t.vendorHandler=new NH(i._context,V),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),(f=t.vendorHandler).on("ontrack",v),e.next=37,t.vendorHandler.subscribe(t);case 37:U=e.sent,f.on("ice_state",(function(e){i.emit(kH.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:ll.CONNECTION_STATE_CONNECTING,connected:ll.CONNECTION_STATE_CONNECTED,disconnected:ll.CONNECTION_STATE_RECONNECTING}[e],userId:t.userId})})),V.once("disconnect",Rm(Tm().mark((function e(){var r,n,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=f)||void 0===r||r.removeAllListeners(),"connected"===(null===(n=i._handler)||void 0===n||null===(o=n.pc)||void 0===o?void 0:o.iceConnectionState)){e.next=4;break}return cG.error("vendor ice failed",t.streamId),e.abrupt("return");case 4:return t.resetHasSubscribed(),i.unsubscribe(t,ul.AUDIO_AND_VIDEO,!0),e.next=8,i.subscribe(t,t.subMediaType);case 8:i.emit(CH.RESUBSCRIBE,{stream:t});case 9:case"end":return e.stop()}}),e)})))),e.next=45;break;case 42:return e.next=44,null===(F=i._handler)||void 0===F?void 0:F.subscribe(t,{multiChatMode:i.multiChatMode()});case 44:U=e.sent;case 45:if(null===(m=t.observer)||void 0===m||m.setHandler(f),U){e.next=48;break}throw new mA(pA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 48:return B=U.audioMid,j=U.videoMid,t.subVideo=c,H={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},G={audio:!i.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:j,audioMid:B,sdpInfo:{sdp:null===(y=U)||void 0===y?void 0:y.partialSdp,semantics:null===(g=U)||void 0===g?void 0:g.semantics,type:null===(S=U)||void 0===S?void 0:S.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i.multiChatMode()||u,video:c},qualityLayer:H},extra:{enableSendRTT:!0},peerConnectionMode:null===(b=U)||void 0===b?void 0:b.peerConnectionMode,supportMultiVendor:!0},null!==(E=U)&&void 0!==E&&E.peerConnectionId&&(G.peerConnectionId=U.peerConnectionId),z=i._context||{},K=z.subscribeFallbackOption,X=z.userPriority,"number"==typeof K&&(G.config.fallbackOption=K),X.has(t.userId)&&(G.config.priority=X.get(t.userId)),null!==(k=U)&&void 0!==k&&k.allSsrc&&(G.extra.subscribeSSRC=U.allSsrc),e.next=60,null===(T=i._dataChannelSignal)||void 0===T?void 0:T.sendSignaling("subscribe",G);case 60:if(200===(null==(W=e.sent)?void 0:W.code)){e.next=63;break}throw new mA(pA.SUBSCRIBE_FAILED,(null==W?void 0:W.message)||"subscribe failed");case 63:return q=null==W?void 0:W.relayMessage,Y=q.audioMid,J=q.videoMid,Jd(I={},B,Y),Jd(I,j,J),Q=I,cG.info("sub midmap",t.userId,Q),t.videoMid=j,t.audioMid=B,t.subMediaType=r,t.streamState=cF.SUB_ED,t.subLayer=H,null===(R=i._monitor)||void 0===R||R.report("rtc_recv_answer",{error_code:0,answer_type:null==W||null===(A=W.relayMessage)||void 0===A?void 0:A.type,sequence_id:(null==W||null===(w=W.relayMessage)||void 0===w?void 0:w.sequenceId)||0,message:null==W||null===(C=W.relayMessage)||void 0===C?void 0:C.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:(null===(x=f)||void 0===x?void 0:x.peerConnectionId)||""}),e.next=74,null===(O=f)||void 0===O?void 0:O.handleAck({action:pF.subscribe,streamId:t.streamId,audioMid:B,videoMid:j,audioTransceiverInit:null===(M=U)||void 0===M?void 0:M.audioTransceiverInit,videoTransceiverInit:null===(D=U)||void 0===D?void 0:D.videoTransceiverInit,signalingAck:{sdp:null==W||null===(P=W.relayMessage)||void 0===P?void 0:P.sdp,sequenceId:null==W||null===(N=W.relayMessage)||void 0===N?void 0:N.sequenceId},stream:t,sdp:U.sdp,generatorSsrc:!!U.allSsrc});case 74:return e.next=76,Y_.all(h);case 76:i.multiChatMode()||(t.subAudio=u),null===(L=i._monitor)||void 0===L||L.report("rtc_subscribe_stat",{result:"success",start:d,message:"unknown",stream_user_id:t.userId}),i._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return i.emit("onRemoteStreamStats",e)}),f),o(null),i.emit("SUB_END",t.streamId),e.next=92;break;case 83:return e.prev=83,e.t0=e.catch(28),e.t0 instanceof Error&&(null===($=i._monitor)||void 0===$||$.report("rtc_subscribe_stat",{result:"fail",start:d,message:e.t0.message,stream_user_id:t.userId})),t.subVideo=l,t.streamState=cF.INIT,e.next=90,null===(Z=f)||void 0===Z?void 0:Z.rollback(t.streamId,t);case 90:a(e.t0),i.emit("SUB_END",t.streamId);case 92:case"end":return e.stop()}}),e,null,[[28,83]])})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)}))),function(e,t,r){return _.apply(this,arguments)})},{key:"_handleSubStreamQueue",value:function(e){var t,r=this;if(null!==(t=this._subStreamQueue[e])&&void 0!==t&&t.length){cG.info("_subStreamQueue","streamId: %o, exec",e);var n=this._subStreamQueue[e].shift(),i=n.fn,o=n.args,a=n.resolve,s=n.reject;i.apply(this,o).then(a,s).finally((function(){return r._handleSubStreamQueue(e)}))}else cG.warn("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(f=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return cG.info("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"updateUserAttributes",value:(v=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return cG.info("updateUserAttributes()","attributes: %o",t),e.next=3,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateUserAttributes",{roomId:this._roomId,sessionId:this._sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"updateSubTrack",value:(p=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._updateSubTrack(t,r,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return p.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(h=Rm(Tm().mark((function e(t,r){var n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(cG.info("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return cG.warn("updateSubTrack()","subLayer no change"),e.abrupt("return");case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new mA(pA.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.subLayer=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"updateSubPriority",value:(l=Rm(Tm().mark((function e(t,r){var n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(cG.info("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return cG.warn("updateSubPriority()","priority no change"),e.abrupt("return",t);case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{priority:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new mA(pA.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.priority=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"_updateSubTrack",value:(d=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(cG.info("updateSubTrack()","mediaType: %o",r),lG("updateSubTrack()",t),!this.multiChatMode()||r!==ul.AUDIO){e.next=5;break}return cG.warn("updateSubTrack","multiChatMode mediaType only audio"),e.abrupt("return",t);case 5:return a=0,a=n===MH.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),cG.info("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,a),t.subMediaType===a&&cG.info("updateSubTrack","mediaType no change"),s=!1,c=!1,wM(a)&&(c=!0),CM(a)&&(s=!0),u={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:s,audio:!!this.multiChatMode()||c}}},e.next=15,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("updateSubscribe",u);case 15:if(200===(null==(d=e.sent)?void 0:d.code)){e.next=18;break}throw new mA(pA.UPDATE_TRACK_FAILED,(null==d?void 0:d.message)||"update track failed");case 18:return this.multiChatMode()||(null===(l=t.observer)||void 0===l||l.setUnmuteAudio(c),t.subAudio=c),null===(o=t.observer)||void 0===o||o.setUnmuteVideo(s),t.subVideo=s,t.subMediaType=a,e.abrupt("return",t);case 23:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return d.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(u=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return cG.info("subscribe4pushTrack()","streamInfo: %o",r),lG("subscribe4pushTrack()",t),t.subAudio=!0,e.next=5,null===(n=this._handler)||void 0===n?void 0:n.subscribe(t,{multiChatMode:this.multiChatMode()});case 5:if(a=e.sent){e.next=8;break}throw new mA(pA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 8:return s=a.audioMid,c=a.videoMid,(u=[]).push(new Y_((function(e,r){var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),uG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(cG.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),d=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",d),this._ontrackCallbackMap.set(t,d),e.next=17,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:pF.pushtrack,streamId:t.streamId,audioMid:s,videoMid:c,stream:t,audioTransceiverInit:null==a?void 0:a.audioTransceiverInit,videoTransceiverInit:null==a?void 0:a.videoTransceiverInit,signalingAck:null==r?void 0:r.message,sdp:a.sdp});case 17:return e.next=19,Y_.all(u);case 19:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return l.emit("onRemoteStreamStats",e)}),this._handler);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(c=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(lG("unsubscribe4removeTrack()",t),cG.info("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId,"trackType: ",n),!(r.sequenceId<t.sequenceId)){e.next=5;break}return cG.warn("unsubscribe4removeTrack()","sequenceId return"),e.abrupt("return");case 5:return u=!!((c=n+1)&ul.AUDIO),d=!!(c&ul.VIDEO),e.next=10,null===(i=this._handler)||void 0===i?void 0:i.handleAck({action:pF.removetrack,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:null===(o=t.observer)||void 0===o||o.setPushTrack(!1),null===(a=t.observer)||void 0===a||a.setUnmuteAudio(!u),t.subAudio=!u,null===(s=t.observer)||void 0===s||s.setUnmuteVideo(!d),t.subVideo=!d,t.subMediaType=t.subMediaType-(t.subMediaType&c),t.virtual&&(t.clean(),t.resetHasSubscribed(),t.statsReport.unsubscribe());case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return c.apply(this,arguments)})},{key:"unsubscribe",value:(s=Rm(Tm().mark((function e(t,r){var n,i,o=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],lG("unsubscribe()",t),!n){e.next=4;break}return e.abrupt("return",this._unsubscribe(t,r));case 4:if(!this.multiChatMode()||!CM(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!==zV.NONE){e.next=9;break}return e.abrupt("return",this._unsubscribe(t,r));case 9:return e.abrupt("return",this._updateSubTrack(t,r,MH.UNSUB));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_unsubscribe",value:(a=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subConfig.muteReplaceUnsub){e.next=2;break}return e.abrupt("return",this._updateSubTrack(t,r,MH.UNSUB));case 2:return a={roomId:this._roomId,streamId:t.streamId,userId:t.userId},s=t.vendorHandler||this.handler,null===(n=this._dataChannelSignal)||void 0===n||n.sendSignaling("unsubscribe",a).catch((function(){})),t.streamState=cF.INIT,this._subStreamQueue[t.streamId]&&(this._subStreamQueue[t.streamId].forEach((function(e){return(0,e.resolve)(null)})),delete this._subStreamQueue[t.streamId]),t.subVideo=!1,null===(i=t.observer)||void 0===i||i.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(o=t.observer)||void 0===o||o.setSubscribeAudio(!1)),e.next=12,null==s?void 0:s.handleAck({action:pF.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 12:c=e.sent,this._subResolves[c]&&this._subResolves[c].forEach((function(e){return e(0)})),cG.info("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t=this._ontrackCallbackMap.get(e);if(t){var r=e.vendorHandler||this._handler;null==r||r.off("ontrack",t),this._ontrackCallbackMap.delete(e)}}},{key:"handleRemoveStream",value:(o=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(lG("handleRemoveStream()",t),t.subVideo=!1,t.streamState!==cF.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t,ul.AUDIO_AND_VIDEO,!0);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"leave",value:(i=Rm(Tm().mark((function e(){var t,r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(cG.info("leave()"),this._stopJoinRoom5xxRetry(),this._joinRoomFailed("leave_room"),"connected"!==this.connectionState){e.next=20;break}return t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=7,this._joinLeaveLock.lock();case 7:return r=e.sent,e.prev=8,e.next=11,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 11:r(),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(8),r(),e.t0;case 18:e.next=21;break;case 20:return e.abrupt("return",Y_.reject(new mA(pA.NOT_CONNECTED_YET,"server not connected")));case 21:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(){return i.apply(this,arguments)})},{key:"subscribePublicStream",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._handler)||void 0===r?void 0:r.subscribe(t,{multiChatMode:!1});case 2:if(s=e.sent){e.next=5;break}throw new mA(pA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=lM(),u=s.audioMid,d=s.videoMid,e.t0=this._context.appId,e.t1=t.streamId,e.t2=u,e.t3=d,e.t4={sdp:null==s?void 0:s.partialSdp,semantics:null==s?void 0:s.semantics,type:null==s?void 0:s.type},e.next=15,ZN();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=CD.VERSION,e.t8=ED.getDeviceId(),e.t9=this._context.appId,e.t10=this._businessId,e.t11=this._context.useCloudProxy,e.t12={supportedCodecs:e.t5,deviceType:"web",userAgent:e.t6,sdkVersion:e.t7,deviceId:e.t8,appId:e.t9,businessId:e.t10,enableCloudProxy:e.t11},e.t13={enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}},l={appId:e.t0,streamId:e.t1,audio:!0,video:!0,data:!0,audioMid:e.t2,videoMid:e.t3,sdpInfo:e.t4,params:e.t12,config:e.t13},e.next=27,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",l);case 27:return h=e.sent,p=[],this._subResolves[t.streamId]=[],p.push(new Y_((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),uG);t.on("ontrack",(function r(i){"video"===i.mediaType&&(cG.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p.push(new Y_((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),uG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(cG.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",v),this._ontrackCallbackMap.set(t,v),f=null==h?void 0:h.relayMessage,_=f.sequenceId,m=f.sdp,t.videoMid=d,t.audioMid=u,t.sequenceId=_,t.streamState=cF.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:pF.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:m,sequenceId:_},stream:t});case 44:return e.next=46,Y_.all(p);case 46:null===(a=this._monitor)||void 0===a||a.report("rtc_subscribe_stat",{result:"success",start:c,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return y.emit("onRemoteStreamStats",e)}),this._handler);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(r=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return lG("unsubscribePublicStream()",t),n={appId:this._context.appId,streamId:t.streamId},e.prev=2,e.next=5,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=cF.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:pF.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;cG.info("destroy()"),this._joinRoomFailed("leave_room"),this._token=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId="",this._stopJoinRoom5xxRetry(),null===(e=this._handler)||void 0===e||e.destroy(),this._handler=void 0,null===(t=this._dataChannelSignal)||void 0===t||t.destroy(),this._dataChannelSignal=void 0,this._connectionManager.destroy(),null===(r=this._monitor)||void 0===r||r.set({connection_id:""}),this._removeSignalEventHandler(),this.removeAllListeners(),this.connectionState="disconnected"}},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendP2PMessage({to:e,from:this._userInfo.userId,room:this._roomId,app:this._context.appId,msg:t})}},{key:"sendRoomMessage",value:function(e){var t;return null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("customMessage",e)}},{key:"_joinRoomWithRetry",value:function(e,t,r){var n=this;return new Y_((function(i,o){n._dataChannelSignal.sendSignaling(e,t,void 0,1e4).then((function(e){n.emit("onJoinRoomAck",e),i(e)})).catch((function(a){if(r=r||new VH,a.code>=500&&a.code<600&&lM()-r.initTs<6e4){var s,c=r.getRetryDelay();return cG.warn("_joinRoomWithRetry",Om(s="joinRoom failed(code: ".concat(a.code,"), will retry after ")).call(s,c,"ms")),void(n._joinRoom5xxTimer=window.setTimeout((function(){delete n._joinRoom5xxTimer,n._joinRoomWithRetry(e,t,r).then(i).catch(o)}),c))}o(a)}))}))}},{key:"_stopJoinRoom5xxRetry",value:function(){this._joinRoom5xxTimer&&(clearTimeout(this._joinRoom5xxTimer),delete this._joinRoom5xxTimer)}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n,i;cG.info("connectStateChange","connected"),e.connectionState="connected",null===(r=e._dataChannelSignal)||void 0===r||r.destroy(),null===(n=e._handler)||void 0===n||n.destroy(),e._handler=yH(e._context,t.pc),e._dataChannelSignal=t.signaling,e.supportConcurrent="chrome"===(null===(i=e._handler)||void 0===i?void 0:i.name),e._addSignalEventHandler(),e.isReconnecting&&(e._reportJoinRoomStart(),e._callJoinRoom(!0))})),this._connectionManager.on("disconnected",(function(t){e.connectionState="disconnected",cG.error("connectStateChange","disconnected. %o",t),e.isReconnecting&&e.safeEmit(CH.RECONNECT_FAILED)})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",cG.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.connectionState="disconnected",e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",cG.warn("connectStateChange","reconnecting"),e.safeEmit("reconnecting")})),this._connectionManager.on("connectWidthTcp",(function(){e.safeEmit(CH.ON_ICE_CONNECT_WITH_TCP)})),["__onGetIceConfigHook","__onIceConnectSuccessHook"].forEach((function(t){e._connectionManager.on(t,(function(){return e.emit(t)}))}))}},{key:"_reportJoinRoomStart",value:function(){var e;this._joinRoomStartTs=lM(),this.emit("__joinRoomStartReport"),null===(e=this._monitor)||void 0===e||e.report("join_room",{type:"begin",start:this._joinRoomStartTs,result:!1,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC})}},{key:"_joinRoomSuccess",value:function(e){var t,r;(this._joinReject&&this._joinResolve&&(this._joinResolve(e),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomSuccessReport"),null===(t=this._monitor)||void 0===t||t.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!0,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),null===(r=this._monitor)||void 0===r||r.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:lM()-this._joinRoomStartTs}),delete this._joinRoomStartTs)}},{key:"_joinRoomFailed",value:function(e,t){var r;(this._joinReject&&this._joinResolve&&(this._joinReject(new mA(t||pA.JOIN_ROOM_FAILED,e)),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomFailedReport"),null===(r=this._monitor)||void 0===r||r.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!1,reason:e},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),delete this._joinRoomStartTs)}},{key:"multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"sendForwardStreamSignal",value:(t=Rm(Tm().mark((function e(t,r,n){var i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o={forwardStreamType:t,roomId:r},("start"===t||"update"===t)&&(o.dstRoomInfos=null==n?void 0:jm(n).call(n,(function(e){return{dstRoomId:e.roomId,dstToken:pM.token2auth(a._context.appId,e.roomId,a._clientId,e.token)}}))),e.abrupt("return",null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("forwardStream",o));case 4:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}},{key:"vendorConfig",get:function(){return this._vendorConfig}}]),T}(aP);function pG(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._handler||"connected"!==this._state){e.next=6;break}for(r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=4,n.apply(this,i);case 4:e.next=7;break;case 6:throw new mA(pA.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function vG(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var t,r,i,o,a=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pubSubLock.lock();case 2:for(t=e.sent,this.supportConcurrent&&t(),e.prev=4,r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=8,n.apply(this,i);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,this.supportConcurrent||t(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[4,,9,12]])}))),r}sG([function(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var t,r,i,o,a=this,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=s.length,r=new Array(t),i=0;i<t;i++)r[i]=s[i];return o=!1,e.abrupt("return",new Y_(function(){var e=Rm(Tm().mark((function e(t,i){var s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new mA(pA.OPERATION_CANCEL,"operation not finish when leave"))})),e.prev=1,e.next=4,n.apply(a,r);case 4:s=e.sent,t(s),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o||i(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)}))),r}],hG.prototype,"join",1),sG([vG,pG],hG.prototype,"publish",1),sG([vG,pG],hG.prototype,"updatePubTrack",1),sG([vG,pG],hG.prototype,"unpublish",1),sG([vG,pG],hG.prototype,"subscribe",1),sG([pG],hG.prototype,"controlMessage",1),sG([pG],hG.prototype,"updateUserAttributes",1),sG([pG],hG.prototype,"updateSubTrack",1),sG([pG],hG.prototype,"updateSubTrackLayer",1),sG([pG],hG.prototype,"updateSubPriority",1),sG([vG,pG],hG.prototype,"subscribe4pushTrack",1),sG([vG,pG],hG.prototype,"unsubscribe4removeTrack",1),sG([vG,pG],hG.prototype,"unsubscribe",1),sG([pG],hG.prototype,"handleRemoveStream",1),sG([vG],hG.prototype,"subscribePublicStream",1),sG([vG],hG.prototype,"unsubscribePublicStream",1);var fG,_G=function(){var e=Rm(Tm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,f,_,m,y;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getOrgTrack():null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getOrgTrack(),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.receiver:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.receiver,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,gL(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,f=gE(p=v||[]).call(p,(function(e){return"inbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(_=e.sent,m=[],null==_||_.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==(null==v?void 0:v.length)||0===m.length){e.next=22;break}return e.next=21,gL(r.pc);case 21:y=e.sent;case 22:u=Nm({type:t,reports:jm(v).call(v,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==f?void 0:f.bytesReceived,framesReceived:null==f?void 0:f.framesReceived,packetsReceived:null==f?void 0:f.packetsReceived,allReports:y}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Nm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_recv_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),mG=function(){var e=Rm(Tm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,f,_,m,y;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack("preprocessing"):null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.sender:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.sender,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,gL(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,f=gE(p=v||[]).call(p,(function(e){return"outbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(_=e.sent,m=[],null==_||_.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==v.length||0===m.length){e.next=22;break}return e.next=21,gL(r.pc);case 21:y=e.sent;case 22:u=Nm({type:t,reports:jm(v).call(v,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==f?void 0:f.bytesSent,framesSent:null==f?void 0:f.framesSent,packetsSent:null==f?void 0:f.packetsSent,allReports:y}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Nm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_send_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),yG=new Nw("RecvFrameObserver",0),gG=function(e){DI(a,e);var t,r,n,i,o=QI(a);function a(e,t){var r;return Vl(this,a),Jd(tI(r=o.call(this)),"_audioEventSessionId",fM()),Jd(tI(r),"_videoEventSessionId",fM()),Jd(tI(r),"_handler",void 0),Jd(tI(r),"_stream",void 0),Jd(tI(r),"_firstAudioFrameTimer",void 0),Jd(tI(r),"_firstVideoFrameTimer",void 0),Jd(tI(r),"_transportDelayInterval",void 0),Jd(tI(r),"_transportDelay",void 0),Jd(tI(r),"_firstVideoFrameInterval",void 0),Jd(tI(r),"_firstAudioFrameInterval",void 0),Jd(tI(r),"_isScreen",!1),Jd(tI(r),"_audioFirstFrameState",0),Jd(tI(r),"_videoFirstFrameState",0),Jd(tI(r),"_timeout",1e4),Jd(tI(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(tI(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(tI(r),"_login",!1),Jd(tI(r),"_unMuteAudio",!1),Jd(tI(r),"_enableAudio",!1),Jd(tI(r),"_unMuteVideo",!1),Jd(tI(r),"_enableVideo",!1),Jd(tI(r),"_remoteUnmuteAudio",!1),Jd(tI(r),"_remoteUnmuteVideo",!1),Jd(tI(r),"_audioExternal",!1),Jd(tI(r),"_pushAudio",!1),Jd(tI(r),"_videoExternal",!1),Jd(tI(r),"_pushVideo",!1),Jd(tI(r),"_autoSubscribeVideo",!1),Jd(tI(r),"_autoSubscribeAudio",!1),Jd(tI(r),"_autoSubscribe",!1),Jd(tI(r),"_publishVideo",!1),Jd(tI(r),"_publishAudio",!1),Jd(tI(r),"_subscribeAudio",!1),Jd(tI(r),"_subscribeVideo",!1),Jd(tI(r),"_subscribe",!1),Jd(tI(r),"_pushTrack",!1),Jd(tI(r),"_multiChatMode",!1),Jd(tI(r),"_monitor",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=VO(e.engineId),r}return Ul(a,[{key:"beginRecvFrame",value:(i=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,xE(n=["login","unmute","subscribe","push_track"]).call(n,r)>=0&&(i=0,o=!1),"audio"===t?(o||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},p={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(a=this._stream)||void 0===a||!a.isScreen),start:null===(s=this._currentAudioRecv)||void 0===s?void 0:s.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,transport_delay:i,vendor_mode:(null===(u=this._stream)||void 0===u?void 0:u.vendorCode)||0,pc_session_id:(null===(d=this._stream)||void 0===d?void 0:d.pcSessionId)||(null===(l=this._handler)||void 0===l?void 0:l.peerConnectionId)},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){_G("audio",E._handler,E._stream,E._monitor),E.stopRecvFrame("audio","timeout"),E._firstAudioFrameInterval&&window.clearInterval(E._firstAudioFrameInterval)}),this._timeout),yG.info("rtcFirstFrameRecv",Nm(p)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",p),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):"video"===t&&(o||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},b={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(v=this._stream)||void 0===v||!v.isScreen),start:null===(f=this._currentVideoRecv)||void 0===f?void 0:f.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,transport_delay:i,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(y=this._stream)||void 0===y?void 0:y.pcSessionId)||(null===(g=this._handler)||void 0===g?void 0:g.peerConnectionId)},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){_G("video",E._handler,E._stream,E._monitor),E.stopRecvFrame("video","timeout"),E._firstVideoFrameInterval&&window.clearInterval(E._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),yG.info("rtcFirstFrameRecv",Nm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u;if(1!==this._audioFirstFrameState)return;var d={event_type:"recv_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioRecv)||void 0===n?void 0:n.startTime,reason:t,result:!1,stream_user_id:null===(i=this._stream)||void 0===i?void 0:i.userId,event_session_id:this._audioEventSessionId,type:null===(o=this._currentAudioRecv)||void 0===o?void 0:o.type,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,yG.info("rtcFirstFrameRecv",Nm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._audioFirstFrameState=2}else if("video"===e){var l,h,p,v,f,_,m,y;if(1!==this._videoFirstFrameState)return;var g={event_type:"recv_end",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),start:null===(h=this._currentVideoRecv)||void 0===h?void 0:h.startTime,reason:t,result:!1,stream_user_id:null===(p=this._stream)||void 0===p?void 0:p.userId,event_session_id:this._videoEventSessionId,type:null===(v=this._currentVideoRecv)||void 0===v?void 0:v.type,vendor_mode:(null===(f=this._stream)||void 0===f?void 0:f.vendorCode)||0,pc_session_id:(null===(_=this._stream)||void 0===_?void 0:_.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,yG.info("rtcFirstFrameRecv",Nm(g)),null===(y=this._monitor)||void 0===y||y.report("rtc_first_frame",g),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:if(r=this._transportDelay,"audio"!==t){e.next=19;break}if(1===this._audioFirstFrameState){e.next=6;break}return e.abrupt("return");case 6:if(this._currentAudioRecv){e.next=8;break}return e.abrupt("return");case 8:d=this._currentAudioRecv,l=d.type,h=d.startTime,xE(n=["login","unmute","subscribe","push_track"]).call(n,l)>=0&&(r=0),p={event_type:"recv_end",media_type:t,start:h,result:!0,is_screen:!(null===(i=this._stream)||void 0===i||!i.isScreen),stream_user_id:null===(o=this._stream)||void 0===o?void 0:o.userId,event_session_id:this._audioEventSessionId,type:l,transport_delay:r,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),yG.info("rtcFirstFrameRecv",Nm(p)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",p),this.emit("recvAudioFirstFrame"),this._audioFirstFrameState=3,e.next=33;break;case 19:if("video"!==t){e.next=33;break}if(1===this._videoFirstFrameState){e.next=22;break}return e.abrupt("return");case 22:if(this._currentVideoRecv){e.next=24;break}return e.abrupt("return");case 24:b=this._currentVideoRecv,E=b.type,k=b.startTime,xE(v=["login","unmute","subscribe","push_track"]).call(v,E)>=0&&(r=0),T={event_type:"recv_end",media_type:t,is_screen:!(null===(f=this._stream)||void 0===f||!f.isScreen),start:k,result:!0,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,event_session_id:this._videoEventSessionId,type:E,transport_delay:r,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(y=this._stream)||void 0===y?void 0:y.pcSessionId)||(null===(g=this._handler)||void 0===g?void 0:g.peerConnectionId)},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),yG.info("rtcFirstFrameRecv",Nm(T)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",T),this.emit("recvVideoFirstFrame"),this._videoFirstFrameState=3;case 33:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLogin",value:function(e){var t,r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};this._login!==e&&(this._login=e,e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&o.audio&&this.beginRecvFrame("audio","login"),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame("video","login"),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame("audio","leave_room"),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame("video","leave_room"))}},{key:"setUnmuteAudio",value:function(e){var t,r,n;if(this._unMuteAudio!==e){this._unMuteAudio=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasAudio);null!==(r=this._stream)&&void 0!==r&&r.audioHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.audioHasPublish&&(this._unMuteAudio&&i?this.beginRecvFrame("audio","unmute"):i&&this.stopRecvFrame("audio","mute"))}}},{key:"setRemoteUnmuteAudio",value:function(e){this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame("audio","remote_unmute"):this.stopRecvFrame("audio","remote_mute"))}},{key:"setEnableAudio",value:function(e){this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame("audio","enable"):this.stopRecvFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t,r,n;if(this._unMuteVideo!==e){this._unMuteVideo=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasVideo);null!==(r=this._stream)&&void 0!==r&&r.videoHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.videoHasPublish&&(this._unMuteVideo&&i?this.beginRecvFrame("video","unmute"):i&&this.stopRecvFrame("video","mute"))}}},{key:"setHandler",value:function(e){this._handler=e}},{key:"setRemoteUnmuteVideo",value:function(e){this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame("video","remote_unmute"):this.stopRecvFrame("video","remote_mute"))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame("video","enable"):this.stopRecvFrame("video","disable"))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal=e}},{key:"setPushAudio",value:function(e){var t;this._audioExternal&&this._pushAudio!==e&&(this._pushAudio=e),this._pushAudio&&this.beginRecvFrame("audio","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.beginRecvFrame("audio","push")}},{key:"setExternalVideoSource",value:function(e){this._videoExternal=e}},{key:"setPushVideo",value:function(e){var t;this._videoExternal&&this._pushVideo!==e&&(this._pushVideo=e),this._pushVideo&&this.beginRecvFrame("video","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.beginRecvFrame("video","push")}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame("video","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unpublish")}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame("audio","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unpublish")}},{key:"setAutoSubscribe",value:function(e){this._autoSubscribe=e}},{key:"setAutoSubscribeVideo",value:function(e){this._autoSubscribeVideo=e}},{key:"setAutoSubscribeAudio",value:function(e){this._autoSubscribeAudio=e}},{key:"setSubscribeAudio",value:function(e){var t,r;this._autoSubscribeAudio||this._subscribeAudio===e||(this._subscribe=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasAudio&&this.beginRecvFrame("audio","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unsubscribe")}},{key:"setSubscribeVideo",value:function(e){var t,r;this._autoSubscribeVideo||this._subscribeVideo===e||(this._subscribeVideo=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&this.beginRecvFrame("video","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unsubscribe")}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(e&&!this._isScreen&&this.beginRecvFrame("audio","push_track"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","remove_track"))}},{key:"setMultiChatMode",value:function(e){this._multiChatMode=e}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"_watchForFirstVideoFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(Rm(Tm().mark((function n(){var i,o,a,s,c,u,d,l;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a||!a.getTrack()){n.next=12;break}return n.next=3,gL(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.videoTrack)||void 0===u?void 0:u.getTrack());case 3:if(d=n.sent,!(l=gE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.framesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.framesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(Rm(Tm().mark((function n(){var i,o,a,s,c,u,d,l;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a||!a.getOrgTrack()){n.next=12;break}return n.next=3,gL(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.getOrgTrack());case 3:if(d=n.sent,!(l=gE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.totalSamplesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.totalSamplesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"getTransportDelay",value:(r=Rm(Tm().mark((function e(){var t=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelayIntl();case 2:window.clearInterval(this._transportDelayInterval),this._transportDelayInterval=window.setInterval(Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getTransportDelayIntl();case 2:case"end":return e.stop()}}),e)}))),2e3);case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getTransportDelayIntl",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc){e.next=7;break}return e.next=3,gL(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=gE(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=gE(n).call(n,(function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==i?void 0:i.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*o.currentRoundTripTime/2));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"setDisconnect",value:function(){this.stopRecvFrame("audio","connection_lost"),this.stopRecvFrame("video","connection_lost"),this.reset()}},{key:"reset",value:function(){this._currentAudioRecv={startTime:0,eventSessionId:0,type:"login"},this._currentVideoRecv={startTime:0,eventSessionId:0,type:"login"},this._login=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._remoteUnmuteAudio=!1,this._remoteUnmuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoSubscribeVideo=!1,this._autoSubscribeAudio=!1,this._autoSubscribe=!1,this._subscribeAudio=!1,this._subscribeVideo=!1,this._subscribe=!1,this._pushTrack=!1,this._multiChatMode=!1,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._transportDelayInterval&&window.clearInterval(this._transportDelayInterval)}},{key:"audioFirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}},{key:"FirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}}]),a}(nP.exports.EventEmitter),SG=new Nw("SendFrameObserver",0),bG=function(){function e(t,r){Vl(this,e),Jd(this,"_audioEventSessionId",fM()),Jd(this,"_videoEventSessionId",fM()),Jd(this,"_pcSessionId",void 0),Jd(this,"_handler",void 0),Jd(this,"_firstAudioFrameTimer",void 0),Jd(this,"_firstVideoFrameTimer",void 0),Jd(this,"_stream",void 0),Jd(this,"_firstVideoFrameInterval",void 0),Jd(this,"_firstAudioFrameInterval",void 0),Jd(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_login",!1),Jd(this,"_publisher",!1),Jd(this,"_unMuteAudio",!1),Jd(this,"_enableAudio",!1),Jd(this,"_unMuteVideo",!1),Jd(this,"_enableVideo",!1),Jd(this,"_audioExternal",!1),Jd(this,"_pushAudio",!1),Jd(this,"_videoExternal",!1),Jd(this,"_pushVideo",!1),Jd(this,"_autoPublish",!1),Jd(this,"_publish",!1),Jd(this,"_timeout",1e4),Jd(this,"_audioFirstFrameState",0),Jd(this,"_videoFirstFrameState",0),Jd(this,"_monitor",void 0),this._stream=t,this._handler=r,this._monitor=VO(t.engineId)}var t,r;return Ul(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if("audio"===e){var n,i,o,a,s,c,u;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var d={event_type:"begin_send",media_type:e,is_screen:!(null===(n=this._stream)||void 0===n||!n.isScreen),type:t,start:this._currentAudioSend.startTime,event_session_id:this._audioEventSessionId,vendor_mode:(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,pc_session_id:(null===(o=this._stream)||void 0===o?void 0:o.pcSessionId)||(null===(a=this._handler)||void 0===a?void 0:a.peerConnectionId),capture_session_id:null===(s=this._stream)||void 0===s||null===(c=s.audioTrack)||void 0===c?void 0:c.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){mG("audio",r._handler,r._stream,r._monitor),r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),SG.info("rtcFirstFrameSend",Nm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if("video"===e){var l,h,p,v,f,_,m;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var y={event_type:"begin_send",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),type:t,start:this._currentVideoSend.startTime,event_session_id:this._videoEventSessionId,vendor_mode:(null===(h=this._stream)||void 0===h?void 0:h.vendorCode)||0,pc_session_id:(null===(p=this._stream)||void 0===p?void 0:p.pcSessionId)||(null===(v=this._handler)||void 0===v?void 0:v.peerConnectionId),capture_session_id:null===(f=this._stream)||void 0===f||null===(_=f.videoTrack)||void 0===_?void 0:_.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){mG("video",r._handler,r._stream,r._monitor),r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),SG.info("rtcFirstFrameSend",Nm(y)),null===(m=this._monitor)||void 0===m||m.report("rtc_first_frame",y),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u,d;if(1!==this._audioFirstFrameState)return;var l={event_type:"sent_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioSend)||void 0===i?void 0:i.type,vendor_mode:(null===(o=this._stream)||void 0===o?void 0:o.vendorCode)||0,pc_session_id:(null===(a=this._stream)||void 0===a?void 0:a.pcSessionId)||(null===(s=this._handler)||void 0===s?void 0:s.peerConnectionId),capture_session_id:null===(c=this._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,SG.info("rtcFirstFrameSend",Nm(l)),null===(d=this._monitor)||void 0===d||d.report("rtc_first_frame",l),this._audioFirstFrameState=2}else if("video"===e){var h,p,v,f,_,m,y,g,S;if(1!==this._videoFirstFrameState)return;var b={event_type:"sent_end",media_type:e,start:null===(h=this._currentVideoSend)||void 0===h?void 0:h.startTime,is_screen:!(null===(p=this._stream)||void 0===p||!p.isScreen),reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(v=this._currentVideoSend)||void 0===v?void 0:v.type,vendor_mode:(null===(f=this._stream)||void 0===f?void 0:f.vendorCode)||0,pc_session_id:(null===(_=this._stream)||void 0===_?void 0:_.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId),capture_session_id:null===(y=this._stream)||void 0===y||null===(g=y.videoTrack)||void 0===g?void 0:g.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,SG.info("rtcFirstFrameSend",Nm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if("audio"===e){var t,r,n,i,o,a,s;if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var c=this._currentAudioSend,u=c.type,d=c.startTime,l={event_type:"sent_end",media_type:e,is_screen:!(null===(t=this._stream)||void 0===t||!t.isScreen),start:d,result:!0,event_session_id:this._audioEventSessionId,type:u,vendor_mode:(null===(r=this._stream)||void 0===r?void 0:r.vendorCode)||0,pc_session_id:(null===(n=this._stream)||void 0===n?void 0:n.pcSessionId)||(null===(i=this._handler)||void 0===i?void 0:i.peerConnectionId),capture_session_id:null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.captureSessionId};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),SG.info("rtcFirstFrameSend",Nm(l)),null===(s=this._monitor)||void 0===s||s.report("rtc_first_frame",l),this._audioFirstFrameState=3}else if("video"===e){var h,p,v,f,_,m,y;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var g=this._currentVideoSend,S=g.type,b=g.startTime,E={event_type:"sent_end",media_type:e,is_screen:!(null===(h=this._stream)||void 0===h||!h.isScreen),start:b,result:!0,event_session_id:this._videoEventSessionId,type:S,vendor_mode:(null===(p=this._stream)||void 0===p?void 0:p.vendorCode)||0,pc_session_id:(null===(v=this._stream)||void 0===v?void 0:v.pcSessionId)||(null===(f=this._handler)||void 0===f?void 0:f.peerConnectionId),capture_session_id:null===(_=this._stream)||void 0===_||null===(m=_.videoTrack)||void 0===m?void 0:m.captureSessionId};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),SG.info("rtcFirstFrameSend",Nm(E)),null===(y=this._monitor)||void 0===y||y.report("rtc_first_frame",E),this._videoFirstFrameState=3}}},{key:"setLogin",value:function(e){if(this._login!==e){var t,r;if(this._login=e,e)null!==(t=this._stream)&&void 0!==t&&t.videoTrack&&this.beginSendFrame("video","login"),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this.beginSendFrame("audio","login");!e&&this._audioSending&&this.stopSendFrame("audio","leave_room"),!e&&this._videoSending&&this.stopSendFrame("video","leave_room")}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&this._stream.pubVideo&&this.beginSendFrame("video","publish"),(null===(r=this._stream)||void 0===r?void 0:r.audioTrack)&&this._stream.pubAudio&&this.beginSendFrame("audio","publish");!e&&this._audioSending&&this.stopSendFrame("audio","unpublish"),!e&&this._videoSending&&this.stopSendFrame("video","unpublish")}}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&(e&&this.beginSendFrame("audio","unmute"),!e&&this._audioSending&&this.stopSendFrame("audio","mute")))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubAudio&&(this._enableAudio=e,e&&this.beginSendFrame("audio","enable"),!e&&this._audioSending&&this.stopSendFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&(e&&this.beginSendFrame("video","unmute"),!e&&this._videoSending&&this.stopSendFrame("video","mute")))}},{key:"setEnableVideo",value:function(e){var t;this._enableVideo!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubVideo&&(this._enableVideo=e,e&&this.beginSendFrame("video","enable"),!e&&this._videoSending&&this.stopSendFrame("video","disable"))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame("audio","push"),!e&&this._audioSending&&this.stopSendFrame("audio","stop_push"))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame("video","push"),!e&&this._videoSending&&this.stopSendFrame("video","stop_push"))}},{key:"setAutoPublish",value:function(e){this._autoPublish=e}},{key:"setPublisher",value:function(e){this._publisher!==e&&(this._publisher=e,!e&&this._audioSending&&this.stopSendFrame("audio","audience"),!e&&this._videoSending&&this.stopSendFrame("video","audience"))}},{key:"setDisconnect",value:function(){this._audioSending&&this.stopSendFrame("audio","connection_lost"),this._videoSending&&this.stopSendFrame("video","connection_lost"),this.reset()}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"setPCSessionId",value:function(e){this._pcSessionId=e}},{key:"setHandler",value:function(e){this._handler=e}},{key:"_getFirstVideoFrameStats",value:(r=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.videoTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=6;break}return e.next=3,gL(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,c=Hs(s).call(s,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.audioTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=5;break}return e.next=3,gL(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,e.abrupt("return",gE(s).call(s,(function(e){return"outbound-rtp"===e.type})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_watchForFirstVideoFrameSend",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(Rm(Tm().mark((function n(){var i,o,a;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e._getFirstVideoFrameStats();case 2:if(i=n.sent,o=0,a=0,null==i||jm(i).call(i,(function(e){o+=e.framesSent,a+=e.packetsSent})),!(i&&i.length>0&&(o>t||a>r))){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=o,r=a,n.abrupt("return");case 10:e.sendFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),100)}},{key:"_watchForFirstAudioFrameSend",value:function(){var e=this,t=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(Rm(Tm().mark((function r(){var n;return Tm().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e._getFirstAudioFrameStats();case 2:if(!((n=r.sent)&&n.packetsSent>t)){r.next=9;break}if(-1!==t){r.next=7;break}return t=n.packetsSent,r.abrupt("return");case 7:e.sendFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 9:case"end":return r.stop()}}),r)}))),100)}},{key:"reset",value:function(){this._login=!1,this._publisher=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoPublish=!1,this._publish=!1,this._audioFirstFrameState=0,this._videoFirstFrameState=0,this._currentAudioSend={startTime:0,eventSessionId:0,type:"login"},this._currentVideoSend={startTime:0,eventSessionId:0,type:"login"},window.clearTimeout(this._firstAudioFrameTimer),window.clearTimeout(this._firstVideoFrameTimer),window.clearInterval(this._firstAudioFrameInterval),window.clearInterval(this._firstVideoFrameInterval)}},{key:"destroy",value:function(){this.reset(),delete this._stream,delete this._handler}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),EG=(Jd(fG={},"audio",{delay:1200,stallRadio:.3}),Jd(fG,"video",{delay:1200,stallRadio:.6}),Jd(fG,"screen_audio",{delay:1600,stallRadio:.8}),Jd(fG,"screen_video",{delay:1600,stallRadio:.8}),fG),kG=function(){function e(){Vl(this,e),Jd(this,"_preUplinkStats",new $S),Jd(this,"_preDownlinkStats",new $S),Jd(this,"_timer",void 0),Jd(this,"_delayTimer",void 0),Jd(this,"_msc",void 0),Jd(this,"reportor",void 0)}return Ul(e,[{key:"updateUplinkStats",value:function(e){var t=e.audioStats,r=e.videoStats,n=e.isScreen;if(t.sendKBitrate>0&&t.rtt){var i,o,a=n?"screen_audio":"audio",s=t.rtt,c=t._fractionLost,u=t._retransmittedRate,d=this._getQosLevel(s,c||0,u||0),l=this._preUplinkStats.get(a)||[d];this._preUplinkStats.set(a,km(i=Om(o=[]).call(o,Jk(l),[d])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var h,p,v=n?"screen_video":"video",f=r._fractionLost,_=r.rtt,m=r._sendBandWidth,y=r._retransmittedRate;0===m&&(f=Math.max(.65,f));var g=this._getQosLevel(_,f||0,y||0),S=this._preUplinkStats.get(v)||[g];this._preUplinkStats.set(v,km(h=Om(p=[]).call(p,Jk(S),[g])).call(h,-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){if(t){var r,n,i=this._getStreamActiveState(t),o=i.audioActive,a=i.videoActive,s=e.audioStats,c=e.videoStats,u=e.isScreen,d=e.userId;if(o)if(0===s.receivedKBitrate)r=gl.VBAD;else{var l=s.rtt,h=s.audioLossRate,p=s.stallDuration,v=s.statsInterval,f=s.e2eDelay,_=p/v,m=u?"screen_audio":"audio",y=this._getQosLevel(l,h||0,c._retransmittedRate||0),g=this._getDownlinkQoE(m,_,f);r=this._getNetworkQuality(y,g)}if(a)if(0===c.receivedKBitrate||0===c.rtt)n=gl.VBAD;else{var S=c.rtt,b=c.videoLossRate,E=c.stallDuration,k=c.statsInterval,T=c.e2eDelay,I=c._retransmittedRate,R=E/k,A=u?"screen_video":"video",w=this._getQosLevel(S,b||0,I||0),C=this._getDownlinkQoE(A,R,T);n=this._getNetworkQuality(w,C)}var x=r&&n?Math.ceil((r+n)/2):r||n;if(x){var O,M,D,P=Om(O="".concat(d)).call(O,u?"_screen":""),N=this._preDownlinkStats.get(P)||[x];this._preDownlinkStats.set(P,km(M=Om(D=[]).call(D,Jk(N),[x])).call(M,-2)),this._startNetworkQualityReport()}}}},{key:"setMSC",value:function(e){this._msc=e}},{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._delayTimer&&(window.clearTimeout(this._delayTimer),delete this._delayTimer),this._preUplinkStats.clear(),this._preDownlinkStats.clear()}},{key:"_startNetworkQualityReport",value:function(){var e=this;this._delayTimer||this._timer||(this._preUplinkStats.size>0||this._preDownlinkStats.size>0)&&(this._delayTimer=window.setTimeout((function(){delete e._delayTimer,e._reportNetworkQuality(),e._timer=window.setInterval((function(){e._reportNetworkQuality()}),2e3)}),300))}},{key:"_reportNetworkQuality",value:function(){var e,t,r,n,i,o=this;if(mk(e=["connected","connecting"]).call(e,null===(t=this._msc)||void 0===t||null===(r=t.handler)||void 0===r?void 0:r.getConnectionState())){var a,s,c,u=this._getBetterQualityAndRemoveOldest("audio","up"),d=this._getBetterQualityAndRemoveOldest("video","up");n=u&&d?Math.ceil((u+d)/2):u||d||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||gl.EXCELLENT;var l=Hs(a=jm(s=qk(sw(c=this._preDownlinkStats).call(c))).call(s,(function(e){return o._getBetterQualityAndRemoveOldest(e,"down")}))).call(a,(function(e){return e}));i=Math.ceil(pb(l).call(l,(function(e,t){return t+e}),0)/l.length)||gl.UNKNOWN}else n=i=gl.DOWN;navigator.onLine||(n=gl.DOWN,i=gl.DOWN),"function"==typeof this.reportor&&this.reportor(n,i)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getQosLevel",value:function(e,t,r){var n;return n=(!e||e<=250)&&t<=.15?1:(!e||e<=500)&&t<=.3?2:(!e||e<=750)&&t<=.45?3:(!e||e<=1e3)&&t<=.6?4:5,r>.5?n=Math.max(n,4):r>.35?n=Math.max(n,3):r>.15&&(n=Math.max(n,2)),n}},{key:"_getUplinkQoE",value:function(e,t){var r=0;switch(e){case"audio":case"video":r=t<.05?1:t<.1?2:3;break;case"screen_video":case"screen_audio":r=t<.04?1:t<.08?2:3}return r}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=EG[e];return t>n.stallRadio||r>n.delay||t>n.stallRadio/2&&r>n.delay/2?3:(t>n.stallRadio/2||n.delay,2)}},{key:"_getBetterQualityAndRemoveOldest",value:function(e,t){var r=gl.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=Hs(i).call(i,(function(e){return e}));o.length>0&&(r=Math.min.apply(Math,Jk(o))),i.shift(),0===i.length&&n.delete(e)}return r}},{key:"_getStreamActiveState",value:function(e){var t=e.subMediaType,r=e._attributes,n=e.subVideo;return{audioActive:e.subAudio&&wM(t)&&r.localaudio&&r.audiostream,videoActive:n&&CM(t)&&r.localvideo&&r.videostream}}}]),e}(),TG=function(){function e(t){Vl(this,e),Jd(this,"_timer",void 0),Jd(this,"_remoteVideoSizeCache",{}),Jd(this,"_remoteScreenSizeCache",{}),Jd(this,"onchange",void 0),this._room=t,this._start()}return Ul(e,[{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._remoteVideoSizeCache={},this._remoteScreenSizeCache={}}},{key:"_start",value:function(){var e=this;this._timer||(this._timer=window.setInterval((function(){var t={},r={};e._room.remoteStreams.forEach((function(n,i){n.forEach((function(n){var o,a=null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack();if(a){var s=n.isScreen?e._remoteScreenSizeCache:e._remoteVideoSizeCache,c=s[i]||{},u=c.width,d=void 0===u?0:u,l=c.height,h=void 0===l?0:l,p=a.getSettings(),v=p.width,f=void 0===v?0:v,_=p.height,m=void 0===_?0:_;h===m&&d===f||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,f,m),delete s[i],(n.isScreen?r:t)[i]={width:f,height:m}}}))})),an(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),an(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),IG=qk((new TextEncoder).encode("subt")),RG={1:pA.SUBTITLE_ERR_POSTPROCESS,2:pA.SUBTITLE_ERR_CONNECTION_ERROR,3:pA.SUBTITLE_ERR_PROCESS_ERROR},AG=new Nw("SubtitleTool",1),wG=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&xE(t=["zh","en","ja"]).call(t,r.source_language)}catch(a){}else{var n,i,o=(null===(n=navigator.language)||void 0===n?void 0:n.substring(0,2))||"";xE(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=Nm({source_language:o}))}},CG=function(){function e(t){var r,n,i;Vl(this,e),Jd(this,"_taskId",void 0),Jd(this,"_appId",void 0),Jd(this,"_roomId",void 0),Jd(this,"_userId",void 0),Jd(this,"onEvent",void 0),Jd(this,"onMessage",void 0),Jd(this,"_preConfig",void 0),Jd(this,"_timer",void 0),this._room=t,this._appId=null===(r=this._room._roomInfo)||void 0===r?void 0:r.appId,this._roomId=null===(n=this._room._roomInfo)||void 0===n?void 0:n.roomId,this._userId=null===(i=this._room._roomInfo)||void 0===i?void 0:i.userInfo.userId}var t,r,n;return Ul(e,[{key:"start",value:(n=Rm(Tm().mark((function e(t){var r=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(AG.info("start","Invoke config: %o",t),VD(t.mode,"mode",[Rl.ASR_ONLY,Rl.ASR_AND_TRANSLATION]),t.mode!==Rl.ASR_AND_TRANSLATION||-1!==xE(OG).call(OG,t.targetLanguage||"")){e.next=4;break}throw new mA(pA.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new mA(pA.SUBTITLE_ALREADY_ON,"Already turned on subtitle");case 6:return this._preConfig=t,this._taskId=(Date.now().toString()+this._roomId+this._userId).substring(0,20),e.next=10,this._room.subtitleControlMessage(this._genSubtitleSignaling("started",t,this._taskId));case 10:this._preConfig=t,this._timer=self.setTimeout((function(){var e;null===(e=r.onEvent)||void 0===e||e.call(r,{event:Al.ERROR,errorCode:pA.TIME_OUT,errorMessage:"start subtitle timeout."}),delete r._timer,r.stop()}),3e4);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"update",value:(r=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(VD(t.mode,"mode",[Rl.ASR_ONLY,Rl.ASR_AND_TRANSLATION]),t.mode!==Rl.ASR_AND_TRANSLATION||-1!==xE(OG).call(OG,t.targetLanguage||"")){e.next=3;break}throw new mA(pA.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new mA(pA.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new mA(pA.SUBTITLE_NOT_TURNED_ON,"Start subtitle first.");case 7:if((null===(r=this._preConfig)||void 0===r?void 0:r.mode)===t.mode&&this._preConfig.targetLanguage===t.targetLanguage){e.next=11;break}return this._preConfig=t,e.next=11,this._room.subtitleControlMessage(this._genSubtitleSignaling("update",t,this._taskId));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stop",value:function(){var e=this;AG.info("stop","Invoke"),this._taskId&&this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId}).finally((function(){var t;delete e._taskId,null===(t=e.onEvent)||void 0===t||t.call(e,{event:Al.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._taskId||!this._preConfig){e.next=5;break}return e.next=3,this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId});case 3:delete this._taskId,this.start(this._preConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getConfig",value:function(){return this._preConfig}},{key:"destroy",value:function(){AG.info("destroy","Invoke"),this.stop(),delete this._preConfig,delete this._taskId}},{key:"onResult",value:function(e){var t=e.body,r=t.error,n=t.errorMessage,i=t.eventType;if(0!==r){var o,a=new mA(RG[r]||pA.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:Al.ERROR,errorCode:a.code,errorMessage:a.message}),this._clearTimer()}else if("SubtitleStarted"===i){var s;null===(s=this.onEvent)||void 0===s||s.call(this,{event:Al.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(this._taskId&&this._preConfig){var t=xG(e);if(t&&t.length>0){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){i===Rl.ASR_ONLY?e.mode===i&&a.push(e):i===Rl.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==Rl.ASR_ONLY||a.push(e),e.mode===Rl.ASR_ONLY&&e.language===o&&a.push(Zd(Zd({},e),{},{mode:Rl.ASR_AND_TRANSLATION})))})),a.length>0)null===(r=this.onMessage)||void 0===r||r.call(this,a)}return!!t}return!1}},{key:"_genSubtitleSignaling",value:function(e,t,r){return{taskId:r,type:"subtitle",action:e,roomId:this._roomId,appId:this._appId,userId:this._userId,subtitleMeta:{subtitleConfig:{mode:t.mode,usersConfig:[{userId:this._userId,targetLanguages:[t.targetLanguage||""]}]},vendorConfig:{type:0}}}}},{key:"_clearTimer",value:function(){this._timer&&(self.clearTimeout(this._timer),delete this._timer)}}]),e}(),xG=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(IG.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=pM.ab2str(km(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(c){}return!1},OG=["zh","zh-Hant","tn","vi","iu","it","id","hi","en","ho","he","es","el","uk","ur","tk","tr","ti","ty","tl","to","th","ta","te","sl","sk","ss","eo","sm","sg","st","sv","ja","tw","qu","pt","pa","no","nb","nr","my","bn","mn","mh","mk","ml","mr","ms","lu","ro","lt","lv","lo","kj","hr","kn","ki","cs","ca","nl","ko","ht","gu","ka","kl","km","lg","kg","fi","fj","fr","ru","ng","de","tt","da","ts","cv","fa","bs","pl","bi","nd","ba","bg","az","ar","af","sq","ab","os","ee","et","ay","lzh","am","ckb","cy","gl","ha","hy","ig","kmr","ln","nso","ny","om","sn","so","sr","sw","xh","yo","zu"],MG=ad,DG=tc,PG=function(e,t,r,n){for(var i,o=n>1?void 0:n?DG(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&MG(t,r,o),o},NG=function(){function e(t){Vl(this,e),Jd(this,"_forwardDstRooms",new $S),Jd(this,"forwardStreamState","stopped"),Jd(this,"_monitor",void 0),this._room=t,this._monitor=VO(this._room.id)}var t,r,n,i,o,a;return Ul(e,[{key:"startForwardStream2Rooms",value:(a=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!==this.forwardStreamState&&"paused"!==this.forwardStreamState){e.next=2;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke startForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("start",this._room.roomInfo.roomId,t);case 4:return r=e.sent,this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),this.forwardStreamState="running",e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(o=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke updateForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult(t),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("update",this._room._roomInfo.roomId,t);case 6:r=e.sent;case 7:return this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(i=Rm(Tm().mark((function e(){var t,r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke stopForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult([]),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 6:r=e.sent;case 7:if(this._updateDstRooms([],r),!(Jk(sw(t=this._forwardDstRooms).call(t)).length>0)){e.next=10;break}throw new mA(pA.UNEXPECTED_ERROR,"stopforwardstream failed: ".concat(Nm(r)));case 10:return n=this._transformForwardStreamResult(r),this.forwardStreamState="stopped",e.abrupt("return",n);case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(n=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("paused"!==this.forwardStreamState&&"stopped"!==this.forwardStreamState){e.next=2;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke pauseForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 4:return t=e.sent,r=this._transformForwardStreamResult(t),this.forwardStreamState="paused",e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(r=Rm(Tm().mark((function e(){var t,r,n,i,o=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o.length>0&&void 0!==o[0]&&o[0]||!mk(t=["running","stopped"]).call(t,this.forwardStreamState)){e.next=3;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke resumeForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 3:return r=this._getDstRooms(),e.next=6,this._sendForwardStreamSignaling("start",this._room._roomInfo.roomId,r);case 6:return n=e.sent,this._updateDstRooms(r,n),i=this._transformForwardStreamResult(n),this.forwardStreamState="running",e.abrupt("return",i);case 11:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"resumeFromReconnect",value:function(){var e=this;"running"===this.forwardStreamState&&this.resumeForwardStream2AllRooms(!0).then((function(t){t.forEach((function(t){t.state===wl.FORWARD_STREAM_STATE_FAILURE&&e._room.safeEmit(CH.ON_FORWARD_STREAM_ERROR,t)}))}))}},{key:"onForwardDstRoomUserKick",value:function(e){var t=[{dstRoomId:e.dstRoomId,code:200,forwardStreamType:"stop"}];this._updateDstRooms([],t),this._room.safeEmit(CH.ON_FORWARD_STREAM_ERROR,{roomId:e.dstRoomId,state:wl.FORWARD_STREAM_STATE_FAILURE,error:Cl.FORWARD_STREAM_ERROR_REMOTE_KICKED})}},{key:"clear",value:function(){this._forwardDstRooms.clear(),this.forwardStreamState="stopped"}},{key:"_mockForwardStreamResult",value:function(e){var t=this,r=[];return this._forwardDstRooms.forEach((function(e,t){r.push({dstRoomId:t,forwardStreamType:"stop",code:200})})),e.forEach((function(e){var n,i=QR(r).call(r,(function(t){return t.dstRoomId===e.roomId}));-1===i?r.push({dstRoomId:e.roomId,forwardStreamType:"start",code:e.roomId===(null===(n=t._room.roomInfo)||void 0===n?void 0:n.roomId)?400:200}):r[i].forwardStreamType="update"})),r}},{key:"_transformForwardStreamResult",value:function(e){e||(e=[]);var t,r=[],n=$T(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=i.dstRoomId,a=i.code,s={roomId:o,state:wl.FORWARD_STREAM_STATE_SUCCESS,error:Cl.FORWARD_STREAM_ERROR_OK};200===a||(400===a?(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_REMOTE_KICKED):a>=700&&a<800?(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_INVALID_TOKEN):(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_RESPONSE)),r.push(s)}}catch(c){n.e(c)}finally{n.f()}return r}},{key:"_updateDstRooms",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];0===(null==r?void 0:r.length)&&this._forwardDstRooms.clear(),r.forEach((function(r){var n=r.dstRoomId,i=r.code,o=r.forwardStreamType;if(200===i)if("stop"===o)t._forwardDstRooms.delete(n);else{var a,s=gE(e).call(e,(function(e){return e.roomId===n}));if(!s&&!t._forwardDstRooms.has(n))throw new mA(pA.UNEXPECTED_ERROR,"unknow roomid ".concat(n," in signaling return"));var c=null!==(a=t._forwardDstRooms.get(n))&&void 0!==a?a:{token:void 0};c=wb(c,s),t._forwardDstRooms.set(n,c)}else t._forwardDstRooms.has(n)&&t._forwardDstRooms.delete(n)}))}},{key:"_getDstRooms",value:function(){var e=[];return this._forwardDstRooms.forEach((function(t,r){e.push({roomId:r,token:t.token})})),e}},{key:"_sendForwardStreamSignaling",value:(t=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="".concat(fM()),"stop"!==t&&(a=jm(n).call(n,(function(e){return e.roomId})),null===(o=this._monitor)||void 0===o||o.report("rtc_forward_stream",{type:"begin",dst_rooms:"{ ".concat(jm(a).call(a,(function(e){return'"'.concat(e,'"')})).join(",")," }"),event_session_id:i})),e.next=4,this._room._mediaServerClient.sendForwardStreamSignal(t,r,n);case 4:if(s=e.sent,c=[],200===(null==s?void 0:s.code)){e.next=9;break}throw"stop"!==t&&(null==n||n.forEach((function(e){c.push({dst_room_id:e.roomId,result:"server error ".concat(null==s?void 0:s.code)})})),null===(u=this._monitor)||void 0===u||u.report("rtc_forward_stream",{type:"end",dst_rooms:Nm(c),event_session_id:i})),new mA(pA.UNEXPECTED_ERROR,"server side internal error, error code: ".concat(s));case 9:return"stop"!==t&&(null===(d=s.forwardStreamResults)||void 0===d||d.forEach((function(e){c.push({dst_room_id:e.dstRoomId,result:"dst room lost"})})),null===(l=s.forwardStreamResults)||void 0===l||l.forEach((function(e){var t=gE(c).call(c,(function(t){return t.dst_room_id===e.dstRoomId}));t&&(200===e.code?"update"===e.forwardStreamType?t.result="update":t.result="success":t.result="server error ".concat(e.code))})),null===(h=this._monitor)||void 0===h||h.report("rtc_forward_stream",{type:"end",dst_rooms:Nm(c),event_session_id:i})),e.abrupt("return",s.forwardStreamResults);case 11:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})}]),e}();function LG(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=this._room._roomInfo)||void 0===r||!r.roomId){e.next=7;break}for(i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=4,n.apply(this,o);case 4:return e.abrupt("return",e.sent);case 7:throw new mA(pA.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 8:case"end":return e.stop()}}),e,this)}))),r}PG([LG],NG.prototype,"startForwardStream2Rooms",1),PG([LG],NG.prototype,"updateForwardStream2Rooms",1),PG([LG],NG.prototype,"stopForwardStream2Rooms",1),PG([LG],NG.prototype,"pauseForwardStream2AllRooms",1),PG([LG],NG.prototype,"resumeForwardStream2AllRooms",1);var UG=new Nw("Room",1),VG={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},FG=function(e){DI(O,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x=QI(O);function O(e,t){var r;return Vl(this,O),Jd(tI(r=x.call(this)),"id",void 0),Jd(tI(r),"_mediaServerClient",void 0),Jd(tI(r),"_localStream",void 0),Jd(tI(r),"_localScreenStream",void 0),Jd(tI(r),"_remoteUsers",new $S),Jd(tI(r),"_remoteStreams",new $S),Jd(tI(r),"_remoteStreamStreamIdUserIdMap",{}),Jd(tI(r),"_virtualStreams",[]),Jd(tI(r),"_context",void 0),Jd(tI(r),"_sessionId",void 0),Jd(tI(r),"_connectionLostTimer",void 0),Jd(tI(r),"_serverConfig",void 0),Jd(tI(r),"_roomConfig",void 0),Jd(tI(r),"_roomInfo",void 0),Jd(tI(r),"_userDuplicateLoginTimerMap",new $S),Jd(tI(r),"_networkQualityManager",void 0),Jd(tI(r),"_videoSizeObserver",void 0),Jd(tI(r),"_hasPublished",!1),Jd(tI(r),"_subtitleTool",void 0),Jd(tI(r),"_csrcUserIdMap",void 0),Jd(tI(r),"_publishOnDemandItem",void 0),Jd(tI(r),"_onceTriggerBySignal",!1),Jd(tI(r),"_pubTransceiverReady",!1),Jd(tI(r),"_publishOnDemandBusy",!1),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_forwardStreamManager",void 0),UG.info("constructor","invoke"),r.id=t.id,r._roomConfig=e,r._mediaServerClient=new hG(t),r._networkQualityManager=new kG,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(tI(r)),r._videoSizeObserver=new TG(tI(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(tI(r)),r._context=t,r._csrcUserIdMap={},r._monitor=VO(r.id),r._forwardStreamManager=new NG(tI(r)),r._addHandlerEventHandler(),r}return Ul(O,[{key:"hasScreenPublished",get:function(){var e;return null===(e=this._localScreenStream)||void 0===e?void 0:e.hasPublished}},{key:"hasPublished",get:function(){var e;return null===(e=this._localStream)||void 0===e?void 0:e.hasPublished}},{key:"connectionState",get:function(){return this._mediaServerClient.connectionState}},{key:"remoteUsers",get:function(){return this._remoteUsers}},{key:"remoteStreams",get:function(){return this._remoteStreams}},{key:"localStream",get:function(){return this._localStream}},{key:"localScreenStream",get:function(){return this._localScreenStream}},{key:"roomInfo",get:function(){return this._roomInfo}},{key:"roomConfig",set:function(e){this._roomConfig=e}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D=this;null===(e=this._mediaServerClient)||void 0===e||e.on(bH.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(bH.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return D._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(bH.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(bH.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return D._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(bH.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(bH.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return D._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(bH.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(bH.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return D._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(bH.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(bH.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(bH.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(bH.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(bH.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(bH.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(bH.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(bH.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(bH.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(bH.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(bH.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(bH.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(EH.RSCP,(function(e,t){!!gE(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:mk(t).call(t,null===(r=D._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(t?D._pubTransceiverReady=!0:D._onceTriggerBySignal=!0,t&&D._onceTriggerBySignal||(D._publishOnDemandItem=e),D._pubTransceiverReady&&D._onPublishOnDemand())})),null===(b=this._mediaServerClient)||void 0===b||b.on(EH.RTT,this._onRTT.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(EH.SSC,this._onSSC.bind(this)),null===(k=this._mediaServerClient)||void 0===k||k.on(kH.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(kH.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return D.emit(kH.ON_VENDOR_CONNECTION_STATE_CHANGE,e)})),null===(I=this._mediaServerClient)||void 0===I||I.on(bH.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){D._networkQualityManager.updateDownlinkStats(e,D._findRemoteStreamByScreen(e.userId,e.isScreen)),D.emit(CH.ON_REMOTE_STREAM_STATS,xM(e))})),null===(A=this._mediaServerClient)||void 0===A||A.on(CH.RESUBSCRIBE,(function(e){D.emit(CH.RESUBSCRIBE,e)})),null===(w=this._mediaServerClient)||void 0===w||w.on(CH.RECONNECT_FAILED,(function(){D.emit(CH.RECONNECT_FAILED)})),null===(C=this._mediaServerClient)||void 0===C||C.on("joinSuccess",this._onJoinSucc.bind(this)),null===(x=this._mediaServerClient)||void 0===x||x.on(bH.ON_FORWARD_DST_ROOM_USER_KICK,this._forwardStreamManager.onForwardDstRoomUserKick.bind(this._forwardStreamManager)),null===(O=this._mediaServerClient)||void 0===O||O.on(CH.ON_REJOIN_WITH_TCP,(function(){D.emit(CH.ON_REJOIN_WITH_TCP)})),null===(M=this._mediaServerClient)||void 0===M||M.on(CH.ON_ICE_CONNECT_WITH_TCP,(function(){D.emit(CH.ON_ICE_CONNECT_WITH_TCP)}))}},{key:"_onLocalStreamStats",value:function(e){this._networkQualityManager.updateUplinkStats(e),this.emit(CH.ON_LOCAL_STREAM_STATS,xM(e))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(C=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.connect();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"join",value:(w=Rm(Tm().mark((function e(t,r,n,i,o){var a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(a=this._monitor)||void 0===a||a.set({rtc_app_id:t,room_id:r,user_id:i.userId}),UG.info("join()"),this._mediaServerClient.setLiveControlMessage(o),this._roomInfo={appId:t,roomId:r,token:n,userInfo:i,roomProfile:this._roomConfig.roomProfileType},this.setSessionId(),e.prev=5,e.next=8,this._mediaServerClient.join(this._roomInfo);case 8:return c=e.sent,null!==(s=c.roomAttributes)&&void 0!==s&&s.multiChatMode&&this._handleFFAudioTrack(),this._initSubtitleTool(),e.abrupt("return",{users:c.clients,streams:c.streams});case 14:if(e.prev=14,e.t0=e.catch(5),e.t0.code===pA.OPERATION_CANCEL){e.next=18;break}throw e.t0;case 18:case"end":return e.stop()}}),e,this,[[5,14]])}))),function(e,t,r,n,i){return w.apply(this,arguments)})},{key:"publishScreen",value:(A=Rm(Tm().mark((function e(t,r,n,i,o){var a,s,c,u,d,l,h,p,v,f,_,m;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(UG.info("publishScreen()"),this._localScreenStream||(this._localScreenStream=new uF(this._context),null!==(a=this._mediaServerClient)&&void 0!==a&&null!==(s=a.vendorConfig)&&void 0!==s&&s.enableMultiVendor&&(this._localScreenStream.pcSessionId=_w()),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new bG(this._localScreenStream,this._mediaServerClient.handler))),c=!1,u=!1,d=!1,l=!1,!this._localScreenStream.videoTrack&&r?(r instanceof mV&&(u=!0),c=!0):this._localScreenStream.videoTrack&&!r&&(c=!1),!this._localScreenStream.audioTrack&&n?(n instanceof yV&&(l=!0),d=!0):this._localScreenStream.audioTrack&&!n&&(d=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(wM(i)&&(this._localScreenStream.pubAudio=o===OH.PUB),CM(i)&&(this._localScreenStream.pubVideo=o===OH.PUB),UG.info("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(h=this._localScreenStream)||void 0===h||!h.hasPublished){e.next=17;break}return e.abrupt("return",this.unpublishScreen());case 17:return e.abrupt("return");case 18:if(this._localScreenStream.hasPublished){e.next=24;break}return null===(p=this._localScreenStream.observer)||void 0===p||p.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return u?null===(v=this._localScreenStream.observer)||void 0===v||v.setPushVideo(c):null===(f=this._localScreenStream.observer)||void 0===f||f.setEnableVideo(c),l?null===(_=this._localScreenStream.observer)||void 0===_||_.setPushAudio(d):null===(m=this._localScreenStream.observer)||void 0===m||m.setEnableAudio(d),e.next=28,this.updatePubScreenTrack();case 28:this._localScreenStream.pubAudio||this._localScreenStream.pubVideo?this._localScreenStream.startReport(this._onLocalStreamStats.bind(this),this._mediaServerClient.handler):this._localScreenStream.stopReport("unpublish screen");case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return A.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(R=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(UG.info("updatePubScreenTrack","Invoke updatePubScreenTrack"),!this._localScreenStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return R.apply(this,arguments)})},{key:"unpublishScreen",value:(I=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(UG.info("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=8;break}return null===(t=this._localScreenStream.observer)||void 0===t||t.setPublish(!1),e.next=5,this._mediaServerClient.unpublish(this._localScreenStream);case 5:this._localScreenStream.stopReport("unpublish screen"),this._localScreenStream.clean(),this._localScreenStream=void 0;case 8:case"end":return e.stop()}}),e,this)}))),function(){return I.apply(this,arguments)})},{key:"liveControlMessage",value:(T=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UG.info("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),e.next=4,this._mediaServerClient.controlMessage(t);case 4:this._mediaServerClient.setLiveControlMessage("stopped"===t.action?void 0:t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(k=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._mediaServerClient.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"subtitleControlMessage",value:(E=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.controlMessage(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"updateUserAttributes",value:(b=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UG.info("updateUserAttributes","Invoke updateUserAttributes"),t.role&&this._roomInfo&&(this._roomInfo.userInfo.role=t.role),e.next=4,this._mediaServerClient.updateUserAttributes(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"publish",value:(S=Rm(Tm().mark((function e(t,r,n,i,o,a){var s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=E.length>6&&void 0!==E[6]&&E[6],UG.info("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new uF(this._context),null!==(u=this._mediaServerClient)&&void 0!==u&&null!==(d=u.vendorConfig)&&void 0!==d&&d.enableMultiVendor&&(this._localStream.pcSessionId=_w()),this._mediaServerClient.handler&&(this._localStream.observer=new bG(this._localStream,this._mediaServerClient.handler)),c=!0,this._localStream.vendorCode=(null===(l=this._mediaServerClient.vendorConfig)||void 0===l?void 0:l.vendorCode)||0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,o&&(wM(o)&&(this._localStream.pubAudio=a===OH.PUB),CM(o)&&(this._localStream.pubVideo=a===OH.PUB),UG.info("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=26;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=12;break}return e.abrupt("return");case 12:return e.prev=12,s?null===(h=this._localStream.observer)||void 0===h||h.setLogin(!0):c&&(p=!!this._localStream.videoTrack,v=!!this._localStream.audioTrack,f=this._localStream.videoTrack instanceof mV,_=this._localStream.audioTrack instanceof yV,this._roomConfig.isAutoPublish&&!this._hasPublished?(p&&(f?null===(m=this._localStream.observer)||void 0===m||m.setPushVideo(!0):null===(y=this._localStream.observer)||void 0===y||y.setEnableVideo(!0)),v&&(_?null===(g=this._localStream.observer)||void 0===g||g.setPushAudio(!0):null===(S=this._localStream.observer)||void 0===S||S.setEnableAudio(!0))):null===(b=this._localStream.observer)||void 0===b||b.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(CH.ON_PUBLISH_RESULT,{isScreen:!1,state:ol.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(CH.ON_PUBLISH_RESULT,{isScreen:!1,state:ol.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:this._localStream.pubAudio||this._localStream.pubVideo?this._localStream.startReport(this._onLocalStreamStats.bind(this),this._mediaServerClient.handler):this._localStream.stopReport("unpublish");case 29:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return S.apply(this,arguments)})},{key:"updatePubTrack",value:(g=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(UG.info("updatePubTrack","Invoke updatePubTrack"),!this._localStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"unpublish",value:(y=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(UG.info("unpublish","Invoke unpublish"),!this._localStream){e.next=7;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.stopReport("unpublish"),this._localStream.clean(),this._localStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"subscribe",value:(m=Rm(Tm().mark((function e(t,r,n){var i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UG.info("subscribe","remoteStream %o",t),i=void 0,n&&(i=this._getSubLayer(n,t)),e.next=5,this._mediaServerClient.subscribe(t,r,i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return m.apply(this,arguments)})},{key:"updateSubTrack",value:(_=Rm(Tm().mark((function e(t,r,n,i){var o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(UG.info("updateSubTrack","Invoke updateSubTrack"),!i){e.next=4;break}return e.next=4,null===(a=this._mediaServerClient)||void 0===a?void 0:a.updateSubTrackLayer(t,i);case 4:return e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrack(t,r,n));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return _.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(f=Rm(Tm().mark((function e(t,r){var n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((a=this._findRemoteStreamByScreen(t,!1))&&a.hasSubscribed&&!((null==a||null===(n=a.attributes)||void 0===n||null===(i=n.videoDescriptions)||void 0===i?void 0:i.length)<=1)){e.next=3;break}return e.abrupt("return");case 3:return s=this._getSubLayer(r,a),a.originalStreamIndex=s.spatialLayer,e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrackLayer(a,s));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,c=s.videoDescriptions,u=s.subVideoDescriptions,d=Array.isArray(u)?u:c,l=-1,h=e.width*e.height,p=0;p<(null==d?void 0:d.length);p++){var v,f;if(h>=(null===(v=d[p])||void 0===v?void 0:v.width)*(null===(f=d[p])||void 0===f?void 0:f.height)){l=p;break}}var _=d[0];if(-1===l)_=d[l=d.length-1];else if(0!==l){var m=d[l-1].width*d[l-1].height,y=(m-h)/(m-d[l].width*d[l].height);_=y<.1?d[l-1]:d[l],l=y<.1?l-1:l}return a=null!==(r=null===(n=_)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=_)||void 0===o?void 0:o.video_index)&&void 0!==i?i:l,spatialSubLayer:a}}},{key:"unsubscribe",value:(v=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UG.info("unsubscribe","Invoke unsubscribe"),e.next=3,this._mediaServerClient.unsubscribe(t,r);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"startSubtitle",value:(p=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subtitleTool){e.next=5;break}return e.next=3,this._subtitleTool.start(t);case 3:e.next=6;break;case 5:throw new mA(pA.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"stopSubtitle",value:(h=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(t=this._subtitleTool)||void 0===t||t.stop();case 1:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"startForwardStream2Rooms",value:(l=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.startForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(d=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.updateForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(u=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.stopForwardStream2Rooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(c=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.pauseForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(s=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.resumeForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"leave",value:(a=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=h.length>0&&void 0!==h[0]&&h[0],UG.info("leave","Invoke leave"),n=lM(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,e.prev=5,s=$T(oR(a=this._remoteStreams).call(a));try{for(s.s();!(c=s.n()).done;)u=c.value,Array.isArray(u)&&u.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(p){s.e(p)}finally{s.f()}return this._localStream&&(null===(d=this._localStream.observer)||void 0===d||d.setLogin(!1)),e.next=11,this._mediaServerClient.leave().catch((function(){}));case 11:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:lM()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=24;break;case 16:if(e.prev=16,e.t0=e.catch(5),!r){e.next=22;break}throw e.t0;case 22:this.destroy();case 23:e.t0 instanceof Error&&(null===(l=this._monitor)||void 0===l||l.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:lM()-n}));case 24:case"end":return e.stop()}}),e,this,[[5,16]])}))),function(){return a.apply(this,arguments)})},{key:"updateRemoteUserPriority",value:function(e){var t,r=this;null===(t=this.remoteStreams.get(e))||void 0===t||t.forEach((function(t){var n=(r._context||{}).userPriority;t.hasSubscribed&&n.has(e)&&r._mediaServerClient.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e;UG.info("destroy","Invoke destroy"),jO(this.id,"room_destroy","".concat((new Error).stack)),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._mediaServerClient.destroy(),this._removeHandlerEventHandler(),this._roomInfo=void 0,this._remoteUsers=new $S;var t,r,n,i=$T(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=eI(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.destroy()}))}}catch(a){i.e(a)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new $S,this._localStream)&&(null===(r=this._localStream)||void 0===r||r.clean(),this._localStream=void 0);this._localScreenStream&&(null===(n=this._localScreenStream)||void 0===n||n.clean(),this._localScreenStream=void 0);this._removeHandlerEventHandler(),clearTimeout(this._connectionLostTimer),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={},this._forwardStreamManager.clear()}},{key:"updateToken",value:(o=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UG.info("updateToken","Invoke updateToken"),this._roomInfo&&(this._roomInfo.token=t),e.prev=2,e.next=5,this._mediaServerClient.updateToken(t);case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(2),this.safeEmit(CH.ON_ROOM_ERROR,{errorCode:pA.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return o.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._mediaServerClient)||void 0===r?void 0:r.sendUserMessage(e,t)}},{key:"setSessionId",value:function(){var e;this._sessionId=vw(),this._mediaServerClient._sessionId=this._sessionId,null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(i=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=s.length>1&&void 0!==s[1]&&s[1],a={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:o,message:"",roomId:null===(n=this._roomInfo)||void 0===n?void 0:n.roomId},!o){e.next=8;break}return e.next=5,pM.ab2b64str(t);case 5:a.message=e.sent,e.next=9;break;case 8:a.message=t;case 9:return e.abrupt("return",null===(i=this._mediaServerClient)||void 0===i?void 0:i.sendRoomMessage(a));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"_onJoinSucc",value:function(e){var t,r,n,i=this,o=e.joinRes,a=e.reconnect;UG.info("_onJoinSucc()","invoke. ".concat(a?"[reconnect]":"")),this._serverConfig=o.config,this._mediaServerClient.roomAttributes=o.roomAttributes;var s=[],c=[],u=[],d=[],l=[];null===(t=o.clientsDetail)||void 0===t||t.forEach((function(e){if(e.attributes&&(e.attributes.serverMuteVideo&&i.safeEmit(CH.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&i.safeEmit(CH.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio})),e.clientId!==o.clientId){var t=i._remoteUsers.get(e.clientId);t?t._stillExist=!0:s.push(e)}}));var h,p=$T(oR(r=this._remoteUsers).call(r));try{for(p.s();!(h=p.n()).done;){var v=h.value;v._stillExist||c.push({clientId:v.userId}),delete v._stillExist}}catch(y){p.e(y)}finally{p.f()}o.streams.forEach((function(e){var t=i._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,l.push(e)):d.push(e)}));var f,_=$T(oR(n=this._remoteStreams).call(n));try{for(_.s();!(f=_.n()).done;){var m=f.value;Array.isArray(m)&&m.forEach((function(e){e.stillExist?delete e.stillExist:u.push({clientId:e.userId,streamId:e.streamId,message:gH.clientDisconnected})}))}}catch(y){_.e(y)}finally{_.f()}c.forEach((function(e){return i._onUserDisconnection(e)})),s.forEach((function(e){return i._onUserConnection(e)})),u.forEach((function(e){return i._onRemoveStream(e)})),d.forEach((function(e){return i._onAddStream(e,{fromSignal:!1})})),l.forEach((function(e){return i._onUpdateStreamAttributes(e)})),a&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r,n,i,o=this;this._localStream&&(this._localStream.clean(),this._localStream.vendorCode=(null===(r=this._mediaServerClient.vendorConfig)||void 0===r?void 0:r.vendorCode)||0,null===(n=this._localStream.observer)||void 0===n||n.setLogin(!0),this._mediaServerClient.publish(this._localStream).catch((function(e){})));this._localScreenStream&&(this._localScreenStream.clean(),null===(i=this._localScreenStream.observer)||void 0===i||i.setLogin(!0),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var a,s=$T(oR(t=this._remoteStreams).call(t));try{for(s.s();!(a=s.n()).done;){var c=a.value;Array.isArray(c)&&c.forEach(function(){var e=Rm(Tm().mark((function e(t){var r,n,i,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=17;break}return t.resetHasSubscribed(),e.prev=2,UG.info(Om(r="start resubscribe ".concat(t.userId," with ")).call(r,t.subMediaType)),CM(t.subMediaType)&&(null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!0)),wM(t.subMediaType)&&(null===(i=t.observer)||void 0===i||i.setSubscribeAudio(!0)),e.next=8,o._mediaServerClient.subscribe(t,t.subMediaType);case 8:UG.info(Om(a="success resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType)),o.safeEmit(CH.RESUBSCRIBE,{stream:t}),e.next=17;break;case 12:e.prev=12,e.t0=e.catch(2),UG.error(Om(s=Om(c="failed resubscribe ".concat(t.userId," with ")).call(c,t.subMediaType,", error:")).call(s,e.t0)),t.clean(),null==t||t.resetHasSubscribed();case 17:case"end":return e.stop()}}),e,null,[[2,12]])})));return function(t){return e.apply(this,arguments)}}())}}catch(u){s.e(u)}finally{s.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect(),this._forwardStreamManager.resumeFromReconnect()}},{key:"_handleFFAudioTrack",value:function(){var e,t,r,n,i=null===(e=this._mediaServerClient)||void 0===e||null===(t=e.handler)||void 0===t?void 0:t.audioTrack4ff,o=null===(r=this._mediaServerClient)||void 0===r||null===(n=r.handler)||void 0===n?void 0:n.getTransceivers();if(i&&Array.isArray(o)){var a=gE(o).call(o,(function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===i}));if(a){var s=new dF(this._context,"ff-stream","ff-stream",!1,!1,VG);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=DV(i),this._virtualStreams.push(s),this.safeEmit(CH.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?gE(r).call(r,(function(e){return e.streamId===t})):null}},{key:"_findRemoteStreamByScreen",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?gE(r).call(r,(function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.needEmit,i=void 0===n||n,o=r.fromSignal,a=void 0===o||o,s=r.virtual,c=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var u=this._roomConfig,d=u.isAutoSubscribeAudio,l=u.isAutoSubscribeVideo,h=this._findRemoteStreamByScreen(e.clientId,e.screen);if(h&&h.streamId!==e.streamId){var p,v=null===(p=this._remoteStreams.get(e.clientId))||void 0===p?void 0:Hs(p).call(p,(function(e){return e.streamId!==h.streamId}));h.clean(),this._remoteStreams.set(e.clientId,v||[])}var f=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,f)f.attributes=e.attributes;else if((f=new dF(this._context,e.clientId,e.streamId,e.screen,!1,e.attributes)).virtual=c,this._initStreamListeners(f),!c){var _=this._remoteStreams.get(e.clientId);_?_.push(f):this._remoteStreams.set(e.clientId,[f])}if(this._mediaServerClient.handler&&(f.observer=new gG(f,this._mediaServerClient.handler)),!f.isScreen&&l){var m,y,g,S,b,E,k,T;if(a&&f.hasVideo)if(f.attributes.extvideo)null===(m=f.observer)||void 0===m||m.setExternalVideoSource(!0),null===(y=f.observer)||void 0===y||y.setPushVideo(!0);else null===(g=f.observer)||void 0===g||g.setExternalVideoSource(!1),null===(S=f.observer)||void 0===S||S.setPublishVideo(!0);if(a&&f.hasAudio&&d&&!this._mediaServerClient.roomAttributes.multiChatMode)if(f.attributes.extaudio)null===(b=f.observer)||void 0===b||b.setExternalAudioSource(!0),null===(E=f.observer)||void 0===E||E.setPushAudio(!0);else null===(k=f.observer)||void 0===k||k.setExternalAudioSource(!1),null===(T=f.observer)||void 0===T||T.setPublishAudio(!0);if(i&&!a){var I,R=this._roomConfig,A=R.isAutoSubscribeAudio,w=R.isAutoSubscribeVideo;null===(I=f.observer)||void 0===I||I.setLogin(!0,{audio:!!A&&!this.multiChatMode,video:!!w})}}return i&&this.safeEmit(bH.ON_ADD_STREAM,{stream:f}),f}}},{key:"_onUserConnection",value:function(e){var t;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var r=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof r)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(r);var n={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,Zd({},n)),this.safeEmit(bH.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(CH.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(CH.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var a=null;i===TH.kickedByAdmin?a=pA.KICKED_OUT:i===TH.onUserTokenDidExpire?a=pA.TOKEN_EXPIRED:i===TH.userDuplicateLogin&&(a=pA.DUPLICATE_LOGIN),o===IH.roomDismissByAdmin&&(a=pA.ROOM_DISMISS),a&&this.safeEmit(CH.ON_ROOM_ERROR,{errorCode:a})}else{var s=tl.DROPPED;i===TH.userLeave?s=tl.QUIT:i===TH.kickedByAdmin?s=tl.KICKED_BY_ADMIN:i===TH.roleChanged&&(s=tl.SWITCH_TO_INVISIBLE);var c=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:gH.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(CH.ON_USER_LEAVE,{userInfo:{userId:n},reason:s})};if(i===TH.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(n);u&&self.clearTimeout(u);var d=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(n,d)}else c()}}},{key:"_onRemoveStream",value:function(e){var t,r=this;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var n=this._remoteStreams.get(e.clientId);if(n){var i=gE(n).call(n,(function(t){return t.streamId===e.streamId}));if(i){var o,a,s;if(null===(o=this._mediaServerClient)||void 0===o||o.handleRemoveStream(i,e).then((function(){var t=r._remoteStreams.get(e.clientId);t&&(t=Hs(t).call(t,(function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),r._remoteStreams.set(e.clientId,t))})).finally((function(){r.safeEmit(bH.ON_REMOVE_STREAM,{stream:i,reason:e.message,callback:function(){return i.destroy()}})})),i.hasVideo)null===(a=i.observer)||void 0===a||a.setPublishVideo(!1);if(i.hasAudio&&!this._mediaServerClient.roomAttributes.multiChatMode)null===(s=i.observer)||void 0===s||s.setPublishAudio(!1)}}}}},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(CH.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(CH.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=Zd(Zd({},this._mediaServerClient.roomAttributes),e.roomAttributes)),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this._roomConfig,r=t.isAutoSubscribeAudio,n=t.isAutoSubscribeVideo,i=e.clientId,o=e.streamId,a=e.attributes,s=this._findRemoteStream(i,o);if(s){var c,u,d=s.attributes,l=Zd(Zd({},d),a),h=!1,p=l.localaudio!==d.localaudio,v=!1,f=!1,_=l.localvideo!==d.localvideo,m=!1,y=zV.NONE,g=zV.NONE;if(l.audiostream!==d.audiostream&&(h=l.localaudio,v=!!l.audiostream,l.audiostream?y|=ul.AUDIO:g|=ul.AUDIO),l.videostream!==d.videostream&&(f=l.localvideo,m=!!l.videostream,l.videostream?y|=ul.VIDEO:g|=ul.VIDEO),y&&this.safeEmit(CH.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:OH.PUB,remoteStream:s}),g&&this.safeEmit(CH.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:OH.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(CH.ON_USER_START_AUDIO_CAPTURE,{userId:i},s)}else{var T,I,R,A;if(l.extaudio)null===(T=s.observer)||void 0===T||T.setExternalAudioSource(!0),null===(I=s.observer)||void 0===I||I.setPushAudio(!1);else null===(R=s.observer)||void 0===R||R.setExternalAudioSource(!1),null===(A=s.observer)||void 0===A||A.setEnableAudio(!1);!s.isScreen&&this.safeEmit(CH.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(l.localvideo!==d.localvideo)if(l.localvideo){var w,C,x,O;if(n&&l.videostream)if(l.extvideo)null===(w=s.observer)||void 0===w||w.setExternalVideoSource(!0),null===(C=s.observer)||void 0===C||C.setPushVideo(!0);else null===(x=s.observer)||void 0===x||x.setExternalVideoSource(!1),null===(O=s.observer)||void 0===O||O.setEnableVideo(!0);this.safeEmit(CH.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var M,D,P,N;if(l.extvideo)null===(M=s.observer)||void 0===M||M.setExternalVideoSource(!0),null===(D=s.observer)||void 0===D||D.setPushVideo(!1);else null===(P=s.observer)||void 0===P||P.setExternalVideoSource(!1),null===(N=s.observer)||void 0===N||N.setEnableVideo(!1);!s.isScreen&&this.safeEmit(CH.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!p)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(v);if(f&&!_)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteVideo(m)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&hA(t).call(t,"audio_mux")){var n=this._onAddStream(Zd(Zd({},e),{},{attributes:VG}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(CH.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){UG.error("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:Om(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:LH.TRACK_ERROR})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message,o=e.trackType;UG.info("_onRemoveTrack","remove track: %o",r);var a=this._findRemoteStream(r,n);a&&(a.removeTrack=!0,null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(a,i,o),this.emit(CH.REMOVE_PUSH_TRACK,{stream:a,mediaType:o+1}))}},{key:"_onMeetingSpeakerChange",value:function(e){if(Array.isArray(null==e?void 0:e.speakerCsrcInfo)){var t={};null==e||e.speakerCsrcInfo.forEach((function(e){var r=e.csrc,n=e.userId;e.isScreen||(t[r]=n)})),this._csrcUserIdMap=t}Array.isArray(e.muxStreamInUse)&&this._virtualStreams.forEach((function(t){var r;null!==(r=e.muxStreamInUse)&&void 0!==r&&mk(r).call(r,t.streamId)?t.virtualOccupy=!0:t.virtualOccupy=!1}))}},{key:"getActiveSpeakerInMultiChatMode",value:function(){var e=this,t=[];return this._virtualStreams.forEach((function(r){var n,i=null===(n=r.audioTransceiver)||void 0===n?void 0:n.receiver;if(i){var o=eI(i.getContributingSources()||[],1)[0];if(o){var a=o.audioLevel,s=o.source;e._csrcUserIdMap[s]&&t.push({userId:e._csrcUserIdMap[s],audioLevel:a})}}})),t.length&&HR(t).call(t,(function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_onReconnecting",value:function(){var e,t,r,n,i,o,a,s=this;if(this._roomInfo){var c,u=$T(oR(a=this._remoteStreams).call(a));try{for(u.s();!(c=u.n()).done;){var d=c.value;Array.isArray(d)&&d.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()}))}}catch(l){u.e(l)}finally{u.f()}this._virtualStreams.forEach((function(e){var t;s.emit(CH.REMOVE_PUSH_TRACK,{stream:e,mediaType:ul.AUDIO}),null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()})),this._virtualStreams=[],null===(e=this.localStream)||void 0===e||null===(t=e.observer)||void 0===t||t.setDisconnect(),null===(r=this.localStream)||void 0===r||r.clean(),null===(n=this.localScreenStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setDisconnect(),null===(o=this.localScreenStream)||void 0===o||o.clean()}}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===dG.DISCONNECTED)t=ll.CONNECTION_STATE_DISCONNECTED;else if(e.next===dG.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._mediaServerClient.isReconnecting?ll.CONNECTION_STATE_RECONNECTED:ll.CONNECTION_STATE_CONNECTED;else{if(e.next!==dG.CONNECTING)return;this._mediaServerClient.isReconnecting?(t=ll.CONNECTION_STATE_RECONNECTING,this._onReconnecting()):t=ll.CONNECTION_STATE_CONNECTING}e.prev===dG.CONNECTED&&e.next===dG.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(kH.ON_CONNECTION_STATE_CHANGE,{state:ll.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setMSC(this._mediaServerClient),this.safeEmit(kH.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(CH.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:null===(n=t._roomInfo)||void 0===n?void 0:n.roomId,streamIndex:e.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(bH.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(bH.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(bH.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new CG(this),this._subtitleTool.onEvent=function(t){e.emit(CH.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(CH.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=xH.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=xH.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?xH.START_FAILED:xH.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?xH.STOP_FAILED:xH.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?xH.UPDATE_FAILED:xH.UPDATE_SUCCESS}this.safeEmit(bH.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(bH.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(bH.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("publish"!==t.type){e.next=11;break}if(s=void 0,(null===(r=this.localStream)||void 0===r?void 0:r.streamId)===t.streamId?s=this.localStream:(null===(n=this.localScreenStream)||void 0===n?void 0:n.streamId)===t.streamId&&(s=this.localScreenStream),s){e.next=5;break}return e.abrupt("return");case 5:return null===(i=s)||void 0===i||i.clean(),e.next=8,null===(o=this._mediaServerClient)||void 0===o?void 0:o.unpublish(s).catch((function(){}));case 8:null===(a=this._mediaServerClient)||void 0===a||a.publish(s).catch((function(){})),e.next=20;break;case 11:if("subscribe"!==t.type){e.next=20;break}if(c=this._remoteStreamStreamIdUserIdMap[t.streamId],!(u=this._findRemoteStream(c,t.streamId))){e.next=20;break}return e.next=17,null===(d=this._mediaServerClient)||void 0===d?void 0:d.unsubscribe(u,ul.AUDIO_AND_VIDEO);case 17:return e.next=19,null===(l=this._mediaServerClient)||void 0===l?void 0:l.subscribe(u,u.subMediaType,u.subLayer);case 19:this.safeEmit(CH.RESUBSCRIBE,{stream:u});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===SH.PushLimitWarn&&(null!==(t=this._localStream)&&void 0!==t&&t.pubAudio||null!==(r=this._localStream)&&void 0!==r&&r.pubVideo||this.unpublish())}},{key:"_onPublishOnDemand",value:(r=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publishOnDemandItem&&!this._publishOnDemandBusy&&!1!==(null===(t=this._serverConfig)||void 0===t||null===(r=t.engine_VPM)||void 0===r||null===(n=r.ondemand)||void 0===n?void 0:n.enable)){e.next=2;break}return e.abrupt("return");case 2:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(o=this._localStream)||void 0===o||!o.videoTransceiver){e.next=16;break}return this._publishOnDemandBusy=!0,u=this._publishOnDemandItem,this._publishOnDemandItem=void 0,d=[],l=null===(s=this._localStream)||void 0===s?void 0:s.stream.id,h=null===(c=this._localStream)||void 0===c?void 0:c.videoTransceiver.sender,p=h.getParameters(),Array.isArray(p.encodings)&&Array.isArray(u)&&(f={},UG.info("_onPublishOnDemand exec","usedDescriptions: %o",u),u.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&mk(t).call(t,l)){var r=null==e?void 0:e.Metadata.VideoIndex;f[r]=!0}})),p.encodings=jm(v=p.encodings).call(v,(function(e){if(e.rid){f[e.rid]?e.active=!0:e.active=!1;var t=Number(e.rid);d[t]=e.active}return e})),this._context&&(this._context.activeSimStreams=d)),e.next=13,h.setParameters(p);case 13:this._publishOnDemandBusy=!1,e.next=18;break;case 16:if(null!==(a=this._localStream)&&void 0!==a&&a.videoTransceiver){e.next=18;break}return e.abrupt("return");case 18:this._onPublishOnDemand();case 19:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_onRTT",value:function(e){var t=e.StreamIds,r=e.Metadata;if(t.length&&r){var n,i=t[0];null!==(n=this._context)&&void 0!==n&&n.streamRTT&&(this._context.streamRTT[i]={audio:r.audio_rtt,video:r.video_rtt})}}},{key:"_onSSC",value:function(e){var t=e.StreamIds,r=e.Metadata,n=t[0],i=this._remoteStreamStreamIdUserIdMap[n],o=this._findRemoteStream(i,n),a={userId:i,isScreen:!!o&&o.isScreen,beforeVideoIndex:r.ssc_items[0].prev_layer_id,afterVideoIndex:r.ssc_items[0].cur_layer_id,beforeEnable:0!==r.ssc_items[0].prev_video_open,afterEnable:0!==r.ssc_items[0].cur_video_open,reason:r.ssc_items[0].change_reason};this.emit(CH.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(CH.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(CH.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"multiChatMode",get:function(){var e;return null===(e=this._mediaServerClient)||void 0===e?void 0:e.multiChatMode()}},{key:"setAudioEncodeMaxBitrate",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(n=t===cl.STREAM_INDEX_MAIN?this.localStream:this.localScreenStream)||!n.pubAudio){e.next=7;break}if(null==(o=null===(i=n.audioTransceiver)||void 0===i?void 0:i.sender.getParameters())||!o.encodings.length){e.next=7;break}return o.encodings[0].maxBitrate=1e3*r,e.next=7,null===(a=n.audioTransceiver)||void 0===a?void 0:a.sender.setParameters(o);case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),O}(aP),BG=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=document.createElement(e);return t.id&&(r.id=t.id),t.classList&&t.classList.forEach((function(e){r.classList.add(e)})),t.style&&wb(r.style,t.style),t.attributes&&RA(t.attributes).forEach((function(e){var t=eI(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},jG=new Nw("Player",0),HG=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],GG={playsinline:"","webkit-playsinline":""},zG={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},KG=function(e){DI(n,e);var t,r=QI(n);function n(e,t){var i;Vl(this,n),Jd(tI(i=r.call(this)),"_containerDom",void 0),Jd(tI(i),"_videoDom",void 0),Jd(tI(i),"__cumulativeTime",void 0),Jd(tI(i),"userId",void 0),Jd(tI(i),"renderMode",void 0),Jd(tI(i),"mirrorType",hl.MIRROR_TYPE_NONE),Jd(tI(i),"isScreen",void 0),Jd(tI(i),"isLocal",void 0),Jd(tI(i),"played",!1),Jd(tI(i),"_needLoad",!1),Jd(tI(i),"_emitPlayFailed",!1),Jd(tI(i),"_videoContainer",void 0),Jd(tI(i),"_safari15VideoTimer",void 0),Jd(tI(i),"_monitor",void 0),Jd(tI(i),"_onLocalTrackMute",void 0),Jd(tI(i),"_onInterruptionEnd",void 0),Jd(tI(i),"_needResume",!1),Jd(tI(i),"emitVideoEvent",(function(e){var t,r,n={type:"video",rawEvent:e,readyState:(null===(t=i._videoDom)||void 0===t?void 0:t.readyState)||0,userId:i.userId,eventName:e.type,currentTime:(null===(r=i._videoDom)||void 0===r?void 0:r.currentTime)||0,isScreen:i.isScreen};switch(i.emit("playback_event",n),e.type){case"canplay":case"loadeddata":i._internalPlay();break;case"playing":jG.info("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"));break;case"pause":jG.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element pause")),i._needResume&&(jG.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element resume")),i._internalPlay(),i._needResume=!1)}})),Jd(tI(i),"_internalPlay",(function(){var e;if(null!==(e=i._videoDom)&&void 0!==e&&e.paused){var t=i._videoDom.play();null!=t&&t.then&&t.then((function(){var e;i.isLocal&&WM&&!i._needLoad&&(null===(e=i._videoDom)||void 0===e||e.load(),i._needLoad=!0)})).catch((function(e){var t,r,n,o,a,s;i._emitPlayFailed||("AbortError"!==e.name?(i._emitPlayFailed=!0,null===(t=i._monitor)||void 0===t||t.report("rtc_error",{message:Om(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:LH.AUTOPLAY_FAILED}),i.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(n=i._videoDom)||void 0===n?void 0:n.readyState)||0,userId:i.userId,eventName:"autoplay-error",currentTime:(null===(o=i._videoDom)||void 0===o?void 0:o.currentTime)||0,isScreen:i.isScreen})):null===(a=i._monitor)||void 0===a||a.report("rtc_error",{message:Om(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:LH.AUTOPLAY_FAILED}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=VO(e);var a=t.userId,s=t.isScreen?sl.RENDER_MODE_FIT:sl.RENDER_MODE_HIDDEN;i.renderMode=void 0!==t.renderMode?t.renderMode:s;var c="string"==typeof o?document.getElementById(o):o;if(!c)throw new mA(pA.CANT_FIND_DOM,"can't find dom");return i._videoContainer=document.createElement("div"),i._videoContainer.style.width="100%",i._videoContainer.style.height="100%",i._videoContainer.style.position="relative",i._videoContainer.style.overflow="hidden",i._containerDom=c,i.userId=a,i.isLocal=!!t.isLocal,i.isScreen=!!t.isScreen,i._initVideo(),i}return Ul(n,[{key:"_initVideo",value:function(){var e,t=this;this._videoDom||(this._videoDom=BG("video",{style:{width:"100%",height:"100%"},attributes:zG}),this._videoDom.id=Om(e="".concat(this.userId,"_")).call(e,dM()),this.setRenderMode(this.renderMode),this.mirror(this.mirrorType===hl.MIRROR_TYPE_RENDER));this._videoContainer.appendChild(this._videoDom),this._containerDom.appendChild(this._videoContainer),this._initListeners(),this._onLocalTrackMute=function(){t._needResume=!0},this._onInterruptionEnd=function(){jG.warn("resume player after iOS interruption"),t._internalPlay()},ZU.on(JU.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),ZU.on(JU.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),ZU.on(JU.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd)}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&HG.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&&HG.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(KM){var n;if(null===(n=this._videoDom)||void 0===n||!n.requestVideoFrameCallback)return;this._videoDom.requestVideoFrameCallback((function n(i,o){var a=o.presentationTime;if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t.__cumulativeTime){var s,c=(a-t.__cumulativeTime)%2e3,u=c>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:u,stallCount:u?1:0,stallDuration:c})}t.__cumulativeTime=a,t._videoDom.requestVideoFrameCallback(n)}))}else this.on("playback_event",(function(n){var i;if("timeupdate"===n.eventName){if(0===(null===(i=t._videoDom)||void 0===i?void 0:i.currentTime))return;if(void 0===t.__cumulativeTime)return void(t.__cumulativeTime=t._videoDom.currentTime);if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t._videoDom.currentTime>t.__cumulativeTime){var o=Math.floor(1e3*(t._videoDom.currentTime-t.__cumulativeTime)),a=t._videoDom.currentTime-t.__cumulativeTime>r;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"_recordPause",value:function(e){var t=this;void 0===e.statsReport.isPaused&&this.on("playback_event",(function(r){if("pause"===r.eventName)e.statsReport.isPaused=!0,e.statsReport.pauseStart=lM();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=lM()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{key:"setRenderMode",value:function(e){this.renderMode=e,this._videoDom&&(this.renderMode===sl.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this.renderMode===sl.RENDER_MODE_FILL?this._videoDom.style.objectFit="fill":this._videoDom.style.objectFit="cover")}},{key:"playVideo",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,jG.info("playVideo","play video track: ".concat(this.userId)),!(o&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(n=t.getTrack())||void 0===n?void 0:n.id))){e.next=5;break}try{jO(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(uq){}return e.abrupt("return");case 5:o||(this._initVideo(),o=this._videoDom),jG.info("playVideo","play video by dom: ".concat(null===(i=o)||void 0===i?void 0:i.id)),(a=new MediaStream).addTrack(t.getTrack("preprocessing")),o.srcObject=a,o&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),o&&!this._videoContainer.contains(o)&&this._videoContainer.appendChild(o),setTimeout((function(){return s._internalPlay()})),r&&CD.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(jG.info("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,!this._videoDom)throw new mA(pA.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||eD?this._videoDom.play():Y_.resolve()}},{key:"mirror",value:function(e){var t;jG.info("mirror",Om(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?hl.MIRROR_TYPE_RENDER:hl.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=this._containerDom;(jG.info("stop","stop video track: ".concat(this.userId)),this._videoDom)&&(t||(this._videoDom.srcObject=null),null!=r&&r.contains(this._videoContainer)&&r.removeChild(this._videoContainer),null!==(e=this._videoContainer)&&void 0!==e&&e.contains(this._videoDom)&&this._videoContainer.removeChild(this._videoDom));this.__cumulativeTime=void 0,this.played=!1}},{key:"destroy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];jG.info("destroy","video player: ".concat(this.userId)),this.stop(e),OI(CI(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),ZU.off(JU.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),ZU.off(JU.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),ZU.off(JU.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd),this._videoDom&&delete this._videoDom,this._safari15VideoTimer&&(window.clearInterval(this._safari15VideoTimer),this._safari15VideoTimer=void 0)}},{key:"domElement",get:function(){return this._videoDom}}]),n}(nP.exports.EventEmitter),XG=function(e){DI(i,e);var t,r,n=QI(i);function i(e,t){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{divId:void 0,muted:!1,isScreen:!1},a=o.divId,s=o.muted,c=o.isScreen;if(Vl(this,i),Jd(tI(r=n.call(this)),"_containerDom",void 0),Jd(tI(r),"_audioDom",void 0),Jd(tI(r),"_fakeAudioDom",void 0),Jd(tI(r),"userId",void 0),Jd(tI(r),"muted",!1),Jd(tI(r),"_emitPlayFailed",!1),Jd(tI(r),"played",!1),Jd(tI(r),"isScreen",void 0),Jd(tI(r),"_wechatTimer",void 0),Jd(tI(r),"_edgeTimer",void 0),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_pasued",!0),Jd(tI(r),"emitAudioEvent",(function(e){var t,n,i={type:"audio",rawEvent:e,readyState:(null===(t=r._audioDom)||void 0===t?void 0:t.readyState)||0,userId:r.userId,eventName:e.type,currentTime:(null===(n=r._audioDom)||void 0===n?void 0:n.currentTime)||0};"playing"===e.type&&jG.info("AudioPlayerPlaying","[userId-".concat(r.userId,"] audio element playing")),"pause"===e.type&&(jG.info("AudioPlayerPause","[userId-".concat(r.userId,"] audio element pause")),r._pasued||r._internalPlay()),nD&&eD&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),tD&&QM&&"error"===e.type&&(clearTimeout(r._edgeTimer),r._edgeTimer=window.setTimeout((function(){var e;0===(null===(e=r._audioDom)||void 0===e?void 0:e.currentTime)&&r._autoPlayError("edge")}),500)),r.emit("playback_event",i)})),Jd(tI(r),"_internalPlay",(function(){var e,t;if(jO(r.engineId,"_internalPlay",{paused:null===(e=r._audioDom)||void 0===e?void 0:e.paused}),null!==(t=r._audioDom)&&void 0!==t&&t.paused)try{var n,i=r._audioDom.play(),o=rV.getAudioContextInstance();if("suspended"===o.state){var a=o.resume(),s=setTimeout((function(){var e;"suspended"===o.state&&(r._autoPlayError("AudioContext cannot resume"),null===(e=r._monitor)||void 0===e||e.report("rtc_error",{message:"audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - timeout"),error_code:-1e3}));clearTimeout(s)}));a.catch((function(e){var t,n,i;r._autoPlayError("AudioContext cannot resume"),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Om(n=Om(i="audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - rejected by: [")).call(i,null==e?void 0:e.name,"]")).call(n,null==e?void 0:e.message),error_code:-1e3})})).finally((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(nD&&tD&&(i=i.then((function(){return new Y_((function(e){setTimeout(Rm(Tm().mark((function t(){var n;return Tm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(n=r._audioDom)||void 0===n||n.pause(),r._audioDom.volume=1,t.next=4,r._audioDom.play();case 4:e();case 5:case"end":return t.stop()}}),t)}))),500)}))}))),i.then((function(){jO(r.engineId,"_internalPlay successfully",{userId:r.userId}),r._pasued=!1})).catch((function(e){var t,n,i;r._autoPlayError(e),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Om(n=Om(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:LH.AUTOPLAY_FAILED})})))}catch(l){var c,u,d;r._autoPlayError(l),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:Om(u=Om(d="audio autoplay failed, userId: ".concat(r.userId,": ")).call(d,l.message," ")).call(u,l.name),error_code:LH.AUTOPLAY_FAILED})}})),r.engineId=e,a){var u=document.getElementById(a);if(!u)throw new mA(pA.CANT_FIND_DOM,"can't find dom");r._containerDom=u}else r._containerDom=document.body;return r.userId=t,r.muted=s,r.isScreen=c,r._monitor=VO(e),r._initAudio(),r}return Ul(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=BG("audio",{style:{display:"none"},attributes:GG}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Om(e="".concat(this.userId,"_")).call(e,dM()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&HG.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&&(HG.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.removeEventListener(t,e.emitAudioEvent)})),this._audioDom.removeEventListener("canplay",this._internalPlay),this._audioDom.removeEventListener("loadeddata",this._internalPlay))}},{key:"playAudio",value:(r=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(jG.info("playAudio","play audio track: ".concat(this.userId)),!((o=this._audioDom)&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(r=t.getTrack())||void 0===r?void 0:r.id))){e.next=4;break}return e.abrupt("return");case 4:o||(this._initAudio(),o=this._audioDom),a=new MediaStream,t instanceof GV?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.getOrgTrack()]),a.addTrack(t.getTrack())):a.addTrack(t.getTrack("preprocessing")),nD&&tD&&(this._audioDom.volume=0),o.srcObject=a,null===(n=o)||void 0===n||n.addEventListener("canplay",this._internalPlay),null===(i=o)||void 0===i||i.addEventListener("loadeddata",this._internalPlay),setTimeout((function(){return s._internalPlay()})),this.played=!0;case 13:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_autoPlayError",value:function(e){var t,r;this._emitPlayFailed||(this._emitPlayFailed=!0,this.emit("playback_event",{type:"audio",rawEvent:e,readyState:(null===(t=this._audioDom)||void 0===t?void 0:t.readyState)||0,userId:this.userId,eventName:"autoplay-error",currentTime:(null===(r=this._audioDom)||void 0===r?void 0:r.currentTime)||0}))}},{key:"pause",value:function(){if(!this._audioDom)throw new mA(pA.INVALID_PARAMS,"Player not found");this._pasued=!0,this._audioDom.pause()}},{key:"manuallyPlay",value:function(){var e,t=this;if(jG.info("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new mA(pA.INVALID_PARAMS,"Player not found");if(!this.played)return Y_.resolve();this._audioDom.volume=1,this._audioDom.muted=!1,null===(e=this._fakeAudioDom)||void 0===e||e.play();var r=[],n=this._audioDom.play();null!=n&&n.then&&r.push(n);var i=rV.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?Y_.all(r):Y_.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jG.info("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,qU.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=jm(r).call(r,(function(e){return e.deviceId})),mk(n).call(n,t)&&this._audioDom&&this._audioDom.setSinkId){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,this._audioDom.setSinkId(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"stop",value:function(){var e=this._containerDom;jG.info("stopAudio","stop audio track: ".concat(this.userId)),this._audioDom&&(this._audioDom.srcObject=null,null!=e&&e.contains(this._audioDom)&&e.removeChild(this._audioDom)),this._fakeAudioDom&&(this._fakeAudioDom.srcObject=null,this._fakeAudioDom=void 0),this.played=!1}},{key:"domElement",get:function(){return this._audioDom}},{key:"destroy",value:function(){jG.info("destroy","audio player: ".concat(this.userId)),this.stop(),OI(CI(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom),this._edgeTimer&&clearTimeout(this._edgeTimer)}}]),i}(nP.exports.EventEmitter);function WG(e,t,r,n){var i=function(){var e=Rm(Tm().mark((function e(t,i){var o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null==n?void 0:n.get(i),Array.isArray(o)&&(o=null===(a=o)||void 0===a?void 0:gE(a).call(a,(function(e){return e.isScreen===r}))),!t){e.next=9;break}if(!t.played){e.next=8;break}return e.next=6,t.manuallyPlay();case 6:e.next=9;break;case 8:o&&(t instanceof KG&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof XG&&o.audioTrack&&t.playAudio(o.audioTrack));case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();if(t)return i(e.get(t),t);var o=[];return e.forEach((function(e,t){return o.push(i(e,t))})),Y_.all(o)}var qG=i,YG=lt("iterator"),JG=!qG((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),!e.toJSON||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[YG]||"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})),QG=Jt,ZG=E,$G=2147483647,ez=/[^\0-\u007E]/,tz=/[.\u3002\uFF0E\uFF61]/g,rz="Overflow: input needs wider integers to process",nz=RangeError,iz=ZG(tz.exec),oz=Math.floor,az=String.fromCharCode,sz=ZG("".charCodeAt),cz=ZG([].join),uz=ZG([].push),dz=ZG("".replace),lz=ZG("".split),hz=ZG("".toLowerCase),pz=function(e){return e+22+75*(e<26)},vz=function(e,t,r){var n=0;for(e=r?oz(e/700):e>>1,e+=oz(e/t);e>455;)e=oz(e/35),n+=36;return oz(n+36*e/(e+38))},fz=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=sz(e,r++);if(i>=55296&&i<=56319&&r<n){var o=sz(e,r++);56320==(64512&o)?uz(t,((1023&i)<<10)+(1023&o)+65536):(uz(t,i),r--)}else uz(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&&uz(t,az(n));var c=t.length,u=c;for(c&&uz(t,"-");u<i;){var d=$G;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=u+1;if(d-o>oz(($G-a)/l))throw nz(rz);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>$G)throw nz(rz);if(n==o){for(var h=a,p=36;;){var v=p<=s?1:p>=s+26?26:p-s;if(h<v)break;var f=h-v,_=36-v;uz(t,az(pz(v+f%_))),h=oz(f/_),p+=36}uz(t,az(pz(h))),s=vz(a,l,u==c),a=0,u++}}a++,o++}return cz(t,"")},_z=Ar,mz=n,yz=O,gz=E,Sz=w,bz=JG,Ez=li,kz=Qy,Tz=Ni,Iz=Pc,Rz=Zi,Az=mp,wz=R,Cz=Ye,xz=Yt,Oz=fn,Mz=tr,Dz=$,Pz=yn,Nz=Gn,Lz=V,Uz=gh,Vz=hh,Fz=wp,Bz=lR,jz=lt("iterator"),Hz="URLSearchParams",Gz="URLSearchParamsIterator",zz=Rz.set,Kz=Rz.getterFor(Hz),Xz=Rz.getterFor(Gz),Wz=Object.getOwnPropertyDescriptor,qz=function(e){if(!Sz)return mz[e];var t=Wz(mz,e);return t&&t.value},Yz=qz("fetch"),Jz=qz("Request"),Qz=qz("Headers"),Zz=Jz&&Jz.prototype,$z=Qz&&Qz.prototype,eK=mz.RegExp,tK=mz.TypeError,rK=mz.decodeURIComponent,nK=mz.encodeURIComponent,iK=gz("".charAt),oK=gz([].join),aK=gz([].push),sK=gz("".replace),cK=gz([].shift),uK=gz([].splice),dK=gz("".split),lK=gz("".slice),hK=/\+/g,pK=Array(4),vK=function(e){return pK[e-1]||(pK[e-1]=eK("((?:%[\\da-f]{2}){"+e+"})","gi"))},fK=function(e){try{return rK(e)}catch(uq){return e}},_K=function(e){var t=sK(e,hK," "),r=4;try{return rK(t)}catch(uq){for(;r;)t=sK(t,vK(r--),fK);return t}},mK=/[!'()~]|%20/g,yK={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},gK=function(e){return yK[e]},SK=function(e){return sK(nK(e),mK,gK)},bK=Iz((function(e,t){zz(this,{type:Gz,iterator:Uz(Kz(e).entries),kind:t})}),"Iterator",(function(){var e=Xz(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),EK=function(e){this.entries=[],this.url=null,void 0!==e&&(Dz(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===iK(e,0)?lK(e,1):e:Pz(e)))};EK.prototype={type:Hz,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=Vz(e);if(c)for(r=(t=Uz(e,c)).next;!(n=yz(r,t)).done;){if(o=(i=Uz(Mz(n.value))).next,(a=yz(o,i)).done||(s=yz(o,i)).done||!yz(o,i).done)throw tK("Expected sequence with length 2");aK(this.entries,{key:Pz(a.value),value:Pz(s.value)})}else for(var u in e)Cz(e,u)&&aK(this.entries,{key:u,value:Pz(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=dK(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=dK(t,"="),aK(this.entries,{key:_K(cK(r)),value:_K(oK(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],aK(r,SK(e.key)+"="+SK(e.value));return oK(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var kK=function(){Az(this,TK);var e=arguments.length>0?arguments[0]:void 0;zz(this,new EK(e))},TK=kK.prototype;if(kz(TK,{append:function(e,t){Fz(arguments.length,2);var r=Kz(this);aK(r.entries,{key:Pz(e),value:Pz(t)}),r.updateURL()},delete:function(e){Fz(arguments.length,1);for(var t=Kz(this),r=t.entries,n=Pz(e),i=0;i<r.length;)r[i].key===n?uK(r,i,1):i++;t.updateURL()},get:function(e){Fz(arguments.length,1);for(var t=Kz(this).entries,r=Pz(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){Fz(arguments.length,1);for(var t=Kz(this).entries,r=Pz(e),n=[],i=0;i<t.length;i++)t[i].key===r&&aK(n,t[i].value);return n},has:function(e){Fz(arguments.length,1);for(var t=Kz(this).entries,r=Pz(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){Fz(arguments.length,1);for(var r,n=Kz(this),i=n.entries,o=!1,a=Pz(e),s=Pz(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?uK(i,c--,1):(o=!0,r.value=s));o||aK(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=Kz(this);Bz(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=Kz(this).entries,n=xz(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 bK(this,"keys")},values:function(){return new bK(this,"values")},entries:function(){return new bK(this,"entries")}},{enumerable:!0}),Ez(TK,jz,TK.entries,{name:"entries"}),Ez(TK,"toString",(function(){return Kz(this).serialize()}),{enumerable:!0}),Tz(kK,Hz),_z({global:!0,constructor:!0,forced:!bz},{URLSearchParams:kK}),!bz&&wz(Qz)){var IK=gz($z.has),RK=gz($z.set),AK=function(e){if(Dz(e)){var t,r=e.body;if(Oz(r)===Hz)return t=e.headers?new Qz(e.headers):new Qz,IK(t,"content-type")||RK(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Nz(e,{body:Lz(0,Pz(r)),headers:Lz(0,t)})}return e};if(wz(Yz)&&_z({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Yz(e,arguments.length>1?AK(arguments[1]):{})}}),wz(Jz)){var wK=function(e){return Az(this,Zz),new Jz(e,arguments.length>1?AK(arguments[1]):{})};Zz.constructor=wK,wK.prototype=Zz,_z({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:wK})}}var CK,xK=Ar,OK=w,MK=JG,DK=n,PK=Yt,NK=E,LK=li,UK=function(e,t,r){return QG.f(e,t,r)},VK=mp,FK=Ye,BK=Rb,jK=Xk,HK=ni,GK=Ud.codeAt,zK=function(e){var t,r,n=[],i=lz(dz(hz(e),tz,"."),".");for(t=0;t<i.length;t++)r=i[t],uz(n,iz(ez,r)?"xn--"+fz(r):r);return cz(n,".")},KK=yn,XK=Ni,WK=wp,qK={URLSearchParams:kK,getState:Kz},YK=Zi,JK=YK.set,QK=YK.getterFor("URL"),ZK=qK.URLSearchParams,$K=qK.getState,eX=DK.URL,tX=DK.TypeError,rX=DK.parseInt,nX=Math.floor,iX=Math.pow,oX=NK("".charAt),aX=NK(/./.exec),sX=NK([].join),cX=NK(1..toString),uX=NK([].pop),dX=NK([].push),lX=NK("".replace),hX=NK([].shift),pX=NK("".split),vX=NK("".slice),fX=NK("".toLowerCase),_X=NK([].unshift),mX="Invalid scheme",yX="Invalid host",gX="Invalid port",SX=/[a-z]/i,bX=/[\d+-.a-z]/i,EX=/\d/,kX=/^0x/i,TX=/^[0-7]+$/,IX=/^\d+$/,RX=/^[\da-f]+$/i,AX=/[\0\t\n\r #%/:<>?@[\\\]^|]/,wX=/[\0\t\n\r #/:<>?@[\\\]^|]/,CX=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,xX=/[\t\n\r]/g,OX=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)_X(t,e%256),e=nX(e/256);return sX(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+=cX(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},MX={},DX=BK({},MX,{" ":1,'"':1,"<":1,">":1,"`":1}),PX=BK({},DX,{"#":1,"?":1,"{":1,"}":1}),NX=BK({},PX,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),LX=function(e,t){var r=GK(e,0);return r>32&&r<127&&!FK(t,e)?e:encodeURIComponent(e)},UX={ftp:21,file:null,http:80,https:443,ws:80,wss:443},VX=function(e,t){var r;return 2==e.length&&aX(SX,oX(e,0))&&(":"==(r=oX(e,1))||!t&&"|"==r)},FX=function(e){var t;return e.length>1&&VX(vX(e,0,2))&&(2==e.length||"/"===(t=oX(e,2))||"\\"===t||"?"===t||"#"===t)},BX=function(e){return"."===e||"%2e"===fX(e)},jX={},HX={},GX={},zX={},KX={},XX={},WX={},qX={},YX={},JX={},QX={},ZX={},$X={},eW={},tW={},rW={},nW={},iW={},oW={},aW={},sW={},cW=function(e,t,r){var n,i,o,a=KK(e);if(t){if(i=this.parse(a))throw tX(i);this.searchParams=null}else{if(void 0!==r&&(n=new cW(r,!0)),i=this.parse(a,null,n))throw tX(i);(o=$K(new ZK)).bindURL(this),this.searchParams=o}};cW.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||jX,d=0,l="",h=!1,p=!1,v=!1;for(e=KK(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=lX(e,CX,"")),e=lX(e,xX,""),n=jK(e);d<=n.length;){switch(i=n[d],u){case jX:if(!i||!aX(SX,i)){if(t)return mX;u=GX;continue}l+=fX(i),u=HX;break;case HX:if(i&&(aX(bX,i)||"+"==i||"-"==i||"."==i))l+=fX(i);else{if(":"!=i){if(t)return mX;l="",u=GX,d=0;continue}if(t&&(c.isSpecial()!=FK(UX,l)||"file"==l&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=l,t)return void(c.isSpecial()&&UX[c.scheme]==c.port&&(c.port=null));l="","file"==c.scheme?u=eW:c.isSpecial()&&r&&r.scheme==c.scheme?u=zX:c.isSpecial()?u=qX:"/"==n[d+1]?(u=KX,d++):(c.cannotBeABaseURL=!0,dX(c.path,""),u=oW)}break;case GX:if(!r||r.cannotBeABaseURL&&"#"!=i)return mX;if(r.cannotBeABaseURL&&"#"==i){c.scheme=r.scheme,c.path=HK(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=sW;break}u="file"==r.scheme?eW:XX;continue;case zX:if("/"!=i||"/"!=n[d+1]){u=XX;continue}u=YX,d++;break;case KX:if("/"==i){u=JX;break}u=iW;continue;case XX:if(c.scheme=r.scheme,i==CK)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=HK(r.path),c.query=r.query;else if("/"==i||"\\"==i&&c.isSpecial())u=WX;else if("?"==i)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=HK(r.path),c.query="",u=aW;else{if("#"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=HK(r.path),c.path.length--,u=iW;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=HK(r.path),c.query=r.query,c.fragment="",u=sW}break;case WX:if(!c.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=iW;continue}u=JX}else u=YX;break;case qX:if(u=YX,"/"!=i||"/"!=oX(l,d+1))continue;d++;break;case YX:if("/"!=i&&"\\"!=i){u=JX;continue}break;case JX:if("@"==i){h&&(l="%40"+l),h=!0,o=jK(l);for(var f=0;f<o.length;f++){var _=o[f];if(":"!=_||v){var m=LX(_,NX);v?c.password+=m:c.username+=m}else v=!0}l=""}else if(i==CK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(h&&""==l)return"Invalid authority";d-=jK(l).length+1,l="",u=QX}else l+=i;break;case QX:case ZX:if(t&&"file"==c.scheme){u=rW;continue}if(":"!=i||p){if(i==CK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(c.isSpecial()&&""==l)return yX;if(t&&""==l&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(l))return a;if(l="",u=nW,t)return;continue}"["==i?p=!0:"]"==i&&(p=!1),l+=i}else{if(""==l)return yX;if(a=c.parseHost(l))return a;if(l="",u=$X,t==ZX)return}break;case $X:if(!aX(EX,i)){if(i==CK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()||t){if(""!=l){var y=rX(l,10);if(y>65535)return gX;c.port=c.isSpecial()&&y===UX[c.scheme]?null:y,l=""}if(t)return;u=nW;continue}return gX}l+=i;break;case eW:if(c.scheme="file","/"==i||"\\"==i)u=tW;else{if(!r||"file"!=r.scheme){u=iW;continue}if(i==CK)c.host=r.host,c.path=HK(r.path),c.query=r.query;else if("?"==i)c.host=r.host,c.path=HK(r.path),c.query="",u=aW;else{if("#"!=i){FX(sX(HK(n,d),""))||(c.host=r.host,c.path=HK(r.path),c.shortenPath()),u=iW;continue}c.host=r.host,c.path=HK(r.path),c.query=r.query,c.fragment="",u=sW}}break;case tW:if("/"==i||"\\"==i){u=rW;break}r&&"file"==r.scheme&&!FX(sX(HK(n,d),""))&&(VX(r.path[0],!0)?dX(c.path,r.path[0]):c.host=r.host),u=iW;continue;case rW:if(i==CK||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&VX(l))u=iW;else if(""==l){if(c.host="",t)return;u=nW}else{if(a=c.parseHost(l))return a;if("localhost"==c.host&&(c.host=""),t)return;l="",u=nW}continue}l+=i;break;case nW:if(c.isSpecial()){if(u=iW,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=CK&&(u=iW,"/"!=i))continue}else c.fragment="",u=sW;else c.query="",u=aW;break;case iW:if(i==CK||"/"==i||"\\"==i&&c.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=fX(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"==i||"\\"==i&&c.isSpecial()||dX(c.path,"")):BX(l)?"/"==i||"\\"==i&&c.isSpecial()||dX(c.path,""):("file"==c.scheme&&!c.path.length&&VX(l)&&(c.host&&(c.host=""),l=oX(l,0)+":"),dX(c.path,l)),l="","file"==c.scheme&&(i==CK||"?"==i||"#"==i))for(;c.path.length>1&&""===c.path[0];)hX(c.path);"?"==i?(c.query="",u=aW):"#"==i&&(c.fragment="",u=sW)}else l+=LX(i,PX);break;case oW:"?"==i?(c.query="",u=aW):"#"==i?(c.fragment="",u=sW):i!=CK&&(c.path[0]+=LX(i,MX));break;case aW:t||"#"!=i?i!=CK&&("'"==i&&c.isSpecial()?c.query+="%27":c.query+="#"==i?"%23":LX(i,MX)):(c.fragment="",u=sW);break;case sW:i!=CK&&(c.fragment+=LX(i,DX))}d++}},parseHost:function(e){var t,r,n;if("["==oX(e,0)){if("]"!=oX(e,e.length-1))return yX;if(t=function(e){var t,r,n,i,o,a,s,c=[0,0,0,0,0,0,0,0],u=0,d=null,l=0,h=function(){return oX(e,l)};if(":"==h()){if(":"!=oX(e,1))return;l+=2,d=++u}for(;h();){if(8==u)return;if(":"!=h()){for(t=r=0;r<4&&aX(RX,h());)t=16*t+rX(h(),16),l++,r++;if("."==h()){if(0==r)return;if(l-=r,u>6)return;for(n=0;h();){if(i=null,n>0){if(!("."==h()&&n<4))return;l++}if(!aX(EX,h()))return;for(;aX(EX,h());){if(o=rX(h(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;l++}c[u]=256*c[u]+i,2!=++n&&4!=n||u++}if(4!=n)return;break}if(":"==h()){if(l++,!h())return}else if(h())return;c[u++]=t}else{if(null!==d)return;l++,d=++u}}if(null!==d)for(a=u-d,u=7;0!=u&&a>0;)s=c[u],c[u--]=c[d+a-1],c[d+--a]=s;else if(8!=u)return;return c}(vX(e,1,-1)),!t)return yX;this.host=t}else if(this.isSpecial()){if(e=zK(e),aX(AX,e))return yX;if(t=function(e){var t,r,n,i,o,a,s,c=pX(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(i=c[n]))return e;if(o=10,i.length>1&&"0"==oX(i,0)&&(o=aX(kX,i)?16:8,i=vX(i,8==o?1:2)),""===i)a=0;else{if(!aX(10==o?IX:8==o?TX:RX,i))return e;a=rX(i,o)}dX(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=iX(256,5-t))return null}else if(a>255)return null;for(s=uX(r),n=0;n<r.length;n++)s+=r[n]*iX(256,3-n);return s}(e),null===t)return yX;this.host=t}else{if(aX(wX,e))return yX;for(t="",r=jK(e),n=0;n<r.length;n++)t+=LX(r[n],MX);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return FK(UX,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&VX(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,i=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",e.includesCredentials()&&(u+=r+(n?":"+n:"")+"@"),u+=OX(i),null!==o&&(u+=":"+o)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+sX(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw tX(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new uW(e.path[0]).origin}catch(uq){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+OX(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(KK(e)+":",jX)},getUsername:function(){return this.username},setUsername:function(e){var t=jK(KK(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=LX(t[r],NX)}},getPassword:function(){return this.password},setPassword:function(e){var t=jK(KK(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=LX(t[r],NX)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?OX(e):OX(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,QX)},getHostname:function(){var e=this.host;return null===e?"":OX(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,ZX)},getPort:function(){var e=this.port;return null===e?"":KK(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=KK(e))?this.port=null:this.parse(e,$X))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+sX(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,nW))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=KK(e))?this.query=null:("?"==oX(e,0)&&(e=vX(e,1)),this.query="",this.parse(e,aW)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=KK(e))?("#"==oX(e,0)&&(e=vX(e,1)),this.fragment="",this.parse(e,sW)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var uW=function(e){var t=VK(this,dW),r=WK(arguments.length,1)>1?arguments[1]:void 0,n=JK(t,new cW(e,!1,r));OK||(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())},dW=uW.prototype,lW=function(e,t){return{get:function(){return QK(this)[e]()},set:t&&function(e){return QK(this)[t](e)},configurable:!0,enumerable:!0}};if(OK&&(UK(dW,"href",lW("serialize","setHref")),UK(dW,"origin",lW("getOrigin")),UK(dW,"protocol",lW("getProtocol","setProtocol")),UK(dW,"username",lW("getUsername","setUsername")),UK(dW,"password",lW("getPassword","setPassword")),UK(dW,"host",lW("getHost","setHost")),UK(dW,"hostname",lW("getHostname","setHostname")),UK(dW,"port",lW("getPort","setPort")),UK(dW,"pathname",lW("getPathname","setPathname")),UK(dW,"search",lW("getSearch","setSearch")),UK(dW,"searchParams",lW("getSearchParams")),UK(dW,"hash",lW("getHash","setHash"))),LK(dW,"toJSON",(function(){return QK(this).serialize()}),{enumerable:!0}),LK(dW,"toString",(function(){return QK(this).serialize()}),{enumerable:!0}),eX){var hW=eX.createObjectURL,pW=eX.revokeObjectURL;hW&&LK(uW,"createObjectURL",PK(hW,eX)),pW&&LK(uW,"revokeObjectURL",PK(pW,eX))}XK(uW,"URL"),xK({global:!0,constructor:!0,forced:!MK,sham:!OK},{URL:uW});var vW=ee.URL,fW=function(){var e=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(vW.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)}}(),_W=ad,mW=tc,yW=function(e,t,r,n){for(var i,o=n>1?void 0:n?mW(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&&_W(t,r,o),o},gW=function(){function e(t,r){Vl(this,e),Jd(this,"_sharedAudioContext",new AudioContext),Jd(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),Jd(this,"_localGainNode",this._sharedAudioContext.createGain()),Jd(this,"_bufferGainNode",this._sharedAudioContext.createGain()),Jd(this,"_audioBufferSource",void 0),Jd(this,"_localSource",void 0),Jd(this,"_context",void 0),Jd(this,"_failedAudioList",[]),Jd(this,"_startingIds",new $S),Jd(this,"_revokeURLs",new JN),Jd(this,"mixingMap",new $S),Jd(this,"resourcesCache",new $S),Jd(this,"volumeConfig",new $S),Jd(this,"cachedBuffer",[]),Jd(this,"id","AudioMixingManager"),this.engineId=r,this._context=t,this._localGainNode.gain.value=1}var t,r,n;return Ul(e,[{key:"mixMediaStream",value:function(e){this._localSource&&this._localSource.disconnect(this._localGainNode),this._localSource=this._sharedAudioContext.createMediaStreamSource(e),this._localSource.connect(this._localGainNode).connect(this._audioDestination)}},{key:"startAudioMixing",value:(n=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this._startingIds.get(t)){e.next=3;break}return console.warn("AudioMixing task id: ".concat(t," is starting")),e.abrupt("return");case 3:if(this._startingIds.set(t,t),i=n.playCount,VD(o=n.type,"mixingType",Qj(Ml)),a=this._context.getLocalAudioTrack()){e.next=9;break}return e.abrupt("return");case 9:if((s=a.getTrack("preprocessing"))&&this.mixMediaStream(new MediaStream([s])),null!=(c=this.mixingMap.get(t))&&c.audioNode){c.audioNode.pause(),this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_STOPPED,error:vA.AUDIO_MIXING_ERROR_OK});try{c.gainNode.disconnect(this._audioDestination),c.audioSource.disconnect(c.gainNode)}catch(y){}}if(!(d=this.resourcesCache.get(t))||d.filePath!==r){e.next=18;break}u=d.getAudioNode(),e.next=31;break;case 18:return e.next=20,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw m._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FAILED,error:vA.AUDIO_MIXING_ERROR_START_FAILED}),new mA(pA.LOAD_RESOURCES_FAILED,e.statusText)}));case 20:return l=e.sent,Qb(r).call(r,"mp3")?h={type:"audio/mpeg"}:Qb(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=24,fW(l,h);case 24:if(e.sent){e.next=28;break}throw this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FAILED,error:vA.AUDIO_MIXING_ERROR_START_FAILED}),new mA(pA.LOAD_RESOURCES_FAILED,"invalid audio resource");case 28:(u=new Audio).crossOrigin="anonymous",u.src=vW.createObjectURL(new Blob([l],h));case 31:return i<=0?u.loop=!0:i>0&&(p=i,u.onended=function(){--p>0?u.play():(m.mixingMap.delete(t),m._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FINISHED,error:vA.AUDIO_MIXING_ERROR_OK}))}),e.prev=32,e.next=35,u.play();case 35:e.next=42;break;case 37:e.prev=37,e.t0=e.catch(32),console.error(e.t0),this._failedAudioList.push(u),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:cl.STREAM_INDEX_MAIN,mediaType:ul.AUDIO});case 42:if(this._startingIds.delete(t),v=this._sharedAudioContext.createMediaElementSource(u),f=this._sharedAudioContext.createGain(),_=this.volumeConfig.get(t),f.gain.value=_?_/100:1,v.connect(f).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:v,audioNode:u,gainNode:f,type:"file"}),o===Ml.PUBLISH)try{f.disconnect(this._sharedAudioContext.destination)}catch(y){}else f.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_PLAYING,error:vA.AUDIO_MIXING_ERROR_OK});case 52:case"end":return e.stop()}}),e,this,[[32,37]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"stopAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&"file"===t.type&&(this.mixingMap.delete(e),t.audioNode.pause(),t.audioSource.disconnect(t.gainNode),t.gainNode.disconnect(this._audioDestination),this._context.emitMessage({mixId:e,state:Dl.AUDIO_MIXING_STATE_STOPPED,error:vA.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Dl.AUDIO_MIXING_STATE_PAUSED,error:vA.AUDIO_MIXING_ERROR_OK}),t.audioNode.pause())}},{key:"resumeAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Dl.AUDIO_MIXING_STATE_PLAYING,error:vA.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stopAudioMixing(t),e.next=3,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw new mA(pA.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FAILED,error:vA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof mA)throw e;throw new mA(pA.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,Qb(r).call(r,"mp3")?i={type:"audio/mpeg"}:Qb(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,fW(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FAILED,error:vA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new mA(pA.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_PRELOADED,error:vA.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=vW.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new Y_((function(e){var r=vW.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)),vW.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){VD(e,"type",Qj(Ml));var t=this._context.getLocalAudioTrack();if(t){var r=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([r])),e===Ml.PUBLISH)try{this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(n){}else this._bufferGainNode.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],e),this._bufferGainNode.connect(this._audioDestination),this._context.emitMessage({mixId:-1,state:Dl.AUDIO_MIXING_STATE_PCM_ENABLED,error:vA.AUDIO_MIXING_ERROR_OK})}}},{key:"disableAudioMixingBuffer",value:function(){if(this.cachedBuffer=[],this._audioBufferSource){try{this._audioBufferSource.disconnect(this._bufferGainNode),this._bufferGainNode.disconnect(this._audioDestination),this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(e){}finally{this._audioBufferSource=void 0}this._context.updateLocalAudioTrack(),this._context.emitMessage({mixId:-1,state:Dl.AUDIO_MIXING_STATE_PCM_DISABLED,error:vA.AUDIO_MIXING_ERROR_OK})}}},{key:"pushAudioMixingBuffer",value:function(e){var t=this;if(!(this._audioBufferSource&&(this.cachedBuffer.push(e),this.cachedBuffer.length>0))){this._audioBufferSource=this._sharedAudioContext.createBufferSource(),this._audioBufferSource.buffer=e,this._audioBufferSource.connect(this._bufferGainNode);try{this._audioBufferSource.start()}catch(r){this._failedAudioList.push(this._audioBufferSource)}this._audioBufferSource.onended=function(){var e;if(null===(e=t._audioBufferSource)||void 0===e||e.disconnect(t._bufferGainNode),t._audioBufferSource=void 0,t.cachedBuffer.length){var r=t.cachedBuffer.shift();r&&t.pushAudioMixingBuffer(r)}}}}},{key:"stopAll",value:function(){var e=this;if(this._localSource)try{this._localSource.disconnect(this._localGainNode),delete this._localSource}catch(t){}this.mixingMap.forEach((function(t,r){e.stopAudioMixing(r)}))}},{key:"mixTrack",get:function(){return this._audioDestination.stream.getAudioTracks()[0]}},{key:"sharedAudioContext",get:function(){return this._sharedAudioContext}},{key:"resumeLocalPlay",value:(t=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=$T(this._failedAudioList),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=24;break}if(i=n.value,e.prev=6,!(i instanceof HTMLAudioElement)){e.next=13;break}return i.muted=!1,e.next=11,i.play();case 11:e.next=14;break;case 13:i.start();case 14:e.next=22;break;case 16:return e.prev=16,e.t0=e.catch(6),t.push(i),console.error(e.t0),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:cl.STREAM_INDEX_MAIN,mediaType:ul.AUDIO}),e.abrupt("break",24);case 22:e.next=4;break;case 24:e.next=29;break;case 26:e.prev=26,e.t1=e.catch(2),r.e(e.t1);case 29:return e.prev=29,r.f(),e.finish(29);case 32:this._failedAudioList=t;case 33:case"end":return e.stop()}}),e,this,[[2,26,29,32],[6,16]])}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e=this._sharedAudioContext;"closed"!==e.state&&"function"==typeof e.close&&e.close(),this.cachedBuffer=[],this.mixingMap.clear(),this.resourcesCache.clear(),this.volumeConfig.clear(),this._startingIds=new $S,this._revokeURLs.forEach((function(e){vW.revokeObjectURL(e)}))}}]),e}();yW([FO("id","filePath","options")],gW.prototype,"startAudioMixing",1),yW([FO("id")],gW.prototype,"stopAudioMixing",1),yW([FO("id")],gW.prototype,"pauseAudioMixing",1),yW([FO("id")],gW.prototype,"resumeAudioMixing",1),yW([FO("id")],gW.prototype,"preloadAudioMixing",1),yW([FO("id")],gW.prototype,"unloadAudioMixing",1),yW([FO("id")],gW.prototype,"getAudioMixingVolume",1),yW([FO("id","volume")],gW.prototype,"setAudioMixingVolume",1),yW([FO("id")],gW.prototype,"getAudioMixingDuration",1),yW([FO("id")],gW.prototype,"getAudioMixingCurrentPosition",1),yW([FO("id","position")],gW.prototype,"setAudioMixingPosition",1),yW([FO("type")],gW.prototype,"enableAudioMixingBuffer",1),yW([FO()],gW.prototype,"disableAudioMixingBuffer",1),yW([FO("buffer")],gW.prototype,"pushAudioMixingBuffer",1);var SW=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(SW||{}),bW=new Nw("RTMClient",1),EW=function(e){DI(c,e);var t,r,n,i,o,a,s=QI(c);function c(e){var t;return Vl(this,c),Jd(tI(t=s.call(this)),"_dataChannelSignal",void 0),Jd(tI(t),"_handler",void 0),Jd(tI(t),"_dataChannelSignalState",dG.DISCONNECTED),Jd(tI(t),"_loginSessionId",null),Jd(tI(t),"_userId",null),Jd(tI(t),"_token",null),Jd(tI(t),"_loginResolveCallback",void 0),Jd(tI(t),"_loginRejectCallback",void 0),Jd(tI(t),"_wait_login_token",!1),Jd(tI(t),"_serverParamsCache",void 0),Jd(tI(t),"id",void 0),Jd(tI(t),"_connectionManager",void 0),Jd(tI(t),"isReconnecting",!1),t._ctx=e,t.id=e.id,t._connectionManager=new iG(e),t._addConnectHandler(),t}return Ul(c,[{key:"login",value:function(e,t){var r=this;return new Y_((function(n,i){var o;if(bW.info("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new mA(pA.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new mA(pA.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=VO(r.id))||void 0===o||o.set({rtm_user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():r.connect().then((function(){r._login()}))}))}},{key:"logout",value:(a=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(pA.NOT_LOGIN,"login first");case 2:return e.next=4,null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId},{functionType:tG.C2RTM}).catch((function(){}));case 4:this._clearState();case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"updateLoginToken",value:(o=Rm(Tm().mark((function e(t){var r=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new Y_((function(e,t){r._wait_login_token?(r._loginResolveCallback=e,r._loginRejectCallback=t,r._login()):e()})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(i=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(pA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,peerUserId:t},{functionType:tG.C2RTM});case 5:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(n=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(pA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"setServerParams",value:(r=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,UD(t,"signature"),UD(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new mA(pA.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,signature:t,url:r},{functionType:tG.C2RTM}).catch((function(e){throw new mA(pA.UNEXPECTED_ERROR,e.msg)}));case 8:this._serverParamsCache={signature:t,url:r},this.emit("onServerParamsSetResult"),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(0),this.emit("onServerParamsSetResult",e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,12]])}))),function(e,t){return r.apply(this,arguments)})},{key:"sendServerMessage",value:(t=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(pA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:"",room:"",type:YH.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e;bW.info("destroy","invoke."),OI(CI(c.prototype),"removeAllListeners",this).call(this),this._loginResolveCallback&&this._loginRejectCallback&&(this._loginRejectCallback(new mA(pA.LOGIN_FAILED,"logout")),delete this._loginResolveCallback,delete this._loginRejectCallback),null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),delete this._dataChannelSignal,this._clearState(),this._connectionManager.destroy(),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=dM();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:pM.token2auth(this._ctx.appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:CD.VERSION,deviceId:ED.getDeviceId(),appId:this._ctx.appId,userId:this._userId},accessParams:Nm({requireICEUfragV2:!0})},{functionType:tG.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,wO.setRtsSessionId(e.id,t),e._wait_login_token=!1,e._serverParamsCache&&e.setServerParams(e._serverParamsCache.signature,e._serverParamsCache.url)})).catch((function(t){var r,n,i=t||{},o=i.code,a=i.message;e._wait_login_token=!1,o>=700&&o<800?708===o?(r=pA.INVALID_PARAMS,n="Invalid userId"):(r=pA.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=pA.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new mA(r,a||n))})).finally((function(){delete e._loginResolveCallback,delete e._loginRejectCallback}))}}},{key:"connect",value:function(){var e=this;return new Y_((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==dG.CONNECTED)throw new mA(pA.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n;e._dataChannelSignalState=dG.CONNECTED,bW.info("connectStateChange","connected"),null===(r=e._handler)||void 0===r||r.destroy(),null===(n=e._dataChannelSignal)||void 0===n||n.destroy(),e._handler=yH(e._ctx,t.pc),e._dataChannelSignal=t.signaling,e._addSignalEventHandler(),e.isReconnecting&&e._login()})),this._connectionManager.on("disconnected",(function(t){e._dataChannelSignalState=dG.DISCONNECTED,bW.warn("connectStateChange","disconnected. %o",t),e.isReconnecting&&(e.emit("onUserDisconnection"),e._clearState())})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=dG.CONNECTING,bW.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=dG.CONNECTING,bW.warn("connectStateChange","reconnecting")}))}},{key:"_addSignalEventHandler",value:function(){var e,t,r,n=this;null===(e=this._dataChannelSignal)||void 0===e||e.on(bH.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(t=this._dataChannelSignal)||void 0===t||t.on(bH.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(r=this._dataChannelSignal)||void 0===r||r.on(bH.USER_DISCONNECTION,(function(){n.emit("onUserDisconnection"),n._clearState()}))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,wO.setRtsSessionId(this.id,"")}}]),c}(nP.exports.EventEmitter),kW=function(){function e(t){Vl(this,e),Jd(this,"_roomId",void 0),Jd(this,"_constraints",{}),Jd(this,"_profile",void 0),Jd(this,"_customMaxBitrate",0),this._appId=t}return Ul(e,[{key:"setRoomId",value:function(e){this._roomId=e}},{key:"setAudioProfile",value:function(e){this._profile=e,this._customMaxBitrate=0}},{key:"customMaxBitrate",get:function(){return this._customMaxBitrate}},{key:"setCustomMaxBitrate",value:function(e){var t=ED.getEngineWebConfig(this._appId,this._roomId||"").audio_encode;this._customMaxBitrate=null!=t&&t.bitrate?0:1e3*e}},{key:"getOpusConfigStr",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=ED.getEngineWebConfig(this._appId,this._roomId||""),n=r.audio_encode,i=this.getConstraints(),o=i.sampleRate,a=i.channelCount,s="number"==typeof o?o:null==o?void 0:o.exact,c="number"==typeof a?a:null==a?void 0:a.exact,u={};t.split(";").forEach((function(e){var t=eI(e.split("="),2),r=t[0],n=t[1];r&&n&&(u[r]=n)}));var d=(null==n?void 0:n.bitrate)||this._customMaxBitrate||this._getConfigByAudioProfile().bitrate;d&&(u.maxaveragebitrate=d);var l=(null==n?void 0:n.enc_sample_rate)||s;l&&(u["sprop-maxcapturerate"]=l);var h=(null==n?void 0:n.playback_rate)||s;return h&&(u.maxplaybackrate=h),(c&&c>1||null!=n&&n.stereo)&&(u["sprop-stereo"]=1,u.stereo=1),null!=n&&n.dtx&&(u.usedtx=1),jm(e=an(u)).call(e,(function(e){var t;return Om(t="".concat(e,"=")).call(t,u[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=Zd(Zd({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=Zd({},this._constraints),t=ED.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;DM(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),DM(null==t?void 0:t.channel)||(e.channelCount=t.channel),DM(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),DM(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),DM(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return DM(e.sampleRate)&&!DM(n)&&(e.sampleRate=n),DM(e.channelCount)&&!DM(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case El.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case El.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case El.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case El.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case El.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),TW=function(e){DI(o,e);var t,r,n,i=QI(o);function o(e,t,r){var n,a=r.businessId;return Vl(this,o),Jd(tI(n=i.call(this)),"_mediaServerClient",void 0),Jd(tI(n),"_appId",void 0),Jd(tI(n),"remoteStreams",void 0),Jd(tI(n),"_businessId",void 0),Jd(tI(n),"_ctx",void 0),n.id=e,n._appId=t,n.remoteStreams=new $S,n._businessId=a,n._ctx={id:n.id,appId:n._appId,avSync:!0,audioProfileManager:new kW(n._appId),useCloudProxy:!1,userPriority:new $S,joinRoomConfig:new TD(n.id),enableFallbackHandler:KW(t),enableStandardHandler:XW(t),pcKillSwitch:Zd(Zd({ctor_sdpsemantics_add:!0,ctor_encodedinsetablestream_add:!0,sld_rtcpfb_rrtr_add:!0,sld_ext_sdesmid_remove:!0,sld_fmtp_sps_add:!0,sld_fmtp_bitrate_add:!0,sld_fmtp_opus_add:!0},OD("PC_KILLSWITCH")),zW(n._appId))},n}return Ul(o,[{key:"connect",value:(n=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new hG(this._ctx),this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=5,this._mediaServerClient.connect();case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new mA(pA.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new dF(this._ctx,t,t,!1,!0,{audiostream:!0,localaudio:!0,videostream:!0,localvideo:!0,extaudio:!1,extvideo:!1,videoDescriptions:[]})).on("onSEIMessage",(function(e){if(e instanceof Uint8Array)for(var t=OM(e),i=0;i<t.seiCount;i++)n.emit(CH.ON_SEI_MESSAGED_RECEIVED,{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._mediaServerClient.subscribePublicStream(r);case 6:return this.remoteStreams.set(t,r),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopPlayPublicStream",value:function(e){var t=this.remoteStreams.get(e);if(t)return this.remoteStreams.delete(e),this._mediaServerClient.unsubscribePublicStream(t)}},{key:"destroy",value:function(){var e;this.remoteStreams.forEach((function(e){e.clean()})),this.remoteStreams=new $S,null===(e=this._mediaServerClient)||void 0===e||e.destroy(),this.removeAllListeners()}},{key:"_handleReconnected",value:(t=Rm(Tm().mark((function e(){var t,r,n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=$T(this.remoteStreams);try{for(n=function(){var e=eI(r.value,1)[0];i.remoteStreams.delete(e),i.startPlayPublicStream(e).then((function(){var t=i.remoteStreams.get(e);i.safeEmit(CH.RESUBSCRIBE,{stream:t})}))},t.s();!(r=t.n()).done;)n()}catch(o){t.e(o)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on("joinSuccess",(function(e){e.reconnect&&r._handleReconnected()})),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}(aP),IW=new Nw("AudioDeviceManager",1),RW=function(e){DI(c,e);var t,r,n,i,o,a,s=QI(c);function c(e){var t;return Vl(this,c),Jd(tI(t=s.call(this)),"_audioLevelFetcher",void 0),Jd(tI(t),"_playbackDeviceTestTimer",void 0),Jd(tI(t),"_audioElement",void 0),Jd(tI(t),"_audioTrack",void 0),Jd(tI(t),"_mediaRecorder",void 0),Jd(tI(t),"_recoderTimer",void 0),Jd(tI(t),"_isAudioPlaybackDeviceTesting",!1),Jd(tI(t),"_isAudioDeviceRecordTesting",!1),Jd(tI(t),"_audioCaptureAndRecoderResolve",void 0),Jd(tI(t),"_onAutoplayFailed",void 0),Jd(tI(t),"_audioPlaybackDeviceId",void 0),t._extensionManager=e,t}return Ul(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new mA(pA.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,IW.info("startAudioPlaybackDeviceTest()","Invoke"),e.prev=4,e.next=7,this._playAudioFile(t,{loop:!0});case 7:e.next=14;break;case 9:throw e.prev=9,e.t0=e.catch(4),IW.error("startAudioPlaybackDeviceTest()","error",e.t0),this.stopAudioPlaybackDeviceTest(),e.t0;case 14:this._startEmitAudioPlaybackDeviceTestVolume(r);case 15:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return a.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this._isAudioPlaybackDeviceTesting&&(IW.info("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=Rm(Tm().mark((function e(t,r,n){var i,o=this,a=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=a.length>3&&void 0!==a[3]?a[3]:3e4,window.MediaRecorder){e.next=3;break}throw new mA(pA.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 3:if(!this._isAudioDeviceRecordTesting&&!this._isAudioPlaybackDeviceTesting){e.next=5;break}throw new mA(pA.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 5:return this._isAudioDeviceRecordTesting=!0,IW.info("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){IW.info("startAudioDeviceRecordTest()","".concat(i,'ms automatic call method "stopAudioDeviceRecordAndPlayTest"')),o._stopAudioCaptureAndRecoder()}),i),e.prev=8,this._onAutoplayFailed=r,e.next=12,this._startAudioCaptureAndRecoder(t,null!=n?n:100);case 12:e.next=19;break;case 14:throw e.prev=14,e.t0=e.catch(8),this._isAudioDeviceRecordTesting=!1,delete this._onAutoplayFailed,e.t0;case 19:delete this._audioCaptureAndRecoderResolve;case 20:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(e,t,r){return o.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){IW.info("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(IW.info("stopAudioDevicePlayTest()","Invoke"),this._isAudioDeviceRecordTesting=!1,this.stopAudioDeviceRecordAndPlayTest(),this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement()),delete this._onAutoplayFailed}},{key:"getRecordTrack",value:function(){return this._audioTrack}},{key:"setSinkId",value:(i=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new mA(pA.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,qU.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new mA(pA.INVALID_DEVICE_ID,"audio playback device id ".concat(t," is invalid"));case 8:return this._audioPlaybackDeviceId=t,this._setAudioCtxSinkId(),e.abrupt("return",r);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getSinkId",value:function(){return this._audioPlaybackDeviceId}},{key:"destroy",value:function(){IW.info("destroy()","Invoke"),OI(CI(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.info("_playAudioFile()",Om(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new Y_((function(e,n){var o=BG("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new tV(o),o.onplaying=function(){o.onplaying=null,IW.info("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=Rm(Tm().mark((function e(t){var r,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:IW.error("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new mA(pA.LOAD_RESOURCES_FAILED,"Failed to play recorded audio".concat(i?", reason: ".concat(i):".")));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i._setAudioCtxSinkId().then((function(){var e,t;return null===(e=o.play())||void 0===e||null===(t=e.catch)||void 0===t?void 0:t.call(e,(function(e){var t;IW.warn("_playAudioFile()","autoplay error",e);var r=Om(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return Y_.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new mA(pA.LOAD_RESOURCES_FAILED,r))}))}))})));case 2:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"_destroyAudioElement",value:function(){this._audioElement&&(IW.info("_destroyAudioElement()","Invoke"),this._audioElement.onplaying=null,this._audioElement.onerror=null,this._audioElement.src="",delete this._audioElement,"function"==typeof this._audioCaptureAndRecoderResolve&&this._audioCaptureAndRecoderResolve())}},{key:"_startEmitAudioPlaybackDeviceTestVolume",value:function(e){var t=this;e=Math.max(e,100),this._audioElement&&(IW.info("_startEmitAudioPlaybackDeviceTestVolume()","start timer(".concat(e,"ms)")),this._playbackDeviceTestTimer=self.setInterval((function(){t._audioLevelFetcher&&t.emit("onAudioPlaybackDeviceTestVolume",t._audioLevelFetcher.getAudioLevel())}),e))}},{key:"_stopEmitAudioPlaybackDeviceTestVolume",value:function(){var e;void 0!==this._playbackDeviceTestTimer&&(IW.info("_stopEmitAudioPlaybackDeviceTestVolume()","stop timer"),self.clearInterval(this._playbackDeviceTestTimer),delete this._playbackDeviceTestTimer),null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),delete this._audioLevelFetcher}},{key:"_startAudioCaptureAndRecoder",value:(r=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,CV({},this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r),n=new MediaStream([this._audioTrack.getTrack("preprocessing")]),IW.info("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new Y_((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=gE(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),IW.info("startAudioDeviceRecordTest()","use mimeType: ".concat(o))),i._mediaRecorder=new MediaRecorder(n,o?{mimeType:o}:void 0);var s=i._mediaRecorder.mimeType;i._mediaRecorder.ondataavailable=function(){var n=Rm(Tm().mark((function n(o){var a,c;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return IW.info("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(vW.createObjectURL(c),{loop:!1});case 6:n.next=11;break;case 8:return n.prev=8,n.t0=n.catch(3),n.abrupt("return",r(n.t0));case 11:i._startEmitAudioPlaybackDeviceTestVolume(t),null===(a=i._audioElement)||void 0===a||a.addEventListener("ended",(function(){i.stopAudioDevicePlayTest(),e()})),i._audioCaptureAndRecoderResolve=e,n.next=17;break;case 16:e();case 17:case"end":return n.stop()}}),n,null,[[3,8]])})));return function(e){return n.apply(this,arguments)}}(),i._mediaRecorder.onerror=function(e){r(new mA(pA.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},i._audioCaptureAndRecoderResolve=e,i._mediaRecorder.start()})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_stopAudioCaptureAndRecoder",value:function(){var e;this._mediaRecorder&&("recording"===this._mediaRecorder.state&&this._mediaRecorder.stop(),delete this._mediaRecorder),null===(e=this._audioTrack)||void 0===e||e.close(),delete this._audioTrack}},{key:"_setAudioCtxSinkId",value:(t=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=rV.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),IW.info("setSinkId","ctx.sinkId=".concat(t))}catch(o){IW.error("setSinkId",Om(i="failed, ".concat(o.name," - ")).call(i,o.message))}}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),c}(nP.exports.EventEmitter),AW=new Nw("VideoSnapshot",1),wW=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},CW=function(){var e=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=document.createElement("canvas"),o=i.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(a=function(e,t,n){return t=t||e.width,n=n||e.height,i.width=t,i.height=n,r?o.setTransform(-1,0,0,1,t,0):o.setTransform(1,0,0,1,0,0),o.drawImage(e,0,0,t,n),o.getImageData(0,0,t,n)},s=Date.now(),!(c=wW(n))){e.next=16;break}return AW.info("takeSnapshot","VideoPlayer already set."),e.next=11,a(c,c.videoWidth,c.videoHeight);case 11:return u=e.sent,AW.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",u);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(d=new window.ImageCapture(t)).track.readyState||!d.track.enabled||d.track.muted){e.next=29;break}return AW.info("takeSnapshot","use ImageCapture"),e.t0=a,e.next=23,d.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return l=e.sent,AW.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 29:return AW.info("takeSnapshot","use temp video"),e.abrupt("return",new Y_((function(e,r){var n=new MediaStream([t]),i=document.createElement("video");i.setAttribute("playsinline",""),i.muted=!0,document.body.appendChild(i),i.onplaying=function(){var r=a(i,i.videoWidth,i.videoHeight);AW.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e(r),n.removeTrack(t),i.srcObject=null,i.load()},i.onerror=r,i.srcObject=n,i.play()})));case 31:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),xW=function(){return{url:"",video:{codec:Il.H264,width:640,height:360,fps:15,gop:2,kBitRate:OW(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:Tl.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function OW(e,t,r){return e*t<=288e3?r<=15?800:1200:e*t<=864e3?r<=15?1200:1800:e*t<=1152e3?r<=15?1600:2400:e*t<=2592e3?r<=15?2500:3750:r<=15?3300:5e3}function MW(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new mA(pA.INVALID_PARAMS,"Invalid rtmp address")}function DW(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new mA(pA.INVALID_PARAMS,"regions should not be empty.");var t,r=$T(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new mA(pA.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new mA(pA.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(i){r.e(i)}finally{r.f()}}function PW(e,t){var r,n,i,o=function(e,r){var n=pb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=pb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),xW());return n&&r(n)?n:i},a=function(e){return e%2==0?e:e+1},s=a(o(["video","width"],(function(e){return e>=2&&e<=1920}))),c=a(o(["video","height"],(function(e){return e>=2&&e<=1920}))),u=o(["video","fps"],(function(e){return e>=1&&e<=60})),d=(null===(r=t.video)||void 0===r?void 0:r.kBitRate)||0,l=o(["audio","sampleRate"],(function(e){var t;return!!gE(t=[32e3,44100,48e3]).call(t,(function(t){return t===e||t/1e3===e}))}));return{type:"transcode",action:e,transcodeMeta:{transcode:{url:t.url},control:{protocol:"2.0"},audio:{codec:o(["audio","codec"],(function(e){return"AAC"===e})),bitRate:1e3*o(["audio","kBitRate"],(function(e){return e>=32&&e<=192})),sampleRate:l<100?1e3*l:l,channels:o(["audio","channels"],(function(e){var t;return mk(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return mk(t=[Tl.LC,Tl.HEv1,Tl.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return mk(t=["H264","H265"]).call(t,e)})),fps:u,gop:o(["video","gop"],(function(e){return e>=1&&e<=5}))*u,bitRate:1e3*(d>=16&&d<=1e4?d:OW(s,c,u)),width:s,height:c},layout:{canvas:{bgnd:o(["layout","backgroundColor"],(function(e){return/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(e)}))},regions:(null===(n=t.layout)||void 0===n||null===(i=n.regions)||void 0===i?void 0:jm(i).call(i,(function(e){var t,r;return{alpha:!e.alpha||Number(e.alpha)>1||Number(e.alpha)<=0?1:Number(e.alpha),uid:e.userId,zorder:!e.zorder||Number(e.zorder)<0||Number(e.zorder)>100?0:Number(e.zorder),x:!e.x||Number(e.x)>=1||Number(e.x)<0?0:Number(e.x),y:!e.y||Number(e.y)>=1||Number(e.y)<0?0:Number(e.y),w:!e.w||Number(e.w)>1||Number(e.w)<=0?1:Number(e.w),h:!e.h||Number(e.h)>1||Number(e.h)<=0?1:Number(e.h),renderMode:e.renderMode&&mk(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&mk(r=[0,1,2]).call(r,e.contentControl)?e.contentControl:0,screen:!!e.isScreenStream}})))||[],app_data:o(["layout","appData"],(function(e){return"string"==typeof e}))}}}}var NW,LW={getDefaultValue:xW,checkStartParams:function(e){var t;MW(e.url),DW(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&MW(e.url),DW(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return PW("started",e)},getUpdateParams:function(e){return PW("layoutChanged",e)}},UW=ad,VW=tc,FW=function(e,t,r,n){for(var i,o=n>1?void 0:n?VW(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&&UW(t,r,o),o},BW=new Nw("Engine",0),jW=function(e){DI(ke,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D,P,N,L,U,V,F,B,j,H,G,z,K,X,W,q,Y,J,Q,Z,$,ee,te,re,ne,ie,oe,ae,se,ce,ue,de,le,he,pe,ve,fe,_e,me,ye,ge,Se,be,Ee=QI(ke);function ke(e,t,r){var n;return Vl(this,ke),Jd(tI(n=Ee.call(this)),"monitor",void 0),Jd(tI(n),"_room",void 0),Jd(tI(n),"_publicStreamManager",void 0),Jd(tI(n),"_appId",void 0),Jd(tI(n),"_businessId",void 0),Jd(tI(n),"_visibility",!0),Jd(tI(n),"_localVideoTrack",void 0),Jd(tI(n),"_localAudioTrack",void 0),Jd(tI(n),"_localImgVideoTrack",void 0),Jd(tI(n),"_localImgScreenTrack",void 0),Jd(tI(n),"_localScreenVideoTrack",void 0),Jd(tI(n),"_localScreenAudioTrack",void 0),Jd(tI(n),"_tempMixingAudioTrack",void 0),Jd(tI(n),"_localAudioVolume",100),Jd(tI(n),"_localScreenAudioVolume",100),Jd(tI(n),"_remoteAudioVolume",new $S),Jd(tI(n),"_remoteScreenAudioVolume",new $S),Jd(tI(n),"_publicAudioVolume",new $S),Jd(tI(n),"_videoPlayer",void 0),Jd(tI(n),"_screenPlayer",void 0),Jd(tI(n),"_remoteVideoPlayer",new $S),Jd(tI(n),"_remoteScreenPlayer",new $S),Jd(tI(n),"_remoteAudioPlayer",new $S),Jd(tI(n),"_remoteScreenAudioPlayer",new $S),Jd(tI(n),"_publicStreamAudioPlayer",new $S),Jd(tI(n),"_publicStreamVideoPlayer",new $S),Jd(tI(n),"_publicStreamIds",new $S),Jd(tI(n),"_roomConfig",void 0),Jd(tI(n),"_videoStreamConstraints",DD),Jd(tI(n),"_audioStreamConstraints",{}),Jd(tI(n),"_enableSimulcast",!1),Jd(tI(n),"_videoStreamEncodeConfig",[DD]),Jd(tI(n),"_screenStreamEncodeConfig",[PD]),Jd(tI(n),"_dummyMainImage",void 0),Jd(tI(n),"_dummyScreenImage",void 0),Jd(tI(n),"_trackSourceType",void 0),Jd(tI(n),"_liveTranscodeConfig",void 0),Jd(tI(n),"_startCloudProxyTimestamp",void 0),Jd(tI(n),"_localVideoDeviceId",void 0),Jd(tI(n),"_localAudioDeviceId",void 0),Jd(tI(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),Jd(tI(n),"_audioVolumeIndicationTimer",void 0),Jd(tI(n),"_dummyMainTimer",void 0),Jd(tI(n),"_dummyScreenTimer",void 0),Jd(tI(n),"_audioPropertiesReportTimer",null),Jd(tI(n),"_mirrorType",hl.MIRROR_TYPE_RENDER),Jd(tI(n),"_audioMixingManager",void 0),Jd(tI(n),"_pubLock",void 0),Jd(tI(n),"_rtmClient",void 0),Jd(tI(n),"_messageStatisticsObserver",void 0),Jd(tI(n),"_tempRoomInfo",void 0),Jd(tI(n),"_originIceConfigRequestUrls",void 0),Jd(tI(n),"_originConfigServerUrls",void 0),Jd(tI(n),"_originLogServerUrl",void 0),Jd(tI(n),"_extensionManager",void 0),Jd(tI(n),"_audioDeviceManager",void 0),Jd(tI(n),"_remoteVideoConfig",new $S),Jd(tI(n),"_cameraCapturing",!1),Jd(tI(n),"_interruptCameraCapture",!1),Jd(tI(n),"_micCapturing",!1),Jd(tI(n),"_interruptMicCapture",!1),Jd(tI(n),"_config",void 0),Jd(tI(n),"_needClosePreTrack",!1),Jd(tI(n),"_ctx",void 0),Jd(tI(n),"_updateMixAudioTrack",function(){var e=Rm(Tm().mark((function e(t){var r,i,o=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:Ml.PLAYOUT_AND_PUBLISH,BW.info("_updateMixAudioTrack()"),n._localAudioTrack){e.next=5;break}return t&&(n._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(n._localAudioTrack.mixType=i,n._localAudioTrack.mixedAudioTrack=t):(delete n._localAudioTrack.mixType,delete n._localAudioTrack.mixedAudioTrack),null===(r=n._room)||void 0===r||!r.hasPublished){e.next=9;break}return e.next=9,n._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),Jd(tI(n),"_onAudioMixingMessage",(function(e){n.safeEmit(Nl.onAudioMixingStateChanged,e)})),Jd(tI(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(Nl.onAutoplayFailed,e)})),n.id=t,n._appId=e,n._pubLock=new wH("pubLock"),n._addDeviceEventHandler(),n._extensionManager=new iV(t),n._audioDeviceManager=new RW(n._extensionManager),n._audioMixingManager=new gW({getLocalAudioTrack:function(){return n._localAudioTrack},updateLocalAudioTrack:n._updateMixAudioTrack,emitMessage:n._onAudioMixingMessage,onAutoPlayFailed:n._onAudioMixingAutoplayFailed},t),n._ctx={id:t,appId:e,avSync:!0,streamRTT:{},useCloudProxy:!1,audioProfileManager:new kW(e),userPriority:new $S,expectedIDC:null==r?void 0:r.expectedIDC,joinRoomConfig:new TD(t),enableFallbackHandler:KW(e),enableStandardHandler:XW(e),pcKillSwitch:Zd(Zd({ctor_sdpsemantics_add:!0,ctor_encodedinsetablestream_add:!0,sld_rtcpfb_rrtr_add:!0,sld_ext_sdesmid_remove:!0,sld_fmtp_sps_add:!0,sld_fmtp_bitrate_add:!0,sld_fmtp_opus_add:!0},OD("PC_KILLSWITCH")),zW(n._appId))},window.__rtc_engine__=tI(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=tI(n),n._trackSourceType={video:$d.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:$d.VIDEO_SOURCE_TYPE_INTERNAL,audio:el.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:el.AUDIO_SOURCE_TYPE_INTERNAL},n._config=r,n._rtmClient=new EW(n._ctx),n._handleRTMClient(n._rtmClient),n._handleAudioDeviceManager(),n._messageStatisticsObserver=new CO(t),n.monitor=VO(t),wO.createRTSMsgReportor(n.id),n._getServerConfig(),n}return Ul(ke,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(be=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("updateToken()","token: %s",t),UD(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return n=this._tempRoomInfo,i=n.config,o=n.userInfo,a=n.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,a,o,i);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new mA(pA.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,null===(r=this._room)||void 0===r?void 0:r.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return be.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(Se=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("setVideoCaptureDevice()","deviceId: %s",t),UD(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:return r=XB({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},nD&&XM&&pD>=85&&pD<=91&&(null===(n=this._videoPlayer)||void 0===n||n.removeTrack()),this._needClosePreTrack=this._needClosePreTrack||nD&&XM,this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),BW.info("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=13,AV(r,this._extensionManager).catch((function(e){if(o._localVideoTrack&&!o._localVideoTrack.dummy)return BW.warn("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),o._removeLocalTrackEvents(o._localVideoTrack),o._localVideoTrack.close(),delete o._localVideoTrack,AV(r,o._extensionManager).then((function(e){return o._needClosePreTrack=!0,e})).catch(Rm(Tm().mark((function t(){var r;return Tm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return BW.error("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,AV(o._videoStreamConstraints,o._extensionManager);case 3:throw r=t.sent,o._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 13:return i=e.sent,BW.success("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=r,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),e.next=19,this._switchTrack(i);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return Se.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(ge=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("setAudioCaptureDevice()","deviceId: %s",t),UD(t,"deviceId"),this._localAudioDeviceId=t,this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.prev=8,this._micCapturing=!0,e.next=12,CV(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 12:if(i=e.sent,!this._interruptMicCapture){e.next=18;break}return this._interruptMicCapture=!1,i.close(),this._localAudioTrack=void 0,e.abrupt("return");case 18:if(this._initLocalTrackEvents(i),this._localAudioTrack=i,this._localAudioTrack.setVolume(this._localAudioVolume),this._room){e.next=23;break}return e.abrupt("return");case 23:if(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.pubAudio){e.next=26;break}return e.next=26,this._updatePublish();case 26:return e.prev=26,this._micCapturing=!1,e.finish(26);case 29:case"end":return e.stop()}}),e,this,[[8,,26,29]])}))),function(e){return ge.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){qU.on(Nl.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),qU.on(Nl.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,M,D,P,N=this;null===(e=this._room)||void 0===e||e.on(bH.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(bH.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(bH.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(CH.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(CH.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(CH.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(bH.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(bH.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(bH.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(bH.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(bH.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?N._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?N._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&N._onLiveTranscodingResult(e)})),null===(l=this._room)||void 0===l||l.on(kH.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(kH.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return N.safeEmit(Nl.onVendorConnectionStateChanged,e)})),null===(p=this._room)||void 0===p||p.on(CH.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(v=this._room)||void 0===v||v.on(CH.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(CH.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(_=this._room)||void 0===_||_.on(CH.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=N._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&N.safeEmit(Nl.onAutoPublishResult,e)})),null===(m=this._room)||void 0===m||m.on(CH.ON_REMOTE_STREAM_STATS,(function(e){N.safeEmit(Nl.onRemoteStreamStats,e)})),null===(y=this._room)||void 0===y||y.on(CH.ON_LOCAL_STREAM_STATS,(function(e){N.safeEmit(Nl.onLocalStreamStats,e)})),null===(g=this._room)||void 0===g||g.on(CH.ON_SUBTITLE_STATE_CHANGED,(function(e){N.safeEmit(Nl.onSubtitleStateChanged,e)})),null===(S=this._room)||void 0===S||S.on(CH.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){N.safeEmit(Nl.onSubtitleMessageReceived,e)})),null===(b=this._room)||void 0===b||b.on(CH.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(E=this._room)||void 0===E||E.on(CH.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;N._updateAudioPlayerState(t),N.safeEmit(Nl.onUserStartAudioCapture,{userId:r})})),null===(k=this._room)||void 0===k||k.on(CH.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;N.safeEmit(Nl.onUserStopAudioCapture,{userId:t})})),null===(T=this._room)||void 0===T||T.on(CH.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;N.safeEmit(Nl.onUserStartVideoCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(CH.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;N.safeEmit(Nl.onUserStopVideoCapture,{userId:t})})),null===(R=this._room)||void 0===R||R.on(CH.ON_SEI_MESSAGED_RECEIVED,(function(e){N.safeEmit(Nl.onSEIMessageReceived,e)})),null===(A=this._room)||void 0===A||A.on(CH.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){N.safeEmit(Nl.onRemoteVideoSizeChanged,e,t)})),null===(w=this._room)||void 0===w||w.on(CH.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return N.safeEmit(Nl.onSimulcastSubscribeFallback,e)})),null===(C=this._room)||void 0===C||C.on(CH.RECONNECT_FAILED,(function(){N.safeEmit(Nl.onError,{errorCode:pA.RECONNECT_FAILED})})),null===(x=this._room)||void 0===x||x.on(CH.ON_VIDEO_STREAM_BANNED,(function(e){N.safeEmit(Nl.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(O=this._room)||void 0===O||O.on(CH.ON_AUDIO_STREAM_BANNED,(function(e){N.safeEmit(Nl.onAudioStreamBanned,{uid:e.uid,banned:e.banned})})),null===(M=this._room)||void 0===M||M.on(CH.ON_FORWARD_STREAM_ERROR,(function(e){N.safeEmit(Nl.onForwardStreamError,e)})),null===(D=this._room)||void 0===D||D.on(CH.ON_REJOIN_WITH_TCP,(function(){N.safeEmit(Nl.onRejoinWithTcp)})),null===(P=this._room)||void 0===P||P.on(CH.ON_ICE_CONNECT_WITH_TCP,(function(){N.safeEmit(Nl.onIceConnectWithTcp)}))}},{key:"safeEmit",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return ZD(e)&&BO(this.id,e,i),(t=OI(CI(ke.prototype),"safeEmit",this)).call.apply(t,Om(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(ye=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._room){e.next=2;break}return e.abrupt("return",!1);case 2:return this._room=new FG({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:bl.communication},this._ctx),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return ye.apply(this,arguments)})},{key:"joinRoom",value:(me=Rm(Tm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,i),zD(t)||UD(t,"token"),KD(r),qD(n),YD(i=XB({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:bl.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==dG.CONNECTED){e.next=8;break}throw new mA(pA.REPEAT_JOIN,"Already joined");case 8:return null===(a=this.monitor)||void 0===a||a.report("rtc_sdk_api_call",{sdk_api_name:"host",message:location.host,error_code:0}),this._room||(this._room=new FG(i,this._ctx),this._addHandlerEventHandler()),this._room.roomConfig=i,s=this._liveTranscodeConfig&&LW.getStartParams(this._liveTranscodeConfig),c=Zd(Zd({},n),{},{businessId:this._businessId,role:this._visibility?SW.NORMAL_USER:SW.SILENT_USER}),e.prev=13,this._ctx.useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),wG(c),e.next=18,this._room.join(this._appId,r,t,c,s);case 18:return d=e.sent,this._roomConfig=i,this._ctx.audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,null!==(u=i)&&void 0!==u&&u.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:ul.AUDIO_AND_VIDEO}):this.safeEmit(Nl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),wO.setRoomId(this.id,r),wO.setUserId(this.id,n.userId),e.abrupt("return",d);case 28:throw e.prev=28,e.t0=e.catch(13),e.t0.code===pA.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:c}),null===(l=this._room)||void 0===l||l.destroy(),delete this._room,e.t0;case 34:case"end":return e.stop()}}),e,this,[[13,28]])}))),function(e,t,r,n){return me.apply(this,arguments)})},{key:"leaveRoom",value:(_e=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],BW.info("leaveRoom()"),!t){e.next=7;break}return e.next=5,null===(r=this._room)||void 0===r?void 0:r.leave(t);case 5:e.next=8;break;case 7:null===(n=this._room)||void 0===n||n.leave(t).catch();case 8:this._removeHandlerEventHandler(),this._ctx.audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new $S,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new $S,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new $S,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new $S,this._roomConfig=void 0,this._publicStreamIds=new $S,wO.setRoomId(this.id,""),wO.setUserId(this.id,"");case 24:case"end":return e.stop()}}),e,this)}))),function(){return _e.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;BW.info("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,null===(t=this._videoPlayer)||void 0===t||t.destroy(),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._videoStreamEncodeConfig=[DD],this._screenStreamEncodeConfig=[PD],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),wO.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localScreenVideoTrack=void 0),this._localImgVideoTrack&&(this._localImgVideoTrack.stop(),this._localImgVideoTrack=void 0),this._localImgScreenTrack&&(this._localImgScreenTrack.stop(),this._localImgScreenTrack=void 0),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new $S,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new $S,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new $S,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new $S,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new $S,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new $S,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new $S,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new $S,this._ctx.userPriority.clear(),this._extensionManager.destroy(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1,this._ctx.avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(fe=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!CM(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,kV(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return fe.apply(this,arguments)})},{key:"unpublishStream",value:(ve=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("unpublishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!r){e.next=5;break}return e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.unpublish());case 5:return e.next=7,this._updatePublish({mediaType:t,pubState:OH.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return ve.apply(this,arguments)})},{key:"publishScreen",value:(pe=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!CM(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,IV(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:OH.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof mA)){e.next=18;break}throw e.t0;case 18:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return pe.apply(this,arguments)})},{key:"unpublishScreen",value:(he=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.info("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:OH.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return he.apply(this,arguments)})},{key:"subscribeStream",value:(le=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.info("subscribeStream()","userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!1,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return le.apply(this,arguments)})},{key:"_subscribe",value:(de=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),n!==ul.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=5;break}return BW.warn("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 5:if(u=this._room.remoteStreams.get(r),d=null==u?void 0:gE(u).call(u,(function(e){return e.isScreen===t}))){e.next=9;break}throw new mA(pA.STREAM_NOT_EXIST,"stream not exist");case 9:return l=this._pauseAllSubscribeState.audio,h=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&ul.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&ul.VIDEO),BW.warn("subscribeStream()","due to pauseAll mediaType: %o",n),p=d.hasSubscribed,v=this._remoteVideoConfig.get(r)||(null===(o=this._roomConfig)||void 0===o?void 0:o.remoteVideoConfig),d.originalMediaType=n,e.next=19,this._room.subscribe(d,n,v);case 19:wM(n)&&this._updateAudioPlayerState(d),CM(n)&&this._updateVideoPlayerState(d),f=0,_=0,l!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?f|=ul.AUDIO:_|=ul.AUDIO),h!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?f|=ul.VIDEO:_|=ul.VIDEO),f&&this.pauseAllSubscribedStream(f),_&&this.resumeAllSubscribedStream(_),this._pauseAllSubscribeState.resumeStreamIds[d.streamId]=d.streamId,!t&&(null!==(a=this._roomConfig)&&void 0!==a&&a.isAutoSubscribeAudio||null!==(s=this._roomConfig)&&void 0!==s&&s.isAutoSubscribeVideo)&&(d.audioTrack||d.videoTrack)&&(m={userId:r,isScreen:!1,state:il.SUBSCRIBE_SUCC},this.safeEmit(Nl.onAutoSubscribeResult,m)),null!==(c=this._room)&&void 0!==c&&c.multiChatMode||p||!wM(n)||!d.hasAudio||null===(y=d.observer)||void 0===y||y.setSubscribeAudio(!0),!p&&CM(n)&&d.hasVideo&&(null===(g=d.observer)||void 0===g||g.setSubscribeVideo(!0));case 31:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return de.apply(this,arguments)})},{key:"unsubscribeStream",value:(ue=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:BW.info("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this._unsubscribe(!1,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ue.apply(this,arguments)})},{key:"subscribeScreen",value:(ce=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.info("subscribeScreen() userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!0,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ce.apply(this,arguments)})},{key:"unsubscribeScreen",value:(se=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:BW.info("unsubscribeScreen() userId: %o, mediaType: %o",t,r),this._unsubscribe(!0,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return se.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(this._checkMediaType(r),this._assertNotInRoom(),r!==ul.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a,s=this._room.remoteStreams.get(t),c=null==s?void 0:gE(s).call(s,(function(t){return t.isScreen===e}));if(null==c||!c.hasSubscribed)throw new mA(pA.STREAM_NOT_EXIST,"stream not exist");if(nD&&pD&&pD>=85&&pD<=91&&r!==ul.AUDIO)null===(a=e?this._remoteScreenPlayer.get(t):this._remoteVideoPlayer.get(t))||void 0===a||a.stop();return this._room.unsubscribe(c,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[c.streamId]}))}BW.warn("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(ae=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.info("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),XD(t),$D(r),this._remoteVideoConfig.set(t,r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.updateSubVideoConfig(t,r).then((function(){})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return ae.apply(this,arguments)})},{key:"startVideoCapture",value:(oe=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("startVideoCapture()","deviceId: %s",t),zD(t)||UD(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!(this._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=8;break}throw new mA(pA.REPEAT_CAPTURE,"Has already capture");case 8:return a=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?a.facingMode=t:a.deviceId={exact:t},this._videoStreamConstraints=a),s={},e.prev=11,this._cameraCapturing=!0,e.next=15,AV(a,this._extensionManager);case 15:if(u=e.sent,!this._interruptCameraCapture){e.next=22;break}throw this._interruptCameraCapture=!1,this._removeLocalTrackEvents(u),this._localVideoTrack=void 0,u.close(),new mA(pA.INTERRUPT,"interrupt by stopVideoCapture");case 22:if(this._initLocalTrackEvents(u),this._localVideoTrack=u,null===(c=this._videoPlayer)||void 0===c||c.playVideo(u),(d=null==u?void 0:u.getTrack())&&(s=d.getSettings(),l={width:s.width,height:s.height},this._localVideoTrack.resolution=l,setTimeout((function(){return p.safeEmit(Nl.onLocalVideoSizeChanged,{streamIndex:cl.STREAM_INDEX_MAIN,info:l})}))),this._room){e.next=29;break}return e.abrupt("return",s);case 29:return e.prev=29,this._cameraCapturing=!1,e.finish(29);case 32:return h=this._room._roomConfig.isAutoPublish,(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubVideo||h)&&(this._visibility?this._updatePublish():this.safeEmit(Nl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableVideo(!0),e.abrupt("return",s);case 36:case"end":return e.stop()}}),e,this,[[11,,29,32]])}))),function(e){return oe.apply(this,arguments)})},{key:"stopVideoCapture",value:(ie=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("stopVideoCapture()"),!this._cameraCapturing){e.next=5;break}return this._interruptCameraCapture=!0,BW.warn("stopVideoCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 7:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),this._localVideoTrack&&(this._localVideoTrack.dummy||((s=this._extensionManager.getPluginByName(nV.PRE_PROCESSING,"RTCBeautyExtension"))&&s.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(null===(c=this._localVideoTrack)||void 0===c||c.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=11;break}return e.abrupt("return");case 11:if(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.pubVideo){e.next=14;break}return e.next=14,this._updatePublish();case 14:null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setEnableVideo(!1);case 15:case"end":return e.stop()}}),e,this)}))),function(){return ie.apply(this,arguments)})},{key:"startAudioCapture",value:(ne=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("startAudioCapture()","deviceId: $o",t),zD(t)||UD(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,this._trackSourceType.audio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:if(!this._micCapturing&&!this._localAudioTrack){e.next=8;break}throw new mA(pA.REPEAT_CAPTURE,"Has already capture");case 8:return t&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),a={},e.prev=10,this._micCapturing=!0,e.next=14,CV(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 14:if(s=e.sent,!this._interruptMicCapture){e.next=21;break}throw this._interruptMicCapture=!1,this._removeLocalTrackEvents(s),s.close(),this._localAudioTrack=void 0,new mA(pA.INTERRUPT,"interrupt by stopAudioCapture");case 21:if(this._initLocalTrackEvents(s),this._localAudioTrack=s,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),s.getOrgTrack()&&(a=s.getOrgTrack().getSettings()),this._room){e.next=28;break}return e.abrupt("return",a);case 28:return e.prev=28,this._micCapturing=!1,e.finish(28);case 31:return c=this._room._roomConfig.isAutoPublish,(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubAudio||c)&&(this._visibility?this._updatePublish():this.safeEmit(Nl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableAudio(!0),e.abrupt("return",a);case 35:case"end":return e.stop()}}),e,this,[[10,,28,31]])}))),function(e){return ne.apply(this,arguments)})},{key:"stopAudioCapture",value:(re=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("stopAudioCapture()"),!this._micCapturing){e.next=5;break}return this._interruptMicCapture=!0,BW.warn("stopAudioCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.audio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._room){e.next=12;break}return e.abrupt("return");case 12:if(null===(t=this._room)||void 0===t||null===(r=t.localStream)||void 0===r||!r.pubAudio){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return re.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return BW.info("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(te=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m=this,y=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=y.length>0&&void 0!==y[0]?y[0]:{},BW.info("startScreenCapture()","config: %o",c),u=c.enableAudio,d=void 0!==u&&u,this._trackSourceType.screenVideo!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,OV(d,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(l=e.sent,h=eI(l,2),p=h[0],null==(v=h[1])||v.setVolume(this._localScreenAudioVolume),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(t=this._localScreenAudioTrack)||void 0===t||t.close(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=p,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&p.setContentHint(null===(f=this._screenStreamEncodeConfig[0])||void 0===f?void 0:f.contentHint),(_=null==p?void 0:p.getTrack())&&setTimeout((function(){var e=_.getSettings(),t={width:e.width,height:e.height};p.resolution=t,m.safeEmit(Nl.onLocalVideoSizeChanged,{streamIndex:cl.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),v&&(this._localScreenAudioTrack=v,this._initLocalTrackEvents(v)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),!(null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubAudio||null!==(a=this._room)&&void 0!==a&&null!==(s=a.localScreenStream)&&void 0!==s&&s.pubVideo)){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return te.apply(this,arguments)})},{key:"stopScreenCapture",value:(ee=Rm(Tm().mark((function e(){var t,r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localImgScreenTrack&&(null===(a=this._localScreenVideoTrack)||void 0===a||a.setTrack(this._localImgScreenTrack,this._extensionManager),this._localScreenVideoTrack.dummy=!0))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,!(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localScreenStream)&&void 0!==n&&n.pubAudio||null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubVideo)){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return ee.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(BW.info("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),VD(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,i,o,a=Zd(Zd({userId:this._getUserId()},t),{},{isLocal:!0});if(JD(a),e===cl.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new KG(this.id,a),this._initPlayerEvents(this._videoPlayer,!1,e),this._videoPlayer.mirror(!!this._mirrorType),this._localVideoTrack&&!this._localVideoTrack.dummy&&(null===(r=this._config)||void 0===r?void 0:r.autoPlayPolicy)!==kl.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),(null===(n=this._room)||void 0===n?void 0:n.localStream)&&(this._room.localStream.videoDom=this._videoPlayer.domElement),this._videoPlayer.domElement;if(e===cl.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new KG(this.id,Zd(Zd({},a),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==kl.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),(null===(o=this._room)||void 0===o?void 0:o.localScreenStream)&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),this._screenPlayer.domElement;if(t&&void 0!==t.renderMode){var s=e===cl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer;null==s||s.setRenderMode(t.renderMode)}}else{var c,u;e===cl.STREAM_INDEX_MAIN?(null===(c=this._videoPlayer)||void 0===c||c.destroy(!0),delete this._videoPlayer):(null===(u=this._screenPlayer)||void 0===u||u.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:($=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("startLiveTranscoding()","transcode: %o",t),LW.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.roomInfo)&&n.roomId.length+n.userInfo.userId.length>126)){e.next=6;break}throw new mA(pA.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(Nl.onStreamMixingEvent,{event:xH.START,error:0,message:""}),!this._room||this._room.connectionState!==dG.CONNECTED){e.next=11;break}return e.next=11,null===(i=this._room)||void 0===i?void 0:i.liveControlMessage(LW.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof mA)){e.next=19;break}throw e.t0;case 19:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return $.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(Z=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=XB({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,LW.checckUpdateParams(i),this._liveTranscodeConfig=XB(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(Nl.onStreamMixingEvent,{event:xH.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(LW.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof mA)){e.next=21;break}throw e.t0;case 21:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return Z.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(Q=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(Nl.onStreamMixingEvent,{event:xH.STOP,error:0,message:""}),e.next=8,null===(t=this._room)||void 0===t?void 0:t.liveControlMessage({action:"stopped",type:"transcode"});case 8:e.next=17;break;case 10:if(e.prev=10,e.t0=e.catch(4),!(e.t0 instanceof mA)){e.next=16;break}throw e.t0;case 16:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return Q.apply(this,arguments)})},{key:"startSubtitle",value:(J=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.info("startSubtitle()","config: %o",t),this._assertNotInRoom(),e.next=4,null===(r=this._room)||void 0===r?void 0:r.startSubtitle(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return J.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;BW.info("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return BW.info("setBusinessId()","businessId: %s",e),!function(e){return"string"!=typeof e}(e)&&!this._room&&(this.monitor.set({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(Y=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("setUserVisibility()","enable: %o",t),t=!!t,this._visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._visibility=t,e.abrupt("return");case 7:if(this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),e.t0=!t,!e.t0){e.next=13;break}return e.next=13,this._room.unpublish();case 13:return e.next=15,this._room.updateUserAttributes({role:t?SW.NORMAL_USER:SW.SILENT_USER});case 15:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:ul.AUDIO_AND_VIDEO});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return Y.apply(this,arguments)})},{key:"_initPlayerEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:cl.STREAM_INDEX_MAIN,i=n===cl.STREAM_INDEX_SCREEN;e.on("playback_event",(function(n){switch(n.eventName){case"timeupdate":return;case"loadeddata":if("audio"===n.type){var o,a,s=e.userId.replace("_screen",""),c=null===(o=t._room)||void 0===o||null===(a=o.remoteStreams.get(s))||void 0===a?void 0:gE(a).call(a,(function(e){return e.isScreen===i})),u=function(){r?t.safeEmit(Nl.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(Nl.onAudioFirstFrameDecoded,{userId:s,isScreen:i}),t.safeEmit(Nl.onRemoteAudioFirstFrame,{userId:s,isScreen:i})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:i})};c&&c.observer&&!c.observer.audioFirstFrameReceived?c.observer.once("recvAudioFirstFrame",u):u()}else{var d,l,h={userId:e.userId,height:(null===(d=e.domElement)||void 0===d?void 0:d.videoHeight)||0,width:(null===(l=e.domElement)||void 0===l?void 0:l.videoWidth)||0,isScreen:i};r?(h.publicStreamId=h.userId,delete h.userId,delete h.isScreen,t.safeEmit(Nl.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(Nl.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(Nl.onVideoFirstFrameRendered,h),t.safeEmit(Nl.onVideoFirstFrameDecoded,h),t.safeEmit(Nl.onRemoteVideoFirstFrame,h)),t.monitor.report("first_remote_video_render",{stream_id:"",stream_user_id:n.userId||""},{isScreen:i})}break;case"autoplay-error":return r&&(n.publicStreamId=n.userId),jO(t.id,"autoplay-error",e instanceof KG?"video":"audio",0,n.userId||""),void t.safeEmit(Nl.onAutoplayFailed,{userId:n.userId,kind:e instanceof KG?"video":"audio",mediaType:e instanceof KG?ul.VIDEO:ul.AUDIO,streamIndex:e.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN})}t.safeEmit(Nl.onPlayerEvent,n)}))}},{key:"_initLocalTrackEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];["track-ended","track-mute","track-unmute"].forEach((function(r){e.on(r,function(){var e=Rm(Tm().mark((function e(n){var i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.monitor.report("rtc_error",{message:Om(i="track-".concat(r," mediaType: ")).call(i,n.getTrack().kind),error_code:LH.TRACK_ERROR,capture_session_id:n.captureSessionId,media_type:r,reason:r}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),a=n.getTrack(),s=a.kind,t.safeEmit({"track-ended":Nl.onTrackEnded,"track-mute":Nl.onTrackMute,"track-unmute":Nl.onTrackUnmute}[r],{kind:s,isScreen:o}),!rD&&!ZM){e.next=13;break}if("track-mute"!==r){e.next=12;break}if(ZU.emit(JU.ON_IOS_LOCAL_TRACK_MUTE,s),"audio"!==s){e.next=12;break}return e.next=11,t.stopAudioCapture();case 11:t.startAudioCapture();case 12:"track-unmute"===r&&ZU.emit(JU.ON_IOS_LOCAL_TRACK_UNMUTE,s);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),e.on("resolution-change",(function(e){t._extensionManager.getPluginsByType(nV.PRE_PROCESSING).forEach((function(t){var r;null==t||null===(r=t.applyConstraints)||void 0===r||r.call(t,e)})),t.safeEmit(Nl.onLocalVideoSizeChanged,{streamIndex:r?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN,info:e})}))}},{key:"_removeLocalTrackEvents",value:function(e){e.removeAllListeners("track-ended"),e.removeAllListeners("track-mute"),e.removeAllListeners("track-unmute"),e.removeAllListeners("resolution-change")}},{key:"setRemoteVideoPlayer",value:function(e,t){BW.info("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),VD(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),JD(t);var r,n,i,o=t.userId;if(e===cl.STREAM_INDEX_MAIN){var a,s,c;if(null===(a=this._remoteVideoPlayer.get(o))||void 0===a||a.destroy(),!t.renderDom)return;var u=new KG(this.id,t);this._initPlayerEvents(u,!1,e),this._remoteVideoPlayer.set(o,u);var d=null===(s=this._room)||void 0===s||null===(c=s.remoteStreams.get(o))||void 0===c?void 0:gE(c).call(c,(function(e){return!e.isScreen}));return d&&(this._updateVideoPlayerState(d),d.videoDom=u.domElement),u.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var l=new KG(this.id,Zd(Zd({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(o,l),this._initPlayerEvents(l,!1,e);var h=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(o))||void 0===i?void 0:gE(i).call(i,(function(e){return e.isScreen}));return h&&(this._updateVideoPlayerState(h),h.videoDom=l.domElement),l.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){BW.info("setLocalVideoMirrorType()","mirrorType: %o",e),VD(e,"mirrorType",[hl.MIRROR_TYPE_NONE,hl.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(q=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.info("setAudioPlaybackDevice()","deviceId: %s",t),UD(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(Nl.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:Nm(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return q.apply(this,arguments)})},{key:"play",value:(W=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=y.length>1&&void 0!==y[1]?y[1]:ul.AUDIO_AND_VIDEO,a=y.length>2?y[2]:void 0,BW.info("play()","userId: %s, mediaType: %s, streamIndex: %s",t,o,a),s=!t||t===this._getUserId()||"local_user"===t,c=void 0===a||a===cl.STREAM_INDEX_MAIN,u=void 0===a||a===cl.STREAM_INDEX_SCREEN,d=o!==ul.VIDEO,l=o!==ul.AUDIO,h=[],s&&l&&(c&&this._localVideoTrack&&(null===(p=this._videoPlayer)||void 0===p||p.mirror(!!this._mirrorType),h.push(null===(v=this._videoPlayer)||void 0===v?void 0:v.manuallyPlay())),u&&this._localScreenVideoTrack&&h.push(null===(f=this._screenPlayer)||void 0===f?void 0:f.manuallyPlay())),t===(null===(r=this._audioMixingManager)||void 0===r?void 0:r.id)&&h.push(this._audioMixingManager.resumeLocalPlay()),_=null===(n=this._room)||void 0===n?void 0:n.remoteStreams,l&&c&&h.push(WG(this._remoteVideoPlayer,t,!1,_)),l&&u&&h.push(WG(this._remoteScreenPlayer,t,!0,_)),d&&c&&h.push(WG(this._remoteAudioPlayer,t,!1,_)),l&&u&&h.push(WG(this._remoteScreenAudioPlayer,t,!0,_)),m=null===(i=this._publicStreamManager)||void 0===i?void 0:i.remoteStreams,d&&h.push(WG(this._publicStreamVideoPlayer,t,!1,m)),l&&h.push(WG(this._publicStreamAudioPlayer,t,!1,m)),e.abrupt("return",Y_.all(h).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return W.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(X=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),wM(t)&&(s._pauseAllSubscribeState.audio=!0),CM(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",Y_.resolve());case 6:n=[],i=$T(oR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(e.hasSubscribed){s._pauseAllSubscribeState.resumeStreamIds[e.streamId]=e.streamId;var r=s._unsubscribe(e.isScreen,e.userId,t,!0);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",Y_.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return X.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(K=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.info("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),wM(t)&&(s._pauseAllSubscribeState.audio=!1),CM(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",Y_.resolve());case 6:n=[],i=$T(oR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(s._pauseAllSubscribeState.resumeStreamIds[e.streamId]){delete s._pauseAllSubscribeState.resumeStreamIds[e.streamId];var r=s._subscribe(e.isScreen,e.userId,t);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",Y_.all(n).then((function(){var e,t;null===(e=s._room)||void 0===e||null===(t=e.remoteStreams)||void 0===t||t.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){s._updateAudioPlayerState(e),s._updateVideoPlayerState(e)}))}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return K.apply(this,arguments)})},{key:"sendUserMessage",value:(z=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XD(t),QD(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!1,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!1,o,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return z.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(G=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XD(t),jD(r,"message"),QD(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 G.apply(this,arguments)})},{key:"sendRoomMessage",value:(H=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return QD(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 H.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(j=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return QD(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t,!0))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return j.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(B=Rm(Tm().mark((function e(){var t,r=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.length>0&&void 0!==r[0]?r[0]:{},BW.info("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,HD(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._ctx.audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return B.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(F=Rm(Tm().mark((function e(){var t,r=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},BW.info("setVideoCaptureConfig()","config: %o",t),e.abrupt("return",this._setVideoCaptureConfig(t));case 3:case"end":return e.stop()}}),e,this)}))),function(){return F.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(V=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,HD(r),n=Zd(Zd({},r),{},{deviceId:this._videoStreamConstraints.deviceId}),!this._localVideoTrack){e.next=7;break}return e.next=7,this._localVideoTrack.updateVideoCaptureConfig(n);case 7:return this._videoStreamConstraints=n,e.abrupt("return",(null===(t=this._localVideoTrack)||void 0===t?void 0:t.getTrack().getSettings())||{});case 9:case"end":return e.stop()}}),e,this)}))),function(){return V.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return BW.info("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==(null==dD?void 0:dD[0])&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&NM("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(U=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(BW.info("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),tP(t=Hs(t).call(t,(function(e){return!!e}))),t.length>3&&(NM("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=km(t).call(t,0,3)),n=1;n<t.length;n++)i=LM(t[0].width)/LM(t[n].width)||1,Math.floor(i)!==i&&NM("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");HR(t).call(t,(function(e,t){return t.maxKbps-e.maxKbps})),this._setVideoCaptureConfig(Zd({},t[0])),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(cl.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 11:case"end":return e.stop()}}),e,this)}))),function(e){return U.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(L=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:BW.info("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&(this._localScreenVideoTrack.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(cl.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(BW.info("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!lL())throw new mA(pA.NOT_SUPPORTED,"Browser does not support sending SEI");VD(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),LD(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(pM.str2ab(t)):t;if(t.length){var i;if(e===cl.STREAM_INDEX_MAIN){var o,a,s;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=null===(s=this._room)||void 0===s?void 0:s.localStream}else{var c,u,d;if(null===(c=this._room)||void 0===c||null===(u=c.localScreenStream)||void 0===u||!u.hasPublished)return;i=null===(d=this._room)||void 0===d?void 0:d.localScreenStream}if(n.byteLength>4096)BW.warn("sei size must not bigger than 4KB");else{var l=dM();i.seiList.push({content:n,uuid:l,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=QR(e=i.seiList).call(e,(function(e){return e.uuid===l}));if(r)rk(t=i.seiList).call(t,r,1)}}),2e3)}}else BW.warn("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;BW.info("setAudioVolumeIndicationInterval()","interval %o: ",e),("number"!=typeof e||e<200)&&(e=200);var r=[];this._audioVolumeIndicationTimer&&clearInterval(this._audioVolumeIndicationTimer),this._audioVolumeIndicationTimer=setInterval((function(){var e,n;r=[],null===(e=t._room)||void 0===e||e.remoteStreams.forEach((function(e,t){var n;if(0!==e.length){var i=gE(e).call(e,(function(e){return!e.isScreen})),o=null==i||null===(n=i.audioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t,volume:o||0})}}));var i=null===(n=t._localAudioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t._getUserId(),volume:i||0}),t.safeEmit(Nl.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=pb(t).call(t,(function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=n?i?n.audioPropertiesInfo.nonlinearVolume>i.audioPropertiesInfo.nonlinearVolume?n:i:n:i)&&r.audioPropertiesInfo.nonlinearVolume>-35){var o,a;if(r.streamKey)o=this._room.remoteUsers.get(r.streamKey.userId);else o=null===(a=this._room._roomInfo)||void 0===a?void 0:a.userInfo;o&&this.safeEmit(Nl.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};BW.info("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.interval,o=void 0===i?100:i;this._stopAudioPropertiesReport(),o<=0||(o=Math.max(100,o),this._audioPropertiesReportTimer=self.setInterval((function(){if(n||"hidden"!==document.visibilityState){var t=[],r=e._audioDeviceManager.getRecordTrack()||e._localAudioTrack;if(r){var i=r.getAudioLevel();t.push({streamIndex:cl.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:i,nonlinearVolume:AM(i)}})}if(e._localScreenAudioTrack){var o=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:cl.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:o,nonlinearVolume:AM(o)}})}if(e.safeEmit(Nl.onLocalAudioPropertiesReport,t),e._room){var a,s=[];if(null!==(a=e._room)&&void 0!==a&&a.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i=255*t.audioLevel;s.push({streamKey:{userId:t.userId,streamIndex:cl.STREAM_INDEX_MAIN,roomId:null===(r=e._room)||void 0===r||null===(n=r._roomInfo)||void 0===n?void 0:n.roomId},audioPropertiesInfo:{linearVolume:i,nonlinearVolume:AM(i)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();s.push({streamKey:{userId:r,streamIndex:t.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN,roomId:null===(n=e._room)||void 0===n||null===(i=n.roomInfo)||void 0===i?void 0:i.roomId},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:AM(o)}})}}))}));e.safeEmit(Nl.onRemoteAudioPropertiesReport,s),e._sendActiveSpeaker(t,Hs(s).call(s,(function(e){return e.streamKey.streamIndex!==cl.STREAM_INDEX_SCREEN})))}}}),o))}},{key:"setVideoSourceType",value:(N=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),VD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),VD(r,"VideoSourceType",[$d.VIDEO_SOURCE_TYPE_EXTERNAL,$d.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===cl.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,BW.print("setVideoSourceType",Om(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==cl.STREAM_INDEX_MAIN){e.next=17;break}if(u=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(u=!0,(d=this._extensionManager.getPluginByName(nV.PRE_PROCESSING,"RTCBeautyExtension"))&&d.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(o=this._videoPlayer)||void 0===o||o.stop(),this._localVideoTrack=void 0,l=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,u?null===(h=this._room)||void 0===h||null===(p=h.localStream)||void 0===p||null===(v=p.observer)||void 0===v||v.setEnableVideo(!1):null===(f=this._room)||void 0===f||null===(_=f.localStream)||void 0===_||null===(m=_.observer)||void 0===m||m.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubVideo||l)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==cl.STREAM_INDEX_SCREEN){e.next=26;break}if(b=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(b=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(y=this._screenPlayer)||void 0===y||y.stop(),this._localScreenVideoTrack=void 0,b?null===(E=this._room)||void 0===E||null===(k=E.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setEnableVideo(!1):null===(I=this._room)||void 0===I||null===(R=I.localScreenStream)||void 0===R||null===(A=R.observer)||void 0===A||A.setPushVideo(!1),null===(g=this._room)||void 0===g||null===(S=g.localScreenStream)||void 0===S||!S.pubVideo){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return N.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(P=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.print("setExternalVideoTrack()","index: %o, track: %o",t,r),VD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),FD(r),t!==cl.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.video===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,PV(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,this._initLocalTrackEvents(this._localVideoTrack),null===(n=this._videoPlayer)||void 0===n||n.playVideo(this._localVideoTrack),s=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,!(null!==(o=this._room)&&void 0!==o&&null!==(a=o.localStream)&&void 0!==a&&a.pubVideo||s)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(t!==cl.STREAM_INDEX_SCREEN){e.next=27;break}if(this._trackSourceType.screenVideo===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 18:return e.next=20,VV(r,this._extensionManager);case 20:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(c=this._screenPlayer)||void 0===c||c.playVideo(this._localScreenVideoTrack),null===(u=this._room)||void 0===u||null===(d=u.localScreenStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setPushVideo(!0),null===(h=this._room)||void 0===h||null===(p=h.localScreenStream)||void 0===p||!p.pubVideo){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return P.apply(this,arguments)})},{key:"setAudioSourceType",value:(D=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),VD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),VD(r,"audioSourceType",[el.AUDIO_SOURCE_TYPE_EXTERNAL,el.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===cl.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,BW.print("setVideoSourceType",Om(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==cl.STREAM_INDEX_MAIN){e.next=16;break}if(c=!1,this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL&&(c=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,u=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,c?null===(d=this._room)||void 0===d||null===(l=d.localStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setEnableAudio(!1):null===(p=this._room)||void 0===p||null===(v=p.localStream)||void 0===v||null===(f=v.observer)||void 0===f||f.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==cl.STREAM_INDEX_SCREEN){e.next=24;break}if(y=!1,this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL&&(y=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,y?null===(g=this._room)||void 0===g||null===(S=g.localScreenStream)||void 0===S||null===(b=S.observer)||void 0===b||b.setEnableAudio(!1):null===(E=this._room)||void 0===E||null===(k=E.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setPushAudio(!1),null===(_=this._room)||void 0===_||null===(m=_.localScreenStream)||void 0===m||!m.pubAudio){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return D.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(M=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.print("setExternalAudioTrack()","index: %o, track: %o",t,r),VD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),FD(r),t!==cl.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,LV(r,this._extensionManager);case 8:if(this._localAudioTrack=e.sent,this._localAudioTrack.setVolume(this._localAudioVolume),this._initLocalTrackEvents(this._localAudioTrack),u=null===(n=this._room)||void 0===n?void 0:n._roomConfig.isAutoPublish,null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setPushAudio(!0),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==cl.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,BV(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(d=this._room)||void 0===d||null===(l=d.localScreenStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setPushAudio(!0),null===(p=this._room)||void 0===p||null===(v=p.localScreenStream)||void 0===v||!v.pubAudio){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return M.apply(this,arguments)})},{key:"login",value:(O=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.info("login()","token: %o, userInfo: %o",t,r),zD(t)||UD(t,"token"),XD(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return O.apply(this,arguments)})},{key:"logout",value:(x=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.info("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"updateLoginToken",value:(C=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.info("updateLoginToken()","token: %o",t),zD(t)||UD(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(w=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.info("getPeerOnlineStatus()","userId: %o",t),XD(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(A=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XD(t),QD(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!1,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return A.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(R=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XD(t),jD(r,"message"),QD(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!0,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"setServerParams",value:(I=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.info("setServerParams()","signature: %o, url: %0",t,r),e.abrupt("return",this._rtmClient.setServerParams(t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return I.apply(this,arguments)})},{key:"sendServerMessage",value:(T=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UD(t,"message"),QD(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!1,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(k=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jD(t,"message"),QD(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!0,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new mA(pA.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");BW.info("startCloudProxy()",e),UD(e.logProxy,"logProxy"),UD(e.accessProxy,"accessProxy"),UD(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=OD("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=OD("LOG_SERVER_URL"),this._originConfigServerUrls=OD("CONFIG_REQUEST_DOMAINS"),xD("ICE_CONFIG_REQUEST_URLS",e.accessProxy),xD("LOG_SERVER_URL",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://".concat(e)),"".concat(e,"/video/v1/webrtc_log/")}(e.logProxy)),xD("CONFIG_REQUEST_DOMAINS",[e.configProxy]),ED.clearAccessNode(this._appId),ED.clearAccessUrls(),this._ctx.useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){var e;if(this._room)throw new mA(pA.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");BW.info("stopCloudProxy()"),xD("ICE_CONFIG_REQUEST_URLS",null===(e=this._originIceConfigRequestUrls)||void 0===e?void 0:jm(e).call(e,(function(e){return e.replace("https://","").replace("/dispatch/v1/AccessInfo?Action=GetAccessInfo","")}))),xD("LOG_SERVER_URL",this._originLogServerUrl),xD("CONFIG_REQUEST_DOMAINS",this._originConfigServerUrls),ED.clearAccessNode(this._appId),ED.clearAccessUrls(),this._ctx.useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(E=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),WD(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new mA(pA.REPEAT_PUSH,"repeat push public media stream");case 5:return o=MD(t,"started",r),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.publicStreamControlMessage(o))||void 0===i?void 0:i.then((function(){a._publicStreamIds.set(t,t)})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return E.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(b=Rm(Tm().mark((function e(t,r){var n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),WD(t),this._assertNotInRoom(),i=MD(t,"layoutChanged",r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.publicStreamControlMessage(i));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"stopPushPublicStream",value:(S=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.print("startPushPublicStream()","publicStreamId: %o",t),WD(t),this._assertNotInRoom(),e.abrupt("return",null===(r=this._room)||void 0===r?void 0:r.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){n._publicStreamIds.delete(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"startPlayPublicStream",value:(g=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(WD(t),this._publicStreamManager){e.next=8;break}return this._publicStreamManager=new TW(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.on(CH.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=c._publicStreamAudioPlayer.get(t.streamId);n&&t.audioTrack&&(n.stop(),n.playAudio(null===(r=e.stream)||void 0===r?void 0:r.audioTrack));var i,o=c._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),null===(r=this._publicStreamManager)||void 0===r||r.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,c.safeEmit(Nl.onPublicStreamStats,e)})),null===(n=this._publicStreamManager)||void 0===n||n.on(CH.ON_SEI_MESSAGED_RECEIVED,(function(e){c.safeEmit(Nl.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 XG(this.id,t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===kl.VIDEO_ONLY,isScreen:!1}),this._initPlayerEvents(a,!0),a.playAudio(i.audioTrack),this._publicStreamAudioPlayer.set(t,a));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(y=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publicStreamManager){e.next=2;break}return e.abrupt("return");case 2:this._publicStreamManager.stopPlayPublicStream(t),(r=this._publicStreamAudioPlayer.get(t))&&(r.destroy(),this._publicStreamAudioPlayer.delete(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"setAudioProfile",value:(m=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:BW.info("setAudioProfile()","profile: %o",t),this._shouldUpdateAudioConf("setAudioProfile")&&this._ctx.audioProfileManager.setAudioProfile(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"setAudioEncodeMaxBitrate",value:(_=Rm(Tm().mark((function e(t){var r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.print("setAudioEncodeMaxBitrate()",t),LD(t,"maxBitrate",6,256),this._ctx.audioProfileManager.setCustomMaxBitrate(t),!this._ctx.audioProfileManager.customMaxBitrate){e.next=10;break}if(!zM||!(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubAudio||null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubAudio)){e.next=6;break}throw new mA(pA.NOT_SUPPORTED,"Your browser does not support set audio encode maxBitrate dynamically.");case 6:return e.next=8,null===(a=this._room)||void 0===a?void 0:a.setAudioEncodeMaxBitrate(cl.STREAM_INDEX_MAIN,t);case 8:return e.next=10,null===(s=this._room)||void 0===s?void 0:s.setAudioEncodeMaxBitrate(cl.STREAM_INDEX_SCREEN,t);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i,o;BW.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 KG(this.id,Zd(Zd({},t),{},{userId:e})),this._initPlayerEvents(a,!0),this._publicStreamVideoPlayer.set(e,a);var s=null===(n=this._publicStreamManager)||void 0===n||null===(i=n.remoteStreams)||void 0===i?void 0:i.get(e);null!=s&&s.videoTrack&&(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)!==kl.PLAY_MANUALLY&&a.playVideo(s.videoTrack,s)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(f=Rm(Tm().mark((function e(t,r){var n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Y_((function(e,i){UD(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===cl.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new mA(pA.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new mA(pA.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return f.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===cl.STREAM_INDEX_MAIN?(t=this._dummyMainImage,r=this._videoStreamEncodeConfig[0]):(t=this._dummyScreenImage,r=this._screenStreamEncodeConfig[0]),t){var n,i,o=document.createElement("canvas"),a=o.getContext("2d"),s=LM(r.width),c=LM(r.height);if(!a)throw new mA(pA.UNEXPECTED_ERROR,"Not support canvas");!s||!c||t.width<=s&&t.height<=c?(n=t.width,i=t.height):(n=Math.min(s,t.width*c/t.height),i=Math.min(c,t.height*s/t.width)),o.width=n,o.height=i,a.drawImage(t,0,0,t.width,t.height,0,0,n,i);var u=window.setInterval((function(){t&&a.drawImage(t,0,0,t.width,t.height,0,0,n,i)}),200);e===cl.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=u):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=u);var d,l,h,p,v=o.captureStream(5).getVideoTracks()[0];if(e===cl.STREAM_INDEX_MAIN){if(this._localImgVideoTrack=v,null!==(d=this._localVideoTrack)&&void 0!==d&&d.dummy)null===(l=this._localVideoTrack)||void 0===l||l.setTrack(this._localImgVideoTrack,this._extensionManager)}else if(this._localImgScreenTrack=v,null!==(h=this._localScreenVideoTrack)&&void 0!==h&&h.dummy)null===(p=this._localScreenVideoTrack)||void 0===p||p.setTrack(this._localImgScreenTrack,this._extensionManager)}}},{key:"_addListenExtensionEvent",value:function(e){var t=this;e.on("re-capture-audio",(function(){t._localAudioTrack&&t.stopAudioCapture().then((function(){t.startAudioCapture()}))})),e.on("re-capture-video",(function(){t._localVideoTrack&&!t._localVideoTrack.dummy&&t.stopVideoCapture().then((function(){t.startVideoCapture()}))})),e.on("reset-video-effect",function(){var e=Rm(Tm().mark((function e(r,n){var i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=17;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.prev=2,e.next=5,t._localVideoTrack.generatePreProcessingTrack(t._extensionManager);case 5:e.next=10;break;case 7:e.prev=7,e.t0=e.catch(2),n(e.t0);case 10:if(t._initLocalTrackEvents(t._localVideoTrack),null!==(i=t._videoPlayer)&&void 0!==i&&i.played&&(t._videoPlayer.stop(),t._videoPlayer.playVideo(t._localVideoTrack),t._videoPlayer.mirror(!!t._mirrorType)),t.safeEmit(Nl.onLocalStreamTrackChangedByExtension,{streamIndex:cl.STREAM_INDEX_MAIN,type:"video"}),r(),null===(o=t._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.pubVideo){e.next=17;break}return e.next=17,t._updatePublish();case 17:r();case 18:case"end":return e.stop()}}),e,null,[[2,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"registerExtension",value:(v=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.monitor=this.monitor,e.prev=1,e.next=4,t.isSupported();case 4:if(e.sent){e.next=7;break}throw new Error("This extension is not supported.");case 7:e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(1),new Error("This extension is not supported.");case 12:return e.next=14,t.init({videoCaptureConfig:this._videoStreamConstraints});case 14:this._extensionManager.register(t),this._addListenExtensionEvent(t);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return v.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(Nm(LW.getDefaultValue()))}},{key:"_updatePublish",value:(p=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},BW.info("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:OH.PUB},t=Zd(Zd({},r),t),this._visibility){e.next=6;break}throw new mA(pA.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===dG.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 15:this._videoPlayer&&this._room.localStream&&(this._room.localStream.videoDom=this._videoPlayer.domElement),e.next=25;break;case 18:if(e.prev=18,e.t0=e.catch(12),!(e.t0 instanceof mA)){e.next=24;break}throw e.t0;case 24:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 25:return e.prev=25,n(),e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[12,18,25,28]])}))),function(){return p.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(h=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),UD(t,"filePath"),LD(r,"indicationInterval"),e.next=5,this._audioDeviceManager.startAudioPlaybackDeviceTest(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){BW.info("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(l=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BW.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),LD(t,"indicationInterval"),e.next=4,this._audioDeviceManager.startAudioDeviceRecordTest(t,r,this._localAudioVolume);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){BW.info("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){BW.info("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;BW.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{XD(e),VD(t,"priority",[yl.HIGH,yl.MEDIUM,yl.LOW])}catch(n){return console.warn(n),!1}return this._ctx.userPriority.set(e,t),null===(r=this._room)||void 0===r||r.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(d=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.print("takeLocalSnapshot()","streamIndex: %o",t),VD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),r=t===cl.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new mA(pA.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===cl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",CW(r.getTrack("preprocessing"),(null==n?void 0:n.mirrorType)===hl.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(u=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BW.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),UD(t,"id"),VD(r,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),c=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=gE(i).call(i,(function(e){return e.isScreen===(r===cl.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._publicStreamManager)||void 0===a||null===(s=a.remoteStreams.get(t))||void 0===s?void 0:s.videoTrack)){e.next=6;break}throw new mA(pA.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",CW(c.getTrack(),!1,r===cl.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){BW.info("setSubscribeFallbackOption()","option: %o",e);try{VD(e,"option",[ml.DISABLE,ml.VIDEO_STREAM_LOW,ml.AUDIO_ONLY])}catch(t){return console.warn(t),!1}return!this._room&&(this._ctx.subscribeFallbackOption=e,!0)}},{key:"getLocalStreamTrack",value:function(e,t){var r,n,i,o=this;if(e===cl.STREAM_INDEX_MAIN?(n="video"===t?this.localVideoTrack:this.localAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localStream}):(n="video"===t?this.localScreenVideoTrack:this.localScreenAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localScreenStream}),n){var a=n instanceof HV&&n.mixedAudioTrack?n.mixedAudioTrack:n.getTrack("preprocessing");if(a){var s=i();return this._reportMsTrackEvent(a,(null==s||null===(r=s.stream)||void 0===r?void 0:r.id)||"local"),a}}}},{key:"getRemoteStreamTrack",value:function(e,t,r){var n,i,o=(null===(n=this._room)||void 0===n?void 0:n.remoteStreams.get(e))||[];if(o&&o.length){var a,s,c,u,d;if(t===cl.STREAM_INDEX_MAIN)a=gE(o).call(o,(function(e){return!e.isScreen})),i="video"===r?null===(s=a)||void 0===s?void 0:s.videoTrack:null===(c=a)||void 0===c?void 0:c.audioTrack;else a=gE(o).call(o,(function(e){return e.isScreen})),i="video"===r?null===(u=a)||void 0===u?void 0:u.videoTrack:null===(d=a)||void 0===d?void 0:d.audioTrack;if(i){var l=i.getTrack();if(l&&a){var h=a.streamId;return this._reportMsTrackEvent(l,h),l}}}}},{key:"getPublicStreamTrack",value:function(e,t){if(this._publicStreamManager&&this._publicStreamManager.remoteStreams){var r=this._publicStreamManager.remoteStreams.get(e);if(r){var n="video"===t?r.videoTrack:r.audioTrack;if(n){var i=n.getTrack();if(i){var o=r.streamId;return this._reportMsTrackEvent(i,o),i}}}}}},{key:"setRemoteStreamRenderSync",value:function(e){return!this._room&&(this._ctx.avSync=!!e,!0)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i;(VD(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),t=rP(t,"volume",0,400),e===cl.STREAM_INDEX_SCREEN)?(null===(r=this._localScreenAudioTrack)||void 0===r||r.setVolume(t),this._localScreenAudioVolume=t):(null===(n=this._localAudioTrack)||void 0===n||n.setVolume(t),null===(i=this._audioDeviceManager.audioTrack)||void 0===i||i.setVolume(t),this._localAudioVolume=t)}},{key:"setPlaybackVolume",value:function(e,t,r){var n,i,o;if(XD(e),VD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),r=rP(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)NM("setPlaybackVolume is not supported in Conference mode");else{var a=t===cl.STREAM_INDEX_SCREEN;a?this._remoteScreenAudioVolume.set(e,r):this._remoteAudioVolume.set(e,r),null===(i=this._room)||void 0===i||null===(o=i.remoteStreams.get(e))||void 0===o||o.forEach((function(e){var t;e.isScreen===a&&(null===(t=e.audioTrack)||void 0===t||t.setVolume(r))}))}}},{key:"setPublicStreamVolume",value:function(e,t){var r,n,i;UD(e,"publicStreamId"),t=rP(t,"volume",0,400),this._publicAudioVolume.set(e,t),null===(r=this._publicStreamManager)||void 0===r||null===(n=r.remoteStreams.get(e))||void 0===n||null===(i=n.audioTrack)||void 0===i||i.setVolume(t)}},{key:"startForwardStreamToRooms",value:(c=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){KD(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.startForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"updateForwardStreamToRooms",value:(s=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){KD(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.updateForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"stopForwardStreamToRooms",value:(a=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.stopForwardStream2Rooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"pauseForwardStreamToAllRooms",value:(o=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.pauseForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"resumeForwardStreamToAllRooms",value:(i=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.resumeForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_reportMsTrackEvent",value:function(e,t){var r=this;if(!e.hookStop){e.hookStop=!0;var n=e.stop;e.stop=function(){jO(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:{},BW.info("_updateScreenPublish()"),r={mediaType:void 0,pubState:OH.PUB},t=Zd(Zd({},r),t),e.next=6,this._pubLock.lock();case 6:if(n=e.sent,this._room&&this._room.connectionState===dG.CONNECTED){e.next=10;break}return n(),e.abrupt("return");case 10:return e.prev=10,e.next=13,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 13:this._screenPlayer&&this._room.localScreenStream&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),e.next=23;break;case 16:if(e.prev=16,e.t0=e.catch(10),!(e.t0 instanceof mA)){e.next=22;break}throw e.t0;case 22:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 23:return e.prev=23,n(),e.finish(23);case 26:case"end":return e.stop()}}),e,this,[[10,16,23,26]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){BW.info("_updateAudioPlayerState()");var t,r=e.userId,n=e.isScreen,i=n?this._remoteScreenAudioPlayer:this._remoteAudioPlayer,o=i.get(r);if(e.audioTrack&&e.attributes.audiostream&&e.subAudio){var a,s,c,u=n?null!==(a=this._remoteScreenAudioVolume.get(r))&&void 0!==a?a:100:null!==(s=this._remoteAudioVolume.get(r))&&void 0!==s?s:100;if(e.audioTrack.setVolume(u),!o){var d;o=new XG(this.id,r,{muted:(null===(d=this._config)||void 0===d?void 0:d.autoPlayPolicy)===kl.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN),i.set(r,o);var l=this._audioDeviceManager.getSinkId();l&&o.setPlaybackDevice(l)}(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)!==kl.PLAY_MANUALLY&&o.playAudio(e.audioTrack),KM&&ZM&&(t=this._remoteAudioPlayer,NW&&clearTimeout(NW),NW=setTimeout((function(){var e,r=$T(t);try{for(r.s();!(e=r.n()).done;){var n=eI(e.value,2),i=n[0],o=n[1];null!=i&&hA(i).call(i,"mux")&&o.pause()}}catch(l){r.e(l)}finally{r.f()}var a,s=$T(t);try{for(s.s();!(a=s.n()).done;){var c=eI(a.value,2),u=c[0],d=c[1];null!=u&&hA(u).call(u,"mux")&&d.manuallyPlay()}}catch(l){s.e(l)}finally{s.f()}}),2e3))}else{var h;null===(h=o)||void 0===h||h.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;BW.info("_updateVideoPlayerState()");var r,n,i=e.userId;if(r=e.isScreen?this._remoteScreenPlayer.get(i):this._remoteVideoPlayer.get(i),e.videoTrack)r&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==kl.PLAY_MANUALLY&&r.playVideo(e.videoTrack,e);else if(null!==(t=r)&&void 0!==t&&t.played){var o;null===(o=r)||void 0===o||o.stop()}}},{key:"_onAddStream",value:(r=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.stream).videoDom=null===(r=this._remoteVideoPlayer.get(n.userId))||void 0===r?void 0:r.domElement,i=null==n?void 0:n.attributes,o=i.localaudio,a=i.audiostream,s=i.localvideo,c=i.videostream,u=zV.NONE,a&&(u|=ul.AUDIO),c&&(u|=ul.VIDEO),!u){e.next=12;break}return e.next=9,new Y_((function(e){return setTimeout(e)}));case 9:null!=n&&n.isScreen?this.safeEmit(Nl.onUserPublishScreen,{userId:n.userId,mediaType:u}):(this.safeEmit(Nl.onUserPublishStream,{userId:n.userId,mediaType:u,videoStreamDescriptions:null==n||null===(d=n.attributes)||void 0===d?void 0:d.videoDescriptions}),this._handleAutoSubscribe(n,!0)),this.safeEmit("onAddStream",{userId:n.userId,mediaType:u,isScreen:!(null==n||!n.isScreen)}),null!=n&&n.isScreen||(o&&this.safeEmit(Nl.onUserStartAudioCapture,{userId:n.userId}),s&&this.safeEmit(Nl.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=zV.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=ul.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=ul.VIDEO),i){var o,a;if(t&&wM(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&CM(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=GW[e.reason])&&void 0!==t?t:dl.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?Nl.onUserUnpublishScreen:Nl.onUserUnpublishStream,a=zV.NONE;n.attributes.audiostream&&(a|=ul.AUDIO),n.attributes.videostream&&(a|=ul.VIDEO),a!==zV.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),"function"==typeof e.callback&&e.callback(),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){n.isScreen?(r._remoteScreenPlayer.delete(n.userId),r._remoteScreenAudioPlayer.delete(n.userId)):(r._remoteAudioPlayer.delete(n.userId),r._remoteVideoPlayer.delete(n.userId)),null==e||e.destroy()}))}},{key:"_onUserConnection",value:function(e){var t=this;setTimeout((function(){return t.safeEmit(Nl.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){var t=this,r=e.userInfo;this._getRemotePlayer(r.userId,!0).forEach((function(e){t._remoteScreenAudioPlayer.delete(r.userId),t._remoteScreenPlayer.delete(r.userId),null==e||e.destroy()})),this._getRemotePlayer(r.userId,!1).forEach((function(e){t._remoteAudioPlayer.delete(r.userId),t._remoteVideoPlayer.delete(r.userId),null==e||e.destroy()})),this.safeEmit(Nl.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(Nl.onError,e),null===(t=this._room)||void 0===t||t.destroy(),this._room=void 0}},{key:"_onNetworkQuality",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.safeEmit.apply(this,Om(e=[Nl.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._ctx.useCloudProxy&&e.state===ll.CONNECTION_STATE_CONNECTED&&this.safeEmit(Nl.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(Nl.onConnectionStateChanged,e),e.state===ll.CONNECTION_STATE_RECONNECTING){var t,r=$T(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=eI(t.value,2),i=n[0],o=n[1];null!=i&&hA(i).call(i,"mux")&&o.stop()}}catch(a){r.e(a)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ul.AUDIO_AND_VIDEO,n=(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),i=(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e),o=[];return r&ul.AUDIO&&o.push(n),r&ul.VIDEO&&o.push(i),o}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){e.stream&&(this._getRemotePlayer(e.stream.userId,e.stream.isScreen).forEach((function(e){return null==e?void 0:e.stop()})),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){var t=this;if(e.stream){this._updateAudioPlayerState(e.stream);var r=e.stream;this._getRemotePlayer(r.userId,r.isScreen,e.mediaType).forEach((function(n){e.mediaType&ul.AUDIO&&(r.isScreen?t._remoteScreenAudioPlayer.delete(r.userId):t._remoteAudioPlayer.delete(r.userId)),r.isScreen?e.mediaType&ul.VIDEO&&t._remoteScreenPlayer.delete(r.userId):e.mediaType&ul.VIDEO&&t._remoteVideoPlayer.delete(r.userId),null==n||n.destroy()}))}}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(Nl.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(Nl.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t,r=this,n=e.userId,i=e.isScreen,o=e.mediaType,a=e.pubState,s=e.remoteStream,c={userId:n,mediaType:o};(o&ul.AUDIO&&setTimeout((function(){r._updateAudioPlayerState(s)})),i)?a===OH.PUB?this.safeEmit(Nl.onUserPublishScreen,c):this.safeEmit(Nl.onUserUnpublishScreen,Zd(Zd({},c),{},{reason:dl.STREAM_REMOVE_REASON_UNPUBLISH})):a===OH.PUB?(c.videoStreamDescriptions=null==s||null===(t=s.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(Nl.onUserPublishStream,c),this._handleAutoSubscribe(s,!0)):this.safeEmit(Nl.onUserUnpublishStream,Zd(Zd({},c),{},{reason:dl.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(Nl.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(Nl.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Nl.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Nl.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(Nl.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(Nl.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Nl.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(Nl.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Nl.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Nl.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(Nl.onError,{errorCode:pA.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(Nl.onError,{errorCode:pA.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(Nl.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(Nl.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==dG.CONNECTED)throw new mA(pA.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){VD(e,"mediaType",[ul.AUDIO,ul.VIDEO,ul.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e,t;return(null===(e=this._room)||void 0===e||null===(t=e.roomInfo)||void 0===t?void 0:t.userInfo.userId)||"local_user"}},{key:"_switchTrack",value:(t=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,null!==(r=this._videoPlayer)&&void 0!==r&&r.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(t),this._videoPlayer.mirror(!!this._mirrorType)),null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||!i.pubVideo){e.next=6;break}return e.next=6,this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_shouldUpdateAudioConf",value:function(e){var t,r,n,i=(null===(t=this._room)||void 0===t?void 0:t.hasPublished)||(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n?void 0:n.pubAudio)||this._localAudioTrack&&this._localAudioTrack.sourceType===oV.INTERNAL;if(i){var o="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: ".concat(o)),jO(this.id,e,o)}return!i}},{key:"_getServerConfig",value:function(){var e=this,t=ED.getServerConfig(this.appId);t.rts_report&&wO.setConfig(t.rts_report),this._ctx.joinRoomConfig.setServerConfig(t.web_join_room),GO({engineId:this.id,appId:this.appId,sdkVersion:OD("VERSION"),requestDomains:OD("CONFIG_REQUEST_DOMAINS"),keys:["rts_report","web_join_room","web_rtc_config"],deviceId:OD("DEVICE_ID")}).then((function(t){ED.setServerConfig(e.appId,t),e.safeEmit("__onGetServerConfigFinishHook")}))}}]),ke}(aP);FW([FO()],jW.prototype,"updateToken",1),FW([FO()],jW.prototype,"setVideoCaptureDevice",1),FW([FO()],jW.prototype,"setAudioCaptureDevice",1),FW([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=VO(this.id),r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return null==t||t.set({room_id:i[1],user_id:null===(e=i[2])||void 0===e?void 0:e.userId}),n.apply(this,i)}}},FO()],jW.prototype,"connect",1),FW([FO()],jW.prototype,"joinRoom",1),FW([FO()],jW.prototype,"leaveRoom",1),FW([FO()],jW.prototype,"destroy",1),FW([FO()],jW.prototype,"publishStream",1),FW([FO()],jW.prototype,"unpublishStream",1),FW([FO()],jW.prototype,"publishScreen",1),FW([FO()],jW.prototype,"unpublishScreen",1),FW([FO()],jW.prototype,"subscribeStream",1),FW([FO()],jW.prototype,"unsubscribeStream",1),FW([FO()],jW.prototype,"subscribeScreen",1),FW([FO()],jW.prototype,"unsubscribeScreen",1),FW([FO()],jW.prototype,"setRemoteVideoConfig",1),FW([FO()],jW.prototype,"startVideoCapture",1),FW([FO()],jW.prototype,"stopVideoCapture",1),FW([FO()],jW.prototype,"startAudioCapture",1),FW([FO()],jW.prototype,"stopAudioCapture",1),FW([FO()],jW.prototype,"getAudioMixingManager",1),FW([FO()],jW.prototype,"startScreenCapture",1),FW([FO()],jW.prototype,"stopScreenCapture",1),FW([FO()],jW.prototype,"setLocalVideoPlayer",1),FW([FO()],jW.prototype,"startLiveTranscoding",1),FW([FO()],jW.prototype,"updateLiveTranscoding",1),FW([FO()],jW.prototype,"stopLiveTranscoding",1),FW([FO()],jW.prototype,"startSubtitle",1),FW([FO()],jW.prototype,"stopSubtitle",1),FW([FO()],jW.prototype,"setBusinessId",1),FW([FO()],jW.prototype,"setUserVisibility",1),FW([FO()],jW.prototype,"setRemoteVideoPlayer",1),FW([FO()],jW.prototype,"setLocalVideoMirrorType",1),FW([FO()],jW.prototype,"setAudioPlaybackDevice",1),FW([FO()],jW.prototype,"play",1),FW([FO()],jW.prototype,"pauseAllSubscribedStream",1),FW([FO()],jW.prototype,"resumeAllSubscribedStream",1),FW([FO()],jW.prototype,"sendUserMessage",1),FW([FO()],jW.prototype,"sendUserBinaryMessage",1),FW([FO()],jW.prototype,"sendRoomMessage",1),FW([FO()],jW.prototype,"sendRoomBinaryMessage",1),FW([FO()],jW.prototype,"setAudioCaptureConfig",1),FW([PM("4.51"),FO()],jW.prototype,"setVideoCaptureConfig",1),FW([FO()],jW.prototype,"enableSimulcastMode",1),FW([FO()],jW.prototype,"setVideoEncoderConfig",1),FW([FO()],jW.prototype,"setScreenEncoderConfig",1),FW([FO()],jW.prototype,"sendSEIMessage",1),FW([PM("4.42"),FO()],jW.prototype,"setAudioVolumeIndicationInterval",1),FW([FO()],jW.prototype,"enableAudioPropertiesReport",1),FW([FO()],jW.prototype,"setVideoSourceType",1),FW([FO()],jW.prototype,"setExternalVideoTrack",1),FW([FO()],jW.prototype,"setAudioSourceType",1),FW([FO()],jW.prototype,"setExternalAudioTrack",1),FW([FO()],jW.prototype,"login",1),FW([FO()],jW.prototype,"logout",1),FW([FO()],jW.prototype,"updateLoginToken",1),FW([FO()],jW.prototype,"getPeerOnlineStatus",1),FW([FO()],jW.prototype,"sendUserMessageOutsideRoom",1),FW([FO()],jW.prototype,"sendUserBinaryMessageOutsideRoom",1),FW([FO()],jW.prototype,"setServerParams",1),FW([FO()],jW.prototype,"sendServerMessage",1),FW([FO()],jW.prototype,"sendServerBinaryMessage",1),FW([FO()],jW.prototype,"startCloudProxy",1),FW([FO()],jW.prototype,"stopCloudProxy",1),FW([FO()],jW.prototype,"startPushPublicStream",1),FW([FO()],jW.prototype,"updatePublicStreamParam",1),FW([FO()],jW.prototype,"stopPushPublicStream",1),FW([FO("streamId")],jW.prototype,"startPlayPublicStream",1),FW([FO("streamId")],jW.prototype,"stopPlayPublicStream",1),FW([FO()],jW.prototype,"setAudioProfile",1),FW([FO()],jW.prototype,"setAudioEncodeMaxBitrate",1),FW([FO()],jW.prototype,"setPublicStreamVideoPlayer",1),FW([FO()],jW.prototype,"setDummyCaptureImagePath",1),FW([FO()],jW.prototype,"registerExtension",1),FW([FO()],jW.prototype,"startAudioPlaybackDeviceTest",1),FW([FO()],jW.prototype,"stopAudioPlaybackDeviceTest",1),FW([FO()],jW.prototype,"startAudioDeviceRecordTest",1),FW([FO()],jW.prototype,"stopAudioDeviceRecordAndPlayTest",1),FW([FO()],jW.prototype,"stopAudioDevicePlayTest",1),FW([FO()],jW.prototype,"setRemoteUserPriority",1),FW([FO()],jW.prototype,"takeLocalSnapshot",1),FW([FO()],jW.prototype,"takeRemoteSnapshot",1),FW([FO()],jW.prototype,"setSubscribeFallbackOption",1),FW([FO()],jW.prototype,"getLocalStreamTrack",1),FW([FO()],jW.prototype,"getRemoteStreamTrack",1),FW([FO()],jW.prototype,"getPublicStreamTrack",1),FW([FO()],jW.prototype,"setRemoteStreamRenderSync",1),FW([FO()],jW.prototype,"startForwardStreamToRooms",1),FW([FO()],jW.prototype,"updateForwardStreamToRooms",1),FW([FO()],jW.prototype,"stopForwardStreamToRooms",1),FW([FO()],jW.prototype,"pauseForwardStreamToAllRooms",1),FW([FO()],jW.prototype,"resumeForwardStreamToAllRooms",1);var HW,GW={"client unpublished":dl.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":dl.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":dl.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":dl.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":dl.STREAM_REMOVE_REASON_REPUBLISH};function zW(e){var t=ED.getServerConfig(e).web_rtc_config;return null!=t&&t.web_pc_killswitch?null==t?void 0:t.web_pc_killswitch:{}}function KW(e){var t=ED.getServerConfig(e).web_rtc_config;return"boolean"==typeof(null==t?void 0:t.fallback)?!1!==t.fallback&&(!!Array.isArray(null==t?void 0:t.fallback_ua_reg)&&t.fallback_ua_reg.every((function(e){return"string"==typeof e&&new RegExp(e).test(navigator.userAgent)}))):!!OD("ENABLE_FALLBACK_HANDLER")}function XW(e){var t=ED.getServerConfig(e).web_rtc_config;return"boolean"==typeof(null==t?void 0:t.standard)?!1!==t.standard&&(!!Array.isArray(null==t?void 0:t.standard_ua_reg)&&t.standard_ua_reg.every((function(e){return"string"==typeof e&&new RegExp(e).test(navigator.userAgent)}))):!!OD("ENABLE_STANDARD_HANDLER")}var WW=new Nw("VERTC",0);Ew.storeKey=Om(HW="".concat(Date.now(),"-")).call(HW,ED.getDeviceId()),xO({rtc_sdk_version:CD.VERSION,device_id:ED.getDeviceId(),log_cache_key:Ew.storeKey}),OO(CD.LOG_SERVER_URL);var qW=1,YW=function(e,t){WW.info("createEngine","Invoke VERTC.createEngine"),UD(e,"appId");var r=(qW++).toString();return function(e,t){var r=new TO(e);r.set(Zd(Zd({},t),{},{engine_session_id:_w()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),UO.set(e,r)}(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new jW(e,r,t)},JW=function(e){if(WW.info("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof jW))throw new mA(pA.INVALID_ENGINE,"Invalid engine object");var t;e.destroy(),(t=e.monitor).report("sdk_init_engine",{start:Date.now(),type:"end"}),UO.delete(t.id)},QW=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",qU.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ZW=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:{video:!0,audio:!0},r=t.video,n=t.audio,i={video:!1,audio:!1},!r){e.next=14;break}return e.prev=4,e.next=7,qU.getPermissions({video:!0,force:!0});case 7:o=e.sent,i.video=o.video,o.video||(i.videoExceptionError=o.reason),e.next=14;break;case 12:e.prev=12,e.t0=e.catch(4);case 14:if(!n){e.next=25;break}return e.prev=15,e.next=18,qU.getPermissions({audio:!0,force:!0});case 18:a=e.sent,i.audio=a.audio,a.audio||(i.audioExceptionError=a.reason),e.next=25;break;case 23:e.prev=23,e.t1=e.catch(15);case 25:return e.abrupt("return",i);case 26:case"end":return e.stop()}}),e,null,[[4,12],[15,23]])})));return function(){return e.apply(this,arguments)}}(),$W=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",qU.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),eq=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",qU.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),tq=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",qU.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),rq=function(){return CD.VERSION},nq=function(){return DO("isSupported",0,""),QN()},iq=function(){return DO("getSupportedCodecs",0,""),eL()},oq=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(Ew.logLevel=t),r&&(Ew.LogfileSize=r)},aq=function(e){Ew.download(e)};function sq(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Nm(jm(t).call(t,(function(e){return e instanceof jW?"[ENGINE]":e})))}function cq(e,t){return function(){DO(t,0,sq.apply(void 0,arguments));var r=e.apply(void 0,arguments);return"function"==typeof(null==r?void 0:r.then)?r.then((function(e){return PO(t,0,sq(e)),e})).catch((function(e){throw PO(t,e.code,e.message),e})):(PO(t,0,sq(r)),r)}}return Zd(Zd(Zd(Zd({},new(Ul((function e(){Vl(this,e),Jd(this,"getSdkVersion",cq(rq,"getSdkVersion")),Jd(this,"createEngine",cq(YW,"createEngine")),Jd(this,"destroyEngine",cq(JW,"destroyEngine")),Jd(this,"enumerateDevices",cq(QW,"enumerateDevices")),Jd(this,"enableDevices",cq(ZW,"enableDevices")),Jd(this,"enumerateAudioCaptureDevices",cq($W,"enumerateAudioCaptureDevices")),Jd(this,"enumerateVideoCaptureDevices",cq(eq,"enumerateVideoCaptureDevices")),Jd(this,"enumerateAudioPlaybackDevices",cq(tq,"enumerateAudioPlaybackDevices")),Jd(this,"getParameter",OD),Jd(this,"setParameter",xD),Jd(this,"isSupported",cq(nq,"isSupported")),Jd(this,"getSupportedCodecs",cq(iq,"getSupportedCodecs")),Jd(this,"events",Nl),Jd(this,"ErrorCode",pA),Jd(this,"platform","BytePlus"),Jd(this,"commitInfo","release_455<8f96763*>"),Jd(this,"downloadLog",cq(aq,"downloadLog")),Jd(this,"setLogConfig",cq(oq,"setLogConfig"))})))),xl),Pl),{},{events:Nl})}));