@byteplus/rtc 4.58.10 → 4.58.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.esm.min.js +2 -2
- package/index.min.js +2 -2
- package/package.json +1 -1
package/index.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2024 The BytePlusRTC project authors. All Rights Reserved.
|
|
3
3
|
* @brief BytePlusRTC Advance API
|
|
4
|
-
* version: 4.58.
|
|
4
|
+
* version: 4.58.12
|
|
5
5
|
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).BytePlusRTC=t()}(this,(function(){"use strict";function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n=function(e){return e&&e.Math===Math&&e},i=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof t&&t)||function(){return this}()||t||Function("return this")(),o=function(e){try{return!!e()}catch(t){return!0}},a=!o((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),s=a,c=Function.prototype,u=c.apply,d=c.call,l="object"==typeof Reflect&&Reflect.apply||(s?d.bind(u):function(){return d.apply(u,arguments)}),h=a,p=Function.prototype,v=p.call,_=h&&p.bind.bind(v,v),f=h?_:function(e){return function(){return v.apply(e,arguments)}},m=f,g=m({}.toString),y=m("".slice),S=function(e){return y(g(e),8,-1)},b=S,k=f,E=function(e){if("Function"===b(e))return k(e)},T="object"==typeof document&&document.all,I={all:T,IS_HTMLDDA:void 0===T&&void 0!==T},R=I.all,A=I.IS_HTMLDDA?function(e){return"function"==typeof e||e===R}:function(e){return"function"==typeof e},w={},C=!o((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),x=a,O=Function.prototype.call,P=x?O.bind(O):function(){return O.apply(O,arguments)},D={},N={}.propertyIsEnumerable,M=Object.getOwnPropertyDescriptor,L=M&&!N.call({1:2},1);D.f=L?function(e){var t=M(this,e);return!!t&&t.enumerable}:N;var U,V,F=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},B=o,j=S,H=Object,G=f("".split),z=B((function(){return!H("z").propertyIsEnumerable(0)}))?function(e){return"String"===j(e)?G(e,""):H(e)}:H,K=function(e){return null==e},W=K,X=TypeError,Y=function(e){if(W(e))throw X("Can't call method on "+e);return e},q=z,J=Y,Q=function(e){return q(J(e))},Z=A,$=I.all,ee=I.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:Z(e)||e===$}:function(e){return"object"==typeof e?null!==e:Z(e)},te={},re=te,ne=i,ie=A,oe=function(e){return ie(e)?e:void 0},ae=function(e,t){return arguments.length<2?oe(re[e])||oe(ne[e]):re[e]&&re[e][t]||ne[e]&&ne[e][t]},se=f({}.isPrototypeOf),ce="undefined"!=typeof navigator&&String(navigator.userAgent)||"",ue=i,de=ce,le=ue.process,he=ue.Deno,pe=le&&le.versions||he&&he.version,ve=pe&&pe.v8;ve&&(V=(U=ve.split("."))[0]>0&&U[0]<4?1:+(U[0]+U[1])),!V&&de&&(!(U=de.match(/Edge\/(\d+)/))||U[1]>=74)&&(U=de.match(/Chrome\/(\d+)/))&&(V=+U[1]);var _e=V,fe=_e,me=o,ge=i.String,ye=!!Object.getOwnPropertySymbols&&!me((function(){var e=Symbol("symbol detection");return!ge(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&fe&&fe<41})),Se=ye&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,be=ae,ke=A,Ee=se,Te=Object,Ie=Se?function(e){return"symbol"==typeof e}:function(e){var t=be("Symbol");return ke(t)&&Ee(t.prototype,Te(e))},Re=String,Ae=function(e){try{return Re(e)}catch(t){return"Object"}},we=A,Ce=Ae,xe=TypeError,Oe=function(e){if(we(e))return e;throw xe(Ce(e)+" is not a function")},Pe=Oe,De=K,Ne=function(e,t){var r=e[t];return De(r)?void 0:Pe(r)},Me=P,Le=A,Ue=ee,Ve=TypeError,Fe={exports:{}},Be=i,je=Object.defineProperty,He=function(e,t){try{je(Be,e,{value:t,configurable:!0,writable:!0})}catch(r){Be[e]=t}return t},Ge="__core-js_shared__",ze=i[Ge]||He(Ge,{}),Ke=ze;(Fe.exports=function(e,t){return Ke[e]||(Ke[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.32.1",mode:"pure",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.32.1/LICENSE",source:"https://github.com/zloirock/core-js"});var We=Fe.exports,Xe=Y,Ye=Object,qe=function(e){return Ye(Xe(e))},Je=qe,Qe=f({}.hasOwnProperty),Ze=Object.hasOwn||function(e,t){return Qe(Je(e),t)},$e=f,et=0,tt=Math.random(),rt=$e(1..toString),nt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+rt(++et+tt,36)},it=We,ot=Ze,at=nt,st=ye,ct=Se,ut=i.Symbol,dt=it("wks"),lt=ct?ut.for||ut:ut&&ut.withoutSetter||at,ht=function(e){return ot(dt,e)||(dt[e]=st&&ot(ut,e)?ut[e]:lt("Symbol."+e)),dt[e]},pt=P,vt=ee,_t=Ie,ft=Ne,mt=function(e,t){var r,n;if("string"===t&&Le(r=e.toString)&&!Ue(n=Me(r,e)))return n;if(Le(r=e.valueOf)&&!Ue(n=Me(r,e)))return n;if("string"!==t&&Le(r=e.toString)&&!Ue(n=Me(r,e)))return n;throw Ve("Can't convert object to primitive value")},gt=TypeError,yt=ht("toPrimitive"),St=function(e,t){if(!vt(e)||_t(e))return e;var r,n=ft(e,yt);if(n){if(void 0===t&&(t="default"),r=pt(n,e,t),!vt(r)||_t(r))return r;throw gt("Can't convert object to primitive value")}return void 0===t&&(t="number"),mt(e,t)},bt=Ie,kt=function(e){var t=St(e,"string");return bt(t)?t:t+""},Et=ee,Tt=i.document,It=Et(Tt)&&Et(Tt.createElement),Rt=function(e){return It?Tt.createElement(e):{}},At=Rt,wt=!C&&!o((function(){return 7!==Object.defineProperty(At("div"),"a",{get:function(){return 7}}).a})),Ct=C,xt=P,Ot=D,Pt=F,Dt=Q,Nt=kt,Mt=Ze,Lt=wt,Ut=Object.getOwnPropertyDescriptor;w.f=Ct?Ut:function(e,t){if(e=Dt(e),t=Nt(t),Lt)try{return Ut(e,t)}catch(r){}if(Mt(e,t))return Pt(!xt(Ot.f,e,t),e[t])};var Vt=o,Ft=A,Bt=/#|\.prototype\./,jt=function(e,t){var r=Gt[Ht(e)];return r===Kt||r!==zt&&(Ft(t)?Vt(t):!!t)},Ht=jt.normalize=function(e){return String(e).replace(Bt,".").toLowerCase()},Gt=jt.data={},zt=jt.NATIVE="N",Kt=jt.POLYFILL="P",Wt=jt,Xt=Oe,Yt=a,qt=E(E.bind),Jt=function(e,t){return Xt(e),void 0===t?e:Yt?qt(e,t):function(){return e.apply(t,arguments)}},Qt={},Zt=C&&o((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),$t=ee,er=String,tr=TypeError,rr=function(e){if($t(e))return e;throw tr(er(e)+" is not an object")},nr=C,ir=wt,or=Zt,ar=rr,sr=kt,cr=TypeError,ur=Object.defineProperty,dr=Object.getOwnPropertyDescriptor,lr="enumerable",hr="configurable",pr="writable";Qt.f=nr?or?function(e,t,r){if(ar(e),t=sr(t),ar(r),"function"==typeof e&&"prototype"===t&&"value"in r&&pr in r&&!r[pr]){var n=dr(e,t);n&&n[pr]&&(e[t]=r.value,r={configurable:hr in r?r[hr]:n[hr],enumerable:lr in r?r[lr]:n[lr],writable:!1})}return ur(e,t,r)}:ur:function(e,t,r){if(ar(e),t=sr(t),ar(r),ir)try{return ur(e,t,r)}catch(n){}if("get"in r||"set"in r)throw cr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var vr=Qt,_r=F,fr=C?function(e,t,r){return vr.f(e,t,_r(1,r))}:function(e,t,r){return e[t]=r,e},mr=i,gr=l,yr=E,Sr=A,br=w.f,kr=Wt,Er=te,Tr=Jt,Ir=fr,Rr=Ze,Ar=function(e){var t=function(r,n,i){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,i)}return gr(e,this,arguments)};return t.prototype=e.prototype,t},wr=function(e,t){var r,n,i,o,a,s,c,u,d,l=e.target,h=e.global,p=e.stat,v=e.proto,_=h?mr:p?mr[l]:(mr[l]||{}).prototype,f=h?Er:Er[l]||Ir(Er,l,{})[l],m=f.prototype;for(o in t)n=!(r=kr(h?o:l+(p?".":"#")+o,e.forced))&&_&&Rr(_,o),s=f[o],n&&(c=e.dontCallGetSet?(d=br(_,o))&&d.value:_[o]),a=n&&c?c:t[o],n&&typeof s==typeof a||(u=e.bind&&n?Tr(a,mr):e.wrap&&n?Ar(a):v&&Sr(a)?yr(a):a,(e.sham||a&&a.sham||s&&s.sham)&&Ir(u,"sham",!0),Ir(f,o,u),v&&(Rr(Er,i=l+"Prototype")||Ir(Er,i,{}),Ir(Er[i],o,a),e.real&&m&&(r||!m[o])&&Ir(m,o,a)))},Cr=Math.ceil,xr=Math.floor,Or=Math.trunc||function(e){var t=+e;return(t>0?xr:Cr)(t)},Pr=function(e){var t=+e;return t!=t||0===t?0:Or(t)},Dr=Pr,Nr=Math.max,Mr=Math.min,Lr=function(e,t){var r=Dr(e);return r<0?Nr(r+t,0):Mr(r,t)},Ur=Pr,Vr=Math.min,Fr=function(e){return e>0?Vr(Ur(e),9007199254740991):0},Br=Fr,jr=function(e){return Br(e.length)},Hr=Q,Gr=Lr,zr=jr,Kr=function(e){return function(t,r,n){var i,o=Hr(t),a=zr(o),s=Gr(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},Wr={includes:Kr(!0),indexOf:Kr(!1)},Xr={},Yr=Ze,qr=Q,Jr=Wr.indexOf,Qr=Xr,Zr=f([].push),$r=function(e,t){var r,n=qr(e),i=0,o=[];for(r in n)!Yr(Qr,r)&&Yr(n,r)&&Zr(o,r);for(;t.length>i;)Yr(n,r=t[i++])&&(~Jr(o,r)||Zr(o,r));return o},en=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],tn=$r,rn=en,nn=Object.keys||function(e){return tn(e,rn)},on=qe,an=nn;wr({target:"Object",stat:!0,forced:o((function(){an(1)}))},{keys:function(e){return an(on(e))}});var sn=te.Object.keys,cn=r(sn),un={};un[ht("toStringTag")]="z";var dn="[object z]"===String(un),ln=dn,hn=A,pn=S,vn=ht("toStringTag"),_n=Object,fn="Arguments"===pn(function(){return arguments}()),mn=ln?pn: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=_n(e),vn))?r:fn?pn(t):"Object"===(n=pn(t))&&hn(t.callee)?"Arguments":n},gn=mn,yn=String,Sn=function(e){if("Symbol"===gn(e))throw TypeError("Cannot convert a Symbol value to a string");return yn(e)},bn={},kn=C,En=Zt,Tn=Qt,In=rr,Rn=Q,An=nn;bn.f=kn&&!En?Object.defineProperties:function(e,t){In(e);for(var r,n=Rn(t),i=An(t),o=i.length,a=0;o>a;)Tn.f(e,r=i[a++],n[r]);return e};var wn,Cn=ae("document","documentElement"),xn=nt,On=We("keys"),Pn=function(e){return On[e]||(On[e]=xn(e))},Dn=rr,Nn=bn,Mn=en,Ln=Xr,Un=Cn,Vn=Rt,Fn="prototype",Bn="script",jn=Pn("IE_PROTO"),Hn=function(){},Gn=function(e){return"<"+Bn+">"+e+"</"+Bn+">"},zn=function(e){e.write(Gn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Kn=function(){try{wn=new ActiveXObject("htmlfile")}catch(i){}var e,t,r;Kn="undefined"!=typeof document?document.domain&&wn?zn(wn):(t=Vn("iframe"),r="java"+Bn+":",t.style.display="none",Un.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(Gn("document.F=Object")),e.close(),e.F):zn(wn);for(var n=Mn.length;n--;)delete Kn[Fn][Mn[n]];return Kn()};Ln[jn]=!0;var Wn=Object.create||function(e,t){var r;return null!==e?(Hn[Fn]=Dn(e),r=new Hn,Hn[Fn]=null,r[jn]=e):r=Kn(),void 0===t?r:Nn.f(r,t)},Xn={},Yn=$r,qn=en.concat("length","prototype");Xn.f=Object.getOwnPropertyNames||function(e){return Yn(e,qn)};var Jn={},Qn=kt,Zn=Qt,$n=F,ei=function(e,t,r){var n=Qn(t);n in e?Zn.f(e,n,$n(0,r)):e[n]=r},ti=Lr,ri=jr,ni=ei,ii=Array,oi=Math.max,ai=function(e,t,r){for(var n=ri(e),i=ti(t,n),o=ti(void 0===r?n:r,n),a=ii(oi(o-i,0)),s=0;i<o;i++,s++)ni(a,s,e[i]);return a.length=s,a},si=S,ci=Q,ui=Xn.f,di=ai,li="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Jn.f=function(e){return li&&"Window"===si(e)?function(e){try{return ui(e)}catch(t){return di(li)}}(e):ui(ci(e))};var hi={};hi.f=Object.getOwnPropertySymbols;var pi=fr,vi=function(e,t,r,n){return n&&n.enumerable?e[t]=r:pi(e,t,r),e},_i=Qt,fi=function(e,t,r){return _i.f(e,t,r)},mi={},gi=ht;mi.f=gi;var yi,Si,bi,ki=te,Ei=Ze,Ti=mi,Ii=Qt.f,Ri=function(e){var t=ki.Symbol||(ki.Symbol={});Ei(t,e)||Ii(t,e,{value:Ti.f(e)})},Ai=P,wi=ae,Ci=ht,xi=vi,Oi=function(){var e=wi("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=Ci("toPrimitive");t&&!t[n]&&xi(t,n,(function(e){return Ai(r,this)}),{arity:1})},Pi=mn,Di=dn?{}.toString:function(){return"[object "+Pi(this)+"]"},Ni=dn,Mi=Qt.f,Li=fr,Ui=Ze,Vi=Di,Fi=ht("toStringTag"),Bi=function(e,t,r,n){if(e){var i=r?e:e.prototype;Ui(i,Fi)||Mi(i,Fi,{configurable:!0,value:t}),n&&!Ni&&Li(i,"toString",Vi)}},ji=A,Hi=i.WeakMap,Gi=ji(Hi)&&/native code/.test(String(Hi)),zi=i,Ki=ee,Wi=fr,Xi=Ze,Yi=ze,qi=Pn,Ji=Xr,Qi="Object already initialized",Zi=zi.TypeError,$i=zi.WeakMap;if(Gi||Yi.state){var eo=Yi.state||(Yi.state=new $i);eo.get=eo.get,eo.has=eo.has,eo.set=eo.set,yi=function(e,t){if(eo.has(e))throw Zi(Qi);return t.facade=e,eo.set(e,t),t},Si=function(e){return eo.get(e)||{}},bi=function(e){return eo.has(e)}}else{var to=qi("state");Ji[to]=!0,yi=function(e,t){if(Xi(e,to))throw Zi(Qi);return t.facade=e,Wi(e,to,t),t},Si=function(e){return Xi(e,to)?e[to]:{}},bi=function(e){return Xi(e,to)}}var ro={set:yi,get:Si,has:bi,enforce:function(e){return bi(e)?Si(e):yi(e,{})},getterFor:function(e){return function(t){var r;if(!Ki(t)||(r=Si(t)).type!==e)throw Zi("Incompatible receiver, "+e+" required");return r}}},no=S,io=Array.isArray||function(e){return"Array"===no(e)},oo=A,ao=ze,so=f(Function.toString);oo(ao.inspectSource)||(ao.inspectSource=function(e){return so(e)});var co=ao.inspectSource,uo=f,lo=o,ho=A,po=mn,vo=co,_o=function(){},fo=[],mo=ae("Reflect","construct"),go=/^\s*(?:class|function)\b/,yo=uo(go.exec),So=!go.exec(_o),bo=function(e){if(!ho(e))return!1;try{return mo(_o,fo,e),!0}catch(t){return!1}},ko=function(e){if(!ho(e))return!1;switch(po(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return So||!!yo(go,vo(e))}catch(t){return!0}};ko.sham=!0;var Eo=!mo||lo((function(){var e;return bo(bo.call)||!bo(Object)||!bo((function(){e=!0}))||e}))?ko:bo,To=io,Io=Eo,Ro=ee,Ao=ht("species"),wo=Array,Co=function(e){var t;return To(e)&&(t=e.constructor,(Io(t)&&(t===wo||To(t.prototype))||Ro(t)&&null===(t=t[Ao]))&&(t=void 0)),void 0===t?wo:t},xo=function(e,t){return new(Co(e))(0===t?0:t)},Oo=Jt,Po=z,Do=qe,No=jr,Mo=xo,Lo=f([].push),Uo=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=Do(c),_=Po(v),f=Oo(u,d),m=No(_),g=0,y=l||Mo,S=t?y(c,m):r||a?y(c,0):void 0;m>g;g++)if((s||g in _)&&(p=f(h=_[g],g,v),e))if(t)S[g]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return g;case 2:Lo(S,h)}else switch(e){case 4:return!1;case 7:Lo(S,h)}return o?-1:n||i?i:S}},Vo={forEach:Uo(0),map:Uo(1),filter:Uo(2),some:Uo(3),every:Uo(4),find:Uo(5),findIndex:Uo(6),filterReject:Uo(7)},Fo=wr,Bo=i,jo=P,Ho=f,Go=C,zo=ye,Ko=o,Wo=Ze,Xo=se,Yo=rr,qo=Q,Jo=kt,Qo=Sn,Zo=F,$o=Wn,ea=nn,ta=Xn,ra=Jn,na=hi,ia=w,oa=Qt,aa=bn,sa=D,ca=vi,ua=fi,da=We,la=Xr,ha=nt,pa=ht,va=mi,_a=Ri,fa=Oi,ma=Bi,ga=ro,ya=Vo.forEach,Sa=Pn("hidden"),ba="Symbol",ka="prototype",Ea=ga.set,Ta=ga.getterFor(ba),Ia=Object[ka],Ra=Bo.Symbol,Aa=Ra&&Ra[ka],wa=Bo.TypeError,Ca=Bo.QObject,xa=ia.f,Oa=oa.f,Pa=ra.f,Da=sa.f,Na=Ho([].push),Ma=da("symbols"),La=da("op-symbols"),Ua=da("wks"),Va=!Ca||!Ca[ka]||!Ca[ka].findChild,Fa=Go&&Ko((function(){return 7!==$o(Oa({},"a",{get:function(){return Oa(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=xa(Ia,t);n&&delete Ia[t],Oa(e,t,r),n&&e!==Ia&&Oa(Ia,t,n)}:Oa,Ba=function(e,t){var r=Ma[e]=$o(Aa);return Ea(r,{type:ba,tag:e,description:t}),Go||(r.description=t),r},ja=function(e,t,r){e===Ia&&ja(La,t,r),Yo(e);var n=Jo(t);return Yo(r),Wo(Ma,n)?(r.enumerable?(Wo(e,Sa)&&e[Sa][n]&&(e[Sa][n]=!1),r=$o(r,{enumerable:Zo(0,!1)})):(Wo(e,Sa)||Oa(e,Sa,Zo(1,{})),e[Sa][n]=!0),Fa(e,n,r)):Oa(e,n,r)},Ha=function(e,t){Yo(e);var r=qo(t),n=ea(r).concat(Wa(r));return ya(n,(function(t){Go&&!jo(Ga,r,t)||ja(e,t,r[t])})),e},Ga=function(e){var t=Jo(e),r=jo(Da,this,t);return!(this===Ia&&Wo(Ma,t)&&!Wo(La,t))&&(!(r||!Wo(this,t)||!Wo(Ma,t)||Wo(this,Sa)&&this[Sa][t])||r)},za=function(e,t){var r=qo(e),n=Jo(t);if(r!==Ia||!Wo(Ma,n)||Wo(La,n)){var i=xa(r,n);return!i||!Wo(Ma,n)||Wo(r,Sa)&&r[Sa][n]||(i.enumerable=!0),i}},Ka=function(e){var t=Pa(qo(e)),r=[];return ya(t,(function(e){Wo(Ma,e)||Wo(la,e)||Na(r,e)})),r},Wa=function(e){var t=e===Ia,r=Pa(t?La:qo(e)),n=[];return ya(r,(function(e){!Wo(Ma,e)||t&&!Wo(Ia,e)||Na(n,Ma[e])})),n};zo||(Ra=function(){if(Xo(Aa,this))throw wa("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Qo(arguments[0]):void 0,t=ha(e),r=function(e){this===Ia&&jo(r,La,e),Wo(this,Sa)&&Wo(this[Sa],t)&&(this[Sa][t]=!1),Fa(this,t,Zo(1,e))};return Go&&Va&&Fa(Ia,t,{configurable:!0,set:r}),Ba(t,e)},ca(Aa=Ra[ka],"toString",(function(){return Ta(this).tag})),ca(Ra,"withoutSetter",(function(e){return Ba(ha(e),e)})),sa.f=Ga,oa.f=ja,aa.f=Ha,ia.f=za,ta.f=ra.f=Ka,na.f=Wa,va.f=function(e){return Ba(pa(e),e)},Go&&ua(Aa,"description",{configurable:!0,get:function(){return Ta(this).description}})),Fo({global:!0,constructor:!0,wrap:!0,forced:!zo,sham:!zo},{Symbol:Ra}),ya(ea(Ua),(function(e){_a(e)})),Fo({target:ba,stat:!0,forced:!zo},{useSetter:function(){Va=!0},useSimple:function(){Va=!1}}),Fo({target:"Object",stat:!0,forced:!zo,sham:!Go},{create:function(e,t){return void 0===t?$o(e):Ha($o(e),t)},defineProperty:ja,defineProperties:Ha,getOwnPropertyDescriptor:za}),Fo({target:"Object",stat:!0,forced:!zo},{getOwnPropertyNames:Ka}),fa(),ma(Ra,ba),la[Sa]=!0;var Xa=ye&&!!Symbol.for&&!!Symbol.keyFor,Ya=wr,qa=ae,Ja=Ze,Qa=Sn,Za=We,$a=Xa,es=Za("string-to-symbol-registry"),ts=Za("symbol-to-string-registry");Ya({target:"Symbol",stat:!0,forced:!$a},{for:function(e){var t=Qa(e);if(Ja(es,t))return es[t];var r=qa("Symbol")(t);return es[t]=r,ts[r]=t,r}});var rs=wr,ns=Ze,is=Ie,os=Ae,as=Xa,ss=We("symbol-to-string-registry");rs({target:"Symbol",stat:!0,forced:!as},{keyFor:function(e){if(!is(e))throw TypeError(os(e)+" is not a symbol");if(ns(ss,e))return ss[e]}});var cs=f([].slice),us=io,ds=A,ls=S,hs=Sn,ps=f([].push),vs=wr,_s=ae,fs=l,ms=P,gs=f,ys=o,Ss=A,bs=Ie,ks=cs,Es=function(e){if(ds(e))return e;if(us(e)){for(var t=e.length,r=[],n=0;n<t;n++){var i=e[n];"string"==typeof i?ps(r,i):"number"!=typeof i&&"Number"!==ls(i)&&"String"!==ls(i)||ps(r,hs(i))}var o=r.length,a=!0;return function(e,t){if(a)return a=!1,t;if(us(this))return t;for(var n=0;n<o;n++)if(r[n]===e)return t}}},Ts=ye,Is=String,Rs=_s("JSON","stringify"),As=gs(/./.exec),ws=gs("".charAt),Cs=gs("".charCodeAt),xs=gs("".replace),Os=gs(1..toString),Ps=/[\uD800-\uDFFF]/g,Ds=/^[\uD800-\uDBFF]$/,Ns=/^[\uDC00-\uDFFF]$/,Ms=!Ts||ys((function(){var e=_s("Symbol")("stringify detection");return"[null]"!==Rs([e])||"{}"!==Rs({a:e})||"{}"!==Rs(Object(e))})),Ls=ys((function(){return'"\\udf06\\ud834"'!==Rs("\udf06\ud834")||'"\\udead"'!==Rs("\udead")})),Us=function(e,t){var r=ks(arguments),n=Es(t);if(Ss(n)||void 0!==e&&!bs(e))return r[1]=function(e,t){if(Ss(n)&&(t=ms(n,this,Is(e),t)),!bs(t))return t},fs(Rs,null,r)},Vs=function(e,t,r){var n=ws(r,t-1),i=ws(r,t+1);return As(Ds,e)&&!As(Ns,i)||As(Ns,e)&&!As(Ds,n)?"\\u"+Os(Cs(e,0),16):e};Rs&&vs({target:"JSON",stat:!0,arity:3,forced:Ms||Ls},{stringify:function(e,t,r){var n=ks(arguments),i=fs(Ms?Us:Rs,null,n);return Ls&&"string"==typeof i?xs(i,Ps,Vs):i}});var Fs=hi,Bs=qe;wr({target:"Object",stat:!0,forced:!ye||o((function(){Fs.f(1)}))},{getOwnPropertySymbols:function(e){var t=Fs.f;return t?t(Bs(e)):[]}});var js=te.Object.getOwnPropertySymbols,Hs=r(js),Gs=o,zs=_e,Ks=ht("species"),Ws=function(e){return zs>=51||!Gs((function(){var t=[];return(t.constructor={})[Ks]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Xs=Vo.filter;wr({target:"Array",proto:!0,forced:!Ws("filter")},{filter:function(e){return Xs(this,e,arguments.length>1?arguments[1]:void 0)}});var Ys=te,qs=function(e){return Ys[e+"Prototype"]},Js=qs("Array").filter,Qs=se,Zs=Js,$s=Array.prototype,ec=function(e){var t=e.filter;return e===$s||Qs($s,e)&&t===$s.filter?Zs:t},tc=r(ec),rc={exports:{}},nc=wr,ic=o,oc=Q,ac=w.f,sc=C;nc({target:"Object",stat:!0,forced:!sc||ic((function(){ac(1)})),sham:!sc},{getOwnPropertyDescriptor:function(e,t){return ac(oc(e),t)}});var cc=te.Object,uc=rc.exports=function(e,t){return cc.getOwnPropertyDescriptor(e,t)};cc.getOwnPropertyDescriptor.sham&&(uc.sham=!0);var dc=rc.exports,lc=r(dc),hc=C,pc=io,vc=TypeError,_c=Object.getOwnPropertyDescriptor,fc=hc&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}()?function(e,t){if(pc(e)&&!_c(e,"length").writable)throw vc("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},mc=TypeError,gc=function(e){if(e>9007199254740991)throw mc("Maximum allowed index exceeded");return e},yc=qe,Sc=jr,bc=fc,kc=gc;wr({target:"Array",proto:!0,arity:1,forced:o((function(){return 4294967297!==[].push.call({length:4294967296},1)}))||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}}()},{push:function(e){var t=yc(this),r=Sc(t),n=arguments.length;kc(r+n);for(var i=0;i<n;i++)t[r]=arguments[i],r++;return bc(t,r),r}});var Ec,Tc,Ic,Rc=qs("Array").push,Ac=se,wc=Rc,Cc=Array.prototype,xc=r((function(e){var t=e.push;return e===Cc||Ac(Cc,e)&&t===Cc.push?wc:t})),Oc={},Pc=C,Dc=Ze,Nc=Function.prototype,Mc=Pc&&Object.getOwnPropertyDescriptor,Lc=Dc(Nc,"name"),Uc={EXISTS:Lc,PROPER:Lc&&"something"===function(){}.name,CONFIGURABLE:Lc&&(!Pc||Pc&&Mc(Nc,"name").configurable)},Vc=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Fc=Ze,Bc=A,jc=qe,Hc=Vc,Gc=Pn("IE_PROTO"),zc=Object,Kc=zc.prototype,Wc=Hc?zc.getPrototypeOf:function(e){var t=jc(e);if(Fc(t,Gc))return t[Gc];var r=t.constructor;return Bc(r)&&t instanceof r?r.prototype:t instanceof zc?Kc:null},Xc=o,Yc=A,qc=ee,Jc=Wn,Qc=Wc,Zc=vi,$c=ht("iterator"),eu=!1;[].keys&&("next"in(Ic=[].keys())?(Tc=Qc(Qc(Ic)))!==Object.prototype&&(Ec=Tc):eu=!0);var tu=!qc(Ec)||Xc((function(){var e={};return Ec[$c].call(e)!==e}));Yc((Ec=tu?{}:Jc(Ec))[$c])||Zc(Ec,$c,(function(){return this}));var ru={IteratorPrototype:Ec,BUGGY_SAFARI_ITERATORS:eu},nu=ru.IteratorPrototype,iu=Wn,ou=F,au=Bi,su=Oc,cu=function(){return this},uu=function(e,t,r,n){var i=t+" Iterator";return e.prototype=iu(nu,{next:ou(+!n,r)}),au(e,i,!1,!0),su[i]=cu,e},du=f,lu=Oe,hu=A,pu=String,vu=TypeError,_u=function(e,t,r){try{return du(lu(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(n){}},fu=rr,mu=function(e){if("object"==typeof e||hu(e))return e;throw vu("Can't set "+pu(e)+" as a prototype")},gu=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=_u(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return fu(r),mu(n),t?e(r,n):r.__proto__=n,r}}():void 0),yu=wr,Su=P,bu=Uc,ku=uu,Eu=Wc,Tu=Bi,Iu=vi,Ru=Oc,Au=ru,wu=bu.PROPER,Cu=Au.BUGGY_SAFARI_ITERATORS,xu=ht("iterator"),Ou="keys",Pu="values",Du="entries",Nu=function(){return this},Mu=function(e,t,r,n,i,o,a){ku(r,t,n);var s,c,u,d=function(e){if(e===i&&_)return _;if(!Cu&&e in p)return p[e];switch(e){case Ou:case Pu:case Du:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,p=e.prototype,v=p[xu]||p["@@iterator"]||i&&p[i],_=!Cu&&v||d(i),f="Array"===t&&p.entries||v;if(f&&(s=Eu(f.call(new e)))!==Object.prototype&&s.next&&(Tu(s,l,!0,!0),Ru[l]=Nu),wu&&i===Pu&&v&&v.name!==Pu&&(h=!0,_=function(){return Su(v,this)}),i)if(c={values:d(Pu),keys:o?_:d(Ou),entries:d(Du)},a)for(u in c)(Cu||h||!(u in p))&&Iu(p,u,c[u]);else yu({target:t,proto:!0,forced:Cu||h},c);return a&&p[xu]!==_&&Iu(p,xu,_,{name:i}),Ru[t]=_,c},Lu=function(e,t){return{value:e,done:t}},Uu=Q,Vu=Oc,Fu=ro;Qt.f;var Bu=Mu,ju=Lu,Hu="Array Iterator",Gu=Fu.set,zu=Fu.getterFor(Hu);Bu(Array,"Array",(function(e,t){Gu(this,{type:Hu,target:Uu(e),index:0,kind:t})}),(function(){var e=zu(this),t=e.target,r=e.kind,n=e.index++;if(!t||n>=t.length)return e.target=void 0,ju(void 0,!0);switch(r){case"keys":return ju(n,!1);case"values":return ju(t[n],!1)}return ju([n,t[n]],!1)}),"values"),Vu.Arguments=Vu.Array;var Ku={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},Wu=i,Xu=mn,Yu=fr,qu=Oc,Ju=ht("toStringTag");for(var Qu in Ku){var Zu=Wu[Qu],$u=Zu&&Zu.prototype;$u&&Xu($u)!==Ju&&Yu($u,Ju,Qu),qu[Qu]=qu.Array}var ed=o,td=function(e,t){var r=[][e];return!!r&&ed((function(){r.call(null,t||function(){return 1},1)}))},rd=Vo.forEach,nd=td("forEach")?[].forEach:function(e){return rd(this,e,arguments.length>1?arguments[1]:void 0)};wr({target:"Array",proto:!0,forced:[].forEach!==nd},{forEach:nd});var id=qs("Array").forEach,od=mn,ad=Ze,sd=se,cd=id,ud=Array.prototype,dd={DOMTokenList:!0,NodeList:!0},ld=r((function(e){var t=e.forEach;return e===ud||sd(ud,e)&&t===ud.forEach||ad(dd,od(e))?cd:t})),hd=ae,pd=Xn,vd=hi,_d=rr,fd=f([].concat),md=hd("Reflect","ownKeys")||function(e){var t=pd.f(_d(e)),r=vd.f;return r?fd(t,r(e)):t},gd=md,yd=Q,Sd=w,bd=ei;wr({target:"Object",stat:!0,sham:!C},{getOwnPropertyDescriptors:function(e){for(var t,r,n=yd(e),i=Sd.f,o=gd(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&bd(a,t,r);return a}});var kd=r(te.Object.getOwnPropertyDescriptors),Ed={exports:{}},Td=wr,Id=C,Rd=bn.f;Td({target:"Object",stat:!0,forced:Object.defineProperties!==Rd,sham:!Id},{defineProperties:Rd});var Ad=te.Object,wd=Ed.exports=function(e,t){return Ad.defineProperties(e,t)};Ad.defineProperties.sham&&(wd.sham=!0);var Cd=r(Ed.exports),xd={exports:{}},Od=wr,Pd=C,Dd=Qt.f;Od({target:"Object",stat:!0,forced:Object.defineProperty!==Dd,sham:!Pd},{defineProperty:Dd});var Nd=te.Object,Md=xd.exports=function(e,t,r){return Nd.defineProperty(e,t,r)};Nd.defineProperty.sham&&(Md.sham=!0);var Ld=xd.exports,Ud=r(Ld),Vd=wr,Fd=o,Bd=io,jd=ee,Hd=qe,Gd=jr,zd=gc,Kd=ei,Wd=xo,Xd=Ws,Yd=_e,qd=ht("isConcatSpreadable"),Jd=Yd>=51||!Fd((function(){var e=[];return e[qd]=!1,e.concat()[0]!==e})),Qd=function(e){if(!jd(e))return!1;var t=e[qd];return void 0!==t?!!t:Bd(e)};Vd({target:"Array",proto:!0,arity:1,forced:!Jd||!Xd("concat")},{concat:function(e){var t,r,n,i,o,a=Hd(this),s=Wd(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(Qd(o=-1===t?a:arguments[t]))for(i=Gd(o),zd(c+i),r=0;r<i;r++,c++)r in o&&Kd(s,c,o[r]);else zd(c+1),Kd(s,c++,o);return s.length=c,s}}),Ri("asyncIterator"),Ri("hasInstance"),Ri("isConcatSpreadable"),Ri("iterator"),Ri("match"),Ri("matchAll"),Ri("replace"),Ri("search"),Ri("species"),Ri("split");var Zd=Oi;Ri("toPrimitive"),Zd();var $d=ae,el=Bi;Ri("toStringTag"),el($d("Symbol"),"Symbol"),Ri("unscopables"),Bi(i.JSON,"JSON",!0);var tl=te.Symbol,rl=ht,nl=Qt.f,il=rl("metadata"),ol=Function.prototype;void 0===ol[il]&&nl(ol,il,{value:null}),Ri("asyncDispose"),Ri("dispose"),Ri("metadata");var al=tl,sl=f,cl=ae("Symbol"),ul=cl.keyFor,dl=sl(cl.prototype.valueOf),ll=cl.isRegisteredSymbol||function(e){try{return void 0!==ul(dl(e))}catch(t){return!1}};wr({target:"Symbol",stat:!0},{isRegisteredSymbol:ll});for(var hl=We,pl=ae,vl=f,_l=Ie,fl=ht,ml=pl("Symbol"),gl=ml.isWellKnownSymbol,yl=pl("Object","getOwnPropertyNames"),Sl=vl(ml.prototype.valueOf),bl=hl("wks"),kl=0,El=yl(ml),Tl=El.length;kl<Tl;kl++)try{var Il=El[kl];_l(ml[Il])&&fl(Il)}catch(BZ){}var Rl=function(e){if(gl&&gl(e))return!0;try{for(var t=Sl(e),r=0,n=yl(bl),i=n.length;r<i;r++)if(bl[n[r]]==t)return!0}catch(BZ){}return!1};wr({target:"Symbol",stat:!0,forced:!0},{isWellKnownSymbol:Rl}),Ri("matcher"),Ri("observable"),wr({target:"Symbol",stat:!0,name:"isRegisteredSymbol"},{isRegistered:ll}),wr({target:"Symbol",stat:!0,name:"isWellKnownSymbol",forced:!0},{isWellKnown:Rl}),Ri("metadataKey"),Ri("patternMatch"),Ri("replaceAll");var Al=r(al),wl=f,Cl=Pr,xl=Sn,Ol=Y,Pl=wl("".charAt),Dl=wl("".charCodeAt),Nl=wl("".slice),Ml=function(e){return function(t,r){var n,i,o=xl(Ol(t)),a=Cl(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Dl(o,a))<55296||n>56319||a+1===s||(i=Dl(o,a+1))<56320||i>57343?e?Pl(o,a):n:e?Nl(o,a,a+2):i-56320+(n-55296<<10)+65536}},Ll={codeAt:Ml(!1),charAt:Ml(!0)},Ul=Ll.charAt,Vl=Sn,Fl=ro,Bl=Mu,jl=Lu,Hl="String Iterator",Gl=Fl.set,zl=Fl.getterFor(Hl);Bl(String,"String",(function(e){Gl(this,{type:Hl,string:Vl(e),index:0})}),(function(){var e,t=zl(this),r=t.string,n=t.index;return n>=r.length?jl(void 0,!0):(e=Ul(r,n),t.index+=e.length,jl(e,!1))}));var Kl=r(mi.f("iterator"));function Wl(e){return(Wl="function"==typeof Al&&"symbol"==typeof Kl?function(e){return typeof e}:function(e){return e&&"function"==typeof Al&&e.constructor===Al&&e!==Al.prototype?"symbol":typeof e})(e)}var Xl=r(mi.f("toPrimitive"));function Yl(e){var t=function(e,t){if("object"!==Wl(e)||null===e)return e;var r=e[Xl];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==Wl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Wl(t)?t:String(t)}function ql(e,t,r){return(t=Yl(t))in e?Ud(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Jl(e,t){var r=cn(e);if(Hs){var n=Hs(e);t&&(n=tc(n).call(n,(function(t){return lc(e,t).enumerable}))),xc(r).apply(r,n)}return r}function Ql(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?ld(r=Jl(Object(i),!0)).call(r,(function(t){ql(e,t,i[t])})):kd?Cd(e,kd(i)):ld(n=Jl(Object(i))).call(n,(function(t){Ud(e,t,lc(i,t))}))}return e}var Zl=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}(Zl||{}),$l=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}($l||{}),eh=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}(eh||{}),th=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(th||{}),rh=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(rh||{}),nh=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(nh||{}),ih=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(ih||{}),oh=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(oh||{}),ah=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}(ah||{}),sh=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(sh||{}),ch=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(ch||{}),uh=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}(uh||{}),dh=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}(dh||{}),lh=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(lh||{}),hh=function(e){return e[e.NORMAL=0]="NORMAL",e[e.DISCONNECT=1]="DISCONNECT",e[e.RESET=2]="RESET",e}(hh||{}),ph=function(e){return e[e.MICROPHONE=0]="MICROPHONE",e[e.AUDIOMIXING=1]="AUDIOMIXING",e}(ph||{}),vh=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(vh||{}),_h=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(_h||{}),fh=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}(fh||{}),mh=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(mh||{}),gh=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}(gh||{}),yh=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(yh||{}),Sh=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}(Sh||{}),bh=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(bh||{}),kh=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}(kh||{}),Eh=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}(Eh||{}),Th=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}(Th||{}),Ih=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(Ih||{}),Rh=function(e){return e.H264="H264",e.H265="H265",e}(Rh||{}),Ah=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(Ah||{}),wh=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(wh||{}),Ch=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}(Ch||{}),xh=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}(xh||{}),Oh=Object.freeze({__proto__:null,AAC_PROFILE:Ih,AudioProfileType:Eh,AudioReportMode:ph,AudioSourceType:$l,ChannelProfile:th,ConnectionState:dh,FallbackOrRecoverReason:bh,ForwardStreamError:xh,ForwardStreamState:Ch,LocalMainReportMode:hh,LogChannel:vh,MediaType:ch,MirrorMode:oh,MirrorType:lh,NetworkQuality:Sh,PublicInterpolationMode:mh,PublicStreamType:fh,PublishState:ih,RTCAutoPlayPolicy:Th,RemoteUserPriority:yh,RoomProfileType:kh,SUBTITLE_MODE:Ah,StreamIndex:sh,StreamRemoveReason:uh,SubscribeFallbackOption:gh,SubscribeMode:rh,SubscribeState:nh,SubtitleEventType:wh,TRANSCODING_VIDEO_CODEC:Rh,USER_ONLINE_STATUS:_h,UserOfflineReason:eh,VideoRenderMode:ah,VideoSourceType:Zl}),Ph=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}(Ph||{}),Dh=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(Dh||{}),Nh=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}(Nh||{}),Mh=Object.freeze({__proto__:null,AudioMixingDualMonoMode:Ph,AudioMixingState:Nh,AudioMixingType:Dh}),Lh=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.onPublishRetry="onPublishRetry",e.onSubscribeRetry="onSubscribeRetry",e.onPublishResult="onPublishResult",e.onSubscribeResult="onSubscribeResult",e}(Lh||{});function Uh(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),Ud(e,Yl(n.key),n)}}function Vh(e,t,r){return t&&Uh(e.prototype,t),r&&Uh(e,r),Ud(e,"prototype",{writable:!1}),e}function Fh(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}wr({target:"Object",stat:!0,sham:!C},{create:Wn});var Bh=te.Object,jh=r((function(e,t){return Bh.create(e,t)})),Hh=qe,Gh=Wc,zh=Vc;wr({target:"Object",stat:!0,forced:o((function(){Gh(1)})),sham:!zh},{getPrototypeOf:function(e){return Gh(Hh(e))}});var Kh=r(te.Object.getPrototypeOf);wr({target:"Object",stat:!0},{setPrototypeOf:gu});var Wh=te.Object.setPrototypeOf,Xh=r(Wh),Yh=Ze,qh=md,Jh=w,Qh=Qt,Zh=ee,$h=fr,ep=Error,tp=f("".replace),rp=String(ep("zxcasd").stack),np=/\n\s*at [^:]*:[^\n]*/,ip=np.test(rp),op=F,ap=!o((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",op(1,7)),7!==e.stack)})),sp=fr,cp=function(e,t){if(ip&&"string"==typeof e&&!ep.prepareStackTrace)for(;t--;)e=tp(e,np,"");return e},up=ap,dp=Error.captureStackTrace,lp=Oc,hp=ht("iterator"),pp=Array.prototype,vp=function(e){return void 0!==e&&(lp.Array===e||pp[hp]===e)},_p=mn,fp=Ne,mp=K,gp=Oc,yp=ht("iterator"),Sp=function(e){if(!mp(e))return fp(e,yp)||fp(e,"@@iterator")||gp[_p(e)]},bp=P,kp=Oe,Ep=rr,Tp=Ae,Ip=Sp,Rp=TypeError,Ap=function(e,t){var r=arguments.length<2?Ip(e):t;if(kp(r))return Ep(bp(r,e));throw Rp(Tp(e)+" is not iterable")},wp=P,Cp=rr,xp=Ne,Op=function(e,t,r){var n,i;Cp(e);try{if(!(n=xp(e,"return"))){if("throw"===t)throw r;return r}n=wp(n,e)}catch(BZ){i=!0,n=BZ}if("throw"===t)throw r;if(i)throw n;return Cp(n),r},Pp=Jt,Dp=P,Np=rr,Mp=Ae,Lp=vp,Up=jr,Vp=se,Fp=Ap,Bp=Sp,jp=Op,Hp=TypeError,Gp=function(e,t){this.stopped=e,this.result=t},zp=Gp.prototype,Kp=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),_=Pp(t,d),f=function(e){return n&&jp(n,"normal",e),new Gp(!0,e)},m=function(e){return l?(Np(e),v?_(e[0],e[1],f):_(e[0],e[1])):v?_(e,f):_(e)};if(h)n=e.iterator;else if(p)n=e;else{if(!(i=Bp(e)))throw Hp(Mp(e)+" is not iterable");if(Lp(i)){for(o=0,a=Up(e);a>o;o++)if((s=m(e[o]))&&Vp(zp,s))return s;return new Gp(!1)}n=Fp(e,i)}for(c=h?e.next:n.next;!(u=Dp(c,n)).done;){try{s=m(u.value)}catch(BZ){jp(n,"throw",BZ)}if("object"==typeof s&&s&&Vp(zp,s))return s}return new Gp(!1)},Wp=Sn,Xp=wr,Yp=se,qp=Wc,Jp=gu,Qp=function(e,t,r){for(var n=qh(t),i=Qh.f,o=Jh.f,a=0;a<n.length;a++){var s=n[a];Yh(e,s)||r&&Yh(r,s)||i(e,s,o(t,s))}},Zp=Wn,$p=fr,ev=F,tv=function(e,t){Zh(t)&&"cause"in t&&$h(e,"cause",t.cause)},rv=function(e,t,r,n){up&&(dp?dp(e,t):sp(e,"stack",cp(r,n)))},nv=Kp,iv=function(e,t){return void 0===e?arguments.length<2?"":t:Wp(e)},ov=ht("toStringTag"),av=Error,sv=[].push,cv=function(e,t){var r,n=Yp(uv,this);Jp?r=Jp(av(),n?qp(this):uv):(r=n?this:Zp(uv),$p(r,ov,"Error")),void 0!==t&&$p(r,"message",iv(t)),rv(r,cv,r.stack,1),arguments.length>2&&tv(r,arguments[2]);var i=[];return nv(e,sv,{that:i}),$p(r,"errors",i),r};Jp?Jp(cv,av):Qp(cv,av,{name:!0});var uv=cv.prototype=Zp(av.prototype,{constructor:ev(1,cv),message:ev(1,""),name:ev(1,"AggregateError")});Xp({global:!0,constructor:!0,arity:2},{AggregateError:cv});var dv,lv,hv,pv,vv="process"===S(i.process),_v=ae,fv=fi,mv=C,gv=ht("species"),yv=function(e){var t=_v(e);mv&&t&&!t[gv]&&fv(t,gv,{configurable:!0,get:function(){return this}})},Sv=se,bv=TypeError,kv=function(e,t){if(Sv(t,e))return e;throw bv("Incorrect invocation")},Ev=Eo,Tv=Ae,Iv=TypeError,Rv=function(e){if(Ev(e))return e;throw Iv(Tv(e)+" is not a constructor")},Av=rr,wv=Rv,Cv=K,xv=ht("species"),Ov=function(e,t){var r,n=Av(e).constructor;return void 0===n||Cv(r=Av(n)[xv])?t:wv(r)},Pv=TypeError,Dv=function(e,t){if(e<t)throw Pv("Not enough arguments");return e},Nv=/(?:ipad|iphone|ipod).*applewebkit/i.test(ce),Mv=i,Lv=l,Uv=Jt,Vv=A,Fv=Ze,Bv=o,jv=Cn,Hv=cs,Gv=Rt,zv=Dv,Kv=Nv,Wv=vv,Xv=Mv.setImmediate,Yv=Mv.clearImmediate,qv=Mv.process,Jv=Mv.Dispatch,Qv=Mv.Function,Zv=Mv.MessageChannel,$v=Mv.String,e_=0,t_={},r_="onreadystatechange";Bv((function(){dv=Mv.location}));var n_=function(e){if(Fv(t_,e)){var t=t_[e];delete t_[e],t()}},i_=function(e){return function(){n_(e)}},o_=function(e){n_(e.data)},a_=function(e){Mv.postMessage($v(e),dv.protocol+"//"+dv.host)};Xv&&Yv||(Xv=function(e){zv(arguments.length,1);var t=Vv(e)?e:Qv(e),r=Hv(arguments,1);return t_[++e_]=function(){Lv(t,void 0,r)},lv(e_),e_},Yv=function(e){delete t_[e]},Wv?lv=function(e){qv.nextTick(i_(e))}:Jv&&Jv.now?lv=function(e){Jv.now(i_(e))}:Zv&&!Kv?(pv=(hv=new Zv).port2,hv.port1.onmessage=o_,lv=Uv(pv.postMessage,pv)):Mv.addEventListener&&Vv(Mv.postMessage)&&!Mv.importScripts&&dv&&"file:"!==dv.protocol&&!Bv(a_)?(lv=a_,Mv.addEventListener("message",o_,!1)):lv=r_ in Gv("script")?function(e){jv.appendChild(Gv("script"))[r_]=function(){jv.removeChild(this),n_(e)}}:function(e){setTimeout(i_(e),0)});var s_={set:Xv,clear:Yv},c_=function(){this.head=null,this.tail=null};c_.prototype={add:function(e){var t={item:e,next:null},r=this.tail;r?r.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var u_,d_,l_,h_,p_,v_=c_,__=/ipad|iphone|ipod/i.test(ce)&&"undefined"!=typeof Pebble,f_=/web0s(?!.*chrome)/i.test(ce),m_=i,g_=Jt,y_=w.f,S_=s_.set,b_=v_,k_=Nv,E_=__,T_=f_,I_=vv,R_=m_.MutationObserver||m_.WebKitMutationObserver,A_=m_.document,w_=m_.process,C_=m_.Promise,x_=y_(m_,"queueMicrotask"),O_=x_&&x_.value;if(!O_){var P_=new b_,D_=function(){var e,t;for(I_&&(e=w_.domain)&&e.exit();t=P_.get();)try{t()}catch(BZ){throw P_.head&&u_(),BZ}e&&e.enter()};k_||I_||T_||!R_||!A_?!E_&&C_&&C_.resolve?((h_=C_.resolve(void 0)).constructor=C_,p_=g_(h_.then,h_),u_=function(){p_(D_)}):I_?u_=function(){w_.nextTick(D_)}:(S_=g_(S_,m_),u_=function(){S_(D_)}):(d_=!0,l_=A_.createTextNode(""),new R_(D_).observe(l_,{characterData:!0}),u_=function(){l_.data=d_=!d_}),O_=function(e){P_.head||u_(),P_.add(e)}}var N_=O_,M_=function(e){try{return{error:!1,value:e()}}catch(BZ){return{error:!0,value:BZ}}},L_=i.Promise,U_="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,V_=!U_&&!vv&&"object"==typeof window&&"object"==typeof document,F_=i,B_=L_,j_=A,H_=Wt,G_=co,z_=ht,K_=V_,W_=U_,X_=_e,Y_=B_&&B_.prototype,q_=z_("species"),J_=!1,Q_=j_(F_.PromiseRejectionEvent),Z_={CONSTRUCTOR:H_("Promise",(function(){var e=G_(B_),t=e!==String(B_);if(!t&&66===X_)return!0;if(!Y_.catch||!Y_.finally)return!0;if(!X_||X_<51||!/native code/.test(e)){var r=new B_((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[q_]=n,!(J_=r.then((function(){}))instanceof n))return!0}return!t&&(K_||W_)&&!Q_})),REJECTION_EVENT:Q_,SUBCLASSING:J_},$_={},ef=Oe,tf=TypeError,rf=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw tf("Bad Promise constructor");t=e,r=n})),this.resolve=ef(t),this.reject=ef(r)};$_.f=function(e){return new rf(e)};var nf,of,af=wr,sf=vv,cf=i,uf=P,df=vi,lf=Bi,hf=yv,pf=Oe,vf=A,_f=ee,ff=kv,mf=Ov,gf=s_.set,yf=N_,Sf=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(BZ){}},bf=M_,kf=v_,Ef=ro,Tf=L_,If=Z_,Rf=$_,Af="Promise",wf=If.CONSTRUCTOR,Cf=If.REJECTION_EVENT,xf=Ef.getterFor(Af),Of=Ef.set,Pf=Tf&&Tf.prototype,Df=Tf,Nf=Pf,Mf=cf.TypeError,Lf=cf.document,Uf=cf.process,Vf=Rf.f,Ff=Vf,Bf=!!(Lf&&Lf.createEvent&&cf.dispatchEvent),jf="unhandledrejection",Hf=function(e){var t;return!(!_f(e)||!vf(t=e.then))&&t},Gf=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&&Yf(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=Hf(r))?uf(n,r,c,u):c(r)):u(o)}catch(BZ){d&&!i&&d.exit(),u(BZ)}},zf=function(e,t){e.notified||(e.notified=!0,yf((function(){for(var r,n=e.reactions;r=n.get();)Gf(r,e);e.notified=!1,t&&!e.rejection&&Wf(e)})))},Kf=function(e,t,r){var n,i;Bf?((n=Lf.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),cf.dispatchEvent(n)):n={promise:t,reason:r},!Cf&&(i=cf["on"+e])?i(n):e===jf&&Sf("Unhandled promise rejection",r)},Wf=function(e){uf(gf,cf,(function(){var t,r=e.facade,n=e.value;if(Xf(e)&&(t=bf((function(){sf?Uf.emit("unhandledRejection",n,r):Kf(jf,r,n)})),e.rejection=sf||Xf(e)?2:1,t.error))throw t.value}))},Xf=function(e){return 1!==e.rejection&&!e.parent},Yf=function(e){uf(gf,cf,(function(){var t=e.facade;sf?Uf.emit("rejectionHandled",t):Kf("rejectionhandled",t,e.value)}))},qf=function(e,t,r){return function(n){e(t,n,r)}},Jf=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,zf(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=Hf(t);n?yf((function(){var r={done:!1};try{uf(n,t,qf(Qf,r,e),qf(Jf,r,e))}catch(BZ){Jf(r,BZ,e)}})):(e.value=t,e.state=1,zf(e,!1))}catch(BZ){Jf({done:!1},BZ,e)}}};wf&&(Nf=(Df=function(e){ff(this,Nf),pf(e),uf(nf,this);var t=xf(this);try{e(qf(Qf,t),qf(Jf,t))}catch(BZ){Jf(t,BZ)}}).prototype,(nf=function(e){Of(this,{type:Af,done:!1,notified:!1,parent:!1,reactions:new kf,rejection:!1,state:0,value:void 0})}).prototype=df(Nf,"then",(function(e,t){var r=xf(this),n=Vf(mf(this,Df));return r.parent=!0,n.ok=!vf(e)||e,n.fail=vf(t)&&t,n.domain=sf?Uf.domain:void 0,0===r.state?r.reactions.add(n):yf((function(){Gf(n,r)})),n.promise})),of=function(){var e=new nf,t=xf(e);this.promise=e,this.resolve=qf(Qf,t),this.reject=qf(Jf,t)},Rf.f=Vf=function(e){return e===Df||undefined===e?new of(e):Ff(e)}),af({global:!0,constructor:!0,wrap:!0,forced:wf},{Promise:Df}),lf(Df,Af,!1,!0),hf(Af);var Zf=ht("iterator"),$f=!1;try{var em=0,tm={next:function(){return{done:!!em++}},return:function(){$f=!0}};tm[Zf]=function(){return this},Array.from(tm,(function(){throw 2}))}catch(BZ){}var rm=function(e,t){if(!t&&!$f)return!1;var r=!1;try{var n={};n[Zf]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(BZ){}return r},nm=L_,im=Z_.CONSTRUCTOR||!rm((function(e){nm.all(e).then(void 0,(function(){}))})),om=P,am=Oe,sm=$_,cm=M_,um=Kp;wr({target:"Promise",stat:!0,forced:im},{all:function(e){var t=this,r=sm.f(t),n=r.resolve,i=r.reject,o=cm((function(){var r=am(t.resolve),o=[],a=0,s=1;um(e,(function(e){var c=a++,u=!1;s++,om(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 dm=wr,lm=Z_.CONSTRUCTOR;L_&&L_.prototype,dm({target:"Promise",proto:!0,forced:lm,real:!0},{catch:function(e){return this.then(void 0,e)}});var hm=P,pm=Oe,vm=$_,_m=M_,fm=Kp;wr({target:"Promise",stat:!0,forced:im},{race:function(e){var t=this,r=vm.f(t),n=r.reject,i=_m((function(){var i=pm(t.resolve);fm(e,(function(e){hm(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var mm=P,gm=$_;wr({target:"Promise",stat:!0,forced:Z_.CONSTRUCTOR},{reject:function(e){var t=gm.f(this);return mm(t.reject,void 0,e),t.promise}});var ym=rr,Sm=ee,bm=$_,km=function(e,t){if(ym(e),Sm(t)&&t.constructor===e)return t;var r=bm.f(e);return(0,r.resolve)(t),r.promise},Em=wr,Tm=L_,Im=Z_.CONSTRUCTOR,Rm=km,Am=ae("Promise"),wm=!Im;Em({target:"Promise",stat:!0,forced:true},{resolve:function(e){return Rm(wm&&this===Am?Tm:this,e)}});var Cm=P,xm=Oe,Om=$_,Pm=M_,Dm=Kp;wr({target:"Promise",stat:!0,forced:im},{allSettled:function(e){var t=this,r=Om.f(t),n=r.resolve,i=r.reject,o=Pm((function(){var r=xm(t.resolve),i=[],o=0,a=1;Dm(e,(function(e){var s=o++,c=!1;a++,Cm(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 Nm=P,Mm=Oe,Lm=ae,Um=$_,Vm=M_,Fm=Kp,Bm="No one promise resolved";wr({target:"Promise",stat:!0,forced:im},{any:function(e){var t=this,r=Lm("AggregateError"),n=Um.f(t),i=n.resolve,o=n.reject,a=Vm((function(){var n=Mm(t.resolve),a=[],s=0,c=1,u=!1;Fm(e,(function(e){var d=s++,l=!1;c++,Nm(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,Bm)))}))})),--c||o(new r(a,Bm))}));return a.error&&o(a.value),n.promise}});var jm=wr,Hm=L_,Gm=o,zm=ae,Km=A,Wm=Ov,Xm=km,Ym=Hm&&Hm.prototype;jm({target:"Promise",proto:!0,real:!0,forced:!!Hm&&Gm((function(){Ym.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Wm(this,zm("Promise")),r=Km(e);return this.then(r?function(r){return Xm(t,e()).then((function(){return r}))}:e,r?function(r){return Xm(t,e()).then((function(){throw r}))}:e)}});var qm=te.Promise,Jm=$_;wr({target:"Promise",stat:!0},{withResolvers:function(){var e=Jm.f(this);return{promise:e.promise,resolve:e.resolve,reject:e.reject}}});var Qm=qm,Zm=$_,$m=M_;wr({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=Zm.f(this),r=$m(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var eg=Qm,tg=r(eg),rg=wr,ng=io,ig=f([].reverse),og=[1,2];rg({target:"Array",proto:!0,forced:String(og)===String(og.reverse())},{reverse:function(){return ng(this)&&(this.length=this.length),ig(this)}});var ag=qs("Array").reverse,sg=se,cg=ag,ug=Array.prototype,dg=function(e){var t=e.reverse;return e===ug||sg(ug,e)&&t===ug.reverse?cg:t},lg=r(dg),hg=wr,pg=io,vg=Eo,_g=ee,fg=Lr,mg=jr,gg=Q,yg=ei,Sg=ht,bg=cs,kg=Ws("slice"),Eg=Sg("species"),Tg=Array,Ig=Math.max;hg({target:"Array",proto:!0,forced:!kg},{slice:function(e,t){var r,n,i,o=gg(this),a=mg(o),s=fg(e,a),c=fg(void 0===t?a:t,a);if(pg(o)&&(r=o.constructor,(vg(r)&&(r===Tg||pg(r.prototype))||_g(r)&&null===(r=r[Eg]))&&(r=void 0),r===Tg||void 0===r))return bg(o,s,c);for(n=new(void 0===r?Tg:r)(Ig(c-s,0)),i=0;s<c;s++,i++)s in o&&yg(n,i,o[s]);return n.length=i,n}});var Rg=qs("Array").slice,Ag=se,wg=Rg,Cg=Array.prototype,xg=function(e){var t=e.slice;return e===Cg||Ag(Cg,e)&&t===Cg.slice?wg:t},Og=r(xg);function Pg(){Pg=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Ud||function(e,t,r){e[t]=r.value},o="function"==typeof Al?Al:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,r){return Ud(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(O){u=function(e,t,r){return e[t]=r}}function d(e,t,r,n){var o=t&&t.prototype instanceof m?t:m,a=jh(o.prototype),s=new C(n||[]);return i(a,"_invoke",{value:I(e,r,s)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(n){return{type:"throw",arg:n}}}t.wrap=d;var h="suspendedStart",p="suspendedYield",v="executing",_="completed",f={};function m(){}function g(){}function y(){}var S={};u(S,a,(function(){return this}));var b=Kh&&Kh(Kh(x([])));b&&b!==r&&n.call(b,a)&&(S=b);var k=y.prototype=m.prototype=jh(S);function E(e){var t;ld(t=["next","throw","return"]).call(t,(function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function r(i,o,a,s){var c=l(e[i],e,o);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==Wl(d)&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(d).then((function(e){u.value=e,a(u)}),(function(e){return r("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return o=o?o.then(i,i):i()}})}function I(t,r,n){var i=h;return function(o,a){if(i===v)throw new Error("Generator is already running");if(i===_){if("throw"===o)throw a;return{value:e,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var c=R(s,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=_,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?_:p,u.arg===f)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=_,n.method="throw",n.arg=u.arg)}}}function R(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,R(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var o=l(i,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,f;var a=o.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,f):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}function A(e){var t,r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),xc(t=this.tryEntries).call(t,r)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],ld(e).call(e,A,this),this.reset(!0)}function x(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(Wl(t)+" is not iterable")}return g.prototype=y,i(k,"constructor",{value:y,configurable:!0}),i(y,"constructor",{value:g,configurable:!0}),g.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Xh?Xh(e,y):(e.__proto__=y,u(e,c,"GeneratorFunction")),e.prototype=jh(k),e},t.awrap=function(e){return{__await:e}},E(T.prototype),u(T.prototype,s,(function(){return this})),t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=tg);var a=new T(d(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},E(k),u(k,c,"Generator"),u(k,a,(function(){return this})),u(k,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)xc(r).call(r,n);return lg(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}},t.values=x,C.prototype={constructor:C,reset:function(t){var r;if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,ld(r=this.tryEntries).call(r,w),!t)for(var i in this)"t"===i.charAt(0)&&n.call(this,i)&&!isNaN(+Og(i).call(i,1))&&(this[i]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.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,f):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),f},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),w(r),f}},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;w(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:x(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),f}},t}function Dg(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(BZ){return void r(BZ)}s.done?t(c):tg.resolve(c).then(n,i)}function Ng(e){return function(){var t=this,r=arguments;return new tg((function(n,i){var o=e.apply(t,r);function a(e){Dg(o,n,i,a,s,"next",e)}function s(e){Dg(o,n,i,a,s,"throw",e)}a(void 0)}))}}var Mg=qs("Array").concat,Lg=se,Ug=Mg,Vg=Array.prototype,Fg=r((function(e){var t=e.concat;return e===Vg||Lg(Vg,e)&&t===Vg.concat?Ug:t})),Bg=te,jg=l;Bg.JSON||(Bg.JSON={stringify:JSON.stringify});var Hg=function(e,t,r){return jg(Bg.JSON.stringify,null,arguments)},Gg=r(Hg),zg=Vo.map;wr({target:"Array",proto:!0,forced:!Ws("map")},{map:function(e){return zg(this,e,arguments.length>1?arguments[1]:void 0)}});var Kg=qs("Array").map,Wg=se,Xg=Kg,Yg=Array.prototype,qg=r((function(e){var t=e.map;return e===Yg||Wg(Yg,e)&&t===Yg.map?Xg:t})),Jg=r(Sp);wr({target:"Array",stat:!0},{isArray:io});var Qg=r(te.Array.isArray),Zg=rr,$g=Op,ey=Jt,ty=P,ry=qe,ny=function(e,t,r,n){try{return n?t(Zg(r)[0],r[1]):t(r)}catch(BZ){$g(e,"throw",BZ)}},iy=vp,oy=Eo,ay=jr,sy=ei,cy=Ap,uy=Sp,dy=Array,ly=function(e){var t=ry(e),r=oy(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=ey(i,n>2?arguments[2]:void 0));var a,s,c,u,d,l,h=uy(t),p=0;if(!h||this===dy&&iy(h))for(a=ay(t),s=r?new this(a):dy(a);a>p;p++)l=o?i(t[p],p):t[p],sy(s,p,l);else for(d=(u=cy(t,h)).next,s=r?new this:[];!(c=ty(d,u)).done;p++)l=o?ny(u,i,[c.value,p],!0):c.value,sy(s,p,l);return s.length=p,s},hy=ly;wr({target:"Array",stat:!0,forced:!rm((function(e){Array.from(e)}))},{from:hy});var py=te.Array.from,vy=r(py);function _y(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}function fy(e,t){var r;if(e){if("string"==typeof e)return _y(e,t);var n=Og(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?vy(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_y(e,t):void 0}}function my(e,t){var r=void 0!==Al&&Jg(e)||e["@@iterator"];if(!r){if(Qg(e)||(r=fy(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 gy(e,t){return function(e){if(Qg(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==Al&&Jg(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)&&(xc(s).call(s,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)||fy(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.")}()}var yy=wr,Sy=o,by=Jn.f;yy({target:"Object",stat:!0,forced:Sy((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:by});var ky=te.Object,Ey=r((function(e){return ky.getOwnPropertyNames(e)})),Ty=r(ec),Iy=Wr.includes;wr({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return Iy(this,e,arguments.length>1?arguments[1]:void 0)}});var Ry=qs("Array").includes,Ay=ee,wy=S,Cy=ht("match"),xy=function(e){var t;return Ay(e)&&(void 0!==(t=e[Cy])?!!t:"RegExp"===wy(e))},Oy=TypeError,Py=function(e){if(xy(e))throw Oy("The method doesn't accept regular expressions");return e},Dy=ht("match"),Ny=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Dy]=!1,"/./"[e](t)}catch(n){}}return!1},My=wr,Ly=Py,Uy=Y,Vy=Sn,Fy=Ny,By=f("".indexOf);My({target:"String",proto:!0,forced:!Fy("includes")},{includes:function(e){return!!~By(Vy(Uy(this)),Vy(Ly(e)),arguments.length>1?arguments[1]:void 0)}});var jy=qs("String").includes,Hy=se,Gy=Ry,zy=jy,Ky=Array.prototype,Wy=String.prototype,Xy=r((function(e){var t=e.includes;return e===Ky||Hy(Ky,e)&&t===Ky.includes?Gy:"string"==typeof e||e===Wy||Hy(Wy,e)&&t===Wy.includes?zy:t})),Yy=Oe,qy=qe,Jy=z,Qy=jr,Zy=TypeError,$y=function(e){return function(t,r,n,i){Yy(r);var o=qy(t),a=Jy(o),s=Qy(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 Zy("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}},eS={left:$y(!1),right:$y(!0)}.left;wr({target:"Array",proto:!0,forced:!vv&&_e>79&&_e<83||!td("reduce")},{reduce:function(e){var t=arguments.length;return eS(this,e,t,t>1?arguments[1]:void 0)}});var tS=qs("Array").reduce,rS=se,nS=tS,iS=Array.prototype,oS=r((function(e){var t=e.reduce;return e===iS||rS(iS,e)&&t===iS.reduce?nS:t})),aS=C,sS=o,cS=f,uS=Wc,dS=nn,lS=Q,hS=cS(D.f),pS=cS([].push),vS=aS&&sS((function(){var e=Object.create(null);return e[2]=2,!hS(e,2)})),_S=function(e){return function(t){for(var r,n=lS(t),i=dS(n),o=vS&&null===uS(n),a=i.length,s=0,c=[];a>s;)r=i[s++],aS&&!(o?r in n:hS(n,r))||pS(c,e?[r,n[r]]:n[r]);return c}},fS={entries:_S(!0),values:_S(!1)}.entries;wr({target:"Object",stat:!0},{entries:function(e){return fS(e)}});var mS,gS,yS,SS,bS,kS,ES,TS,IS,RS,AS,wS,CS,xS,OS,PS,DS,NS=r(te.Object.entries),MS=r(sn),LS={};function US(e,t){try{var r;return Xy(r=e[t].toString()).call(r,"[native code]")?"native":"non-native"}catch(n){return"untouchable"}}var VS=oS(mS="undefined"!=typeof window?[[null===(gS=window.RTCPeerConnection)||void 0===gS?void 0:gS.prototype,"RTCPeerConnection.prototype"],[window.RTCPeerConnection,"RTCPeerConnection"],[null===(yS=window.RTCDataChannel)||void 0===yS?void 0:yS.prototype,"RTCDataChannel.prototype"],[window.RTCDataChannel,"RTCDataChannel"],[null===(SS=window.MediaStreamTrack)||void 0===SS?void 0:SS.prototype,"MediaStreamTrack.prototype"],[window.MediaStreamTrack,"MediaStreamTrack"],[null===(bS=window.MediaStream)||void 0===bS?void 0:bS.prototype,"MediaStream.prototype"],[window.MediaStream,"MediaStream"],[null===(kS=window.HTMLAudioElement)||void 0===kS?void 0:kS.prototype,"HTMLAudioElement.prototype"],[null===(ES=window.HTMLVideoElement)||void 0===ES?void 0:ES.prototype,"HTMLVideoElement.prototype"],[null===(TS=window.HTMLMediaElement)||void 0===TS?void 0:TS.prototype,"HTMLMediaElement.prototype"],[null!==(IS=null===(RS=window.AudioContext)||void 0===RS?void 0:RS.prototype)&&void 0!==IS?IS:null===(AS=window.webkitAudioContext)||void 0===AS?void 0:AS.prototype,"AudioContext.prototype"],[null===(wS=window.BaseAudioContext)||void 0===wS?void 0:wS.prototype,"BaseAudioContext.prototype"],[null===(CS=window.AudioNode)||void 0===CS?void 0:CS.prototype,"AudioNode.prototype"],[window.navigator.mediaDevices,"navigator.mediaDevices"],[window.console,"console"]]:[]).call(mS,(function(e,t){var r=gy(t,2),n=r[0],i=r[1];return Fg(e).call(e,function(e,t){var r;if(!e)return[];var n=Ey(e);return qg(r=Ty(n).call(n,(function(t){if("peerIdentity"===t)return!1;try{return"function"==typeof e[t]||void 0===e[t]}catch(r){return!1}}))).call(r,(function(r){return{obj:e,prefix:t,attr:r}}))}(n,i))}),[]);"undefined"!=typeof window&&VS.push({obj:window.navigator.mediaDevices,prefix:"navigator.mediaDevices",attr:"getUserMedia"},{obj:window.navigator.mediaDevices,prefix:"navigator.mediaDevices",attr:"getDisplayMedia"},{obj:window.navigator.mediaDevices,prefix:"navigator.mediaDevices",attr:"enumerateDevices"},{obj:window.navigator.mediaDevices,prefix:"navigator.mediaDevices",attr:"getSupportedConstraints"});var FS,BS=my(VS);try{for(BS.s();!(FS=BS.n()).done;){var jS,HS=FS.value,GS=HS.obj,zS=HS.prefix,KS=HS.attr,WS=Fg(jS="".concat(zS,".")).call(jS,KS);LS[WS]=US(GS,KS)}}catch(jZ){BS.e(jZ)}finally{BS.f()}"undefined"!=typeof window&&(Xy(xS=window.location.search).call(xS,"_rtc_debug_")||(null===(OS=window.localStorage)||void 0===OS?void 0:OS.getItem("_rtc_debug_")))&&console.log("RTC_AMBULANCE",LS);var XS=qg(PS=Ty(DS=NS(LS)).call(DS,(function(e){var t=gy(e,2);return t[0],"non-native"===t[1]}))).call(PS,(function(e){var t=gy(e,2),r=t[0];return t[1],r}));MS(XS).length&&console.warn("RTC_AMBULANCE","have non-native code:\n",XS.join("\n"));var YS="\t\n\v\f\r \u2028\u2029\ufeff",qS=Y,JS=Sn,QS=YS,ZS=f("".replace),$S=RegExp("^["+QS+"]+"),eb=RegExp("(^|[^"+QS+"])["+QS+"]+$"),tb=function(e){return function(t){var r=JS(qS(t));return 1&e&&(r=ZS(r,$S,"")),2&e&&(r=ZS(r,eb,"$1")),r}},rb={start:tb(1),end:tb(2),trim:tb(3)},nb=i,ib=o,ob=f,ab=Sn,sb=rb.trim,cb=YS,ub=nb.parseInt,db=nb.Symbol,lb=db&&db.iterator,hb=/^[+-]?0x/i,pb=ob(hb.exec),vb=8!==ub(cb+"08")||22!==ub(cb+"0x16")||lb&&!ib((function(){ub(Object(lb))}))?function(e,t){var r=sb(ab(e));return ub(r,t>>>0||(pb(hb,r)?16:10))}:ub;wr({global:!0,forced:parseInt!==vb},{parseInt:vb});var _b=r(te.parseInt),fb={exports:{}},mb=o((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),gb=o,yb=ee,Sb=S,bb=mb,kb=Object.isExtensible,Eb=gb((function(){kb(1)}))||bb?function(e){return!!yb(e)&&((!bb||"ArrayBuffer"!==Sb(e))&&(!kb||kb(e)))}:kb,Tb=!o((function(){return Object.isExtensible(Object.preventExtensions({}))})),Ib=wr,Rb=f,Ab=Xr,wb=ee,Cb=Ze,xb=Qt.f,Ob=Xn,Pb=Jn,Db=Eb,Nb=Tb,Mb=!1,Lb=nt("meta"),Ub=0,Vb=function(e){xb(e,Lb,{value:{objectID:"O"+Ub++,weakData:{}}})},Fb=fb.exports={enable:function(){Fb.enable=function(){},Mb=!0;var e=Ob.f,t=Rb([].splice),r={};r[Lb]=1,e(r).length&&(Ob.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===Lb){t(n,i,1);break}return n},Ib({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Pb.f}))},fastKey:function(e,t){if(!wb(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!Cb(e,Lb)){if(!Db(e))return"F";if(!t)return"E";Vb(e)}return e[Lb].objectID},getWeakData:function(e,t){if(!Cb(e,Lb)){if(!Db(e))return!0;if(!t)return!1;Vb(e)}return e[Lb].weakData},onFreeze:function(e){return Nb&&Mb&&Db(e)&&!Cb(e,Lb)&&Vb(e),e}};Ab[Lb]=!0;var Bb=fb.exports,jb=wr,Hb=i,Gb=Bb,zb=o,Kb=fr,Wb=Kp,Xb=kv,Yb=A,qb=ee,Jb=K,Qb=Bi,Zb=Qt.f,$b=Vo.forEach,ek=C,tk=ro.set,rk=ro.getterFor,nk=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=Hb[e],c=s&&s.prototype,u={};if(ek&&Yb(s)&&(o||c.forEach&&!zb((function(){(new s).entries().next()})))){var d=(n=t((function(t,r){tk(Xb(t,d),{type:e,collection:new s}),Jb(r)||Wb(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,l=rk(e);$b(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"===e||"set"===e;!(e in c)||o&&"clear"===e||Kb(d,e,(function(r,n){var i=l(this).collection;if(!t&&o&&!qb(r))return"get"===e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||Zb(d,"size",{configurable:!0,get:function(){return l(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Gb.enable();return Qb(n,e,!1,!0),u[e]=n,jb({global:!0,forced:!0},u),o||r.setStrong(n,e,i),n},ik=vi,ok=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:ik(e,n,t[n],r);return e},ak=Wn,sk=fi,ck=ok,uk=Jt,dk=kv,lk=K,hk=Kp,pk=Mu,vk=Lu,_k=yv,fk=C,mk=Bb.fastKey,gk=ro.set,yk=ro.getterFor,Sk={getConstructor:function(e,t,r,n){var i=e((function(e,i){dk(e,o),gk(e,{type:t,index:ak(null),first:void 0,last:void 0,size:0}),fk||(e.size=0),lk(i)||hk(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=yk(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=mk(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),fk?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=mk(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key===t)return r};return ck(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,fk?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),fk?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=uk(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)}}),ck(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)}}),fk&&sk(o,"size",{configurable:!0,get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=yk(t),o=yk(n);pk(e,t,(function(e,t){gk(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)?vk("keys"===t?r.key:"values"===t?r.value:[r.key,r.value],!1):(e.target=void 0,vk(void 0,!0))}),r?"entries":"values",!r,!0),_k(t)}};nk("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Sk);var bk=te.Map,kk=function(e,t){return 1===t?function(t,r){return t[e](r)}:function(t,r,n){return t[e](r,n)}},Ek=kk,Tk=ae("Map"),Ik={Map:Tk,set:Ek("set",2),get:Ek("get",1),has:Ek("has",1),remove:Ek("delete",1),proto:Tk.prototype},Rk=wr,Ak=Oe,wk=Y,Ck=Kp,xk=Ik.Map,Ok=Ik.has,Pk=Ik.get,Dk=Ik.set,Nk=f([].push);Rk({target:"Map",stat:!0,forced:true},{groupBy:function(e,t){wk(e),Ak(t);var r=new xk,n=0;return Ck(e,(function(e){var i=t(e,n++);Ok(r,i)?Nk(Pk(r,i),e):Dk(r,i,[e])})),r}});var Mk=bk,Lk=Jt,Uk=P,Vk=Oe,Fk=Rv,Bk=K,jk=Kp,Hk=[].push,Gk=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return Fk(this),(t=void 0!==a)&&Vk(a),Bk(e)?new this:(r=[],t?(n=0,i=Lk(a,o>2?arguments[2]:void 0),jk(e,(function(e){Uk(Hk,r,i(e,n++))}))):jk(e,Hk,{that:r}),new this(r))};wr({target:"Map",stat:!0,forced:!0},{from:Gk});var zk=cs,Kk=function(){return new this(zk(arguments))};wr({target:"Map",stat:!0,forced:!0},{of:Kk});var Wk=Ae,Xk=function(e){if("object"==typeof e&&"size"in e&&"has"in e&&"get"in e&&"set"in e&&"delete"in e&&"entries"in e)return e;throw TypeError(Wk(e)+" is not a map")},Yk=Xk,qk=Ik.remove;wr({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=Yk(this),r=!0,n=0,i=arguments.length;n<i;n++)e=qk(t,arguments[n]),r=r&&e;return!!r}});var Jk=Xk,Qk=Ik.get,Zk=Ik.has,$k=Ik.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,t){var r,n,i=Jk(this);return Zk(i,e)?(r=Qk(i,e),"update"in t&&(r=t.update(r,e,i),$k(i,e,r)),r):(n=t.insert(e,i),$k(i,e,n),n)}});var eE=P,tE=function(e,t,r){for(var n,i,o=r?e:e.iterator,a=e.next;!(n=eE(a,o)).done;)if(void 0!==(i=t(n.value)))return i},rE=tE,nE=function(e,t,r){return r?rE(e.entries(),(function(e){return t(e[1],e[0])}),!0):e.forEach(t)},iE=Jt,oE=Xk,aE=nE;wr({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=oE(this),r=iE(e,arguments.length>1?arguments[1]:void 0);return!1!==aE(t,(function(e,n){if(!r(e,n,t))return!1}),!0)}});var sE=Jt,cE=Xk,uE=nE,dE=Ik.Map,lE=Ik.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=cE(this),r=sE(e,arguments.length>1?arguments[1]:void 0),n=new dE;return uE(t,(function(e,i){r(e,i,t)&&lE(n,i,e)})),n}});var hE=Jt,pE=Xk,vE=nE;wr({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=pE(this),r=hE(e,arguments.length>1?arguments[1]:void 0),n=vE(t,(function(e,n){if(r(e,n,t))return{value:e}}),!0);return n&&n.value}});var _E=Jt,fE=Xk,mE=nE;wr({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=fE(this),r=_E(e,arguments.length>1?arguments[1]:void 0),n=mE(t,(function(e,n){if(r(e,n,t))return{key:n}}),!0);return n&&n.key}});var gE=function(e,t){return e===t||e!=e&&t!=t},yE=Xk,SE=nE;wr({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return!0===SE(yE(this),(function(t){if(gE(t,e))return!0}),!0)}});var bE=P,kE=Kp,EE=A,TE=Oe,IE=Ik.Map;wr({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new(EE(this)?this:IE);TE(t);var n=TE(r.set);return kE(e,(function(e){bE(n,r,t(e),e)})),r}});var RE=Xk,AE=nE;wr({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){var t=AE(RE(this),(function(t,r){if(t===e)return{key:r}}),!0);return t&&t.key}});var wE=Jt,CE=Xk,xE=nE,OE=Ik.Map,PE=Ik.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=CE(this),r=wE(e,arguments.length>1?arguments[1]:void 0),n=new OE;return xE(t,(function(e,i){PE(n,r(e,i,t),e)})),n}});var DE=Jt,NE=Xk,ME=nE,LE=Ik.Map,UE=Ik.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=NE(this),r=DE(e,arguments.length>1?arguments[1]:void 0),n=new LE;return ME(t,(function(e,i){UE(n,i,r(e,i,t))})),n}});var VE=Xk,FE=Kp,BE=Ik.set;wr({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=VE(this),r=arguments.length,n=0;n<r;)FE(arguments[n++],(function(e,r){BE(t,e,r)}),{AS_ENTRIES:!0});return t}});var jE=Oe,HE=Xk,GE=nE,zE=TypeError;wr({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=HE(this),r=arguments.length<2,n=r?void 0:arguments[1];if(jE(e),GE(t,(function(i,o){r?(r=!1,n=i):n=e(n,i,o,t)})),r)throw zE("Reduce of empty map with no initial value");return n}});var KE=Jt,WE=Xk,XE=nE;wr({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=WE(this),r=KE(e,arguments.length>1?arguments[1]:void 0);return!0===XE(t,(function(e,n){if(r(e,n,t))return!0}),!0)}});var YE=Oe,qE=Xk,JE=TypeError,QE=Ik.get,ZE=Ik.has,$E=Ik.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=qE(this),n=arguments.length;YE(t);var i=ZE(r,e);if(!i&&n<3)throw JE("Updating absent value");var o=i?QE(r,e):YE(n>2?arguments[2]:void 0)(e,r);return $E(r,e,t(o,e,r)),r}});var eT=P,tT=Oe,rT=A,nT=rr,iT=TypeError,oT=function(e,t){var r,n=nT(this),i=tT(n.get),o=tT(n.has),a=tT(n.set),s=arguments.length>2?arguments[2]:void 0;if(!rT(t)&&!rT(s))throw iT("At least one callback required");return eT(o,n,e)?(r=eT(i,n,e),rT(t)&&(r=t(r),eT(a,n,e,r))):rT(s)&&(r=s(),eT(a,n,e,r)),r};wr({target:"Map",proto:!0,real:!0,forced:!0},{upsert:oT}),wr({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:oT});var aT=Mk,sT=r(aT),cT=r(aT),uT=r(Ld),dT=C,lT=f,hT=P,pT=o,vT=nn,_T=hi,fT=D,mT=qe,gT=z,yT=Object.assign,ST=Object.defineProperty,bT=lT([].concat),kT=!yT||pT((function(){if(dT&&1!==yT({b:1},yT(ST({},"a",{enumerable:!0,get:function(){ST(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!==yT({},e)[r]||vT(yT({},t)).join("")!==n}))?function(e,t){for(var r=mT(e),n=arguments.length,i=1,o=_T.f,a=fT.f;n>i;)for(var s,c=gT(arguments[i++]),u=o?bT(vT(c),o(c)):vT(c),d=u.length,l=0;d>l;)s=u[l++],dT&&!hT(a,c,s)||(r[s]=c[s]);return r}:yT,ET=kT;wr({target:"Object",stat:!0,arity:2,forced:Object.assign!==ET},{assign:ET});var TT=r(te.Object.assign),IT=wr,RT=E;w.f;var AT=Fr,wT=Sn,CT=Py,xT=Y,OT=Ny,PT=RT("".endsWith),DT=RT("".slice),NT=Math.min;IT({target:"String",proto:!0,forced:!OT("endsWith")},{endsWith:function(e){var t=wT(xT(this));CT(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:NT(AT(r),n),o=wT(e);return PT?PT(t,o,i):DT(t,i-o.length,i)===o}});var MT=qs("String").endsWith,LT=se,UT=MT,VT=String.prototype,FT=r((function(e){var t=e.endsWith;return"string"==typeof e||e===VT||LT(VT,e)&&t===VT.endsWith?UT:t})),BT=!0,jT=!0;function HT(e,t,r){var n=e.match(t);return n&&n.length>=r&&_b(n[r],10)}function GT(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 cT),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===MS(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},uT(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 zT(e){return"boolean"!=typeof e?new Error("Argument type: "+Wl(e)+". Please use a boolean."):(BT=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function KT(e){return"boolean"!=typeof e?new Error("Argument type: "+Wl(e)+". Please use a boolean."):(jT=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function WT(){if("object"===("undefined"==typeof window?"undefined":Wl(window))){if(BT)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function XT(e,t){jT&&console.warn(e+" is deprecated, please use "+t+" instead.")}function YT(e){return"[object Object]"===Object.prototype.toString.call(e)}function qT(e){var t;return YT(e)?oS(t=MS(e)).call(t,(function(t,r){var n=YT(e[r]),i=n?qT(e[r]):e[r],o=n&&!MS(i).length;return void 0===i||o?t:TT(t,ql({},r,i))}),{}):e}function JT(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),MS(t).forEach((function(n){FT(n).call(n,"Id")?JT(e,e.get(t[n]),r):FT(n).call(n,"Ids")&&t[n].forEach((function(t){JT(e,e.get(t),r)}))})))}function QT(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new cT;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&&JT(e,r,i)}))})),i}var ZT=wr,$T=Vo.find,eI="find",tI=!0;eI in[]&&Array(1)[eI]((function(){tI=!1})),ZT({target:"Array",proto:!0,forced:tI},{find:function(e){return $T(this,e,arguments.length>1?arguments[1]:void 0)}});var rI=qs("Array").find,nI=se,iI=rI,oI=Array.prototype,aI=r((function(e){var t=e.find;return e===oI||nI(oI,e)&&t===oI.find?iI:t})),sI=r(xg),cI=wr,uI=Wr.indexOf,dI=td,lI=E([].indexOf),hI=!!lI&&1/lI([1],1,-0)<0;cI({target:"Array",proto:!0,forced:hI||!dI("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return hI?lI(this,e,t)||0:uI(this,e,t)}});var pI=qs("Array").indexOf,vI=se,_I=pI,fI=Array.prototype,mI=function(e){var t=e.indexOf;return e===fI||vI(fI,e)&&t===fI.indexOf?_I:t},gI=r(mI),yI=r(mI),SI=Ae,bI=TypeError,kI=function(e,t){if(!delete e[t])throw bI("Cannot delete property "+SI(t)+" of "+SI(e))},EI=wr,TI=qe,II=Lr,RI=Pr,AI=jr,wI=fc,CI=gc,xI=xo,OI=ei,PI=kI,DI=Ws("splice"),NI=Math.max,MI=Math.min;EI({target:"Array",proto:!0,forced:!DI},{splice:function(e,t){var r,n,i,o,a,s,c=TI(this),u=AI(c),d=II(e,u),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=u-d):(r=l-2,n=MI(NI(RI(t),0),u-d)),CI(u+r-n),i=xI(c,n),o=0;o<n;o++)(a=d+o)in c&&OI(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]:PI(c,s);for(o=u;o>u-n+r;o--)PI(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]:PI(c,s);for(o=0;o<r;o++)c[o+d]=arguments[o+2];return wI(c,u-n+r),i}});var LI=qs("Array").splice,UI=se,VI=LI,FI=Array.prototype,BI=r((function(e){var t=e.splice;return e===FI||UI(FI,e)&&t===FI.splice?VI:t})),jI=r(eg),HI=r(dc),GI=WT;function zI(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==Wl(e)||e.mandatory||e.optional)return e;var t,r={};(MS(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===Wl(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()+sI(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=Fg(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(Gg(e)))&&"object"===Wl(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(Gg(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===Wl(e.video)){var a=e.video.facingMode;a=a&&("object"===Wl(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=Ty(t).call(t,(function(e){return"videoinput"===e.kind}));var r=aI(t).call(t,(function(e){return s.some((function(t){var r;return Xy(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&Xy(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),GI("chrome: "+Gg(e)),i(e)}));e.video=n(e.video)}return GI("chrome: "+Gg(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 jI.reject(o(e))}))}))}}}}function KI(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function WI(e){if("object"===Wl(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){uT(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=aI(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=aI(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 GT(e,"track",(function(e){return e.transceiver||uT(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function XI(e){if("object"===Wl(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||[],sI(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=yI(t=this._senders).call(t,e);-1!==i&&BI(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=aI(r=t._senders).call(r,(function(t){return t.track===e}));o&&BI(n=t._senders).call(n,yI(i=t._senders).call(i,o),1)}))}}else if("object"===Wl(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},uT(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 YI(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=sI(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 cT(qg(t=MS(e)).call(t,(function(t){return[t,e[t]]})))};if(arguments.length>=2){return t.apply(this,[function(e){i(s(a(e)))},n])}return new jI((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function qI(e){if("object"===Wl(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 QT(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}),GT(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 QT(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?jI.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():jI.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function JI(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},qg(e=MS(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===yI(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(aI(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=Ty(t=this.getSenders()).call(t,(function(e){return-1===yI(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Fg(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&&MS(this._shimmedLocalStreams).forEach((function(r){var n,i,o=yI(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&BI(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function QI(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return JI(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},qg(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(aI(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=sI([]).call(arguments,1);if(1!==s.length||!aI(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");if(aI(i=this.getSenders()).call(i,(function(e){return e.track===t})))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var c=this._streams[r.id];if(c)c.addTrack(t),jI.resolve().then((function(){a.dispatchEvent(new Event("negotiationneeded"))}));else{var u=new e.MediaStream([t]);this._streams[r.id]=u,this._reverseStreams[u.id]=r,this.addStream(u)}return aI(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=ql({},t,(function(){var e=this,t=arguments;return arguments.length&&"function"==typeof arguments[0]?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]=(e=this,r=(t=arguments[0]).sdp,MS(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})),o.apply(this,arguments)):o.apply(this,arguments);var e,t,r};var a=HI(e.RTCPeerConnection.prototype,"localDescription");uT(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||{},MS(this._streams).forEach((function(n){var i;aI(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 MS(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 ZI(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=ql({},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 $I(e,t){GT(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 eR=Object.freeze({__proto__:null,fixNegotiationNeeded:$I,shimAddTrackRemoveTrack:QI,shimAddTrackRemoveTrackWithNative:JI,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"))},shimGetSendersWithDtmf:XI,shimGetStats:YI,shimGetUserMedia:zI,shimMediaStream:KI,shimOnTrack:WI,shimPeerConnection:ZI,shimSenderReceiverGetStats:qI});function tR(e){return function(e){if(Qg(e))return _y(e)}(e)||function(e){if(void 0!==Al&&null!=Jg(e)||null!=e["@@iterator"])return vy(e)}(e)||fy(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 rR=i,nR=o,iR=Sn,oR=rb.trim,aR=YS,sR=f("".charAt),cR=rR.parseFloat,uR=rR.Symbol,dR=uR&&uR.iterator,lR=1/cR(aR+"-0")!=-1/0||dR&&!nR((function(){cR(Object(dR))}))?function(e){var t=oR(iR(e)),r=cR(t);return 0===r&&"-"===sR(t,0)?-0:r}:cR;wr({global:!0,forced:parseFloat!==lR},{parseFloat:lR});var hR=r(te.parseFloat);function pR(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){XT("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"===Wl(e)&&"object"===Wl(e.audio)&&(e=JSON.parse(Gg(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"===Wl(e)&&(e=JSON.parse(Gg(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function vR(e){"object"===Wl(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&uT(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function _R(e,t){if("object"===Wl(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=ql({},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=sI(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,TT({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function fR(e){if("object"===Wl(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):jI.resolve(new cT)}}}function mR(e){if("object"===Wl(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}),GT(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function gR(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;XT("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&Xy(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function yR(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function SR(e){if("object"===Wl(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=tR(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&&!(hR(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(hR(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===MS(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 bR(e){if("object"===Wl(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=Fg(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function kR(e){if("object"===Wl(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?jI.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function ER(e){if("object"===Wl(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?jI.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var TR=Object.freeze({__proto__:null,shimAddTransceiver:SR,shimCreateAnswer:ER,shimCreateOffer:kR,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,jI.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})},shimGetParameters:bR,shimGetUserMedia:pR,shimOnTrack:vR,shimPeerConnection:_R,shimRTCDataChannel:yR,shimReceiverGetStats:mR,shimRemoveStream:gR,shimSenderGetStats:fR});function IR(e){if("object"===Wl(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=[]),Xy(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?Xy(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=yI(t=this._localStreams).call(t,e);if(-1!==i){BI(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){Xy(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function RR(e){if("object"===Wl(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){uT(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=[]),!Xy(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=[]),!(yI(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 AR(e){if("object"===Wl(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),jI.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),jI.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),jI.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),jI.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),jI.resolve()):n},t.addIceCandidate=s}}function wR(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(CR(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function CR(e){return e&&void 0!==e.video?TT({},e,{video:qT(e.video)}):e}function xR(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")?(XT("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(Gg(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&&uT(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function OR(e){"object"===Wl(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&uT(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function PR(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=aI(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=aI(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 DR(e){"object"!==Wl(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var NR=Object.freeze({__proto__:null,shimAudioContext:DR,shimCallbacksAPI:AR,shimConstraints:CR,shimCreateOfferLegacy:PR,shimGetUserMedia:wR,shimLocalStreamsAPI:IR,shimRTCIceServerUrls:xR,shimRemoteStreamsAPI:RR,shimTrackEventTransceiver:OR}),MR=Uc.PROPER,LR=o,UR=YS,VR=rb.trim;wr({target:"String",proto:!0,forced:function(e){return LR((function(){return!!UR[e]()||"
"!=="
"[e]()||MR&&UR[e].name!==e}))}("trim")},{trim:function(){return VR(this)}});var FR,BR,jR=qs("String").trim,HR=se,GR=jR,zR=String.prototype,KR=r((function(e){var t=e.trim;return"string"==typeof e||e===zR||HR(zR,e)&&t===zR.trim?GR:t})),WR={exports:{}};FR=WR,(BR={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=BR.generateIdentifier(),BR.splitLines=function(e){var t;return qg(t=KR(e).call(e).split("\n")).call(t,(function(e){return KR(e).call(e)}))},BR.splitSections=function(e){var t=e.split("\nm=");return qg(t).call(t,(function(e,t){var r;return KR(r=t>0?"m="+e:e).call(r)+"\r\n"}))},BR.getDescription=function(e){var t=BR.splitSections(e);return t&&t[0]},BR.getMediaSections=function(e){var t=BR.splitSections(e);return t.shift(),t},BR.matchPrefix=function(e,t){var r;return Ty(r=BR.splitLines(e)).call(r,(function(e){return 0===yI(e).call(e,t)}))},BR.parseCandidate=function(e){for(var t,r={foundation:(t=0===yI(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:_b(t[3],10),ip:t[4],address:t[4],port:_b(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=_b(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},BR.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(" ")},BR.parseIceOptions=function(e){return e.substr(14).split(" ")},BR.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:_b(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=_b(t[1],10),r.channels=3===t.length?_b(t[2],10):1,r.numChannels=r.channels,r},BR.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"},BR.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:_b(r[0],10),direction:yI(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},BR.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},BR.parseFmtp=function(e){for(var t,r={},n=e.substr(yI(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=KR(o=n[i]).call(o).split("="),r[KR(a=t[0]).call(a)]=t[1]}return r},BR.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&MS(e.parameters).length){var n=[];MS(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},BR.parseRtcpFb=function(e){var t=e.substr(yI(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},BR.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},BR.parseSsrcMedia=function(e){var t=yI(e).call(e," "),r={ssrc:_b(e.substr(7,t-7),10)},n=yI(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},BR.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:qg(t).call(t,(function(e){return _b(e,10)}))}},BR.getMid=function(e){var t=BR.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},BR.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},BR.getDtlsParameters=function(e,t){var r=BR.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:qg(r).call(r,BR.parseFingerprint)}},BR.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},BR.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:_b(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:sI(t).call(t,3)}},BR.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===Wl(e.keyParams)?BR.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},BR.parseCryptoKeyParams=function(e){if(0!==yI(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}},BR.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},BR.getCryptoParameters=function(e,t){var r=BR.matchPrefix(e+t,"a=crypto:");return qg(r).call(r,BR.parseCryptoLine)},BR.getIceParameters=function(e,t){var r=BR.matchPrefix(e+t,"a=ice-ufrag:")[0],n=BR.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},BR.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},BR.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=BR.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=BR.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=BR.parseRtpMap(o),c=BR.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=c.length?BR.parseFmtp(c[0]):{},s.rtcpFeedback=qg(a=BR.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,BR.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return BR.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(BR.parseExtmap(e))})),t},BR.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=qg(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+=BR.writeRtpMap(e),n+=BR.writeFmtp(e),n+=BR.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+=BR.writeExtmap(e)})),n},BR.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],c=BR.parseRtpParameters(e),u=-1!==yI(t=c.fecMechanisms).call(t,"RED"),d=-1!==yI(r=c.fecMechanisms).call(r,"ULPFEC"),l=Ty(n=qg(i=BR.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return BR.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=l.length>0&&l[0].ssrc,p=qg(o=BR.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return qg(t).call(t,(function(e){return _b(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:_b(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),u&&((t=JSON.parse(Gg(t))).fec={ssrc:h,mechanism:d?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var v,_,f=BR.matchPrefix(e,"b=");return f.length&&(f=0===yI(v=f[0]).call(v,"b=TIAS:")?_b(f[0].substr(7),10):0===yI(_=f[0]).call(_,"b=AS:")?1e3*_b(f[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=f}))),s},BR.parseRtcpParameters=function(e){var t,r,n={},i=Ty(t=qg(r=BR.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return BR.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=BR.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=BR.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},BR.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},BR.parseMsid=function(e){var t,r,n,i=BR.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=Ty(t=qg(r=BR.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return BR.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},BR.parseSctpDescription=function(e){var t,r=BR.parseMLine(e),n=BR.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=_b(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=BR.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:_b(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=BR.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:_b(a[0],10),protocol:a[1],maxMessageSize:t}}},BR.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("")},BR.generateSessionId=function(){return Math.random().toString().substr(2,21)},BR.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||BR.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},BR.getDirection=function(e,t){for(var r=BR.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?BR.getDirection(t):"sendrecv"},BR.getKind=function(e){return BR.splitLines(e)[0].split(" ")[0].substr(2)},BR.isRejected=function(e){return"0"===e.split(" ",2)[1]},BR.parseMLine=function(e){var t=BR.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:_b(t[1],10),protocol:t[2],fmt:sI(t).call(t,3).join(" ")}},BR.parseOLine=function(e){var t=BR.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:_b(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},BR.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=BR.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},FR.exports=BR;var XR=WR.exports,YR=r(XR),qR=e({__proto__:null,default:YR},[XR]);function JR(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===Wl(e)&&e.candidate&&0===yI(r=e.candidate).call(r,"a=")&&((e=JSON.parse(Gg(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=YR.parseCandidate(e.candidate),o=TT(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,GT(e,"icecandidate",(function(t){return t.candidate&&uT(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function QR(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||GT(e,"icecandidate",(function(e){if(e.candidate){var t=YR.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function ZR(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||uT(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e,n;(this._sctp=null,"chrome"===t.browser&&t.version>=76)&&("plan-b"===this.getConfiguration().sdpSemantics&&uT(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0}));if(function(e){if(!e||!e.sdp)return!1;var t=YR.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=YR.parseMLine(e);return r&&"application"===r.kind&&-1!==yI(t=r.protocol).call(t,"SCTP")}))}(arguments[0])){var i,o=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=_b(t[1],10);return r!=r?-1:r}(arguments[0]),a=(e=o,n=65536,"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),n),s=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=YR.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=_b(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n}(arguments[0],o);i=0===a&&0===s?Number.POSITIVE_INFINITY:0===a||0===s?Math.max(a,s):Math.min(a,s);var c={};uT(c,"maxMessageSize",{get:function(){return i}}),this._sctp=c}return r.apply(this,arguments)}}}function $R(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},GT(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 eA(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;uT(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),uT(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 tA(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!==yI(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=Ty(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==KR(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 rA(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?jI.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),jI.resolve())})}}function nA(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"!==Wl(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"}return t.sdp||"offer"!==t.type&&"answer"!==t.type?r.apply(this,[t]):("offer"===t.type?this.createOffer:this.createAnswer).apply(this).then((function(t){return r.apply(e,[t])}))})}}var iA=Object.freeze({__proto__:null,removeExtmapAllowMixed:tA,shimAddIceCandidateNullOrEmpty:rA,shimConnectionState:eA,shimMaxMessageSize:ZR,shimParameterlessSetLocalDescription:nA,shimRTCIceCandidate:JR,shimRTCIceCandidateRelayProtocol:QR,shimSendThrowTypeError:$R});if(function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).window,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},r=WT,n=function(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=HT(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=HT(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=HT(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),i={browserDetails:n,commonShim:iA,extractVersion:HT,disableLog:zT,disableWarnings:KT,sdp:qR};switch(n.browser){case"chrome":if(!eR||!ZI||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),i;if(null===n.version)return r("Chrome shim can not determine version, not shimming."),i;r("adapter.js shimming chrome."),i.browserShim=eR,rA(e,n),nA(e),zI(e,n),KI(e),ZI(e,n),WI(e),QI(e,n),XI(e),YI(e),qI(e),$I(e,n),JR(e),QR(e),eA(e),ZR(e,n),$R(e),tA(e,n);break;case"firefox":if(!TR||!_R||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),i;r("adapter.js shimming firefox."),i.browserShim=TR,rA(e,n),nA(e),pR(e,n),_R(e,n),vR(e),gR(e),fR(e),mR(e),yR(e),SR(e),bR(e),kR(e),ER(e),JR(e),eA(e),ZR(e,n),$R(e);break;case"safari":if(!NR||!t.shimSafari)return r("Safari shim is not included in this adapter release."),i;r("adapter.js shimming safari."),i.browserShim=NR,rA(e,n),nA(e),xR(e),PR(e),AR(e),IR(e),RR(e),OR(e),wR(e),DR(e),JR(e),QR(e),ZR(e,n),$R(e),tA(e,n);break;default:r("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var oA=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=oA.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 aA(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var sA=Ze,cA=function(e){return void 0!==e&&(sA(e,"value")||sA(e,"writable"))},uA=P,dA=ee,lA=rr,hA=cA,pA=w,vA=Wc;wr({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return lA(t)===o?t[r]:(n=pA.f(t,r))?hA(n)?n.value:void 0===n.get?void 0:uA(n.get,o):dA(i=vA(t))?e(i,r,o):void 0}});var _A=te.Reflect.get,fA=r(_A),mA=f,gA=Oe,yA=ee,SA=Ze,bA=cs,kA=a,EA=Function,TA=mA([].concat),IA=mA([].join),RA={},AA=kA?EA.bind:function(e){var t=gA(this),r=t.prototype,n=bA(arguments,1),i=function(){var r=TA(n,bA(arguments));return this instanceof i?function(e,t,r){if(!SA(RA,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";RA[t]=EA("C,a","return new C("+IA(n,",")+")")}return RA[t](e,r)}(t,r.length,r):t.apply(e,r)};return yA(r)&&(i.prototype=r),i},wA=AA;wr({target:"Function",proto:!0,forced:Function.bind!==wA},{bind:wA});var CA=qs("Function").bind,xA=se,OA=CA,PA=Function.prototype,DA=r((function(e){var t=e.bind;return e===PA||xA(PA,e)&&t===PA.bind?OA:t}));function NA(e){var t;return(NA=Xh?DA(t=Kh).call(t):function(e){return e.__proto__||Kh(e)})(e)}function MA(){var e;"undefined"!=typeof Reflect&&fA?MA=DA(e=fA).call(e):MA=function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=NA(e)););return e}(e,t);if(n){var i=lc(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return MA.apply(this,arguments)}function LA(e,t){var r;return(LA=Xh?DA(r=Xh).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function UA(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=jh(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Ud(e,"prototype",{writable:!1}),t&&LA(e,t)}var VA=wr,FA=l,BA=AA,jA=Rv,HA=rr,GA=ee,zA=Wn,KA=o,WA=ae("Reflect","construct"),XA=Object.prototype,YA=[].push,qA=KA((function(){function e(){}return!(WA((function(){}),[],e)instanceof e)})),JA=!KA((function(){WA((function(){}))})),QA=qA||JA;VA({target:"Reflect",stat:!0,forced:QA,sham:QA},{construct:function(e,t){jA(e),HA(t);var r=arguments.length<3?e:jA(arguments[2]);if(JA&&!qA)return WA(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 FA(YA,n,t),new(FA(BA,e,n))}var i=r.prototype,o=zA(GA(i)?i:XA),a=FA(e,o,t);return GA(a)?a:o}});var ZA=r(te.Reflect.construct);function $A(){if("undefined"==typeof Reflect||!ZA)return!1;if(ZA.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(ZA(Boolean,[],(function(){}))),!0}catch(e){return!1}}function ew(e){var t=$A();return function(){var r,n=NA(e);if(t){var i=NA(this).constructor;r=ZA(n,arguments,i)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===Wl(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return aA(e)}(this,r)}}var tw=qs("Array").values,rw=mn,nw=Ze,iw=se,ow=tw,aw=Array.prototype,sw={DOMTokenList:!0,NodeList:!0},cw=r((function(e){var t=e.values;return e===aw||iw(aw,e)&&t===aw.values||nw(sw,rw(e))?ow:t})),uw=ai,dw=Math.floor,lw=function(e,t){var r=e.length,n=dw(r/2);return r<8?hw(e,t):pw(e,lw(uw(e,0,n),t),lw(uw(e,n),t),t)},hw=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},pw=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},vw=lw,_w=ce.match(/firefox\/(\d+)/i),fw=!!_w&&+_w[1],mw=/MSIE|Trident/.test(ce),gw=ce.match(/AppleWebKit\/(\d+)\./),yw=!!gw&&+gw[1],Sw=wr,bw=f,kw=Oe,Ew=qe,Tw=jr,Iw=kI,Rw=Sn,Aw=o,ww=vw,Cw=td,xw=fw,Ow=mw,Pw=_e,Dw=yw,Nw=[],Mw=bw(Nw.sort),Lw=bw(Nw.push),Uw=Aw((function(){Nw.sort(void 0)})),Vw=Aw((function(){Nw.sort(null)})),Fw=Cw("sort"),Bw=!Aw((function(){if(Pw)return Pw<70;if(!(xw&&xw>3)){if(Ow)return!0;if(Dw)return Dw<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++)Nw.push({k:t+n,v:r})}for(Nw.sort((function(e,t){return t.v-e.v})),n=0;n<Nw.length;n++)t=Nw[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));Sw({target:"Array",proto:!0,forced:Uw||!Vw||!Fw||!Bw},{sort:function(e){void 0!==e&&kw(e);var t=Ew(this);if(Bw)return void 0===e?Mw(t):Mw(t,e);var r,n,i=[],o=Tw(t);for(n=0;n<o;n++)n in t&&Lw(i,t[n]);for(ww(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:Rw(t)>Rw(r)?1:-1}}(e)),r=Tw(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)Iw(t,n++);return t}});var jw=qs("Array").sort,Hw=se,Gw=jw,zw=Array.prototype,Kw=r((function(e){var t=e.sort;return e===zw||Hw(zw,e)&&t===zw.sort?Gw:t})),Ww=wr,Xw=Vo.findIndex,Yw="findIndex",qw=!0;Yw in[]&&Array(1)[Yw]((function(){qw=!1})),Ww({target:"Array",proto:!0,forced:qw},{findIndex:function(e){return Xw(this,e,arguments.length>1?arguments[1]:void 0)}});var Jw=qs("Array").findIndex,Qw=se,Zw=Jw,$w=Array.prototype,eC=r((function(e){var t=e.findIndex;return e===$w||Qw($w,e)&&t===$w.findIndex?Zw:t})),tC=wr,rC=E;w.f;var nC=Fr,iC=Sn,oC=Py,aC=Y,sC=Ny,cC=rC("".startsWith),uC=rC("".slice),dC=Math.min;tC({target:"String",proto:!0,forced:!sC("startsWith")},{startsWith:function(e){var t=iC(aC(this));oC(e);var r=nC(dC(arguments.length>1?arguments[1]:void 0,t.length)),n=iC(e);return cC?cC(t,n,r):uC(t,r,r+n.length)===n}});var lC=qs("String").startsWith,hC=se,pC=lC,vC=String.prototype,_C=r((function(e){var t=e.startsWith;return"string"==typeof e||e===vC||hC(vC,e)&&t===vC.startsWith?pC:t})),fC=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_EXCEED_QPS="USER_MESSAGE_EXCEED_QPS",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e.SUBTITLE_ALREADY_ON="SUBTITLE_ALREADY_ON",e.SUBTITLE_NOT_TURNED_ON="SUBTITLE_NOT_TURNED_ON",e.SUBTITLE_ERR_POSTPROCESS="SUBTITLE_ERR_POSTPROCESS",e.SUBTITLE_ERR_CONNECTION_ERROR="SUBTITLE_ERR_CONNECTION_ERROR",e.SUBTITLE_ERR_PROCESS_ERROR="SUBTITLE_ERR_PROCESS_ERROR",e.SUBTITLE_ERR_UNKNOWN="SUBTITLE_ERR_UNKNOWN",e.UNEXPECTED_INVOKE_FORWARD_STREAM="UNEXPECTED_INVOKE_FORWARD_STREAM",e.ROOM_FORBIDDEN="ROOM_FORBIDDEN",e.USER_FORBIDDEN="USER_FORBIDDEN",e}(fC||{}),mC=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}(mC||{});function gC(e,t,r){var n;$A()?gC=DA(n=ZA).call(n):gC=function(e,t,r){var n=[null];xc(n).apply(n,t);var i=new(DA(Function).apply(e,n));return r&&LA(i,r.prototype),i};return gC.apply(null,arguments)}function yC(e){var t="function"==typeof sT?new sT:void 0;return yC=function(e){if(null===e||(r=e,-1===gI(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 gC(e,arguments,NA(this).constructor)}return i.prototype=jh(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),LA(i,e)},yC(e)}var SC=r(Wh),bC=function(e){UA(r,e);var t=ew(r);function r(e,n,i){var o;return Fh(this,r),ql(aA(o=t.call(this,n)),"code",void 0),ql(aA(o),"message",void 0),ql(aA(o),"error",void 0),o.code=e,o.message=n,o.error=i,SC(aA(o),r.prototype),o}return Vh(r,[{key:"toString",value:function(){var e;return Fg(e="SDKError: ".concat(this.code," ")).call(e,this.message)}}]),r}(yC(Error)),kC=Pr,EC=Sn,TC=Y,IC=RangeError,RC=f,AC=Fr,wC=Sn,CC=function(e){var t=EC(TC(this)),r="",n=kC(e);if(n<0||n===1/0)throw IC("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},xC=Y,OC=RC(CC),PC=RC("".slice),DC=Math.ceil,NC=function(e){return function(t,r,n){var i,o,a=wC(xC(t)),s=AC(r),c=a.length,u=void 0===n?" ":wC(n);return s<=c||""===u?a:((o=OC(u,DC((i=s-c)/u.length))).length>i&&(o=PC(o,0,i)),e?a+o:o+a)}},MC={start:NC(!1),end:NC(!0)},LC=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(ce),UC=MC.end;wr({target:"String",proto:!0,forced:LC},{padEnd:function(e){return UC(this,e,arguments.length>1?arguments[1]:void 0)}});var VC=qs("String").padEnd,FC=se,BC=VC,jC=String.prototype,HC=r((function(e){var t=e.padEnd;return"string"==typeof e||e===jC||FC(jC,e)&&t===jC.padEnd?BC:t})),GC=vb;wr({target:"Number",stat:!0,forced:Number.parseInt!==GC},{parseInt:GC});var zC=r(te.Number.parseInt),KC=r(py),WC=r(dg),XC=Math.log,YC=Math.LOG10E;wr({target:"Math",stat:!0},{log10:Math.log10||function(e){return XC(e)*YC}});var qC,JC=r(te.Math.log10),QC=qs("Array").keys,ZC=mn,$C=Ze,ex=se,tx=QC,rx=Array.prototype,nx={DOMTokenList:!0,NodeList:!0},ix=r((function(e){var t=e.keys;return e===rx||ex(rx,e)&&t===rx.keys||$C(nx,ZC(e))?tx:t})),ox=new Uint8Array(16);function ax(){if(!qC&&!(qC="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 qC(ox)}var sx=/^(?:[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;for(var cx=[],ux=0;ux<256;++ux)cx.push((ux+256).toString(16).substr(1));function dx(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(cx[e[t+0]]+cx[e[t+1]]+cx[e[t+2]]+cx[e[t+3]]+"-"+cx[e[t+4]]+cx[e[t+5]]+"-"+cx[e[t+6]]+cx[e[t+7]]+"-"+cx[e[t+8]]+cx[e[t+9]]+"-"+cx[e[t+10]]+cx[e[t+11]]+cx[e[t+12]]+cx[e[t+13]]+cx[e[t+14]]+cx[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&sx.test(e)}(r))throw TypeError("Stringified UUID is invalid");return r}function lx(e,t,r){var n=(e=e||{}).random||(e.rng||ax)();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 dx(n)}var hx=function(){return"undefined"==typeof window},px=function(){return lx()},vx=function(e){return"number"==typeof e},_x=function(e){var t;return Xy(t=Function.prototype.toString.call(e)).call(t,"[native code]")};function fx(e){return null==e?"undefined | null":"string"==typeof e?e:Gg({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function mx(e){return null==e?"undefined | null":"string"==typeof e?e:Gg({id:e.id,active:e.active})}function gx(e){return null==e?"undefined | null":"string"==typeof e?e:Gg({track:fx(e.track)})}function yx(e){return null==e?"undefined | null":"string"==typeof e?e:Gg({track:fx(e.track)})}function Sx(e){return null==e?"undefined | null":"string"==typeof e?e:Gg({currentDirection:e.currentDirection,direction:e.direction,mid:e.mid,stopped:e.stopped,receiver:yx(e.receiver),sender:gx(e.sender)})}var bx="@byted/ve-rtc",kx="@byted/ve-rtc-cache-size",Ex=function(){function e(){Fh(this,e),ql(this,"storeKey",void 0),ql(this,"logLevel",void 0),ql(this,"LogfileSize",void 0),ql(this,"db",void 0),ql(this,"logId",void 0),ql(this,"cacheLog",void 0),ql(this,"cachedSize",void 0),ql(this,"preCacheTime",void 0),ql(this,"timer",void 0),ql(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 Vh(e,[{key:"_createStore",value:function(){var e=this;if(!hx()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(bx);try{localStorage.removeItem(kx)}catch(BZ){}},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(kx);if(t)this.cachedSize=Number(t);else cw(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(BZ){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(kx,"".concat(this.cachedSize))}catch(BZ){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(bx,e).objectStore(bx)}},{key:"set",value:function(e){var t=this;return new jI((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Fg(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=Fg(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Fg(s=Fg(c="".concat(l?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(Fg(u="".concat(l)).call(u,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Fg(d="".concat(t.cacheLog)).call(d,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(jZ){var p;if(!e)return n(jZ);t.cacheLog+=Fg(p="\n\n".concat(t.logId,": ")).call(p,e),t.logId++,n(jZ)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Fg(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new jI((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 jI((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 ix(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 jI((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 jI((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}(),Tx=new Ex,Ix=MC.start;wr({target:"String",proto:!0,forced:LC},{padStart:function(e){return Ix(this,e,arguments.length>1?arguments[1]:void 0)}});var Rx=qs("String").padStart,Ax=se,wx=Rx,Cx=String.prototype,xx=r((function(e){var t=e.padStart;return"string"==typeof e||e===Cx||Ax(Cx,e)&&t===Cx.padStart?wx:t})),Ox=function(){function e(){Fh(this,e),ql(this,"_all",{})}return Vh(e,[{key:"on",value:function(e,t){var r=this._all[e];r?r.push(t):this._all[e]=[t]}},{key:"once",value:function(e,t){var r=this;this.on(e,(function n(){t.apply(void 0,arguments),r.off(e,n)}))}},{key:"off",value:function(e,t){var r=this._all[e];null==r||BI(r).call(r,yI(r).call(r,t)>>>0,1)}},{key:"emit",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i=this._all[e];null==i||sI(i).call(i).forEach((function(e){return e.apply(void 0,r)}))}},{key:"safeEmit",value:function(e){try{for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return this.emit.apply(this,Fg(t=[e]).call(t,n))}catch(BZ){console.error(BZ)}}},{key:"destroy",value:function(){this._all={}}}]),e}(),Px=["UPLOAD_CONSOLE_LENGTH_CUT","UPLOAD_REPORT_LIMIT"];var Dx=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"config",{UPLOAD_CONSOLE_ON:!1,UPLOAD_CONSOLE_LENGTH_CUT:200,UPLOAD_REPORT_LIMIT:45e4,ENABLE_REPORT_IDB_BUFFER:!1}),n}return Vh(r,[{key:"setParameter",value:function(e,t){if(function(e){return Xy(Px).call(Px,e)}(e))try{var r=Number(t);if(Number.isNaN(r))return;this.config[e]=r}catch(i){var n;return void console.warn(Fg(n="Cannot convert core lib parameter ".concat(e,":")).call(n,t," into number"))}else this.config[e]=t;this.emit(e,this.config[e])}},{key:"getParameter",value:function(e){return this.config[e]}},{key:"getKeys",value:function(){return MS(this.config)}}]),r}(Ox),Nx=new Dx,Mx=io,Lx=jr,Ux=gc,Vx=Jt,Fx=function(e,t,r,n,i,o,a,s){for(var c,u,d=i,l=0,h=!!a&&Vx(a,s);l<n;)l in r&&(c=h?h(r[l],l,t):r[l],o>0&&Mx(c)?(u=Lx(c),d=Fx(e,t,c,u,d,o-1)-1):(Ux(d+1),e[d]=c),d++),l++;return d},Bx=Fx,jx=qe,Hx=jr,Gx=Pr,zx=xo;wr({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=jx(this),r=Hx(t),n=zx(t,0);return n.length=Bx(n,t,t,r,0,void 0===e?1:Gx(e)),n}});var Kx=qs("Array").flat,Wx=se,Xx=Kx,Yx=Array.prototype,qx=r((function(e){var t=e.flat;return e===Yx||Wx(Yx,e)&&t===Yx.flat?Xx:t})),Jx={};!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=sI(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==Wl(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 Fg([]).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)}(Jx);var Qx={},Zx={},$x={},eO=Jx,tO=0,rO=1;function nO(e){for(var t=e.length;--t>=0;)e[t]=0}var iO=0,oO=29,aO=256,sO=aO+1+oO,cO=30,uO=19,dO=2*sO+1,lO=15,hO=16,pO=7,vO=256,_O=16,fO=17,mO=18,gO=[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],yO=[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],SO=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],bO=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],kO=new Array(2*(sO+2));nO(kO);var EO=new Array(2*cO);nO(EO);var TO=new Array(512);nO(TO);var IO=new Array(256);nO(IO);var RO=new Array(oO);nO(RO);var AO,wO,CO,xO=new Array(cO);function OO(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 PO(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function DO(e){return e<256?TO[e]:TO[256+(e>>>7)]}function NO(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function MO(e,t,r){e.bi_valid>hO-r?(e.bi_buf|=t<<e.bi_valid&65535,NO(e,e.bi_buf),e.bi_buf=t>>hO-e.bi_valid,e.bi_valid+=r-hO):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function LO(e,t,r){MO(e,r[2*t],r[2*t+1])}function UO(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function VO(e,t,r){var n,i,o=new Array(lO+1),a=0;for(n=1;n<=lO;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]=UO(o[s]++,s))}}function FO(e){var t;for(t=0;t<sO;t++)e.dyn_ltree[2*t]=0;for(t=0;t<cO;t++)e.dyn_dtree[2*t]=0;for(t=0;t<uO;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*vO]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function BO(e){e.bi_valid>8?NO(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 jO(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 HO(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&jO(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!jO(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function GO(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?LO(e,i,t):(LO(e,(o=IO[i])+aO+1,t),0!==(a=gO[o])&&MO(e,i-=RO[o],a),LO(e,o=DO(--n),r),0!==(a=yO[o])&&MO(e,n-=xO[o],a))}while(s<e.last_lit);LO(e,vO,t)}function zO(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=dO,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--)HO(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],HO(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++,HO(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,_=0;for(o=0;o<=lO;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<dO;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>v&&(o=v,_++),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!==_){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]--,_-=2}while(_>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),VO(o,u,e.bl_count)}function KO(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[2*_O]++):s<=10?e.bl_tree[2*fO]++:e.bl_tree[2*mO]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function WO(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{LO(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(LO(e,i,e.bl_tree),s--),LO(e,_O,e.bl_tree),MO(e,s-3,2)):s<=10?(LO(e,fO,e.bl_tree),MO(e,s-3,3)):(LO(e,mO,e.bl_tree),MO(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}nO(xO);var XO=!1;function YO(e,t,r,n){MO(e,(iO<<1)+(n?1:0),3),function(e,t,r,n){BO(e),n&&(NO(e,r),NO(e,~r)),eO.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}$x._tr_init=function(e){XO||(!function(){var e,t,r,n,i,o=new Array(lO+1);for(r=0,n=0;n<oO-1;n++)for(RO[n]=r,e=0;e<1<<gO[n];e++)IO[r++]=n;for(IO[r-1]=n,i=0,n=0;n<16;n++)for(xO[n]=i,e=0;e<1<<yO[n];e++)TO[i++]=n;for(i>>=7;n<cO;n++)for(xO[n]=i<<7,e=0;e<1<<yO[n]-7;e++)TO[256+i++]=n;for(t=0;t<=lO;t++)o[t]=0;for(e=0;e<=143;)kO[2*e+1]=8,e++,o[8]++;for(;e<=255;)kO[2*e+1]=9,e++,o[9]++;for(;e<=279;)kO[2*e+1]=7,e++,o[7]++;for(;e<=287;)kO[2*e+1]=8,e++,o[8]++;for(VO(kO,sO+1,o),e=0;e<cO;e++)EO[2*e+1]=5,EO[2*e]=UO(e,5);AO=new OO(kO,gO,aO+1,sO,lO),wO=new OO(EO,yO,0,cO,lO),CO=new OO(new Array(0),SO,0,uO,pO)}(),XO=!0),e.l_desc=new PO(e.dyn_ltree,AO),e.d_desc=new PO(e.dyn_dtree,wO),e.bl_desc=new PO(e.bl_tree,CO),e.bi_buf=0,e.bi_valid=0,FO(e)},$x._tr_stored_block=YO,$x._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 tO;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return rO;for(t=32;t<aO;t++)if(0!==e.dyn_ltree[2*t])return rO;return tO}(e)),zO(e,e.l_desc),zO(e,e.d_desc),a=function(e){var t;for(KO(e,e.dyn_ltree,e.l_desc.max_code),KO(e,e.dyn_dtree,e.d_desc.max_code),zO(e,e.bl_desc),t=uO-1;t>=3&&0===e.bl_tree[2*bO[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?YO(e,t,r,n):4===e.strategy||o===i?(MO(e,2+(n?1:0),3),GO(e,kO,EO)):(MO(e,4+(n?1:0),3),function(e,t,r,n){var i;for(MO(e,t-257,5),MO(e,r-1,5),MO(e,n-4,4),i=0;i<n;i++)MO(e,e.bl_tree[2*bO[i]+1],3);WO(e,e.dyn_ltree,t-1),WO(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),GO(e,e.dyn_ltree,e.dyn_dtree)),FO(e),n&&BO(e)},$x._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*(IO[r]+aO+1)]++,e.dyn_dtree[2*DO(t)]++),e.last_lit===e.lit_bufsize-1},$x._tr_align=function(e){MO(e,2,3),LO(e,vO,kO),function(e){16===e.bi_valid?(NO(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 qO=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 JO=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 QO,ZO=function(e,t,r,n){var i=JO,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},$O={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"},eP=Jx,tP=$x,rP=qO,nP=ZO,iP=$O,oP=0,aP=4,sP=0,cP=-2,uP=-1,dP=4,lP=2,hP=8,pP=9,vP=286,_P=30,fP=19,mP=2*vP+1,gP=15,yP=3,SP=258,bP=SP+yP+1,kP=42,EP=103,TP=113,IP=666,RP=1,AP=2,wP=3,CP=4;function xP(e,t){return e.msg=iP[t],t}function OP(e){return(e<<1)-(e>4?9:0)}function PP(e){for(var t=e.length;--t>=0;)e[t]=0}function DP(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(eP.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 NP(e,t){tP._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,DP(e.strm)}function MP(e,t){e.pending_buf[e.pending++]=t}function LP(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function UP(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-bP?e.strstart-(e.w_size-bP):0,u=e.window,d=e.w_mask,l=e.prev,h=e.strstart+SP,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=SP-(h-o),o=h-SP,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 VP(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-bP)){eP.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,eP.arraySet(s,a.input,a.next_in,d,c),1===a.state.wrap?a.adler=rP(a.adler,s,d,c):2===a.state.wrap&&(a.adler=nP(a.adler,s,d,c)),a.next_in+=d,a.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=yP)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+yP-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<yP)););}while(e.lookahead<bP&&0!==e.strm.avail_in)}function FP(e,t){for(var r,n;;){if(e.lookahead<bP){if(VP(e),e.lookahead<bP&&t===oP)return RP;if(0===e.lookahead)break}if(r=0,e.lookahead>=yP&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+yP-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-bP&&(e.match_length=UP(e,r)),e.match_length>=yP)if(n=tP._tr_tally(e,e.strstart-e.match_start,e.match_length-yP),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=yP){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+yP-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=tP._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(NP(e,!1),0===e.strm.avail_out))return RP}return e.insert=e.strstart<yP-1?e.strstart:yP-1,t===aP?(NP(e,!0),0===e.strm.avail_out?wP:CP):e.last_lit&&(NP(e,!1),0===e.strm.avail_out)?RP:AP}function BP(e,t){for(var r,n,i;;){if(e.lookahead<bP){if(VP(e),e.lookahead<bP&&t===oP)return RP;if(0===e.lookahead)break}if(r=0,e.lookahead>=yP&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+yP-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=yP-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-bP&&(e.match_length=UP(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===yP&&e.strstart-e.match_start>4096)&&(e.match_length=yP-1)),e.prev_length>=yP&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-yP,n=tP._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-yP),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+yP-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=yP-1,e.strstart++,n&&(NP(e,!1),0===e.strm.avail_out))return RP}else if(e.match_available){if((n=tP._tr_tally(e,0,e.window[e.strstart-1]))&&NP(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return RP}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=tP._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<yP-1?e.strstart:yP-1,t===aP?(NP(e,!0),0===e.strm.avail_out?wP:CP):e.last_lit&&(NP(e,!1),0===e.strm.avail_out)?RP:AP}function jP(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 HP(){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=hP,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 eP.Buf16(2*mP),this.dyn_dtree=new eP.Buf16(2*(2*_P+1)),this.bl_tree=new eP.Buf16(2*(2*fP+1)),PP(this.dyn_ltree),PP(this.dyn_dtree),PP(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new eP.Buf16(gP+1),this.heap=new eP.Buf16(2*vP+1),PP(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new eP.Buf16(2*vP+1),PP(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 GP(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=lP,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?kP:TP,e.adler=2===t.wrap?0:1,t.last_flush=oP,tP._tr_init(t),sP):xP(e,cP)}function zP(e){var t,r=GP(e);return r===sP&&((t=e.state).window_size=2*t.w_size,PP(t.head),t.max_lazy_match=QO[t.level].max_lazy,t.good_match=QO[t.level].good_length,t.nice_match=QO[t.level].nice_length,t.max_chain_length=QO[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=yP-1,t.match_available=0,t.ins_h=0),r}function KP(e,t,r,n,i,o){if(!e)return cP;var a=1;if(t===uP&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>pP||r!==hP||n<8||n>15||t<0||t>9||o<0||o>dP)return xP(e,cP);8===n&&(n=9);var s=new HP;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+yP-1)/yP),s.window=new eP.Buf8(2*s.w_size),s.head=new eP.Buf16(s.hash_size),s.prev=new eP.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new eP.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,zP(e)}QO=[new jP(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(VP(e),0===e.lookahead&&t===oP)return RP;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,NP(e,!1),0===e.strm.avail_out))return RP;if(e.strstart-e.block_start>=e.w_size-bP&&(NP(e,!1),0===e.strm.avail_out))return RP}return e.insert=0,t===aP?(NP(e,!0),0===e.strm.avail_out?wP:CP):(e.strstart>e.block_start&&(NP(e,!1),e.strm.avail_out),RP)})),new jP(4,4,8,4,FP),new jP(4,5,16,8,FP),new jP(4,6,32,32,FP),new jP(4,4,16,16,BP),new jP(8,16,32,32,BP),new jP(8,16,128,128,BP),new jP(8,32,128,256,BP),new jP(32,128,258,1024,BP),new jP(32,258,258,4096,BP)],Zx.deflateInit=function(e,t){return KP(e,t,hP,15,8,0)},Zx.deflateInit2=KP,Zx.deflateReset=zP,Zx.deflateResetKeep=GP,Zx.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?cP:(e.state.gzhead=t,sP):cP},Zx.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?xP(e,cP):cP;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===IP&&t!==aP)return xP(e,0===e.avail_out?-5:cP);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===kP)if(2===n.wrap)e.adler=0,MP(n,31),MP(n,139),MP(n,8),n.gzhead?(MP(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)),MP(n,255&n.gzhead.time),MP(n,n.gzhead.time>>8&255),MP(n,n.gzhead.time>>16&255),MP(n,n.gzhead.time>>24&255),MP(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),MP(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(MP(n,255&n.gzhead.extra.length),MP(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=nP(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(MP(n,0),MP(n,0),MP(n,0),MP(n,0),MP(n,0),MP(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),MP(n,3),n.status=TP);else{var a=hP+(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=TP,LP(n,a),0!==n.strstart&&(LP(n,e.adler>>>16),LP(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=nP(e.adler,n.pending_buf,n.pending-i,i)),DP(e),i=n.pending,n.pending!==n.pending_buf_size));)MP(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=nP(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=nP(e.adler,n.pending_buf,n.pending-i,i)),DP(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,MP(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=nP(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=nP(e.adler,n.pending_buf,n.pending-i,i)),DP(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,MP(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=nP(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=EP)}else n.status=EP;if(n.status===EP&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&DP(e),n.pending+2<=n.pending_buf_size&&(MP(n,255&e.adler),MP(n,e.adler>>8&255),e.adler=0,n.status=TP)):n.status=TP),0!==n.pending){if(DP(e),0===e.avail_out)return n.last_flush=-1,sP}else if(0===e.avail_in&&OP(t)<=OP(r)&&t!==aP)return xP(e,-5);if(n.status===IP&&0!==e.avail_in)return xP(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==oP&&n.status!==IP){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(VP(e),0===e.lookahead)){if(t===oP)return RP;break}if(e.match_length=0,r=tP._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(NP(e,!1),0===e.strm.avail_out))return RP}return e.insert=0,t===aP?(NP(e,!0),0===e.strm.avail_out?wP:CP):e.last_lit&&(NP(e,!1),0===e.strm.avail_out)?RP:AP}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=SP){if(VP(e),e.lookahead<=SP&&t===oP)return RP;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=yP&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+SP;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=SP-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=yP?(r=tP._tr_tally(e,1,e.match_length-yP),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=tP._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(NP(e,!1),0===e.strm.avail_out))return RP}return e.insert=0,t===aP?(NP(e,!0),0===e.strm.avail_out?wP:CP):e.last_lit&&(NP(e,!1),0===e.strm.avail_out)?RP:AP}(n,t):QO[n.level].func(n,t);if(s!==wP&&s!==CP||(n.status=IP),s===RP||s===wP)return 0===e.avail_out&&(n.last_flush=-1),sP;if(s===AP&&(1===t?tP._tr_align(n):5!==t&&(tP._tr_stored_block(n,0,0,!1),3===t&&(PP(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),DP(e),0===e.avail_out))return n.last_flush=-1,sP}return t!==aP?sP:n.wrap<=0?1:(2===n.wrap?(MP(n,255&e.adler),MP(n,e.adler>>8&255),MP(n,e.adler>>16&255),MP(n,e.adler>>24&255),MP(n,255&e.total_in),MP(n,e.total_in>>8&255),MP(n,e.total_in>>16&255),MP(n,e.total_in>>24&255)):(LP(n,e.adler>>>16),LP(n,65535&e.adler)),DP(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?sP:1)},Zx.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==kP&&69!==t&&73!==t&&91!==t&&t!==EP&&t!==TP&&t!==IP?xP(e,cP):(e.state=null,t===TP?xP(e,-3):sP):cP},Zx.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,d=t.length;if(!e||!e.state)return cP;if(2===(o=(r=e.state).wrap)||1===o&&r.status!==kP||r.lookahead)return cP;for(1===o&&(e.adler=rP(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(PP(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new eP.Buf8(r.w_size),eP.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,VP(r);r.lookahead>=yP;){n=r.strstart,i=r.lookahead-(yP-1);do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+yP-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=yP-1,VP(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=yP-1,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,sP},Zx.deflateInfo="pako deflate (from Nodeca project)";var WP={},XP=Jx,YP=!0,qP=!0;try{String.fromCharCode.apply(null,[0])}catch(HZ){YP=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(HZ){qP=!1}for(var JP=new XP.Buf8(256),QP=0;QP<256;QP++)JP[QP]=QP>=252?6:QP>=248?5:QP>=240?4:QP>=224?3:QP>=192?2:1;function ZP(e,t){if(t<65534&&(e.subarray&&qP||!e.subarray&&YP))return String.fromCharCode.apply(null,XP.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}JP[254]=JP[254]=1,WP.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 XP.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},WP.buf2binstring=function(e){return ZP(e,e.length)},WP.binstring2buf=function(e){for(var t=new XP.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},WP.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=JP[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 ZP(s,n)},WP.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+JP[e[r]]>t?r:t};var $P=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},eD=Zx,tD=Jx,rD=WP,nD=$O,iD=$P,oD=Object.prototype.toString,aD=0,sD=-1,cD=0,uD=8;function dD(e){if(!(this instanceof dD))return new dD(e);this.options=tD.assign({level:sD,method:uD,chunkSize:16384,windowBits:15,memLevel:8,strategy:cD,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 iD,this.strm.avail_out=0;var r=eD.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==aD)throw new Error(nD[r]);if(t.header&&eD.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?rD.string2buf(t.dictionary):"[object ArrayBuffer]"===oD.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=eD.deflateSetDictionary(this.strm,n))!==aD)throw new Error(nD[r]);this._dict_set=!0}}function lD(e,t){var r=new dD(t);if(r.push(e,!0),r.err)throw r.msg||nD[r.err];return r.result}dD.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=rD.string2buf(e):"[object ArrayBuffer]"===oD.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 tD.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=eD.deflate(i,n))&&r!==aD)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(rD.buf2binstring(tD.shrinkBuf(i.output,i.next_out))):this.onData(tD.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=eD.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===aD):2!==n||(this.onEnd(aD),i.avail_out=0,!0)},dD.prototype.onData=function(e){this.chunks.push(e)},dD.prototype.onEnd=function(e){e===aD&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=tD.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},Qx.Deflate=dD,Qx.deflate=lD,Qx.deflateRaw=function(e,t){return(t=t||{}).raw=!0,lD(e,t)},Qx.gzip=function(e,t){return(t=t||{}).gzip=!0,lD(e,t)};var hD={},pD=rr,vD=P,_D=Ze,fD=se,mD=function(){var e=pD(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},gD=RegExp.prototype,yD=se,SD=function(e){var t=e.flags;return void 0!==t||"flags"in gD||_D(e,"flags")||!fD(gD,e)?t:vD(mD,e)},bD=RegExp.prototype,kD=r((function(e){return e===bD||yD(bD,e)?SD(e):e.flags})),ED={},TD=Jx,ID=15,RD=[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],AD=[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],wD=[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],CD=[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],xD=Jx,OD=qO,PD=ZO,DD=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,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,_=r.lencode,f=r.distcode,m=(1<<r.lenbits)-1,g=(1<<r.distbits)-1;e:do{v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),y=_[p&m];t:for(;;){if(p>>>=S=y>>>24,v-=S,0===(S=y>>>16&255))R[o++]=65535&y;else{if(!(16&S)){if(0==(64&S)){y=_[(65535&y)+(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&y,(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),y=f[p&g];r:for(;;){if(p>>>=S=y>>>24,v-=S,!(16&(S=y>>>16&255))){if(0==(64&S)){y=f[(65535&y)+(p&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(k=65535&y,v<(S&=15)&&(p+=I[n++]<<v,(v+=8)<S&&(p+=I[n++]<<v,v+=8)),(k+=p&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(p>>>=S,v-=S,k>(S=o-a)){if((S=k-S)>d&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(E=0,T=h,0===l){if(E+=u-S,S<b){b-=S;do{R[o++]=h[E++]}while(--S);E=o-k,T=R}}else if(l<S){if(E+=u+l-S,(S-=l)<b){b-=S;do{R[o++]=h[E++]}while(--S);if(E=0,l<b){b-=S=l;do{R[o++]=h[E++]}while(--S);E=o-k,T=R}}}else if(E+=l-S,S<b){b-=S;do{R[o++]=h[E++]}while(--S);E=o-k,T=R}for(;b>2;)R[o++]=T[E++],R[o++]=T[E++],R[o++]=T[E++],b-=3;b&&(R[o++]=T[E++],b>1&&(R[o++]=T[E++]))}else{E=o-k;do{R[o++]=R[E++],R[o++]=R[E++],R[o++]=R[E++],b-=3}while(b>2);b&&(R[o++]=R[E++],b>1&&(R[o++]=R[E++]))}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},ND=function(e,t,r,n,i,o,a,s){var c,u,d,l,h,p,v,_,f,m=s.bits,g=0,y=0,S=0,b=0,k=0,E=0,T=0,I=0,R=0,A=0,w=null,C=0,x=new TD.Buf16(16),O=new TD.Buf16(16),P=null,D=0;for(g=0;g<=ID;g++)x[g]=0;for(y=0;y<n;y++)x[t[r+y]]++;for(k=m,b=ID;b>=1&&0===x[b];b--);if(k>b&&(k=b),0===b)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<b&&0===x[S];S++);for(k<S&&(k=S),I=1,g=1;g<=ID;g++)if(I<<=1,(I-=x[g])<0)return-1;if(I>0&&(0===e||1!==b))return-1;for(O[1]=0,g=1;g<ID;g++)O[g+1]=O[g]+x[g];for(y=0;y<n;y++)0!==t[r+y]&&(a[O[t[r+y]]++]=y);if(0===e?(w=P=a,p=19):1===e?(w=RD,C-=257,P=AD,D-=257,p=256):(w=wD,P=CD,p=-1),A=0,y=0,g=S,h=o,E=k,T=0,d=-1,l=(R=1<<k)-1,1===e&&R>852||2===e&&R>592)return 1;for(;;){v=g-T,a[y]<p?(_=0,f=a[y]):a[y]>p?(_=P[D+a[y]],f=w[C+a[y]]):(_=96,f=0),c=1<<g-T,S=u=1<<E;do{i[h+(A>>T)+(u-=c)]=v<<24|_<<16|f|0}while(0!==u);for(c=1<<g-1;A&c;)c>>=1;if(0!==c?(A&=c-1,A+=c):A=0,y++,0==--x[g]){if(g===b)break;g=t[r+a[y]]}if(g>k&&(A&l)!==d){for(0===T&&(T=k),h+=S,I=1<<(E=g-T);E+T<b&&!((I-=x[E+T])<=0);)E++,I<<=1;if(R+=1<<E,1===e&&R>852||2===e&&R>592)return 1;i[d=A&l]=k<<24|E<<16|h-o|0}}return 0!==A&&(i[h+A]=g-T<<24|64<<16|0),s.bits=k,0},MD=1,LD=2,UD=0,VD=-2,FD=1,BD=12,jD=30,HD=852,GD=592;function zD(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function KD(){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 xD.Buf16(320),this.work=new xD.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function WD(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=FD,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new xD.Buf32(HD),t.distcode=t.distdyn=new xD.Buf32(GD),t.sane=1,t.back=-1,UD):VD}function XD(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,WD(e)):VD}function YD(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)?VD:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,XD(e))):VD}function qD(e,t){var r,n;return e?(n=new KD,e.state=n,n.window=null,(r=YD(e,t))!==UD&&(e.state=null),r):VD}var JD,QD,ZD=!0;function $D(e){if(ZD){var t;for(JD=new xD.Buf32(512),QD=new xD.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(ND(MD,e.lens,0,288,JD,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ND(LD,e.lens,0,32,QD,0,e.work,{bits:5}),ZD=!1}e.lencode=JD,e.lenbits=9,e.distcode=QD,e.distbits=5}function eN(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 xD.Buf8(o.wsize)),n>=o.wsize?(xD.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),xD.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(xD.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}ED.inflateReset=XD,ED.inflateReset2=YD,ED.inflateResetKeep=WD,ED.inflateInit=function(e){return qD(e,15)},ED.inflateInit2=qD,ED.inflate=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R=0,A=new xD.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 VD;(r=e.state).mode===BD&&(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,E=UD;e:for(;;)switch(r.mode){case FD: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=PD(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=jD;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=jD;break}if(d-=4,k=8+(15&(u>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg="invalid window size",r.mode=jD;break}r.dmax=1<<k,e.adler=r.check=1,r.mode=512&u?10:BD,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&kD(r))){e.msg="unknown compression method",r.mode=jD;break}if(57344&kD(r)){e.msg="unknown header flags set",r.mode=jD;break}r.head&&(r.head.text=u>>8&1),512&kD(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=PD(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&kD(r)&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=PD(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&kD(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=PD(r.check,A,2,0)),u=0,d=0,r.mode=5;case 5:if(1024&kD(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&kD(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=PD(r.check,A,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&kD(r)&&((p=r.length)>s&&(p=s),p&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),xD.arraySet(r.head.extra,n,o,p,k)),512&kD(r)&&(r.check=PD(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&kD(r)){if(0===s)break e;p=0;do{k=n[o+p++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k))}while(k&&p<s);if(512&kD(r)&&(r.check=PD(r.check,n,p,o)),s-=p,o+=p,k)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&kD(r)){if(0===s)break e;p=0;do{k=n[o+p++],r.head&&k&&r.length<65536&&(r.head.comment+=String.fromCharCode(k))}while(k&&p<s);if(512&kD(r)&&(r.check=PD(r.check,n,p,o)),s-=p,o+=p,k)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&kD(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=jD;break}u=0,d=0}r.head&&(r.head.hcrc=kD(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=BD;break;case 10:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}e.adler=r.check=zD(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=BD;case BD: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($D(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=jD}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=jD;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;xD.arraySet(i,n,o,p,a),s-=p,o+=p,c-=p,a+=p,r.length-=p;break}r.mode=BD;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=jD;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},E=ND(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,E){e.msg="invalid code lengths set",r.mode=jD;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(g<16)u>>>=f,d-=f,r.lens[r.have++]=g;else{if(16===g){for(I=f+2;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u>>>=f,d-=f,0===r.have){e.msg="invalid bit length repeat",r.mode=jD;break}k=r.lens[r.have-1],p=3+(3&u),u>>>=2,d-=2}else if(17===g){for(I=f+3;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=f,k=0,p=3+(7&(u>>>=f)),u>>>=3,d-=3}else{for(I=f+7;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=f,k=0,p=11+(127&(u>>>=f)),u>>>=7,d-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=jD;break}for(;p--;)r.lens[r.have++]=k}}if(r.mode===jD)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=jD;break}if(r.lenbits=9,T={bits:r.lenbits},E=ND(MD,r.lens,0,r.nlen,r.lencode,0,r.work,T),r.lenbits=T.bits,E){e.msg="invalid literal/lengths set",r.mode=jD;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},E=ND(LD,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,T),r.distbits=T.bits,E){e.msg="invalid distances set",r.mode=jD;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,DD(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===BD&&(r.back=-1);break}for(r.back=0;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(m&&0==(240&m)){for(y=f,S=m,b=g;m=(R=r.lencode[b+((u&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=y,d-=y,r.back+=y}if(u>>>=f,d-=f,r.back+=f,r.length=g,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=BD;break}if(64&m){e.msg="invalid literal/length code",r.mode=jD;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(R=r.distcode[u&(1<<r.distbits)-1])>>>16&255,g=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(0==(240&m)){for(y=f,S=m,b=g;m=(R=r.distcode[b+((u&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=y,d-=y,r.back+=y}if(u>>>=f,d-=f,r.back+=f,64&m){e.msg="invalid distance code",r.mode=jD;break}r.offset=g,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=jD;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=jD;break}p>r.wnext?(p-=r.wnext,v=r.wsize-p):v=r.wnext-p,p>r.length&&(p=r.length),_=r.window}else _=i,v=a-r.offset,p=r.length;p>c&&(p=c),c-=p,r.length-=p;do{i[a++]=_[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=kD(r)?PD(r.check,i,h,a-h):OD(r.check,i,h,a-h)),h=c,(kD(r)?u:zD(u))!==r.check){e.msg="incorrect data check",r.mode=jD;break}u=0,d=0}r.mode=28;case 28:if(r.wrap&&kD(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=jD;break}u=0,d=0}r.mode=29;case 29:E=1;break e;case jD:E=-3;break e;case 31:return-4;default:return VD}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<jD&&(r.mode<27||4!==t))&&eN(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=kD(r)?PD(r.check,i,h,e.next_out-h):OD(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===BD?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&E===UD&&(E=-5),E},ED.inflateEnd=function(e){if(!e||!e.state)return VD;var t=e.state;return t.window&&(t.window=null),e.state=null,UD},ED.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?VD:(r.head=t,t.done=!1,UD):VD},ED.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?VD:11===r.mode&&OD(1,t,n,0)!==r.check?-3:eN(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,UD):VD},ED.inflateInfo="pako inflate (from Nodeca project)";var tN={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 rN=ED,nN=Jx,iN=WP,oN=tN,aN=$O,sN=$P,cN=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},uN=Object.prototype.toString;function dN(e){if(!(this instanceof dN))return new dN(e);this.options=nN.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 sN,this.strm.avail_out=0;var r=rN.inflateInit2(this.strm,t.windowBits);if(r!==oN.Z_OK)throw new Error(aN[r]);if(this.header=new cN,rN.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=iN.string2buf(t.dictionary):"[object ArrayBuffer]"===uN.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=rN.inflateSetDictionary(this.strm,t.dictionary))!==oN.Z_OK))throw new Error(aN[r])}function lN(e,t){var r=new dN(t);if(r.push(e,!0),r.err)throw r.msg||aN[r.err];return r.result}dN.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?oN.Z_FINISH:oN.Z_NO_FLUSH,"string"==typeof e?s.input=iN.binstring2buf(e):"[object ArrayBuffer]"===uN.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 nN.Buf8(c),s.next_out=0,s.avail_out=c),(r=rN.inflate(s,oN.Z_NO_FLUSH))===oN.Z_NEED_DICT&&u&&(r=rN.inflateSetDictionary(this.strm,u)),r===oN.Z_BUF_ERROR&&!0===d&&(r=oN.Z_OK,d=!1),r!==oN.Z_STREAM_END&&r!==oN.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==oN.Z_STREAM_END&&(0!==s.avail_in||n!==oN.Z_FINISH&&n!==oN.Z_SYNC_FLUSH)||("string"===this.options.to?(i=iN.utf8border(s.output,s.next_out),o=s.next_out-i,a=iN.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&nN.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(nN.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!==oN.Z_STREAM_END);return r===oN.Z_STREAM_END&&(n=oN.Z_FINISH),n===oN.Z_FINISH?(r=rN.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===oN.Z_OK):n!==oN.Z_SYNC_FLUSH||(this.onEnd(oN.Z_OK),s.avail_out=0,!0)},dN.prototype.onData=function(e){this.chunks.push(e)},dN.prototype.onEnd=function(e){e===oN.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=nN.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},hD.Inflate=dN,hD.inflate=lN,hD.inflateRaw=function(e,t){return(t=t||{}).raw=!0,lN(e,t)},hD.ungzip=lN;var hN={};(0,Jx.assign)(hN,Qx,hD,tN);var pN=r(hN),vN=1,_N=function(){function e(t){Fh(this,e),ql(this,"lockingPromise",jI.resolve()),ql(this,"locks",0),ql(this,"name",""),ql(this,"lockId",void 0),this.lockId=vN++,t&&(this.name=t)}return Vh(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t=this;this.locks+=1;var r=new jI((function(r){e=function(){t.locks-=1,r()}})),n=this.lockingPromise.then((function(){return e}));return this.lockingPromise=this.lockingPromise.then((function(){return r})),n}}]),e}(),fN="BytePlusRTC",mN=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},gN=function(){function e(t){Fh(this,e),ql(this,"storeName",void 0),ql(this,"pendingList",[]),this.storeName=t,!hx()&&mN()&&this._checkAndCreateStore(t)}var t,r,n,i,o,a,s;return Vh(e,[{key:"_checkAndCreateStore",value:(s=Ng(Pg().mark((function t(r,n){var i,o,a=this;return Pg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e._promiseLock.lock();case 2:if(i=t.sent,!mN.databases){t.next=6;break}return t.next=6,new jI((function(e){var t=function(){return mN.databases().finally(e)};o=setInterval(t,100),t()})).finally((function(){return clearInterval(o)}));case 6:return t.abrupt("return",new jI((function(t){e.db&&(e.db.close(),delete e.db);var o=n?mN().open(fN,n):mN().open(fN);o.onupgradeneeded=function(){o.result.createObjectStore(r)},o.onerror=function(){console.error("IndexedDBInterface error",o.error)},o.onsuccess=function(){var n=o.result;e.db=n;try{e.db.transaction(a.storeName,"readonly"),a.pendingList.forEach(function(){var e=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.txMode,n=t.pendResolve,i=t.pendReject,e.prev=1,e.next=4,a._getStore(r);case 4:o=e.sent,n(o),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),i();case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}()),t()}catch(s){t(a._checkAndCreateStore(r,n.version+1))}finally{i()}}})));case 7:case"end":return t.stop()}}),t)}))),function(e,t){return s.apply(this,arguments)})},{key:"_getStore",value:(a=Ng(Pg().mark((function t(r){var n,i=this;return Pg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e._promiseLock.lock();case 2:return n=t.sent,t.abrupt("return",new jI((function(t,o){if(!e.db)return i.pendingList.push({txMode:r,pendResolve:t,pendReject:o}),void n();try{t(e.db.transaction(i.storeName,r).objectStore(i.storeName))}catch(a){return void i.pendingList.push({txMode:r,pendResolve:t,pendReject:o})}finally{n()}})));case 4:case"end":return t.stop()}}),t)}))),function(e){return a.apply(this,arguments)})},{key:"put2String",value:(o=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{n=Gg(t)}catch(i){n=t}return e.next=3,this.put(n,r);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"get4String",value:(i=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:r=e.sent;try{n=JSON.parse(r)}catch(i){n=r}return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"put",value:(n=Ng(Pg().mark((function e(t,r){var n;return Pg().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 jI((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 n.apply(this,arguments)})},{key:"get",value:(r=Ng(Pg().mark((function e(t){var r;return Pg().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 jI((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 r.apply(this,arguments)})},{key:"del",value:(t=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readwrite");case 2:return r=e.sent,e.abrupt("return",new jI((function(e,n){var i=r.delete(t);i.onsuccess=function(){e()},i.onerror=function(e){n(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();function yN(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=cn(e);for(n=0;n<o.length;n++)r=o[n],gI(t).call(t,r)>=0||(i[r]=e[r]);return i}(e,t);if(Hs){var o=Hs(e);for(n=0;n<o.length;n++)r=o[n],gI(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}ql(gN,"db",void 0),ql(gN,"state","init"),ql(gN,"_promiseLock",new _N("iDB"));var SN=["message"];var bN,kN,EN,TN=new(function(){function e(){Fh(this,e),ql(this,"name","LongStringReportor"),ql(this,"inBuffer",[]),ql(this,"outBuffer",[])}return Vh(e,[{key:"push",value:function(e){var t;e.message&&this.inBuffer.push(Ql(Ql({},e),{},{message:{id:sI(t=px()).call(t,0,3),index:0,end:!0,msg:e.message}}))}},{key:"splice",value:function(e){for(var t=[],r=0;this.outBuffer.length;){var n=Gg(this.outBuffer[0]).length;if(!(n<e))break;e-=n,r+=n,t.push(this.outBuffer.shift())}for(;this.inBuffer[0]&&e>0;){var i=this.inBuffer[0],o=i.message,a=Ql(Ql({},yN(i,SN)),{},{message:Ql(Ql({},o),{},{msg:""})}),s=Gg(a).length,c=e-s,u=Ql({},a);if(c>o.msg.length)u.message.msg=o.msg,this.inBuffer.shift();else{if(!(c>=10))break;var d,l,h=sI(d=o.msg).call(d,0,c);u.message.msg=h,u.message.end=!1,this.inBuffer[0].message.msg=sI(l=o.msg).call(l,c),this.inBuffer[0].message.index++}var p=Gg(u.message),v=p.length;e-=v+s,r+=v+s,t.push(Ql(Ql({},u),{},{message:p}))}return{payload:t,payloadSize:r}}},{key:"unshift",value:function(e){this.outBuffer=Fg(e).call(e,this.outBuffer)}},{key:"get",value:function(){var e,t;return Fg(e=[]).call(e,tR(this.outBuffer),tR(qg(t=this.inBuffer).call(t,(function(e){return Ql(Ql({},e),{},{message:Gg(e.message)})}))))}},{key:"set",value:function(e){var t=this,r=[],n=[];e.forEach((function(e){!function(e){return void 0!==e.report_id}(e)?(e.message||(e.message=""),t.inBuffer.push(Ql(Ql({},e),{},{message:JSON.parse(e.message)}))):t.outBuffer.push(e)})),this.outBuffer=Fg(r).call(r,this.outBuffer),this.inBuffer=Fg(n).call(n,this.inBuffer)}},{key:"isEmpty",value:function(){return 0===this.inBuffer.length&&0===this.outBuffer.length}}]),e}()),IN={product_line:"rtc",report_version:"5",os:"web",user_agent:hx()?"":null===(bN=navigator)||void 0===bN?void 0:bN.userAgent,platform:"web",product:"webrtc",app_state:"active"},RN="LogReportor",AN="undefined"!=typeof window&&(Xy(kN=window.location.search).call(kN,"_rtc_debug_")||(null===(EN=window.localStorage)||void 0===EN?void 0:EN.getItem("_rtc_debug_"))),wN=function(){function e(t){Fh(this,e),ql(this,"_buffer",void 0),this._buffer=new gN(t)}var t,r;return Vh(e,[{key:"set",value:(r=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put2String(t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"get",value:(t=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[],e.prev=1,e.next=4,this._buffer.get4String(t);case 4:n=e.sent,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(1);case 9:return e.abrupt("return",null!==(r=n)&&void 0!==r?r:[]);case 10:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e){return t.apply(this,arguments)})}]),e}(),CN=function(){function e(){var t=this;Fh(this,e),ql(this,"reportCommon",IN),ql(this,"reportIds",new cT),ql(this,"dataBuffer",[]),ql(this,"reportorList",[]),ql(this,"dbBuffer",void 0),ql(this,"posting",!1),ql(this,"sucSendTimer",void 0),ql(this,"preSucTime",0),ql(this,"errSendTimer",void 0),ql(this,"errSendDelay",100),ql(this,"_logServerUrl",void 0),ql(this,"_retryCount",0),ql(this,"_reportLimit",5e5),ql(this,"_disableTimeout",!1),hx()||(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"})})),AN&&(window.__rtc_debug_reportor__=this)),Nx.on("UPLOAD_REPORT_LIMIT",(function(e){t.setReportLimit(e)})),Nx.on("ENABLE_REPORT_IDB_BUFFER",(function(e){e&&t.enableIndexedDBBuffer()})),setTimeout((function(){t.reportorList.push(aM),t.reportorList.push(TN)}))}var t;return Vh(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.reportCommon=TT(this.reportCommon,e)}},{key:"getCommonStats",value:function(){return this.reportCommon}},{key:"setReportLimit",value:function(e){this._reportLimit=Math.max(e,5e4),this._reportLimit=Math.min(e,5e5)}},{key:"getReportId",value:function(e){var t;e=null!==(t=e)&&void 0!==t?t:"__global__",this.reportIds.has(e)||this.reportIds.set(e,0);var r=this.reportIds.get(e);return void 0===r&&(HN("no reportId in reportId map with engine-session-id ".concat(e),0,{}),r=0),this.reportIds.set(e,r+1),r}},{key:"push",value:function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])this.send(e);else{var t,r=null!==(t=e.engine_session_id)&&void 0!==t?t:"__global__";this.reportIds.has(r)||this.reportIds.set(r,0),this.dataBuffer.push(e),!this.posting&&!this.errSendTimer&&Date.now()-this.preSucTime>2e3&&(clearTimeout(this.sucSendTimer),this.send())}}},{key:"enableIndexedDBBuffer",value:function(){var e=this;this.dbBuffer||(this.dbBuffer=new wN("ReportorDBBuffer"),this.dbBuffer.get(RN).then((function(t){t.forEach((function(t){e.push(t)}))})),this.reportorList.forEach((function(t){var r;null===(r=e.dbBuffer)||void 0===r||r.get(t.name).then((function(e){t.set(e)}))})))}},{key:"backup",value:function(){var e=this;try{var t;null===(t=this.dbBuffer)||void 0===t||t.set(tR(this.dataBuffer),RN),this.reportorList.forEach((function(t){var r;null===(r=e.dbBuffer)||void 0===r||r.set(tR(t.get()),t.name)}))}catch(r){HN("Error when save log into IDB",-1,r)}}},{key:"unshift",value:function(e){var t;this.dataBuffer=Fg(t=e[0]).call(t,this.dataBuffer),this.reportorList.forEach((function(t,r){var n;t.unshift(null!==(n=e[r+1])&&void 0!==n?n:[])}))}},{key:"_splice",value:function(){var e,t=this,r=function(e,t){for(var r=0,n=0;n<e.length;n++)if((r+=Gg(e[n]).length)>t)return n;return e.length}(this.dataBuffer,this._reportLimit);0===r&&this.dataBuffer.length>0&&(this._reportLimit=Gg(this.dataBuffer[0]).length+10,r=1,HN("update report limit to ".concat(this._reportLimit),0,null));var n=BI(e=this.dataBuffer).call(e,0,r),i=Gg(n).length,o=[n],a=this._reportLimit-i;return this.reportorList.forEach((function(e){var r=BI(e).call(e,a),n=r.payload,i=r.payloadSize;n.forEach((function(e){var r,n,i;void 0===e.report_id&&(e.report_id=t.getReportId(e.engine_session_id),!hx()&&window.__onRTCReport&&(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,null!==(i=e.engine_session_id)&&void 0!==i?i:"global",e,t.getCommonStats())))})),o.push(n),a-=i})),o}},{key:"send",value:(t=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.backup(),i=oS(n=this.reportorList).call(n,(function(e,t){return e&&t.isEmpty()}),!0),(t||this.dataBuffer.length||!i)&&this._logServerUrl){e.next=4;break}return e.abrupt("return");case 4:if(t||(this.posting=!0),o=[],t||(o=this._splice()),a=AN,s={data:t||qx(o).call(o),header:Ql(Ql({},this.reportCommon),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},c={method:"POST",body:a?Gg(s):pN.gzip(Gg(s))},!this._disableTimeout)try{u=new AbortController,c.signal=u.signal,setTimeout((function(){u.abort()}),1e4)}catch(p){console.warn("AbortController is not supported"),this._disableTimeout=!0}return a||(c.headers={"Content-Encoding":"gzip","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}),h=null,e.prev=13,e.next=16,fetch(this._logServerUrl,c);case 16:if(200!==(d=e.sent).status&&304!==d.status){e.next=23;break}return e.t0=JSON,e.next=21,d.text();case 21:e.t1=e.sent,h=e.t0.parse.call(e.t0,e.t1);case 23:e.next=28;break;case 25:e.prev=25,e.t2=e.catch(13),l=e.t2;case 28:t||(this.posting=!1),h&&0===h.StatusCode?t||r||this.sucSend():(setTimeout((function(){var e,t,r,n;HN(Fg(e="reportor post error, resJSON:".concat(null===(t=h)||void 0===t?void 0:t.toString()," err:")).call(e,l),null!==(r=null===(n=d)||void 0===n?void 0:n.status)&&void 0!==r?r:-1,l)}),0),t?this.send(t):(this.unshift(o),r?this.send():this.errSend()));case 30:case"end":return e.stop()}}),e,this,[[13,25]])}))),function(e,r){return t.apply(this,arguments)})},{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++}}]),e}();var xN,ON=new CN,PN=function(){function e(t){Fh(this,e),ql(this,"modifyIds",{}),this.id=t}return Vh(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=Ql(Ql(Ql({event_key:e,rtc_timestamp:Date.now()},this.modifyIds),t),{},{common_extra_info:Gg(i),report_id:ON.getReportId(this.modifyIds.engine_session_id)});!hx()&&window.__onRTCReport&&(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.modifyIds.engine_session_id,o,ON.getCommonStats()));ON.push(o)}},{key:"reportLog",value:function(e){var t=Ql(Ql({event_key:"rtc_invoke_status",sdk_api_name:"console_log",rtc_timestamp:Date.now()},this.modifyIds),{},{message:e});aM.push(t)}},{key:"reportLongString",value:function(e,t){var r=Ql(Ql({event_key:"rtc_invoke_status",sdk_api_name:"sdk_long_string_".concat(e),rtc_timestamp:Date.now()},this.modifyIds),{},{message:t});TN.push(r)}},{key:"set",value:function(e){this.modifyIds=TT(this.modifyIds,e)}},{key:"destroy",value:function(){}}]),e}();setTimeout((function(){xN=new pM("MessageReportor",1)}),0);var DN=function(){function e(t){Fh(this,e),ql(this,"_preTime",Date.now()),ql(this,"_one2oneNum",0),ql(this,"_one2manyNum",0),ql(this,"_one2oneMsgCache",new cT),ql(this,"_one2manyMsgCache",new cT),ql(this,"roomId",""),ql(this,"userId",""),ql(this,"rtsSessionId",""),this.id=t}return Vh(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,Ql({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,Ql(Ql({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,Ql({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,Ql(Ql({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(xN.info("reportP2PMsg",r.type,Gg(r)),null===(t=KN(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(xN.info("reportOne2ManyMsg",r.type,Gg(r)),null===(t=KN(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)||"",xN.info("reportMsgRecv",t.type,Gg(t)),null===(n=KN(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}();ql(DN,"config",void 0);var NN=new cT,MN={_cache:NN,setConfig:function(e){xN.info("setConfig","get config: ".concat(Gg(e))),DN.config=e},setRtsSessionId:function(e,t){var r=NN.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=NN.get(e)||new DN(e);return NN.set(e,t),t},destroyRTSMsgReportor:function(e){var t=NN.get(e);t&&(t.destroy(),NN.delete(e))},setRoomId:function(e,t){var r=NN.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=NN.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=NN.get(e);if(null!=r&&r.needReport("one2one")){var n,i=Fg(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&&vx(t.report_msg_id)&&(null===(n=NN.get(e))||void 0===n||n.updateP2PMsg(Fg(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&&vx(t.report_msg_id)){var n,i,o=NN.get(e);null==o||o.updateP2PMsg(Fg(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(Fg(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n,i=NN.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:Fg(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&&vx(t.report_msg_id)){var n,i=NN.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Fg(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&&vx(t.report_msg_id)){var n,i,o=NN.get(e);if(o)null==o||o.updateOne2ManyMsg(Fg(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(Fg(i="".concat(t.clientId)).call(i,t.report_msg_id))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&vx(t.report_msg_id)){var n,i=NN.get(e);if(i)i.updateOne2ManyMsg(Fg(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&&vx(t.report_msg_id)){var n,i=NN.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Fg(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})}}},LN=function(){function e(t){Fh(this,e),ql(this,"_timer",void 0),ql(this,"userMessage",{}),ql(this,"roomMessage",{}),this.id=t,this._setTimer()}return Vh(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(MS(this.userMessage).length||MS(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e,t,r,n=this;null===(e=KN(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:qg(t=MS(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:qg(r=MS(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[Fg(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Fg(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[Fg(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Fg(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Fg(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Fg(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)&&(Xy(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[Fg(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}(),UN=function(e){ON.setCommonStats(e)},VN=function(e){ON.setUrl(e)},FN=new PN("global"),BN=function(e,t,r){FN.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},jN=function(e,t,r){FN.report("rtc_sdk_callback",{sdk_callback_name:e,error_code:t,message:r})},HN=function(e,t,r){FN.report("rtc_error",{message:e,error_code:t},r)},GN=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;FN.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)};var zN=new cT,KN=function(e){return zN.get(e)},WN=function(e,t){var r=new PN(e);return r.set(Ql(Ql({},t),{},{engine_session_id:px()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),zN.set(e,r),r};function XN(){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=KN(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=KN(u))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:Gg(ZN(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 qN(u,r,[e||{}]),e})).catch((function(e){throw qN(u,r,e.message,e.code),e})):(qN(u,r,[l||{}]),l)}}}}var YN,qN=function(e,t,r){var n,i=arguments.length>4?arguments[4]:void 0,o={sdk_callback_name:t,error_code:arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,message:Gg(Array.isArray(r)?ZN(r):r)};i&&(o.room_id=i),null===(n=KN(e))||void 0===n||n.report("rtc_sdk_callback",o)},JN=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=KN(e))||void 0===n||n.report("rtc_invoke_status",{sdk_api_name:t,message:r,error_code:i,stream_id:o,elapse:0},a)},QN=10;function ZN(e){return qg(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>QN){var c,u,d,l,h,p=new DataView(o),v=qg(c=KC({length:QN/2})).call(c,(function(e,t){return p.getUint8(t)})),_=qg(u=WC(d=qg(l=KC({length:QN/2})).call(l,(function(e,t){return a-1-t}))).call(d)).call(u,(function(e){return p.getUint8(e)}));s=Fg(h=[]).call(h,tR(v),["..."],tR(_))}else s=KC(new Uint8Array(o));return Fg(n=Fg(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return qg(t).call(t,e);if(Xy(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var f={};for(var m in t)f[m]=e(t[m]);return f}return t}))}var $N="undefined"!=typeof window&&Xy(YN=window.location.search).call(YN,"_rtc_upload_console_"),eM=function(){function e(){var t=this;Fh(this,e),ql(this,"name","ConsoleReportor"),ql(this,"_uuid","".concat(Math.floor(899*Math.random())+100)),ql(this,"_consoleReportId",0),ql(this,"_engineReportIdMap",new cT),ql(this,"_enabled","NULL"),ql(this,"_consoleCutLength",Nx.getParameter("UPLOAD_CONSOLE_LENGTH_CUT")),ql(this,"buffer",[]),$N&&setTimeout((function(){t.switchOn()}),0),Nx.on("UPLOAD_CONSOLE_ON",(function(e){e?t.switchOn():t.turnOff()})),Nx.on("UPLOAD_CONSOLE_LENGTH_CUT",(function(e){t._consoleCutLength=e}))}return Vh(e,[{key:"enabled",get:function(){return"OFF"!==this._enabled}},{key:"switchOn",value:function(){"NULL"===this._enabled&&(console.log("[LoggerReportor.constructor] console upload switch ON"),this._enabled="ON")}},{key:"turnOff",value:function(){"NULL"===this._enabled&&(console.log("[LoggerReportor.constructor] console upload switch OFF"),this._enabled="OFF",this.buffer=[])}},{key:"getEngineConsoleId",value:function(e){var t,r=null!==(t=this._engineReportIdMap.get(e))&&void 0!==t?t:0;return this._engineReportIdMap.set(e,r+1),r}},{key:"report",value:function(e,t,r,n,i,o,a,s,c){var u,d,l,h,p,v,_,f,m,g,y,S=this;if("OFF"!==this._enabled){var b,k=KN(t),E=this._consoleReportId++,T=this.getEngineConsoleId(t),I=tM(c,this._consoleCutLength),R=tR(c),A="".concat(s).replace(/%o|%s/gi,(function(){return tM([R.shift()],S._consoleCutLength)})),w=Fg(u=Fg(d=Fg(l=Fg(h=Fg(p=Fg(v=Fg(_=Fg(f=Fg(m=Fg(g=Fg(y="[".concat(this._uuid,"-")).call(y,E,"][")).call(g,t,"-")).call(m,T,"]-")).call(f,r,"-")).call(_,e,"[")).call(v,n,"]")).call(p,i,"[")).call(h,o,".")).call(l,a,"] ")).call(d,A," ")).call(u,I);k?k.reportLog(w):(b=w,FN.reportLog(b))}}},{key:"push",value:function(e){"OFF"!==this._enabled&&this.buffer.push(e)}},{key:"splice",value:function(e){var t;if("ON"!==this._enabled)return{payload:[],payloadSize:0};var r=function(e,t){for(var r=0,n=0;n<e.length;n++){var i=Gg(e[n]).length;if((r+=i)>t)return{index:n,size:r-i}}return{index:e.length,size:r}}(this.buffer,e),n=r.index,i=r.size;return{payload:BI(t=this.buffer).call(t,0,n),payloadSize:i}}},{key:"unshift",value:function(e){this.buffer=Fg(e).call(e,this.buffer)}},{key:"get",value:function(){return this.buffer}},{key:"set",value:function(e){this.buffer=Fg(e).call(e,this.buffer)}},{key:"isEmpty",value:function(){return"OFF"===this._enabled||0===this.buffer.length}}]),e}();function tM(e,t){return qg(e).call(e,(function(e){var r="";try{if("string"==typeof e)return e;if(void 0===e)return"undefined";if(null===e)return"null";if(e instanceof MediaStreamTrack)return fx(e);if(e instanceof MediaStream)return mx(e);if(e instanceof RTCRtpSender)return gx(e);if(e instanceof RTCRtpReceiver)return yx(e);if(e instanceof RTCRtpTransceiver)return Sx(e);r=Gg(e)}catch(n){r=e.toString()}return r&&r.length>=t&&(r=sI(r).call(r,0,t)),r})).join(", ")}var rM,nM,iM,oM,aM=new eM,sM="[VERTC]",cM="#0050b3",uM=(ql(rM={},"DEBUG","rgba(0, 0, 0, 0)"),ql(rM," INFO","rgba(93, 173, 226, 0)"),ql(rM," WARN","rgba(255, 119, 0, 0.3)"),ql(rM,"ERROR","rgba(255, 0, 0, 0.3)"),ql(rM," SUCC","rgba(0, 119, 0, 0.3)"),rM),dM="undefined"!=typeof window&&(Xy(nM=window.location.search).call(nM,"_rtc_debug_")||(null===(iM=window.localStorage)||void 0===iM?void 0:iM.getItem("_rtc_debug_"))),lM=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"global";Fh(this,e),ql(this,"indent",void 0),ql(this,"module",void 0),ql(this,"_engineId",void 0),this.module=t,this.indent=r,this._engineId=n}return Vh(e,[{key:"_print",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,g=Fg(v=[]).call(v,l),y="".concat(p).replace(/%o/gi,(function(){var e=g.shift();return Gg(e)}));Tx.set(Fg(_=Fg(f=Fg(m="".concat(sM,"[").concat(this.module,".")).call(m,t,"] ")).call(f,y," ")).call(_,qg(g).call(g,(function(e){return Gg(e)})).join(", ")))}catch(BZ){}for(var S="",b=0;b<this.indent;b++)S+=" ";var k=hM();aM.report(sM,this._engineId,k,e,S,this.module,t,p,l),dM&&(r=console).log.apply(r,Fg(n=[Fg(i=Fg(o=Fg(a=Fg(s=Fg(c=Fg(u="%c".concat(k,"-")).call(u,sM,"%c[")).call(c,e,"]%c")).call(s,S,"[")).call(a,this.module,".")).call(o,t,"] ")).call(i,p),"color:".concat(cM,";"),"background-color:".concat(uM[e],";"),"color:".concat(cM,";")]).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._print.apply(this,Fg(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._print.apply(this,Fg(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._print.apply(this,Fg(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._print.apply(this,Fg(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._print.apply(this,Fg(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._print.apply(this,Fg(t=[" SUCC",e]).call(t,n))}}]),e}(),hM=function(){var e,t,r=new Date;return Fg(e="".concat(r.toTimeString().split(" ")[0],":")).call(e,xx(t=r.getMilliseconds().toString()).call(t,3,"0"))},pM=lM,vM=function(e){var t,r=KN(e.engineId),n={keys:ix(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId,deviceId:e.deviceId},i=qg(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:Gg(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=qg(i).call(i,function(){var e=Ng(Pg().mark((function e(t,r){var i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:Gg(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 jI((function(e){(function(e){return new jI((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:Gg(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})}))}))},_M=new Uint8Array(16);function fM(){if(!oM&&!(oM="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return oM(_M)}for(var mM=[],gM=0;gM<256;++gM){var yM;mM.push(sI(yM=(gM+256).toString(16)).call(yM,1))}var SM={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function bM(e,t,r){if(SM.randomUUID&&!t&&!e)return SM.randomUUID();var n=(e=e||{}).random||(e.rng||fM)();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;return(mM[e[t+0]]+mM[e[t+1]]+mM[e[t+2]]+mM[e[t+3]]+"-"+mM[e[t+4]]+mM[e[t+5]]+"-"+mM[e[t+6]]+mM[e[t+7]]+"-"+mM[e[t+8]]+mM[e[t+9]]+"-"+mM[e[t+10]]+mM[e[t+11]]+mM[e[t+12]]+mM[e[t+13]]+mM[e[t+14]]+mM[e[t+15]]).toLowerCase()}(n)}var kM=new TextDecoder,EM=new TextEncoder,TM=function(){return bM()},IM=function(){return Date.now()},RM=!hx()&&"function"==typeof HTMLVideoElement.prototype.requestVideoFrameCallback;function AM(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++){t+=a[o].length}for(var s=new e(t),c=0,u=0,d=n;u<d.length;u++){var l=d[u];s.set(l,c),c+=l.length}return s}var wM=function(){function e(){Fh(this,e)}var t,r;return Vh(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(Ty(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=NS(t);n<i.length;n++){var o=gy(i[n],2),a=o[0],s=o[1];null!==s&&"object"===Wl(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return kM.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 EM.encode(e).buffer}},{key:"ab2b64str",value:(r=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new jI((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=Ng(Pg().mark((function e(t,r){return Pg().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()})).catch((function(e){var n;throw r&&r.report("rtc_error",{error_code:2001,message:Fg(n="".concat(e.message," -> ")).call(n,t)}),e})));case 1:case"end":return e.stop()}}),e)}))),function(e,r){return t.apply(this,arguments)})}]),e}();function CM(){for(var e,t,r=Number(HC(e=sI(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=HC(r).call(r,28,"1").split(""),i=[];n.length;)i.push(BI(n).call(n,0,7));return qg(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return zC(r+e.join(""),2)}))}var xM=function(){return Math.floor(65535*Math.random())};function OM(e){return"string"==typeof e&&yI(e).call(e,"__web__rtc__rtt__")>-1}var PM,DM,NM,MM,LM,UM,VM,FM,BM=function(){var e=Ng(Pg().mark((function e(){var t,r,n,i=arguments;return Pg().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)}}(),jM=function(e){return new jI((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 HM(e){return Number(Math.max(-127,10*JC(Math.pow(e/255,2))).toFixed(2))}function GM(e){return(e&ch.AUDIO)===ch.AUDIO}function zM(e){return(e&ch.VIDEO)===ch.VIDEO}function KM(e){var t={};return MS(e).forEach((function(r){"object"===Wl(e[r])?t[r]=KM(e[r]):_C(r).call(r,"_")||(t[r]=e[r])})),t}function WM(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 XM(e){return void 0===e}function YM(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Fg(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 qM(e){console.warn("[RTC WebSDK]: ".concat(e))}function JM(e){return"number"==typeof e?e:"number"==typeof(null==e?void 0:e.exact)?e.exact:"number"==typeof(null==e?void 0:e.ideal)?e.ideal:"number"==typeof(null==e?void 0:e.max)?e.max:"number"==typeof(null==e?void 0:e.min)?e.min:1}var QM=function(){return"undefined"==typeof window},ZM=QM()?"":window.navigator.userAgent;function $M(){var e="none";return QM()||(null!==ZM.match("Firefox")?e="mozilla":null!==ZM.match("Chrome")?(e="chrome-stable",null!==ZM.match("Electron")&&(e="electron")):(null!==ZM.match("Safari")||null!==ZM.match("AppleWebKit"))&&(e="safari")),e}var eL,tL="mozilla"===$M(),rL="safari"===$M(),nL="chrome-stable"===$M(),iL=!QM()&&/CriOS/i.test(ZM),oL=!QM()&&/Edg\//i.test(ZM),aL=!QM()&&/EdgA/i.test(ZM),sL=!QM()&&/EdgiOS/i.test(ZM),cL=oL||aL||sL,uL=!QM()&&/DingTalk/i.test(navigator.userAgent),dL=!QM()&&(!!/(iPad)/i.exec(ZM)||/Macintosh/i.test(ZM)&&"ontouchend"in document),lL=!QM()&&/Macintosh/i.test(ZM),hL=!QM()&&/MicroMessenger/i.test(ZM),pL=!QM()&&Xy(PM=ZM.toLowerCase()).call(PM,"mobile"),vL=!QM()&&!!/(iPhone|iPad|iPod)/i.exec(ZM),_L=!QM()&&/Android/i.test(ZM),fL=!QM()&&/Windows/i.test(ZM),mL=0,gL="0",yL=!QM()&&(null===(DM=ZM.match(/version\/(\d+)/i))||void 0===DM?void 0:DM[1]);rL&&yL&&(mL=Number(yL),gL=null===(eL=navigator.userAgent.match(/version\/(\d+\.\d+)/i))||void 0===eL?void 0:eL[1]);var SL=!QM()&&(null===(NM=ZM.match(/Firefox\/(\d+)/i))||void 0===NM?void 0:NM[1]);tL&&SL&&(mL=Number(SL));var bL=mL,kL=mL,EL=gL,TL=null!==(MM=!QM()&&(null===(LM=ZM.match(/ ([\d_]+) like Mac OS X/i))||void 0===LM||null===(UM=LM[1])||void 0===UM?void 0:qg(VM=UM.split("_")).call(VM,(function(e){return _b(e)}))))&&void 0!==MM?MM:[],IL=0,RL=!QM()&&(null===(FM=ZM.match(/Chrome\/(\d+)/i))||void 0===FM?void 0:FM[1]);RL&&(IL=Number(RL));var AL=IL,wL="BytePlus",CL="RTC_DEVICE_ID",xL="RTC_ACCESS_NODE",OL="RTC_ACCESS_URLS",PL="ENGINE_WEB_CONFIG",DL="SERVER_CONFIG",NL=function(){function e(){Fh(this,e)}return Vh(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={ttl:arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,saveTime:Date.now(),message:t};try{return localStorage.setItem(e,Gg(r)),!0}catch(n){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}(),ML=function(e){UA(r,e);var t=ew(r);function r(){return Fh(this,r),t.apply(this,arguments)}return Vh(r,[{key:"getDeviceId",value:function(){if(QM())return"";var e=this.get(CL);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 UN({device_id:e}),this.set(CL,e),e}},{key:"getAccessNode",value:function(e){var t;return this.get(Fg(t="".concat(xL,"_").concat(e,"-")).call(t,wL))}},{key:"setAccessNode",value:function(e,t,r){var n;return this.set(Fg(n="".concat(xL,"_").concat(e,"-")).call(n,wL),t,1e3*r)}},{key:"deleteAccessNode",value:function(e,t){var r,n=this.getAccessNode(e),i=this.getTtl(Fg(r="".concat(xL,"_").concat(e,"-")).call(r,wL));Array.isArray(n)&&n.length>0&&((n=Ty(n).call(n,(function(e){return e.mediaID!==t.mediaID&&e.msgKey!==t.msgKey}))).length>0?this.setAccessNode(e,n,i||0):this.clearAccessNode(e))}},{key:"clearAccessNode",value:function(e){var t;this.delete(Fg(t="".concat(xL,"_").concat(e,"-")).call(t,wL))}},{key:"getAccessUrls",value:function(){return this.get("".concat(OL,"-").concat(wL))}},{key:"setAccessUrls",value:function(e){var t=qg(e).call(e,(function(e){var t,r=e.host,n=e.path;return Fg(t="https://".concat(r)).call(t,n)}));return this.set("".concat(OL,"-").concat(wL),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(OL,"-").concat(wL))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Fg(r=Fg(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(PL);return(null==a||null===(i=aI(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=Fg(n=Fg(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(PL)||[];return(a=Ty(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(PL,sI(a).call(a,-5))}}},{key:"getServerConfig",value:function(e){var t,r="".concat(e),n=this.get(DL);return(null==n||null===(t=aI(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(DL)||[];return(n=Ty(n).call(n,(function(e){return e.key!==r}))).push({key:r,config:t}),this.set(DL,sI(n).call(n,-5))}}}]),r}(NL),LL=new ML,UL=new pM("JoinRoomConfig",0),VL=function(){function e(t){var r;Fh(this,e),ql(this,"_useTcpAfterJoinTimeout",e.DEFAULT_CONF.useTcpAfterJoinTimeout),ql(this,"_joinWithTcpOnly",e.DEFAULT_CONF.joinWithTcpOnly),ql(this,"_joinWithTcpOnlyDelay",e.DEFAULT_CONF.joinWithTcpOnlyDelay),ql(this,"_blackBrowserRegexList",[]),this._engineId=t,yI(r=location.search).call(r,"__rtc_tcp_only__")>-1&&(this._joinWithTcpOnly=!0,this._joinWithTcpOnlyDelay=0),this._report()}return Vh(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 aI(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 Gg({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(){UL.print("_report",this.toString()),JN(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}();ql(VL,"DEFAULT_CONF",{useTcpAfterJoinTimeout:!0,joinWithTcpOnly:!1,joinWithTcpOnlyDelay:5e3});var FL="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function BL(){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 jL="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",HL="rtc.rtcplus.com".split(","),GL={VERSION:"4.58.10",ICE_CONFIG_REQUEST_URLS_INTERNAL:qg(FL).call(FL,BL),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:jL,CONFIG_REQUEST_DOMAINS:HL,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",FORCE_ENABLED_REPORT_CALLBACKS:[],SKIP_WEB_AUDIO_IN_TRACK:!1,AUDIO_STALL:!0,VIDEO_STALL:!0,VIDEO_STALL_100MS:!1,STATS_SCALLBACK_SUPPORT:!0,JOIN_ROOM_CONFIG:VL.DEFAULT_CONF,SIGNAL_COMPRESSION:!0,SIGNAL_CROP_JOINROOM:!0,VIDEO_STALL_DATA:500,AUDIO_STALL_DATA:200,IOS_SAFARI_ORIENTATION:!1,FALLBACK_ENCODE_CODEC:""};function zL(e,t){var r;if(BN("setParameter",0,Fg(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("JOIN_ROOM_CONFIG"===e)return VL.setDefaulConf(t);if("ICE_CONFIG_REQUEST_URLS"!==e)if("VIDEO_STALL_DATA"!==e)if("AUDIO_STALL_DATA"!==e)if("VIDEO_STALL_100MS"!==e)if("PLATFORM"!==e||"string"!=typeof t)if("PRODUCT"!==e||"string"!=typeof t)if("FORCE_ENABLED_REPORT_CALLBACKS"!==e){if("LOG_SERVER_URL"===e){var n=t===vh.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===vh.domestic?jL:"string"==typeof t?t:void 0;n&&(GL.LOG_SERVER_URL=n,VN(n))}else if("OVERSEA"===e)return UN({extra_is_oversea:t?"1":"0"}),void(GL.OVERSEA=t);if("CONFIG_REQUEST_DOMAINS"===e&&Array.isArray(t)&&t.length>0)GL.CONFIG_REQUEST_DOMAINS=t;else{"DEVICE_ID"===e&&LL.setDeviceId(t);var i=Nx.getKeys();Xy(i).call(i,e)?Nx.setParameter(e,t):GL[e]=t}}else{var o="string"==typeof t?[t]:t;GL.FORCE_ENABLED_REPORT_CALLBACKS=o}else UN({product:t});else UN({platform:t});else GL.VIDEO_STALL_100MS=RM&&!!t;else GL.AUDIO_STALL_DATA=Math.max(200,Number(t));else GL.VIDEO_STALL_DATA=Math.max(500,Number(t));else{var a="string"==typeof t?[t]:t;GL.ICE_CONFIG_REQUEST_URLS=qg(a).call(a,BL)}}}function KL(e){return"DEVICE_ID"===e?LL.getDeviceId():GL[e]}function WL(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)||mh.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:qg(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 XL=[];function YL(e){XL=e}var qL={width:640,height:480,frameRate:15,maxKbps:600},JL={width:1920,height:1080,frameRate:15,maxKbps:3e3};function QL(e,t){if("boolean"!=typeof e)throw new bC(fC.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function ZL(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(e<i||e>o||"number"!=typeof e)throw new bC(fC.INVALID_PARAMS,Fg(r=Fg(n="Invalid ".concat(t,": the value range is [")).call(n,i,", ")).call(r,o,"]. integer only"))}function $L(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 bC(fC.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!function(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}(e,i,o))throw new bC(fC.INVALID_PARAMS,Fg(r=Fg(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function eU(e,t,r){var n;if(!Xy(r).call(r,e))throw new bC(fC.INVALID_PARAMS,Fg(n="Invalid ".concat(t,": The value can only be set as ")).call(n,Gg(r)))}function tU(e){if(!(e instanceof MediaStreamTrack))throw new bC(fC.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function rU(e,t){if(oU(e))throw new bC(fC.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function nU(e,t){if(!(e instanceof ArrayBuffer))throw new bC(fC.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function iU(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=MS(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(o){}}function oU(e){return null==e}function aU(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new bC(fC.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function sU(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new bC(fC.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function cU(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new bC(fC.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function uU(e){rU(e,"userInfo"),sU(e.userId),oU(e.extraInfo)||$L(e.extraInfo,"userInfo.extraInfo",1,200)}function dU(e){rU(e,"roomConfig"),QL(e.isAutoPublish,"roomConfig.isAutoPublish"),QL(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),QL(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),oU(e.roomProfileType)||eU(e.roomProfileType,"roomConfig",[kh.communication,kh.chat,kh.chatRoom,kh.coHost,kh.meeting,kh.classRoom])}function lU(e){rU(e,"videoPlayerOption")}function hU(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 bC(fC.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:wM.str2ab(Gg(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new bC(fC.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function pU(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new bC(fC.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function vU(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 bC(fC.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function _U(e){var t,r=my(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;ZL(null==n?void 0:n.maxKbps,"maxKbps"),vU(null==n?void 0:n.width,"width"),vU(null==n?void 0:n.height,"height"),vU(null==n?void 0:n.frameRate,"frameRate")}}catch(jZ){r.e(jZ)}finally{r.f()}}function fU(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 ZL(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var mU=r(js),gU={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?sI(n).call(n,1):n);return mU?Fg(i).call(i,mU(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}(gU);var yU=gU.exports,SU=r(yU),bU=new pM("VERTC",0),kU=function(e){UA(r,e);var t=ew(r);function r(){return Fh(this,r),t.apply(this,arguments)}return Vh(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=MA(NA(r.prototype),"emit",this)).call.apply(n,Fg(i=[this,e]).call(i,a))}catch(BZ){return bU.error("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,BZ),console.error(BZ),Boolean(t)}}}]),r}(yU.EventEmitter),EU=r(_A),TU=P,IU=rr,RU=ee,AU=cA,wU=Qt,CU=w,xU=Wc,OU=F;wr({target:"Reflect",stat:!0,forced:o((function(){var e=function(){},t=wU.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=CU.f(IU(t),r);if(!c){if(RU(o=xU(t)))return e(o,r,n,s);c=OU(0)}if(AU(c)){if(!1===c.writable||!RU(s))return!1;if(i=CU.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,wU.f(s,r,i)}else wU.f(s,r,OU(0,n))}else{if(void 0===(a=c.set))return!1;TU(a,s,n)}return!0}});var PU=r(te.Reflect.set),DU=r(mi.f("asyncIterator"));function NU(e){var t,r,n,i=2;for(void 0!==Al&&(r=DU,n=Kl);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new MU(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function MU(e){function t(e){if(Object(e)!==e)return tg.reject(new TypeError(e+" is not an object."));var t=e.done;return tg.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(MU=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?tg.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?tg.reject(e):t(r.apply(this.s,arguments))}},new MU(e)}var LU=[{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}];nk("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Sk);var UU=te.Set,VU=Ae,FU=function(e){if("object"==typeof e&&"size"in e&&"has"in e&&"add"in e&&"delete"in e&&"keys"in e)return e;throw TypeError(VU(e)+" is not a set")},BU=kk,jU=ae("Set"),HU=jU.prototype,GU={Set:jU,add:BU("add",1),has:BU("has",1),remove:BU("delete",1),proto:HU},zU=tE,KU=function(e,t,r){return r?zU(e.keys(),t,!0):e.forEach(t)},WU=KU,XU=GU.Set,YU=GU.add,qU=function(e){var t=new XU;return WU(e,(function(e){YU(t,e)})),t},JU=function(e){return e.size},QU=Oe,ZU=rr,$U=P,eV=Pr,tV=function(e){return{iterator:e,next:e.next,done:!1}},rV="Invalid size",nV=RangeError,iV=TypeError,oV=Math.max,aV=function(e,t,r,n){this.set=e,this.size=t,this.has=r,this.keys=n};aV.prototype={getIterator:function(){return tV(ZU($U(this.keys,this.set)))},includes:function(e){return $U(this.has,this.set,e)}};var sV=function(e){ZU(e);var t=+e.size;if(t!=t)throw iV(rV);var r=eV(t);if(r<0)throw nV(rV);return new aV(e,oV(r,0),QU(e.has),QU(e.keys))},cV=FU,uV=qU,dV=JU,lV=sV,hV=KU,pV=tE,vV=GU.has,_V=GU.remove,fV=function(e){var t=cV(this),r=lV(e),n=uV(t);return dV(t)<=r.size?hV(t,(function(e){r.includes(e)&&_V(n,e)})):pV(r.getIterator(),(function(e){vV(t,e)&&_V(n,e)})),n},mV=function(){return!1},gV=fV;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{difference:gV});var yV=FU,SV=JU,bV=sV,kV=KU,EV=tE,TV=GU.Set,IV=GU.add,RV=GU.has,AV=function(e){var t=yV(this),r=bV(e),n=new TV;return SV(t)>r.size?EV(r.getIterator(),(function(e){RV(t,e)&&IV(n,e)})):kV(t,(function(e){r.includes(e)&&IV(n,e)})),n},wV=AV;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{intersection:wV});var CV=FU,xV=GU.has,OV=JU,PV=sV,DV=KU,NV=tE,MV=Op,LV=function(e){var t=CV(this),r=PV(e);if(OV(t)<=r.size)return!1!==DV(t,(function(e){if(r.includes(e))return!1}),!0);var n=r.getIterator();return!1!==NV(n,(function(e){if(xV(t,e))return MV(n,"normal",!1)}))},UV=LV;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{isDisjointFrom:UV});var VV=FU,FV=JU,BV=KU,jV=sV,HV=function(e){var t=VV(this),r=jV(e);return!(FV(t)>r.size)&&!1!==BV(t,(function(e){if(!r.includes(e))return!1}),!0)},GV=HV;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{isSubsetOf:GV});var zV=FU,KV=GU.has,WV=JU,XV=sV,YV=tE,qV=Op,JV=function(e){var t=zV(this),r=XV(e);if(WV(t)<r.size)return!1;var n=r.getIterator();return!1!==YV(n,(function(e){if(!KV(t,e))return qV(n,"normal",!1)}))},QV=JV;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{isSupersetOf:QV});var ZV=FU,$V=qU,eF=sV,tF=tE,rF=GU.add,nF=GU.has,iF=GU.remove,oF=function(e){var t=ZV(this),r=eF(e).getIterator(),n=$V(t);return tF(r,(function(e){nF(t,e)?iF(n,e):rF(n,e)})),n},aF=oF;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{symmetricDifference:aF});var sF=FU,cF=GU.add,uF=qU,dF=sV,lF=tE,hF=function(e){var t=sF(this),r=dF(e).getIterator(),n=uF(t);return lF(r,(function(e){cF(n,e)})),n},pF=hF;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{union:pF});var vF=UU;wr({target:"Set",stat:!0,forced:!0},{from:Gk}),wr({target:"Set",stat:!0,forced:!0},{of:Kk});var _F=FU,fF=GU.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=_F(this),t=0,r=arguments.length;t<r;t++)fF(e,arguments[t]);return e}});var mF=FU,gF=GU.remove;wr({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=mF(this),r=!0,n=0,i=arguments.length;n<i;n++)e=gF(t,arguments[n]),r=r&&e;return!!r}});var yF=Jt,SF=FU,bF=KU;wr({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=SF(this),r=yF(e,arguments.length>1?arguments[1]:void 0);return!1!==bF(t,(function(e){if(!r(e,e,t))return!1}),!0)}});var kF=mn,EF=Ze,TF=K,IF=Oc,RF=ht("iterator"),AF=Object,wF=A,CF=function(e){if(TF(e))return!1;var t=AF(e);return void 0!==t[RF]||"@@iterator"in t||EF(IF,kF(t))},xF=ee,OF=ae("Set"),PF=function(e){return function(e){return xF(e)&&"number"==typeof e.size&&wF(e.has)&&wF(e.keys)}(e)?e:CF(e)?new OF(e):e},DF=P,NF=PF,MF=fV;wr({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){return DF(MF,this,NF(e))}});var LF=Jt,UF=FU,VF=KU,FF=GU.Set,BF=GU.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=UF(this),r=LF(e,arguments.length>1?arguments[1]:void 0),n=new FF;return VF(t,(function(e){r(e,e,t)&&BF(n,e)})),n}});var jF=Jt,HF=FU,GF=KU;wr({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=HF(this),r=jF(e,arguments.length>1?arguments[1]:void 0),n=GF(t,(function(e){if(r(e,e,t))return{value:e}}),!0);return n&&n.value}});var zF=P,KF=PF,WF=AV;wr({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){return zF(WF,this,KF(e))}});var XF=P,YF=PF,qF=LV;wr({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){return XF(qF,this,YF(e))}});var JF=P,QF=PF,ZF=HV;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){return JF(ZF,this,QF(e))}});var $F=P,eB=PF,tB=JV;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){return $F(tB,this,eB(e))}});var rB=wr,nB=f,iB=FU,oB=KU,aB=Sn,sB=nB([].join),cB=nB([].push);rB({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=iB(this),r=void 0===e?",":aB(e),n=[];return oB(t,(function(e){cB(n,e)})),sB(n,r)}});var uB=Jt,dB=FU,lB=KU,hB=GU.Set,pB=GU.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=dB(this),r=uB(e,arguments.length>1?arguments[1]:void 0),n=new hB;return lB(t,(function(e){pB(n,r(e,e,t))})),n}});var vB=Oe,_B=FU,fB=KU,mB=TypeError;wr({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=_B(this),r=arguments.length<2,n=r?void 0:arguments[1];if(vB(e),fB(t,(function(i){r?(r=!1,n=i):n=e(n,i,i,t)})),r)throw mB("Reduce of empty set with no initial value");return n}});var gB=Jt,yB=FU,SB=KU;wr({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=yB(this),r=gB(e,arguments.length>1?arguments[1]:void 0);return!0===SB(t,(function(e){if(r(e,e,t))return!0}),!0)}});var bB=P,kB=PF,EB=oF;wr({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){return bB(EB,this,kB(e))}});var TB=P,IB=PF,RB=hF;wr({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){return TB(RB,this,IB(e))}});var AB=r(vF),wB=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!QM()&&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,UB();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,LB();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)}}(),CB=function(){var e=Ng(Pg().mark((function e(){var t;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.next=3,UB();case 3:if(e.t0=e.sent,!e.t0){e.next=8;break}return e.next=7,LB();case 7:e.t0=e.sent;case 8:if(!e.t0){e.next=10;break}t.push("H264");case 10:return e.next=12,FB();case 12:if(e.t1=e.sent,!e.t1){e.next=17;break}return e.next=16,VB();case 16:e.t1=e.sent;case 17:if(!e.t1){e.next=19;break}t.push("vp8");case 19:return e.abrupt("return",t);case 20:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),xB=function(){var e=Ng(Pg().mark((function e(){var t;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,CB();case 2:return t=e.sent,e.abrupt("return",qg(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),OB={};function PB(e){var t;if(aI(t=["level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f","profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1","packetization-mode=1;profile-level-id=42e01f;level-asymmetry-allowed=1"]).call(t,(function(t){return null==e?void 0:Xy(e).call(e,t)}))){for(var r=navigator.userAgent.toLowerCase(),n=!1,i=0,o=[/miuibrowser/,/70.*HeyTapBrowser/i];i<o.length;i++){o[i].test(r)&&(n=!0)}return!n}return!1}var DB=function(){var e=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection({sdpSemantics:"unified-plan"})).addTransceiver("video",{direction:t}),e.next=4,r.createOffer();case 4:return n=e.sent,r.close(),e.abrupt("return",n.sdp.toLowerCase());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),NB=function(){var e=Ng(Pg().mark((function e(){var t,r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,DB("sendonly");case 2:if(r=e.sent,!Xy(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,DB("sendonly");case 6:r=e.sent;case 7:return OB.h264encode=PB(r),OB.vp8encode=yI(r).call(r,"vp8")>-1,e.abrupt("return",OB);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),MB=function(){var e=Ng(Pg().mark((function e(){var t,r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,DB("recvonly");case 2:if(r=e.sent,!Xy(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,DB("recvonly");case 6:r=e.sent;case 7:return OB.h264decode=PB(r),OB.vp8decode=yI(r).call(r,"vp8")>-1,e.abrupt("return",OB);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),LB=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==OB.h264encode){e.next=9;break}return e.prev=1,e.next=4,NB();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",OB.h264encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),UB=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==OB.h264decode){e.next=9;break}return e.prev=1,e.next=4,MB();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",OB.h264decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),VB=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==OB.vp8encode){e.next=9;break}return e.prev=1,e.next=4,NB();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",OB.vp8encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),FB=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==OB.vp8decode){e.next=9;break}return e.prev=1,e.next=4,MB();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",OB.vp8decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),BB=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},jB=function(){return lL?nL&&AL>=70||tL&&kL>=80||rL&&bL>=14:fL?nL&&AL>=70||tL&&kL>=80:vL?TL[0]>=14:!!_L&&(nL&&AL>=86)},HB=nL&&AL<=114,GB=!tL||kL>=96,zB=!(rL&&bL<=14),KB=_L&&nL||vL&&(17===TL[0]||16===TL[0]),WB=new cT,XB=function(){var e=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new jI((function(e,r){var n=KL("STATS_SCALLBACK_SUPPORT");if(nL&&void 0===window.InstallTrigger&&HB&&n)try{t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!Xy(QB).call(QB,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(Ql(Ql({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return Ty(r).call(r,(function(t){return"ssrc"!==t.type||t.googTrackId===e}))}})}))}catch(BZ){r(BZ)}else e({all:[],getTrackStats:function(){return[]}})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),YB=function(){var e=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c;return Pg().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 cT,n.forEach((function(e){var t=o.get(e.type)||new cT;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(JB.codec))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=o.get(JB.transport))||void 0===n||n.forEach((function(e){e.id===d&&(s=e,t.add(e))})),null===(i=o.get(JB.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(a=o.get(JB.mediaPlayout))||void 0===a||a.forEach((function(e){e.id===h&&t.add(e)})),s){var p,v,_=s,f=_.localCertificateId,m=_.remoteCertificateId,g=_.selectedCandidatePairId;null===(p=o.get(JB.certificate))||void 0===p||p.forEach((function(e){(e.id===f||e.id===m)&&t.add(e)})),null===(v=o.get(JB.candidatePair))||void 0===v||v.forEach((function(e){e.id===g&&(c=e,t.add(e))}))}if(c){var y,S,b=c,k=b.localCandidateId,E=b.remoteCandidateId;null===(y=o.get(JB.localCandidate))||void 0===y||y.forEach((function(e){e.id===k&&t.add(e)})),null===(S=o.get(JB.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===E&&t.add(e)}))}}))},o.get(JB.mediaSource)?null===(s=o.get(JB.mediaSource))||void 0===s||s.forEach((function(e){var t,r=new AB;r.add(e);var n=[];null===(t=o.get(JB.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=o.get(JB.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=KC(r)})):o.get(JB.track)&&(null===(c=o.get(JB.track))||void 0===c||c.forEach((function(e){var t,r=new AB;r.add(e);var n=[];null===(t=o.get(JB.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.trackId===e.id&&(r.add(t),n.push(t),null===(i=o.get(JB.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=KC(r)}))),null===(r=o.get(JB.inboundRtp))||void 0===r||r.forEach((function(e){var t,r=new AB;r.add(e),null===(t=o.get(JB.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(JB.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(s=t.trackIdentifier)})));i[s]=KC(r)})),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),qB=function(){var e=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u;return Pg().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(!tL&&!rL){e.next=15;break}return o=[],e.prev=5,e.next=8,t.getStats(r);case 8:e.sent.forEach((function(e){o.push(e)})),e.next=14;break;case 12:e.prev=12,e.t0=e.catch(5);case 14:return e.abrupt("return",o);case 15:return(!(a=WB.get(t))||Date.now()-a.timestamp>150)&&(a={timestamp:Date.now(),statsPromise:YB(t),extraStatsPromise:XB(t)},WB.set(t,a)),e.next=19,a.statsPromise;case 19:if(s=e.sent,c=(i?s[i]:s.all)||[],n){e.next=26;break}return e.next=24,a.extraStatsPromise;case 24:u=e.sent,c=Fg(c).call(c,(i?u.getTrackStats(i):u.all)||[]);case 26:return e.abrupt("return",c);case 27:case"end":return e.stop()}}),e,null,[[5,12]])})));return function(t,r,n){return e.apply(this,arguments)}}(),JB=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}(JB||{}),QB=["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"],ZB={},$B={},ej={exports:{}},tj=ej.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"]}]};MS(tj).forEach((function(e){tj[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}));var rj=ej.exports;!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=rj,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t,o={},a=[],s=o;return Ty(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=sI(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 oS(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return qg(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=qg(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 qg(t=e.split(" ")).call(t,(function(e){var t;return oS(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return qg(r=e.split(";")).call(r,(function(e){var r;return qg(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}}))}))}}($B);var nj=rj,ij=/%[sdv%]/g,oj=function(e){var t=1,r=arguments,n=r.length;return e.replace(ij,(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""}}))},aj=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 oj.apply(null,n)},sj=["v","o","s","i","u","e","p","c","b","t","r","z","a"],cj=["i","c","b","a"],uj=$B,dj=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||sj,n=t.innerOrder||cj,i=[];return r.forEach((function(t){nj[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(aj(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(aj(t,r,e))}))}))})),e.media.forEach((function(e){i.push(aj("m",nj.m[0],e)),n.forEach((function(t){nj[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(aj(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(aj(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};ZB.write=dj,ZB.parse=uj.parse,ZB.parseParams=uj.parseParams,ZB.parseFmtpConfig=uj.parseFmtpConfig,ZB.parsePayloads=uj.parsePayloads,ZB.parseRemoteCandidates=uj.parseRemoteCandidates,ZB.parseImageAttributes=uj.parseImageAttributes,ZB.parseSimulcastStreamList=uj.parseSimulcastStreamList;var lj=new pM("FirefoxHandler",3),hj=Math.pow(2,32),pj="kp34Za0H+aVf862l";function vj(e){return e>hj-18?(lj.warn("generateAllSsrc","reset start id",e),vj(e=e-hj+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var _j=function(e,t,r){var n,i,o;return[{id:r,attribute:"cname",value:arguments.length>3&&void 0!==arguments[3]?arguments[3]:"o/i14u9pJrxRKAsu"},{id:r,attribute:"msid",value:Fg(n=Fg(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Fg(o="".concat(e,"-")).call(o,t)}]},fj=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=oS(s).call(s,(function(t,r){return Fg(t).call(t,_j(e,"video",r,c))}),[]),h=[{semantics:"FID",ssrcs:Fg(r="".concat(i," ")).call(r,o)}];u&&h.push({semantics:"FEC-FR",ssrcs:Fg(d="".concat(i," ")).call(d,a)});return{ssrcs:l,ssrcGroups:h}};function mj(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 gj=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=Ql(Ql({},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,ZB.write(i)};function yj(e){return Sj.apply(this,arguments)}function Sj(){return(Sj=Ng(Pg().mark((function e(t){var r,n,i,o,a;return Pg().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,kj(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=bj(n,a),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function bj(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(Ql(Ql({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(Ql(Ql({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var kj=function(){var e=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c;return Pg().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,wM.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=AM(Uint8Array,n,i,o,a),e.next=15,wM.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)}}(),Ej=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=my(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(Xy(o=c.config).call(o,"level-asymmetry-allowed=1")&&Xy(a=c.config).call(a,"packetization-mode=1")&&Xy(s=c.config).call(s,"profile-level-id=42e01f")){r=c.payload;break}}}catch(jZ){i.e(jZ)}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(BI(l=e.rtp).call(l,u,1)[0]);break}}else if(d.codec===t){var h;e.rtp.unshift(BI(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(" ")}},Tj=function(e){var t,r=ZB.parse(e);return r.media=qg(t=r.media).call(t,(function(e){return"audio"===e.type?Aj(e,r):Rj(e,["H264","VP8"],r)})),ZB.write(r)},Ij=function(e){e.media.forEach((function(e){"audio"!==e.type&&"video"!==e.type||e.rtp.forEach((function(t){var r;e.rtcpFb||(e.rtcpFb=[]),aI(r=e.rtcpFb).call(r,(function(e){return e.payload===t.payload&&"rrtr"===e.type}))||e.rtcpFb.push({payload:t.payload,type:"rrtr"})}))}))},Rj=function(e,t,r){var n,i,o,a,s,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{rrtr:!1},u={},d={},l=-1,h=[];(Array.isArray(e.fmtp)&&e.fmtp.forEach((function(e){var t=e.payload,r=e.config;if(_C(r).call(r,"apt=")){var n=sI(r).call(r,4);u[t]=n}else Xy(r).call(r,"42e01f")&&Xy(r).call(r,"packetization-mode=1")&&(l=t)})),Array.isArray(e.rtp))&&(e.rtp=Ty(n=e.rtp).call(n,(function(e){var r,n=e.codec,i=e.payload;switch(n){case"H264":return r=!1,qg(t).call(t,(function(e){"H264"===e&&i===l&&(d[i]=i,h.push(i),r=!0)})),r;case"rtx":return!!d[u[i]]&&(d[i]=i,!0);case"red":case"ulpfec":case"flexfec-03":return d[i]=i,!0;default:return r=!1,qg(t).call(t,(function(e){e===n&&(d[i]=i,h.push(i),r=!0)})),r}})));Array.isArray(e.fmtp)&&(e.fmtp=Ty(i=e.fmtp).call(i,(function(e){return d[e.payload]})));Array.isArray(e.rtcpFb)?e.rtcpFb=Ty(o=e.rtcpFb).call(o,(function(e){return d[e.payload]})):e.rtcpFb=[];(c.rrtr&&h.forEach((function(t){var r;null===(r=e.rtcpFb)||void 0===r||r.push({payload:t,type:"rrtr"})})),wj(e,r),Array.isArray(e.ext))&&(e.ext=Ty(a=e.ext).call(a,(function(e){if("http://www.webrtc.org/experiments/rtp-hdrext/video-content-type"!==e.uri&&"http://www.webrtc.org/experiments/rtp-hdrext/video-timing"!==e.uri&&"http://www.webrtc.org/experiments/rtp-hdrext/color-space"!==e.uri)return e})));"string"==typeof e.payloads&&(e.payloads=Ty(s=e.payloads.split(" ")).call(s,(function(e){return d[e]})).join(" "));return e},Aj=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{rrtr:!1},i={};Array.isArray(e.rtp)&&(e.rtp=Ty(r=e.rtp).call(r,(function(e){var t=e.codec,r=e.payload;return("opus"===t||"red"===t)&&(i[r]=r,!0)})));if(Array.isArray(e.rtcpFb)||(e.rtcpFb=[]),n.rrtr&&MS(i).forEach((function(t){var r;null===(r=e.rtcpFb)||void 0===r||r.push({payload:Number(t),type:"rrtr"})})),wj(e,t),"string"==typeof e.payloads){var o=[];e.payloads.split(" ").forEach((function(e){i[e]&&o.push(e)})),e.payloads=o.join(" ")}return e},wj=function(e,t){e.iceOptions&&delete e.iceOptions,e.icePwd&&(t.icePwd=e.icePwd,delete e.icePwd),e.iceUfrag&&(t.iceUfrag=e.iceUfrag,delete e.iceUfrag),e.fingerprint&&(t.fingerprint=e.fingerprint,delete e.fingerprint)},Cj=function(e){UA(n,e);var t,r=ew(n);function n(e,t){var i;return Fh(this,n),ql(aA(i=r.call(this)),"_peerConnection",void 0),ql(aA(i),"_dataChannel",void 0),ql(aA(i),"_context",void 0),ql(aA(i),"peerConnectionMode",0),ql(aA(i),"id",void 0),ql(aA(i),"_monitor",void 0),ql(aA(i),"logger",void 0),ql(aA(i),"_nextSsrc",Math.floor(Math.random()*hj+1e4)),ql(aA(i),"_aSendonlyAnswerTpl",void 0),ql(aA(i),"_vSendonlyAnswerTpl",void 0),ql(aA(i),"_enableSubFlexfec",!1),ql(aA(i),"audioTrack4ff",void 0),ql(aA(i),"setLocalDescription",void 0),ql(aA(i),"setRemoteDescription",void 0),i.peer=t,i.id=e.id,i._monitor=KN(i.id),i.logger=new pM("BasicHandler",3,e.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 Vh(n,[{key:"destroy",value:function(){this.logger.info("destroy",this.peerConnectionId||""),MA(NA(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),this.logger.info("simulcast() ","simulcastLayers: %o",c)):(c=qg(o=sI(a=sI(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){if(e.width>e.height&&t.width<t.height||e.width<e.height&&t.width>t.height){var r=e.width;e.width=e.height,e.height=r}var n=JM(e.width),i=t.width/n;return{width:n,height:Math.floor(t.height/i),scaleResolutionDownBy:i,frameRate:JM(e.frameRate)||15,maxkbps:e.maxKbps||600}})),this.logger.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,h,p=null==r?void 0:r.preprocessingTrack,v=Ql({},qL);if(p){var _=null==p?void 0:p.getSettings();v={width:Math.floor(_.width),height:Math.floor(_.height),frameRate:Math.floor(_.frameRate)}}"number"!=typeof v.frameRate&&(v.frameRate=30);var f=null==e?void 0:e.videoEncodeConfig[0],m={maxBitrate:1e3*f.maxKbps,rid:"0"};if(e.prevBitrate=f.maxKbps,c.sendEncodings=[m],u.push({width:v.width,height:v.height,framerate:v.frameRate,maxkbps:f.maxKbps,rid:"0"}),i&&(!tL||"VP8"===(null===(l=this._context)||void 0===l||null===(h=l.serverConfig)||void 0===h?void 0:h.videoCodec))){var g,y,S=function(e){for(var t=0,r=e.width*e.height,n=0;n<LU.length;n++)if(r>=LU[n].totalPixels){t=n;break}if(0===t)return LU[t].maxLayers;var i=LU[t-1].totalPixels;return(i-r)/(i-LU[t].totalPixels)<.1?LU[t-1].maxLayers:LU[t].maxLayers}(v);if(this.logger.info("simulcast() ","maxLayers: %o",S),S>1)this._simulcast(e,Ql(Ql({},v),{},{maxKbps:f.maxKbps}),c,u,S),null!==(g=this._context)&&void 0!==g&&null!==(y=g.serverConfig)&&void 0!==y&&y.simulcastOnDemand&&(d=qg(u).call(u,(function(e,t){return Ql(Ql({},e),{},{video_index:t,sub_index:t})})))}}this.logger.info("publish videoTransceiverInit videoDescriptions","",c,u);var b=null==n?void 0:n.preprocessingTrack;(null==n?void 0:n.mixType)!==Dh.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(b=null==n?void 0:n.mixedAudioTrack),b=o&&b?b:"audio";var k=null==r?void 0:r.preprocessingTrack;k=a&&k?k:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",Gg({aTrack:fx(b),vTrack:fx(k),audioTransceiverInit:s,videoTransceiverInit:c}))}catch(BZ){}return{semantics:"unified-plan",videoDescriptions:u,subVideoDescriptions:d,audioTransceiverInit:{track:b,init:s},videoTransceiverInit:{track:k,init:c}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;this.logger.info("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.preprocessingTrack,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 this.logger.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:qg(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",Gg(c.encodings))}catch(BZ){}}}else this.logger.warn("updateMaxBitrate()","no pub")}},{key:"getStats",value:function(e,t){return qB(this._peerConnection,e,t)}},{key:"setCurrentDescription",value:(t=Ng(Pg().mark((function e(){return Pg().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,r=ZB.parse(e);r.media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:aI(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:aI(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&&Xy(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))})),zB&&Ij(r)}},{key:"pc",get:function(){return this._peerConnection}},{key:"peerConnectionId",get:function(){return this.peer.getConnectionId()||""}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n,i=r.codec,o=r.payload;if(Xy(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=aI(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=Fg(s=[]).call(s,tR(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,Ql(Ql({},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}(yU.EventEmitter),xj=function(e){UA(v,e);var t,r,n,i,o,a,s,c,u,d,l,h,p=ew(v);function v(){var e,t,r;return Fh(this,v),ql(aA(r=p.call(this)),"deviceMap",{audioinput:new cT,audiooutput:new cT,videoinput:new cT}),ql(aA(r),"checkDeviceChangeTimer",null),ql(aA(r),"isSupportedPermissionsQuery",!1),ql(aA(r),"isGrantedMicrophonePermission",!1),ql(aA(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!QM()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(aA(r)),!QM()&&r.initListener().then((function(){r.updateDeviceListInSilent()})),r}return Vh(v,[{key:"refreshDevices",value:(h=Ng(Pg().mark((function e(){var t,r,n,i=this,o=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:"audio",navigator.mediaDevices){e.next=3;break}return e.abrupt("return");case 3:if(r=void 0,!tL){e.next=19;break}if(e.prev=5,"audio"!==t){e.next=12;break}return e.next=9,navigator.mediaDevices.getUserMedia({audio:!0});case 9:r=e.sent,e.next=15;break;case 12:return e.next=14,navigator.mediaDevices.getUserMedia({video:!0});case 14:r=e.sent;case 15:e.next=19;break;case 17:e.prev=17,e.t0=e.catch(5);case 19:return e.next=21,navigator.mediaDevices.enumerateDevices();case 21:n=e.sent,r&&r.getTracks().forEach((function(e){return e.stop()})),n.forEach((function(e){var t;e.deviceId&&(null===(t=i.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))}));case 24:case"end":return e.stop()}}),e,null,[[5,17]])}))),function(){return h.apply(this,arguments)})},{key:"initListener",value:(l=Ng(Pg().mark((function e(){var t,r,n,i,o=this;return Pg().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 l.apply(this,arguments)})},{key:"_handleDeviceChange",value:(d=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c=this;return Pg().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(o=void 0,!tL){e.next=7;break}return e.next=6,navigator.mediaDevices.getUserMedia({audio:!0});case 6:o=e.sent;case 7:return e.next=9,navigator.mediaDevices.enumerateDevices();case 9:a=e.sent,a=Ty(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=KC(Fg(t=[]).call(t,tR(cw(r=this.deviceMap.audioinput).call(r)),tR(cw(n=this.deviceMap.videoinput).call(n)),tR(cw(i=this.deviceMap.audiooutput).call(i)))),(pL||dL)&&!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||(Xy(t=e.kind).call(t,"video")?c.emit(Lh.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):Xy(r=e.kind).call(r,"audio")&&c.emit(Lh.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;aI(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),Xy(t=e.kind).call(t,"video")?c.emit(Lh.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):Xy(r=e.kind).call(r,"audio")&&c.emit(Lh.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 16:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"getUserMedia",value:(u=Ng(Pg().mark((function e(t){var r;return Pg().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),null!=t&&t.video?this.refreshDevices("video"):this.refreshDevices("audio"),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(c=Ng(Pg().mark((function e(){var t,r;return Pg().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=Ty(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=Ty(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 c.apply(this,arguments)})},{key:"getPermissions",value:(s=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=(r=l.length>0&&void 0!==l[0]?l[0]:{}).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:if(!n){e.next=75;break}return e.next=73,this.refreshDevices("audio");case 73:e.next=77;break;case 75:return e.next=77,this.refreshDevices("video");case 77:return e.abrupt("return",a);case 78:case"end":return e.stop()}}),e,this,[[31,38]])}))),function(){return s.apply(this,arguments)})},{key:"updateDeviceListInSilent",value:(a=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.isGrantedCameraPermission&&this.isGrantedMicrophonePermission&&this.refreshDevices("audio");case 1:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=Ng(Pg().mark((function e(){var t,r,n,i;return Pg().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",KC(Fg(t=[]).call(t,tR(cw(r=this.deviceMap.audioinput).call(r)),tR(cw(n=this.deviceMap.videoinput).call(n)),tR(cw(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=Ng(Pg().mark((function e(){var t;return Pg().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",KC(cw(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=Ng(Pg().mark((function e(){var t;return Pg().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("video");case 4:return e.abrupt("return",KC(cw(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=Ng(Pg().mark((function e(){var t;return Pg().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("audio");case 4:return e.abrupt("return",KC(cw(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=Ng(Pg().mark((function e(t){var r;return Pg().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",aI(r).call(r,(function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),v}(kU),Oj=new xj;!QM()&&(window.__rtc_dd__=Oj);var Pj=new pM("InternalEventBus",1),Dj=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}(Dj||{}),Nj=function(e){UA(r,e);var t=ew(r);function r(){return Fh(this,r),t.apply(this,arguments)}return Vh(r,[{key:"emit",value:function(e){var t,n;Pj.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=MA(NA(r.prototype),"emit",this)).call.apply(t,Fg(n=[this,e]).call(n,o))}}]),r}(yU.EventEmitter),Mj=new Nj,Lj=new pM("AudioContext",1),Uj=function(){function e(){var t=this;Fh(this,e),ql(this,"_audioContextInstance",void 0),ql(this,"_previousState",""),ql(this,"_currentState",""),ql(this,"_contextStuckAt",0);var r=0;QM()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,Lj.info("currentTime resume"),GN("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,Lj.warn("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),GN("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return Vh(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;Lj.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(),(vL||dL)&&("running"===e._previousState&&"interrupted"===e._currentState&&Mj.emit(Dj.ON_IOS_INTERRUPTION_START),"interrupted"===e._previousState&&"running"===e._currentState&&Mj.emit(Dj.ON_IOS_INTERRUPTION_END))}}return this._audioContextInstance}}]),e}(),Vj=function(){function e(t){Fh(this,e),ql(this,"_ctx",void 0),ql(this,"_analyserNode",void 0),ql(this,"_audioSource",void 0),ql(this,"currentTrackId",void 0),this.currentTrackId=t.id;var r=Fj.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 Vh(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=Ng(Pg().mark((function e(){var t;return Pg().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}(),Fj=new Uj,Bj=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}(Bj||{}),jj=function(){function e(t){Fh(this,e),ql(this,"_plugins",new cT),this.id=t}var t;return Vh(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(eC(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 aI(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=Ng(Pg().mark((function e(t){var r,n,i,o,a;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.mediaTrack,i=my(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}(),Hj=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(Hj||{}),Gj=new pM("VERTC",0),zj=function(){function e(){Fh(this,e),ql(this,"_ac",void 0),ql(this,"_sourceNode",void 0),ql(this,"_gainNode",void 0),ql(this,"_destNode",void 0),this._ac=Fj.getAudioContextInstance(),this._gainNode=this._ac.createGain(),this._destNode=this._ac.createMediaStreamDestination(),this._gainNode.connect(this._destNode)}return Vh(e,[{key:"setVolume",value:function(e){this._gainNode.gain.value=e/100}},{key:"getVolume",value:function(){return Math.round(100*this._gainNode.gain.value)}},{key:"updateInputTrack",value:function(e){this._sourceNode&&(this._sourceNode.mediaStream.getTracks().forEach((function(e){e.stop()})),delete this._sourceNode);var t=new MediaStream;t.addTrack(e),this._sourceNode=this._ac.createMediaStreamSource(t),this._sourceNode.connect(this._gainNode)}},{key:"getOutputTrack",value:function(){return this._destNode.stream.getTracks()[0]}},{key:"destroy",value:function(){var e,t;null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),13!==bL&&this._destNode.stream.getTracks().forEach((function(e){e.stop()})),null===(t=this._sourceNode)||void 0===t||t.disconnect(),this._gainNode.disconnect(),delete this._sourceNode}}]),e}(),Kj=function(e){UA(r,e);var t=ew(r);function r(e,n){var i;return Fh(this,r),ql(aA(i=t.call(this)),"sourceType",1),ql(aA(i),"_originTrack",void 0),ql(aA(i),"_trackId",void 0),ql(aA(i),"_channelCount",void 0),i._trackId=n,i._originTrack=e,i._channelCount=e.getSettings().channelCount,i}return Vh(r,[{key:"getId",value:function(){return this._trackId}},{key:"channelCount",get:function(){var e;return null!==(e=this._channelCount)&&void 0!==e?e:0}},{key:"originTrack",get:function(){return this._originTrack},set:function(e){this._originTrack=e,this._channelCount=mediaTrack.getSettings().channelCount}},{key:"destroy",value:function(){this._originTrack.stop()}}]),r}(kU),Wj=function(e){UA(n,e);var t,r=ew(n);function n(e,t){var i;return Fh(this,n),ql(aA(i=r.call(this,e,t)),"_mediaTrack",void 0),ql(aA(i),"_preProcessingTrack",void 0),ql(aA(i),"_ap",void 0),ql(aA(i),"_extensionManager",void 0),ql(aA(i),"captureSessionId",""),ql(aA(i),"handleTrackEnded",(function(){i.emit("track-ended",aA(i)),i.close()})),ql(aA(i),"handleMute",(function(){i.emit("track-mute",aA(i))})),ql(aA(i),"handleUnmute",(function(){i.emit("track-unmute",aA(i))})),i._initListeners(),i}return Vh(n,[{key:"withWebAudio",get:function(){return!!this._ap}},{key:"mediaTrack",get:function(){var e;return null!==(e=this._mediaTrack)&&void 0!==e?e:this._originTrack}},{key:"preprocessingTrack",get:function(){var e;return null!==(e=this._preProcessingTrack)&&void 0!==e?e:this.mediaTrack}},{key:"setTrack",value:function(e,t){this._originTrack=e,this._ap&&(this._ap.updateInputTrack(e),this._mediaTrack=this._ap.getOutputTrack()),t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._extensionManager=t,this._preProcessingTrack=void 0,e.prev=2,e.next=5,t.getPreProcessingTrack(this);case 5:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),console.error(e.t0);case 12:case"end":return e.stop()}}),e,this,[[2,9]])}))),function(e){return t.apply(this,arguments)})},{key:"close",value:function(){var e,t;this._originTrack.removeEventListener("ended",this.handleTrackEnded),this._originTrack.removeEventListener("mute",this.handleMute),this._originTrack.removeEventListener("unmute",this.handleUnmute),null===(e=this._preProcessingTrack)||void 0===e||e.stop(),null===(t=this._mediaTrack)||void 0===t||t.stop(),this._ap&&this._ap.destroy(),MA(NA(n.prototype),"destroy",this).call(this)}},{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}(Kj),Xj=function(e){UA(r,e);var t=ew(r);function r(e,n){var i;return Fh(this,r),ql(aA(i=t.call(this,e,n)),"_mediaTrack",void 0),ql(aA(i),"_ap",void 0),ql(aA(i),"player",void 0),i._originTrack=e,i}return Vh(r,[{key:"mediaTrack",get:function(){var e;return null!==(e=this._mediaTrack)&&void 0!==e?e:this._originTrack}},{key:"preprocessingTrack",get:function(){return this.mediaTrack}},{key:"withWebAudio",get:function(){return!!this._ap}},{key:"setPlayer",value:function(e){this.player=e}},{key:"close",value:function(){this._ap&&this._ap.destroy()}}]),r}(Kj),Yj=function(e){UA(n,e);var t,r=ew(n);function n(e,t){var i;return Fh(this,n),ql(aA(i=r.call(this,e,t)),"mediaType","video"),ql(aA(i),"resolution",void 0),ql(aA(i),"dummy",!1),ql(aA(i),"videoPlayer",void 0),i.resolution={width:0,height:0},i}return Vh(n,[{key:"updateVideoCaptureConfig",value:(t=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Gj.info("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=Ql({},t)).contentHint,tL&&this.streamIndex===sh.STREAM_INDEX_MAIN&&(r.frameRate={ideal:30,max:30}),e.next=6,this.originTrack.applyConstraints(r);case 6:((n=this.originTrack.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 8: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;"contentHint"in this.originTrack&&Xy(t=["text","motion","detail"]).call(t,e)&&(this.originTrack.contentHint=e)}}]),n}(Wj),qj=function(e){UA(n,e);var t,r=ew(n);function n(){var e,t;Fh(this,n);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(t=r.call.apply(r,Fg(e=[this]).call(e,o))),"mediaType","audio"),ql(aA(t),"audioCaptureConfig",void 0),ql(aA(t),"mixedAudioTrack",void 0),ql(aA(t),"mixType",Dh.PLAYOUT_AND_PUBLISH),ql(aA(t),"_audioFetchMap",new cT),ql(aA(t),"notSupportedWebAudio",!1),t}return Vh(n,[{key:"getAudioLevel",value:function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ph.MICROPHONE,n=r===ph.AUDIOMIXING&&this.mixType!==Dh.PLAYOUT&&null!==(e=this.mixedAudioTrack)&&void 0!==e?e:this.preprocessingTrack,i=this._audioFetchMap.get(r);i&&i.currentTrackId===n.id||(null===(t=i)||void 0===t||t.destroy(),i=new Vj(n),this._audioFetchMap.set(r,i));return i.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=Ng(Pg().mark((function e(){return Pg().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 Gj.info("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,this.originTrack.applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){this._audioFetchMap.forEach((function(e){return e.destroy()})),this._audioFetchMap.clear(),MA(NA(n.prototype),"close",this).call(this)}},{key:"setVolume",value:function(e){var t=!KL("SKIP_WEB_AUDIO_IN_TRACK")&&jB();t||(this.notSupportedWebAudio=!0);var r,n=!this.withWebAudio&&100!==e;try{t&&n&&(Gj.print("Create AudioProcess"),this._ap=new zj,this._ap.updateInputTrack(this.originTrack),this._mediaTrack=this._ap.getOutputTrack(),this._extensionManager&&this.generatePreProcessingTrack(this._extensionManager))}catch(i){Gj.print("WebAudio may not supported, quired return"),this.notSupportedWebAudio=!0}this.notSupportedWebAudio||(null===(r=this._ap)||void 0===r||r.setVolume(e));t&&n&&this.emit("needReplaceTrack",this)}},{key:"getVolume",value:function(){return this._ap?this._ap.getVolume():100}}]),n}(Wj),Jj=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"mediaType","video"),ql(aA(n),"videoPlayer",void 0),n}return Vh(r)}(Xj),Qj=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"mediaType","audio"),ql(aA(n),"_audioLevelFetcher",void 0),ql(aA(n),"notSupportedWebAudio",!1),n}return Vh(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new Vj(this.originTrack)),this._audioLevelFetcher.getAudioLevel()}},{key:"setVolume",value:function(e){var t=!KL("SKIP_WEB_AUDIO_IN_TRACK")&&jB();t||(this.notSupportedWebAudio=!0);var r,n,i=!this.withWebAudio&&100!==e;try{t&&i&&(Gj.print("Create AudioProcess"),this._ap=new zj,this._ap.updateInputTrack(this.originTrack),this._mediaTrack=this._ap.getOutputTrack())}catch(o){Gj.print("WebAudio may not supported, quite return"),this.notSupportedWebAudio=!0}this.notSupportedWebAudio||(null===(r=this._ap)||void 0===r||r.setVolume(e));t&&i&&(this.emit("needReplaceTrack",this),null===(n=this.player)||void 0===n||n.playAudio(this))}},{key:"getVolume",value:function(){return this.notSupportedWebAudio?100:this._ap?this._ap.getVolume():100}},{key:"close",value:function(){var e;null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),MA(NA(r.prototype),"close",this).call(this)}}]),r}(Xj),Zj=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_MAIN),n}return Vh(r)}(qj),$j=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_MAIN),n}return Vh(r)}(Yj),eH=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_MAIN),ql(aA(n),"sourceType",0),n}return Vh(r)}(Yj),tH=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_MAIN),ql(aA(n),"sourceType",0),n}return Vh(r)}(qj),rH=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_SCREEN),n}return Vh(r)}(Yj),nH=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_SCREEN),n}return Vh(r)}(qj),iH=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_SCREEN),ql(aA(n),"sourceType",0),n}return Vh(r)}(Yj),oH=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_SCREEN),ql(aA(n),"sourceType",0),n}return Vh(r)}(qj);function aH(e,t){return sH.apply(this,arguments)}function sH(){return(sH=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new $j(t,TM())).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 cH(e,t){return uH.apply(this,arguments)}function uH(){return(uH=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new rH(t,TM())).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 dH(e,t){return lH.apply(this,arguments)}function lH(){return(lH=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=(null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=KN(r.id),s=TM(),e.prev=3,Gj.info("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o,capture_session_id:s}),u=IM(),tL&&(t.frameRate={ideal:30,max:30}),e.next=10,Oj.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,media_device_name:(null===(c=i.getVideoTracks()[0])||void 0===c?void 0:c.label)||"",reason:"success",elapse:IM()-u,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 bC(fC.GET_VIDEO_TRACK_FAILED,Fg(d="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(d,e.t0.message||"unknown message","."),e.t0);case 18:return l=i.getVideoTracks()[0],(h=new $j(l,TM())).captureSessionId=s,e.next=23,h.generatePreProcessingTrack(r);case 23:return e.abrupt("return",h);case 24:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function hH(e,t){return pH.apply(this,arguments)}function pH(){return(pH=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Gj.info("createMicrophoneAudioTrack","constraints:",t),o=(null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=KN(r.id),s=TM(),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=IM(),(d=r.getPluginByName(Bj.PRE_PROCESSING,"RTCAIAnsExtension"))&&(d.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=11,Oj.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:IM()-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 bC(fC.GET_AUDIO_TRACK_FAILED,Fg(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],(p=new Zj(h,TM())).captureSessionId=s,e.next=24,p.generatePreProcessingTrack(r);case 24:return e.abrupt("return",p);case 25:case"end":return e.stop()}}),e,null,[[4,15]])})))).apply(this,arguments)}function vH(e,t,r){return _H.apply(this,arguments)}function _H(){return(_H=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Gj.print("createCameraAndMicrophoneTrack","audioConstraints:",t,"videoConstraints:",r),a=KN(n.id),c=(null===(i=t.deviceId)||void 0===i?void 0:i.exact)||"default",u=(null===(o=r.deviceId)||void 0===o?void 0:o.exact)||"default",d=TM(),l=TM(),TM(),TM(),e.prev=8,null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:u,capture_session_id:d}),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_begin",media_device_id:c,event_session_id:l}),v=IM(),tL&&(r.frameRate={ideal:30,max:30}),(_=n.getPluginByName(Bj.PRE_PROCESSING,"RTCAIAnsExtension"))&&(_.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=17,Oj.getUserMedia({audio:t,video:r});case 17:s=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:u,media_device_name:(null===(h=s.getVideoTracks()[0])||void 0===h?void 0:h.label)||"",reason:"success",elapse:IM()-v,capture_session_id:d}),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_result",media_device_id:c,media_device_name:(null===(p=s.getAudioTracks()[0])||void 0===p?void 0:p.label)||"",reason:"success",elapse:IM()-v,event_session_id:l}),e.next=27;break;case 22:throw e.prev=22,e.t0=e.catch(8),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:u,error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:d}),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_end",media_device_id:c,error_code:e.t0.code,reason:e.t0.name+e.t0.message,event_session_id:l}),new bC(fC.GET_VIDEO_TRACK_FAILED,Fg(f="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(f,e.t0.message||"unknown message","."),e.t0);case 27:return m=s.getVideoTracks()[0],(g=new $j(m,TM())).captureSessionId=d,e.next=32,g.generatePreProcessingTrack(n);case 32:return y=s.getAudioTracks()[0],(S=new Zj(y,TM())).captureSessionId=l,e.next=37,S.generatePreProcessingTrack(n);case 37:return e.abrupt("return",{videoTrack:g,audioTrack:S});case 38:case"end":return e.stop()}}),e,null,[[8,22]])})))).apply(this,arguments)}function fH(){return mH.apply(this,arguments)}function mH(){return mH=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=_.length>0&&void 0!==_[0]&&_[0],r=_.length>1?_[1]:void 0,n=_.length>2?_[2]:void 0,Gj.info("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=KN(r.id),a=TM(),e.prev=6,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen",capture_session_id:a}),d=IM(),e.next=11,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!rL||"16.1"!==EL))||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",media_device_name:Fg(s="".concat((null===(c=i.getVideoTracks()[0])||void 0===c?void 0:c.label)||"",", ")).call(s,(null===(u=i.getAudioTracks()[0])||void 0===u?void 0:u.label)||""),reason:"success",elapse:IM()-d,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 bC(fC.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 19:return l=i.getVideoTracks()[0],(h=new rH(l,TM())).captureSessionId=a,e.next=24,h.generatePreProcessingTrack(r);case 24:if(!(p=i.getAudioTracks()[0])){e.next=30;break}return v=new nH(p,TM()),e.next=29,v.generatePreProcessingTrack(r);case 29:return e.abrupt("return",[h,v]);case 30:return e.abrupt("return",[h,void 0]);case 31:case"end":return e.stop()}}),e,null,[[6,15]])}))),mH.apply(this,arguments)}function gH(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:TM();return new Qj(e,t)}function yH(e,t){return SH.apply(this,arguments)}function SH(){return(SH=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new eH(t,TM()),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 bH(e,t){return kH.apply(this,arguments)}function kH(){return(kH=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new tH(t,TM()),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 EH(e,t){return TH.apply(this,arguments)}function TH(){return(TH=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new iH(t,TM()),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 IH(e,t){return RH.apply(this,arguments)}function RH(){return(RH=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new oH(t,TM()),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 AH=qj,wH=Qj,CH=function(e){return e[e.NONE=0]="NONE",e}(CH||{}),xH={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)?xH.getAnnexbNals(e):xH.getAvccNals(e)},getAnnexbNals:function(e){for(var t=[],r=xH.getHeaderPositionAnnexB(e),n=r.pos,i=n;n<e.length-4;){var o,a,s=new Uint8Array(sI(o=e.buffer).call(o,n,n+r.headerLength));r.pos===e.position&&e.skip(r.headerLength),i=(r=xH.getHeaderPositionAnnexB(e)).pos;var c={header:s,body:new Uint8Array(sI(a=e.buffer).call(a,n+s.byteLength,i)),type:-1};xH.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(sI(n=e.buffer).call(n,e.position,e.position+4));e.skip(4);var a=new Uint8Array(sI(i=e.buffer).call(i,e.position,e.position+r));e.skip(r);var s={header:o,body:a,type:-1};xH.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}}},OH=function(){function e(t){Fh(this,e),ql(this,"_position",0),ql(this,"_dataview",void 0),this._dataview=new DataView(t)}return Vh(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}(),PH=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(PH||{}),DH=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),NH=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]);function MH(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function LH(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 UH=function(){function e(){Fh(this,e)}return Vh(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?DH:NH,s=MH(e.byteLength+a.byteLength),c=function(e){var t,r=[],n=0,i=my(e);try{for(i.s();!(t=i.n()).done;){var o=t.value;n>=2&&o<=3&&(r.push(3),n=0),0===o?n++:n=0,r.push(o)}}catch(jZ){i.e(jZ)}finally{i.f()}return new Uint8Array(r)}(e);return new Uint8Array(Fg(t=[]).call(t,tR(n),tR(i),tR(o),tR(s),tR(a),tR(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=sI(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=gy(LH(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=NH.byteLength&&i>=NH.byteLength&&sI(t).call(t,r,r+NH.byteLength).toString()===NH.toString()?(r+=NH.byteLength,o=1):t.byteLength>=NH.byteLength&&i>=NH.byteLength&&sI(t).call(t,r,r+DH.byteLength).toString()===DH.toString()&&(r+=DH.byteLength,o=0),{type:o,payload:sI(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new cT,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=gy(LH(e.payload,r),2),i=n[0];r=n[1];var o,a=gy(LH(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,sI(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=my(e);try{for(n.s();!(t=n.n()).done;){var i=gy(t.value,2),o=i[0],a=i[1],s=MH(o),c=MH(a.byteLength);r.push(s,c,a)}}catch(jZ){n.e(jZ)}finally{n.f()}var u=oS(r).call(r,(function(e,t){return e+t.byteLength}),0),d=new Uint8Array(u);return oS(r).call(r,(function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),VH=function(){function e(t){Fh(this,e),ql(this,"_timer",void 0),ql(this,"handler",void 0),ql(this,"_monitor",void 0),ql(this,"logger",void 0),ql(this,"_destroyed",!1),this._context=t,this._monitor=KN(t.id),this.logger=new pM("Stats",3,t.id)}return Vh(e,[{key:"setVar",value:function(e){this.handler=e}},{key:"stopReport",value:function(e){var t;this._timer&&(this.logger.info("stopReport","invoke"),clearTimeout(this._timer),delete this._timer,JN(this._context.id,"del_media_statistics_timer",Fg(t="reason: ".concat(e,", stack: ")).call(t,(new Error).stack),0,this._stream.streamId||""))}},{key:"filterIllegal",value:function(e){var t={};return MS(e).forEach((function(r){null===e[r]||void 0===e[r]||Number.isNaN(e[r])||(t[r]=e[r])})),t}},{key:"destroy",value:function(){this.logger.info("destroy","invoke"),JN(this._context.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.stopReport("destroy"),this._destroyed=!0}}]),e}(),FH=function(e){UA(i,e);var t,r,n=ew(i);function i(e,t){var r;return Fh(this,i),(r=n.call(this,e))._stream=t,r}return Vh(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t){var r,n,i,o=this;if(!this._timer){this.logger.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.preprocessingTrack,u=null===(n=s.videoTrack)||void 0===n?void 0:n.preprocessingTrack;this.getAudioStats(c,a,null===(i=s.audioTrack)||void 0===i?void 0:i.getAudioLevel()),this.getVideoStats(u,a);var d=function(){var e=Ng(Pg().mark((function e(){var t,r,n,i,c,u,d;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=s.audioTrack)||void 0===t?void 0:t.preprocessingTrack,c=null===(r=s.videoTrack)||void 0===r?void 0:r.preprocessingTrack,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=Ng(Pg().mark((function t(){var r;return Pg().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=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a={},s={timestamp:Date.now()},c=this._stream,u=c.streamId,d=c.audioMid,l=c.isScreen,h=c.pubAttributes,p=c.pubAudio,v=c.audioTrack,_={media_type:"audio",is_screen:!!l,direction:"up",stream_id:u,vid:d,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:h.localaudio?"capture_state_on":"capture_state_off",mute_state:p?"mute_state_off":"mute_state_on"},v&&(_.playback_volume=v.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",a);case 7:return e.next=9,this.handler.getStats(t);case 9:if((f=e.sent).length){e.next=12;break}return e.abrupt("return",a);case 12:if(f.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,o=e.clockRate,c=e.roundTripTime,u=e.channels,d=e.audioLevel,l=e.mimeType,h=e.availableIncomingBitrate,p=e.availableOutgoingBitrate,v=e.bytesReceived,f=e.nominated,m=e.id,g=e.currentRoundTripTime,y=e.state,S=e.writable,b=e.requestsReceived,k=e.responsesReceived,E=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,P=e.protocol,D=e.nackCount,N=e.retransmittedBytesSent,M=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(s.packetsSent=r,s.bytesSent=i,_.bytes=i,_.packetsSent=r,_.nackCount=D,_.ssrc=U,_.retransmitted_bytes_sent=N,_.retransmitted_packets_sent=M,s.retransmittedBytesSent=N,s.retransmittedPacketsSent=M):"remote-inbound-rtp"===t?(s.packetsLost=n,_.packetsLost=n,_.net_jitter=1e3*R,a.rtt=1e3*c,_.rtt=a.rtt,a._fractionLost=j||0):"codec"===t?(a.recordSampleRate=o,a.numChannels=u,_.codecName=l):"media-source"===t&&void 0!==d?(_.audio_level=d?-10*JC(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=g,_.ice_pair_state=y,_.ice_pair_writable=S,_.recv_ping_requests=b,_.recv_ping_responses=k,_.sent_ping_requests_before_first_response=E,_.sent_ping_requests_total=E+(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=P):"remote-candidate"===t&&(_.remote_candidate_type=A,_.remote_ip=w||C,_.remote_port=O);var H=KL("STATS_SCALLBACK_SUPPORT");HB&&H||"media-source"===t&&(_.send_level=d)})),void 0===_.volume&&void 0!==n&&(_.volume=n,_.audio_level=n?-10*JC(Math.pow(n/255,2)):n),(m=r.audio).timestamp){e.next=18;break}return r.audio=s,e.abrupt("return",this.filterIllegal(a));case 18:return void 0!==s.packetsLost&&(a.audioLossRate=(s.packetsLost-m.packetsLost)/(s.packetsSent-m.packetsSent),a.audioLossRate=Number.isNaN(a.audioLossRate)?0:a.audioLossRate,_.fraction_lost=a.audioLossRate),a.statsInterval=s.timestamp-m.timestamp,_.stats_interval=a.statsInterval,a.sendKBitrate=(s.bytesSent-m.bytesSent||0)/a.statsInterval*8,_.mediaBitratebps=Math.round(1e3*a.sendKBitrate),_.bandwidth=Math.round(_.mediaBitratebps/1024),void 0!==s.retransmittedBytesSent&&(_.retransmitBitratebps=(s.retransmittedBytesSent-m.retransmittedBytesSent||0)/a.statsInterval),r.audio=s,_.vendor_mode=this._stream.vendorCode||0,_.pc_session_id=null===(i=this.handler)||void 0===i?void 0:i.peerConnectionId,null===(o=this._monitor)||void 0===o||o.report("rtc_media_statistics",_),a._retransmittedRate=(s.retransmittedPacketsSent-m.retransmittedPacketsSent)/(s.packetsSent-m.packetsSent),void 0===a.audioLossRate&&(a.audioLossRate=a._retransmittedRate,_.fraction_lost=a.audioLossRate),a._fractionLost=Math.max(a._fractionLost,a.audioLossRate),e.abrupt("return",this.filterIllegal(a));case 33:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(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,h={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"},t&&this.handler){e.next=6;break}return e.abrupt("return",n);case 6: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=12,this.handler.getStats(t);case 12:if((p=e.sent).length){e.next=15;break}return e.abrupt("return",n);case 15: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,_=e.firCount,f=e.targetBitrate,m=e.roundTripTime,g=e.mimeType,y=e.frameWidth,S=e.frameHeight,b=e.packetsSent,k=e.googActualEncBitrate,E=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,P=e.nominated,D=e.id,N=e.currentRoundTripTime,M=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,W=e.requestsReceived,X=e.responsesReceived,Y=e.googRetransmitBitrate,q=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!==y&&((!n.encodedFrameWidth||y>n.encodedFrameWidth)&&(n.encodedFrameWidth=y),(!n.encodedFrameHeight||S>n.encodedFrameHeight)&&(n.encodedFrameHeight=S),h.frame_size_height=S,h.frame_size_width=y)):"track"===t?(n.encodedFrameWidth=y,n.encodedFrameHeight=S,h.frame_size_height=S,h.frame_size_width=y):"remote-inbound-rtp"===t?(i.packetsLost=a,n.rtt=1e3*m,h.rtt=n.rtt,h.jitter=1e3*ne,h.packetsLost=a,n._fractionLost=oe||0):"codec"===t?(n.codecType=g,h.codecName=g):"candidate-pair"===t?(h.ice_available_incoming_bitrate=C,h.ice_available_outgoing_bitrate=x,h.ice_bytes_received=O,h.ice_bytes_sent=s,h.ice_nominated=Number(P),h.ice_pair_id=D,h.ice_pair_rtt=N,h.ice_pair_state=M,h.ice_pair_writable=L,h.recv_ping_requests=W,h.recv_ping_responses=X,h.sent_ping_requests_before_first_response=q,h.sent_ping_requests_total=q+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=k,h.available_receive_bandwidth=E,h.available_send_bandwidth=T,h.bucket_delay=R,h.retransmitBitratebps=Y,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 _e=KL("STATS_SCALLBACK_SUPPORT");if(!HB||!_e){var fe=r.video,me=i.timestamp-fe.timestamp;if("outbound-rtp"===t){var ge=s-fe.bytesSent,ye=u-fe.retransmittedBytesSent;h.encBitratebps=Math.round(8e3*(ge-ye)/me),h.bucket_delay=l/b,h.retransmitBitratebps=Math.round(8e3*ye/me),h.targetEncBitratebps=f,h.transmit_bitrate=Math.round(1e3*(s-fe.bytesSent)*8/me),h.avg_encode_ms=1e3*p/o,h.firsReceived=_+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)}})),(_=r.video).timestamp){e.next=21;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 21:return n.statsInterval=i.timestamp-_.timestamp,h.stats_interval=n.statsInterval,f=MS(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=this._context.activeSimStreams||[],h.sim_retransmittedRate=[],y=!1,Kw(f).call(f,(function(e,t){return Number(e)-Number(t)})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,p=t.qualityLimitationDurations,v=t.qualityLimitationResolutionChanges,f=t.retransmittedPacketsSent,m=t.pliCount,g=t.keyFramesEncoded;void 0!==l&&(h.sim_qualityLimitationReason||(h.sim_qualityLimitationReason=[],h.sim_qualityLimitationDurations=[],h.sim_qualityLimitationResolutionChanges=[]),h.sim_qualityLimitationReason.push(l),h.sim_qualityLimitationDurations.push(p),h.sim_qualityLimitationResolutionChanges.push(v));var S=_.simulcast[e];if(h.sim_enc_width.push(r||0),h.sim_enc_height.push(o||0),h.sim_enc_key_frames.push(g||0),S){var b=(a-S.bytesSent||0)/n.statsInterval;h.sim_enc_bps.push(Math.round(8e3*b)),h.sim_enc_bandwidth.push(Math.round(8e3*b/1024));var k=1e3*(s-S.framesEncoded)/n.statsInterval;h.sim_enc_framerate.push(Math.round(k)),h.sim_rids.push(e);var E=void 0!==c?c-S.framesSent:s-S.framesEncoded,T=1e3*E/n.statsInterval;h.sim_sent_framerate.push(Math.round(T));var I=(u-S.packetsLost)/(d-S.packetsSent);n._retransmittedRate=(f-S.retransmittedPacketsSent)/(d-S.packetsSent),I=Number.isNaN(I)?0:I,h.sim_fraction_lost.push(I),h.sim_keyencoded.push(m-S.pliCount>0),h.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!y&&(n.sentKBitrate=8*b,n.encoderOutputFrameRate=k,n.encodedFrameCount=E,n.sentFrameRate=T,n.videoLossRate=I,y=!0)}})),h.vendor_mode=this._stream.vendorCode||0,h.pc_session_id=null===(m=this.handler)||void 0===m?void 0:m.peerConnectionId,null===(g=this._monitor)||void 0===g||g.report("rtc_media_statistics",h)):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-_.framesSent:i.framesEncoded-_.framesEncoded,n.sentKBitrate=(i.bytesSent-_.bytesSent||0)/n.statsInterval*8,h.bitrate=Math.round(1e3*n.sentKBitrate),h.bandwidth=Math.round(h.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-_.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-_.packetsLost)/(i.packetsSent-_.packetsSent),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,h.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-_.retransmittedPacketsSent)/(i.packetsSent-_.packetsSent),h.vendor_mode=this._stream.vendorCode||0,h.pc_session_id=null===(S=this.handler)||void 0===S?void 0:S.peerConnectionId,null===(b=this._monitor)||void 0===b||b.report("rtc_media_statistics",h)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 28:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(VH),BH=function(e){UA(o,e);var t,r,n,i=ew(o);function o(e,t){var r;return Fh(this,o),(r=i.call(this,e))._stream=t,r}return Vh(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._timer){e.next=2;break}return e.abrupt("return");case 2:return this.logger.info("setRemoteStreamStatsEvtInterval","invoke"),this.setVar(r),a={audio:{},video:{}},this._destroyed=!1,s=this._stream,c=null===(n=s.audioTrack)||void 0===n?void 0:n.originTrack,u=null===(i=s.videoTrack)||void 0===i?void 0:i.originTrack,this.getRemoteVideoStats(u,a),e.next=12,this.getRemoteAudioStats(c,a,null===(o=this._stream.audioTrack)||void 0===o?void 0:o.getAudioLevel());case 12:d=function(){var e=Ng(Pg().mark((function e(){var r,n,i,o,c,u,h;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=null===(r=s.audioTrack)||void 0===r?void 0:r.originTrack,c=null===(n=s.videoTrack)||void 0===n?void 0:n.originTrack,e.next=4,l.getRemoteAudioStats(o,a,null===(i=l._stream.audioTrack)||void 0===i?void 0:i.getAudioLevel());case 4:return u=e.sent,e.next=7,l.getRemoteVideoStats(c,a);case 7:h=e.sent,t({audioStats:u,videoStats:h,isScreen:s.isScreen,userId:s.userId,streamId:s.streamId}),l._destroyed||(l._timer=setTimeout(d,2e3));case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this.stopReport("start a new timer."),this._timer=setTimeout(d,2e3);case 15:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"unsubscribe",value:function(){this.logger.info("unsubscribe","invoke"),MA(NA(o.prototype),"stopReport",this).call(this,"unsubscribe"),this._stream.stopAudioStallObserve()}},{key:"getRemoteAudioStats",value:(r=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c={},u={},d=this._stream,l=d.streamId,h=d.userId,p=d.isScreen,v=d.audioMid,_=d.subMediaType,f=d._attributes,m=d.virtual,g=d.audioTrack,y={media_type:"audio",is_screen:!!p,direction:"down",stream_id:l,stream_user_id:h,vid:v,audio_mux:m,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:GM(_)?"mute_state_off":"mute_state_on",remote_user_capture_state:f.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:f.localaudio&&f.audiostream?"mute_state_off":"mute_state_on"},g&&(y.playback_volume=g.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",c);case 7:return e.next=9,this.handler.getStats(t);case 9:if((S=e.sent).length){e.next=12;break}return e.abrupt("return",c);case 12:if(S.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,o=e.bytesReceived,a=e.jitterBufferDelay,s=e.jitterBufferEmittedCount,d=e.clockRate,h=e.channels,p=e.totalSamplesReceived,v=e.concealedSamples,_=e.silentConcealedSamples,f=e.concealmentEvents,m=e.totalRoundTripTime,g=e.packetsDiscarded,S=e.state,b=e.currentRoundTripTime,k=e.audioLevel,T=e.totalAudioEnergy,I=e.totalSamplesDuration,R=e.mimeType,A=e.googDecodingNormal,w=e.googDecodingMuted,C=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,O=e.bytesSent,P=e.nominated,D=e.id,N=e.writable,M=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,W=e.consentRequestsSent,X=e.responsesSent,Y=e.ssrc,q=e.nackCount,J=e.lastPacketReceivedTimestamp,Q=e.concealmentevents,Z=e.fecPacketsReceived;if("inbound-rtp"===t)u.packetsLost=r,u.packetsReceived=i,y.packetsLost=r,y.packetsReceived=i,y.packetsDiscarded=g,y.nackCount=q,y.lastPacketReceivedTimestamp=J,y.concealmentevents=Q,u.bytesReceived=o,void 0!==a&&(c.jitterBufferDelay=a/s*1e3,y.average_jitter_buffer_delay_ms=c.jitterBufferDelay),void 0!==p&&(u.totalSamplesReceived=p,c.concealedSamples=v,u.concealedSamples=v,u.silentConcealedSamples=_,y.concealedSamples=v,c.concealmentEvents=f,y.totalSamplesReceived=p),void 0!==Z&&(y.fec_packets_received=Z,u.fecPacketsReceived=Z),y.jitter=1e3*M,y.ssrc=Y,void 0!==k&&0!==k?(y.audio_level=k?-10*JC(Math.pow(k,2)):k,y.volume=255*k):(y.volume=null!=n?n:255*k,y.audio_level=n?-10*JC(Math.pow(n/255,2)):n),void 0!==T&&(y.total_audio_energy=T),void 0!==I&&(y.totalAudioDuration=I);else if("codec"===t)c.recordSampleRate=d,h&&(c.numChannels=h),y.codecName=R;else if("candidate-pair"===t){var $,ee;y.ice_available_incoming_bitrate=C,y.ice_available_outgoing_bitrate=x,y.ice_bytes_received=o,y.ice_bytes_sent=O,y.ice_nominated=Number(P),y.ice_pair_id=D,y.ice_pair_rtt=b,y.rtt=1e3*b,y.rtt&&null!==($=E._context.streamRTT)&&void 0!==$&&null!==(ee=$[l])&&void 0!==ee&&ee.audio&&(y.total_rtt_ms=Math.round(y.rtt+E._context.streamRTT[l].audio)),y.ice_pair_state=S,y.ice_pair_writable=N,y.recv_ping_requests=G,y.recv_ping_responses=z,y.sent_ping_requests_before_first_response=K,y.sent_ping_requests_total=K+(W||0),y.sent_ping_responses=X,"succeeded"===S&&(c.rtt=1e3*b,c.total_rtt=1e3*m)}else"track"===t&&void 0!==k?(0===k&&0!==n?(y.volume=n,y.audio_level=n?-10*JC(Math.pow(n/255,2)):n):(y.audio_level=k?-10*JC(Math.pow(k,2)):k,y.volume=255*k),y.total_audio_energy=T,y.totalAudioDuration=I):"ssrc"===t?(y.decodingNormal=A,y.recvAudioLevel=H,y.decodingMuted=w):"local-candidate"===t?(y.local_candidate_type=L,y.local_ip=U||V,y.local_network_type=F,y.local_port=B,y.protocol=j):"remote-candidate"===t&&(y.remote_candidate_type=L,y.remote_ip=U||V,y.remote_port=B)})),(b=r.audio).timestamp){e.next=18;break}return u.timestamp=Date.now(),r.audio=u,e.abrupt("return",this.filterIllegal(c));case 18:if(void 0===u.concealedSamples){e.next=25;break}return y.interval_concealed_samples=u.concealedSamples-b.concealedSamples,y.interval_samples_received=u.totalSamplesReceived-b.totalSamplesReceived,y.interval_silent_concealed_samples=u.silentConcealedSamples-b.silentConcealedSamples,e.next=24,this._stream.updateAudioStallInfo(y,c,u);case 24:k=e.sent;case 25:return u.timestamp=Date.now(),c.audioLossRate=(u.packetsLost-b.packetsLost)/(u.packetsReceived-b.packetsReceived+(u.packetsLost-b.packetsLost)),c.audioLossRate=Number.isNaN(c.audioLossRate)?0:c.audioLossRate,y.fraction_lost=c.audioLossRate,c.statsInterval=u.timestamp-b.timestamp,y.stats_interval=c.statsInterval,c.receivedKBitrate=(u.bytesReceived-b.bytesReceived||0)/c.statsInterval*8,y.bandwidth=Math.round(1e3*c.receivedKBitrate/1024),void 0!==u.concealedSamples&&(c.receivedSampleRate=1e3*y.interval_samples_received/c.statsInterval),void 0!==u.fecPacketsReceived&&(y.fecBitratebps=(u.fecPacketsReceived-b.fecPacketsReceived||0)/c.statsInterval),y.average_jitter_buffer_delay_ms&&y.total_rtt_ms&&(c.e2eDelay=y.average_jitter_buffer_delay_ms+y.total_rtt_ms),null!==(i=this._context.streamRTT)&&void 0!==i&&null!==(o=i[l])&&void 0!==o&&o.audio&&(c.totalRtt=(y.rtt?y.rtt:0)+this._context.streamRTT[l].audio),r.audio=u,y.vendor_mode=this._stream.vendorCode||0,y.pc_session_id=null===(a=this.handler)||void 0===a?void 0:a.peerConnectionId,null===(s=this._monitor)||void 0===s||s.report("rtc_media_statistics",y,k),e.abrupt("return",this.filterIllegal(c));case 42:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k=this;return Pg().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.userId,h=u.isScreen,p=u.subMediaType,v=u._attributes,_=Ql({media_type:"video",is_screen:!!h,direction:"down",stream_id:d,stream_user_id:l,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:zM(p)?"mute_state_off":"mute_state_on",remote_user_capture_state:v.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:v.localvideo&&v.videostream?"mute_state_off":"mute_state_on"},this._stream.getVideoRenderInfo()),t&&this.handler){e.next=6;break}return e.abrupt("return",s);case 6:return s.isScreen=h,e.next=9,this.handler.getStats(t);case 9:if((f=e.sent).length){e.next=12;break}return e.abrupt("return",s);case 12:if(f.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,i=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,u=e.framesDecoded,l=e.jitterBufferDelay,h=e.jitterBufferEmittedCount,p=e.mimeType,v=e.firCount,f=e.availableIncomingBitrate,m=e.availableOutgoingBitrate,g=e.bytesSent,y=e.nominated,S=e.id,b=e.currentRoundTripTime,E=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,P=e.protocol,D=e.requestsReceived,N=e.responsesReceived,M=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)c.packetsLost=i,_.packetsLost=i,c.packetsReceived=o,_.packetsReceived=o,c.bytesReceived=a,_.bytes=a,c.framesDecoded=u,c.totalDecodeTime=H,void 0!==l&&(c.jitterBufferDelay=l/h*1e3,_.average_jitter_buffer_delay_ms=c.jitterBufferDelay),_.fir_count=v,_.nackCount=x,c.nackCount=x,_.pli_count=O,_.ssrc=V,_.framesDropped=K,_.jitter=1e3*F,_.framesReceived=B,c.framesReceived=B,_.framesDecoded=u,_.key_frames_decoded=j,_.decoder_name=G,_.last_packet_received_timestamp=z,void 0!==n&&(s.width=n,_.frame_size_width=n,s.height=r,_.frame_size_height=r);else if("track"===t&&void 0!==n)s.width=n,_.frame_size_width=n,s.height=r,_.frame_size_height=r,void 0!==B&&(_.framesReceived=B,c.framesReceived=B);else if("codec"===t)_.codecName=p;else if("candidate-pair"===t){var W,X;_.ice_available_incoming_bitrate=f,_.ice_available_outgoing_bitrate=m,_.ice_bytes_received=a,_.ice_bytes_sent=g,_.ice_nominated=Number(y),_.ice_pair_id=S,_.ice_pair_rtt=b,_.rtt=1e3*b,_.rtt&&null!==(W=k._context.streamRTT)&&void 0!==W&&null!==(X=W[d])&&void 0!==X&&X.video&&(_.total_rtt_ms=Math.round(_.rtt+(k._context.streamRTT[d].video||0))),s.rtt=_.rtt,_.ice_pair_state=E,_.ice_pair_writable=T,_.recv_ping_requests=D,_.recv_ping_responses=N,_.sent_ping_requests_before_first_response=M,_.sent_ping_requests_total=M+(L||0),_.sent_ping_responses=U}else"local-candidate"===t?(_.local_candidate_type=I,_.local_ip=R||A,_.local_network_type=w,_.local_port=C,_.protocol=P):"remote-candidate"===t&&(_.remote_candidate_type=I,_.remote_ip=R||A,_.remote_port=C)})),(m=r.video).timestamp){e.next=17;break}return r.video=c,e.abrupt("return",this.filterIllegal(s));case 17:return g=c.packetsLost-m.packetsLost,y=c.packetsReceived-m.packetsReceived,s.videoLossRate=g/(y+g),m.totalDecodeTime&&m.framesDecoded&&c.framesDecoded!==m.framesDecoded&&(S=c.totalDecodeTime-m.totalDecodeTime,b=c.framesDecoded-m.framesDecoded,_.decode_elapse_per_frame=Number((S/b*1e3).toFixed(2))),s._retransmittedRate=(c.nackCount-m.nackCount)/(y+g),s.videoLossRate=Number.isNaN(s.videoLossRate)?0:s.videoLossRate,_.fraction_lost=s.videoLossRate,s.statsInterval=c.timestamp-m.timestamp,_.stats_interval=s.statsInterval,s.receivedKBitrate=(c.bytesReceived-m.bytesReceived||0)/s.statsInterval*8,_.bitrate=Math.round(1e3*s.receivedKBitrate),_.bandwidth=Math.round(_.bitrate/1024),s.decoderOutputFrameRate=1e3*(c.framesDecoded-m.framesDecoded)/s.statsInterval,s.receivedFrameRate=1e3*(c.framesReceived-m.framesReceived)/s.statsInterval,_.frame_rate_decoded=Math.round(s.decoderOutputFrameRate),_.frame_rate_received=Math.round(s.receivedFrameRate),_.average_jitter_buffer_delay_ms&&_.total_rtt_ms&&(s.e2eDelay=_.average_jitter_buffer_delay_ms+_.total_rtt_ms),null!==(n=this._context.streamRTT)&&void 0!==n&&null!==(i=n[d])&&void 0!==i&&i.video&&(s.totalRtt=(_.rtt?_.rtt:0)+(this._context.streamRTT[d].video||0)),r.video=c,this._stream.updateVideoStallInfo(_,s),_.vendor_mode=this._stream.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",_),e.abrupt("return",this.filterIllegal(s));case 41:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){MA(NA(o.prototype),"destroy",this).call(this),MA(NA(o.prototype),"stopReport",this).call(this,"destroy"),this._stream.stopAudioStallObserve()}}]),o}(VH),jH=function(){function e(t,r){Fh(this,e),ql(this,"_removeHandler",void 0),ql(this,"_remotePauseHandler",void 0),ql(this,"_prePts",void 0),ql(this,"_stallList",void 0),ql(this,"_videoInWaiting",!1),ql(this,"_videoInWaitingCallback",!1),ql(this,"_videoInWaiting100ms",!1),ql(this,"_isPaused",void 0),ql(this,"_pauseStart",0),ql(this,"_pauseDuration",0),ql(this,"_requestVideoFrameCallbackTimer",void 0),ql(this,"_logger",void 0),ql(this,"_player",void 0),ql(this,"_recentVideoInfo",void 0),ql(this,"_stallTimeThreshold",void 0),ql(this,"_openVideoStall100ms",GL.VIDEO_STALL_100MS);var n=t?1500:rL||tL?550:500;this._stallTimeThreshold={report:n,callback:Math.max(GL.VIDEO_STALL_DATA,n)},this._logger=new pM("VideoStallObserver",1,r)}return Vh(e,[{key:"start",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this._logger.print("start","invoke"),this._player=e,RM&&!r)e.domElement&&(this._requestVideoFrameCallbackTimer=e.domElement.requestVideoFrameCallback(this._onVideoRefresh.bind(this)),this._removeHandler=function(){var r;t._requestVideoFrameCallbackTimer&&(null===(r=e.domElement)||void 0===r||r.cancelVideoFrameCallback(t._requestVideoFrameCallbackTimer))});else{var n=function(r){return t._onVideoTimeupdate(r,e)};e.on("playback_event",n),this._removeHandler=function(){return e.off("playback_event",n)}}var i=function(e){return t._onVideoPause(e)};e.on("playback_event",i),this._remotePauseHandler=function(){return e.off("playback_event",i)}}},{key:"getRecentRenderInfo4Report",value:function(){var e=this,t={};return this._recentVideoInfo&&MS(this._recentVideoInfo).forEach((function(r){var n,i=r.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return Fg(t="".concat(e[0],"_")).call(t,e[1].toLowerCase())}));t["video_".concat(i)]=null===(n=e._recentVideoInfo)||void 0===n?void 0:n[r]})),t}},{key:"stop",value:function(){var e,t;this._logger.print("stop","invoke"),delete this._player,null===(e=this._removeHandler)||void 0===e||e.call(this),delete this._removeHandler,null===(t=this._remotePauseHandler)||void 0===t||t.call(this),delete this._remotePauseHandler,delete this._stallList,delete this._prePts,delete this._recentVideoInfo,this._videoInWaiting=!1,this._videoInWaitingCallback=!1,this._videoInWaiting100ms=!1}},{key:"destroy",value:function(){this.stop()}},{key:"getStallInfo",value:function(e){var t=this,r=e.interval,n=e.frameRateReceived,i=e.frameRateDecoded,o=e.bitrate,a={pts:0,report:{stallCount:0,stallDuration:0,list:[]},callback:{stallCount:0,stallDuration:0},pauseDuration:this._getPauseDuration()};this._stallList&&((rL||tL)&&(0===o||(i||1/0)<=1||(n||1/0)<=1)||0===this._stallList.length?(a.report.stallDuration=a.callback.stallDuration=2e3,a.report.stallCount=a.callback.stallCount=this._videoInWaiting?0:1,this._openVideoStall100ms&&(a.stall100ms={count:this._videoInWaiting100ms?0:1,duration:2e3}),this._videoInWaiting=!0,this._videoInWaitingCallback=!0,this._videoInWaiting100ms=!0):this._stallList.forEach((function(e,n){var i=e.timeUpdateInterval;0===n&&t._videoInWaiting&&(i=Math.round(e.timeUpdateInterval%r));var o=e.timeUpdateInterval>t._stallTimeThreshold.report;o&&(a.report.list.push(e.timeUpdateInterval),a.report.stallDuration+=i,t._videoInWaiting||a.report.stallCount++),t._videoInWaiting=o,e.timeUpdateInterval>t._stallTimeThreshold.callback?(a.callback.stallDuration+=i,t._videoInWaitingCallback||a.callback.stallCount++,t._videoInWaitingCallback=!0):t._videoInWaitingCallback=!1,t._openVideoStall100ms&&(a.stall100ms||(a.stall100ms={count:0,duration:0}),e.timeUpdateInterval>100?(a.stall100ms.duration+=i,t._videoInWaiting100ms||a.stall100ms.count++,t._videoInWaiting100ms=!0):t._videoInWaiting100ms=!1),a.pts=e.playTime})),this._stallList=[]);return a}},{key:"_getPauseDuration",value:function(){var e=this._pauseDuration;if(this._pauseDuration=0,this._isPaused){var t=IM(),r=t-(this._pauseStart||0);r>500&&(this._pauseStart=t,e+=r)}return e}},{key:"_onVideoPause",value:function(e){if("pause"===e.eventName)this._isPaused=!0,this._pauseStart=IM();else if("play"===e.eventName&&this._isPaused){this._isPaused=!1;var t=IM()-this._pauseStart;t>500&&(this._pauseDuration+=t)}}},{key:"_onVideoTimeupdate",value:function(e,t){if("timeupdate"===e.eventName){var r=t.domElement;if(!r||0===r.currentTime)return;if(void 0===this._prePts)return void(this._prePts=r.currentTime);if(this._stallList||(this._stallList=[]),r.currentTime>this._prePts){var n=r.currentTime-this._prePts;this._stallList.push({playTime:r.currentTime,timeUpdateInterval:Math.round(1e3*n)})}this._prePts=r.currentTime}}},{key:"_onVideoRefresh",value:function(e,t){var r,n;if(this._stallList||(this._stallList=[]),this._prePts){var i=t.presentationTime-this._prePts;this._stallList.push({playTime:t.presentationTime,timeUpdateInterval:Math.round(i)})}this._recentVideoInfo=t,this._prePts=t.presentationTime,null===(r=this._player)||void 0===r||null===(n=r.domElement)||void 0===n||n.requestVideoFrameCallback(this._onVideoRefresh.bind(this))}}]),e}(),HH=function(){function e(t){Fh(this,e),ql(this,"_audioStallTimer",void 0),ql(this,"_preSample",void 0),ql(this,"_isStallInPreCallbackEnd",!1),ql(this,"_isStallInPreReportEnd",!1),ql(this,"_stallList",[]),this._stream=t}var t,r;return Vh(e,[{key:"start",value:function(t,r){this.stop(),GL.AUDIO_STALL&&e.interval>0&&"number"==typeof t&&"number"==typeof r&&(this._preSample={ts:IM(),concealedSamples:t,totalSamplesReceived:r},this._startStallCountInterval())}},{key:"stop",value:function(){this._stallList=[],this._audioStallTimer&&(clearTimeout(this._audioStallTimer),delete this._audioStallTimer)}},{key:"destroy",value:function(){this.stop()}},{key:"getAudioStallInfo",value:(r=Ng(Pg().mark((function t(){var r,n,i,o,a;return Pg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={stats_count:Ty(r=this._stallList).call(r,(function(e){return!!e.get_stats_cost})).length,stall_list:tR(this._stallList)},t.prev=1,t.next=4,this._audioStallCount();case 4:t.next=8;break;case 6:t.prev=6,t.t0=t.catch(1);case 8:return i=KH(this._stallList,2,this._isStallInPreReportEnd),this._isStallInPreReportEnd=i.isStallInEnd,o=GL.AUDIO_STALL_DATA/e.interval,a=KH(this._stallList,o,this._isStallInPreCallbackEnd),this._isStallInPreCallbackEnd=a.isStallInEnd,this.stop(),this._startStallCountInterval(),t.abrupt("return",{report:{stall_count:i.stall_count,stall_duration:i.stall_duration,list:i.list},callback:{stall_count:a.stall_count,stall_duration:a.stall_duration,list:a.list},extra:n});case 16:case"end":return t.stop()}}),t,this,[[1,6]])}))),function(){return r.apply(this,arguments)})},{key:"_startStallCountInterval",value:function(){var t=this,r=function(){var n=Ng(Pg().mark((function n(){return Pg().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return clearTimeout(t._audioStallTimer),delete t._audioStallTimer,n.next=4,t._audioStallCount();case 4:t._audioStallTimer||(t._audioStallTimer=setTimeout(r,e.interval));case 5:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}();this._audioStallTimer=setTimeout(r,e.interval)}},{key:"_audioStallCount",value:(t=Ng(Pg().mark((function t(){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R;return Pg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._preSample&&!(IM()-this._preSample.ts<.5*e.interval)){t.next=2;break}return t.abrupt("return");case 2:if(r=this._stream,n=r.hasAudio,i=r.subAudio,o=r.virtual,a=r.virtualOccupy,s=r.removeTrack,c=r.audioTrack,!s&&c){t.next=7;break}return clearTimeout(this._audioStallTimer),delete this._audioStallTimer,t.abrupt("return");case 7:if((u=n&&i)&&(!o||a)){t.next=13;break}this._preSample.ts=IM(),this._stallList.push({reason:u?Fg(l="virtual: ".concat(o,", virtualOccupy: ")).call(l,a):Fg(d="hasAudio: ".concat(n,", subAudio: ")).call(d,i)}),t.next=29;break;case 13:return h=IM(),_=0,t.prev=15,t.next=18,null===(f=this._stream.audioTransceiver)||void 0===f?void 0:f.receiver.getStats();case 18:null==(m=t.sent)||m.forEach((function(e){"inbound-rtp"===e.type&&(p=e),_++})),t.next=25;break;case 22:t.prev=22,t.t0=t.catch(15),v=t.t0.message||Gg(t.t0);case 25:g=IM(),y=IM(),S=y-this._preSample.ts,p?(k=(b=p).concealedSamples,E=b.totalSamplesReceived,T=k-this._preSample.concealedSamples,I=E-this._preSample.totalSamplesReceived,R=T>=0&&I>=0&&T>=e.ratio*I,this._stallList.push({concealed:T,received:I,diff:S,start:this._preSample.ts,end:y,get_stats_cost:g-h,get_stats_start:h,get_stats_end:g,is_stall:R}),this._preSample.concealedSamples=k,this._preSample.totalSamplesReceived=E,this._preSample.ts=y):this._stallList.push({diff:S,start:this._preSample.ts,end:y,get_stats_cost:g-h,get_stats_start:h,get_stats_end:g,reason:_?v||"no inbound-rtp":"no report"});case 29:case"end":return t.stop()}}),t,this,[[15,22]])}))),function(){return t.apply(this,arguments)})}],[{key:"setAudioStallConfig",value:function(t){e.interval=((null==t?void 0:t.audio_stall_interval)||200)/2,e.ratio=(null==t?void 0:t.audio_stall_ratio)||.6}}]),e}();ql(HH,"interval",100),ql(HH,"ratio",.6);var GH,zH,KH=function(e,t,r){for(var n,i={stall_count:0,stall_duration:0,isStallInEnd:!1,list:[]},o=0,a=0,s=0;s<e.length;s++){var c=e[s];c.is_stall&&(o++,a+=c.diff||0);var u=s===e.length-1;if(!c.is_stall||u){var d=o>=t,l=s+t-o-1;if(!d&&o>2){var h=0;sI(e).call(e,s+1,l+1).forEach((function(e){e.is_stall&&(h+=e.diff||0)})),(d=a+h>HH.interval*t*HH.ratio)&&(s=l,a+=h)}d&&(i.stall_count++,i.stall_duration+=a,i.list.push(a)),u&&(i.isStallInEnd=d),o=a=0}}return!0===(null===(n=e[0])||void 0===n?void 0:n.is_stall)&&r&&i.stall_count>0&&i.stall_count--,i},WH=function(e){UA(r,e);var t=ew(r);function r(e){var n;return Fh(this,r),ql(aA(n=t.call(this)),"_videoPlayer",void 0),ql(aA(n),"isScreen",!1),ql(aA(n),"audioMid",void 0),ql(aA(n),"videoMid",void 0),ql(aA(n),"videoTransceiver",void 0),ql(aA(n),"audioTransceiver",void 0),ql(aA(n),"vendorHandler",void 0),ql(aA(n),"vendorCode",0),ql(aA(n),"engineId",void 0),ql(aA(n),"logger",void 0),n.engineId=e.id,n.logger=new pM("Stream",0,e.id),n}return Vh(r,[{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}(kU),XH=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(XH||{}),YH=function(e){UA(r,e);var t=ew(r);function r(e){var n;return Fh(this,r),ql(aA(n=t.call(this,e)),"id",void 0),ql(aA(n),"stream",void 0),ql(aA(n),"streamId",void 0),ql(aA(n),"seiList",[]),ql(aA(n),"videoTrack",void 0),ql(aA(n),"audioTrack",void 0),ql(aA(n),"videoEncodeConfig",[qL]),ql(aA(n),"subVideoDescriptions",[]),ql(aA(n),"enableSimulcast",!1),ql(aA(n),"observer",void 0),ql(aA(n),"statsReport",void 0),ql(aA(n),"prevBitrate",0),ql(aA(n),"pubAudio",!1),ql(aA(n),"pubVideo",!1),ql(aA(n),"pubAttributes",void 0),ql(aA(n),"pcSessionId",void 0),n.stream=new MediaStream,n.id=px(),n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1,videoDescriptions:[]},n.statsReport=new FH(e,aA(n)),n}return Vh(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(BB()){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=UH.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)BI(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 this.logger.warn("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender){var e=this.audioTransceiver.sender.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else this.logger.warn("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){JN(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),MA(NA(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.mediaTrack;return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}},{key:"resetStream",value:function(){this.stream=new MediaStream}}]),r}(WH),qH=function(e){UA(n,e);var t,r=ew(n);function n(e,t,i,o,a,s){var c;return Fh(this,n),ql(aA(c=r.call(this,e)),"streamId",void 0),ql(aA(c),"userId",void 0),ql(aA(c),"isPublic",void 0),ql(aA(c),"hasVideo",void 0),ql(aA(c),"hasAudio",void 0),ql(aA(c),"_attributes",void 0),ql(aA(c),"streamState",void 0),ql(aA(c),"removeTrack",!1),ql(aA(c),"observer",void 0),ql(aA(c),"statsReport",void 0),ql(aA(c),"subVideo",void 0),ql(aA(c),"subAudio",void 0),ql(aA(c),"subMediaType",void 0),ql(aA(c),"subLayer",void 0),ql(aA(c),"_sequenceId",void 0),ql(aA(c),"stream",void 0),ql(aA(c),"videoTrack",void 0),ql(aA(c),"audioTrack",void 0),ql(aA(c),"recordedVideoFrames",void 0),ql(aA(c),"stillExist",void 0),ql(aA(c),"originalMediaType",void 0),ql(aA(c),"priority",void 0),ql(aA(c),"originalStreamIndex",0),ql(aA(c),"virtual",void 0),ql(aA(c),"pcSessionId",void 0),ql(aA(c),"_virtualOccupy",void 0),ql(aA(c),"_videoStallObserver",void 0),ql(aA(c),"_audioStallObserver",void 0),ql(aA(c),"_handler",void 0),c.virtual=!1,c._virtualOccupy=!1,c.userId=t,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=CH.NONE,c.subLayer={spatialLayer:0,spatialSubLayer:-1},c.streamState=0,c.statsReport=new BH(e,aA(c)),c.enableVendorMode&&(c.pcSessionId=px()),c}return Vh(n,[{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:"startReport",value:function(e,t){this.statsReport.setRemoteStreamStatsEvtInterval(e,t),this._handler=t}},{key:"getStats",value:function(e,t){var r;return null===(r=this._handler)||void 0===r?void 0:r.getStats(e,t)}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){xH.getNalunits(new OH(t.data)).forEach((function(t){if(t.sei){var r=UH.decodeSeiBody(t.body);r&&r.type!==PH.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else this.logger.warn("no receiver found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){var e=this;if(this.audioTransceiver&&this.audioTransceiver.receiver){var t=this.audioTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){t.data.byteLength<=1e3?r.enqueue(t):e.logger.print("too large audio frame",t.data.byteLength)}})).pipeTo(n)}else this.logger.warn("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n;try{var i;JN(this.engineId,"Stream.ontrack",Gg({uid:this.userId,streamId:this.streamId,streams:oS(i=e.streams).call(i,(function(e,t){return e+mx(t)}),""),transceiver:Sx(e.transceiver),track:fx(e.track)}),0,this.streamId||"")}catch(BZ){}if(this.enableVendorMode||null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&Xy(n).call(n,this.streamId)){var o,a=e.track;"video"===(null==a?void 0:a.kind)?this._setVideoTrack(a):"audio"===(null===(o=e.track)||void 0===o?void 0:o.kind)&&this._setAudioTrack(a),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"startVideoStallObserve",value:function(e){this.logger.info("startVideoStallObserve","invoke"),this._videoStallObserver||(this._videoStallObserver=new jH(this.isScreen,this.engineId)),this._videoStallObserver.start(e),this._videoPlayer=e}},{key:"stopVideoStallObserve",value:function(){var e;this.logger.info("stopVideoStallObserve","invoke"),null===(e=this._videoStallObserver)||void 0===e||e.stop(),delete this._videoPlayer}},{key:"updateVideoStallInfo",value:function(e,t){var r,n=null===(r=this._videoStallObserver)||void 0===r?void 0:r.getStallInfo({interval:e.stats_interval||0,bitrate:e.bitrate,frameRateDecoded:e.frame_rate_decoded,frameRateReceived:e.frame_rate_received});if(n){var i=Math.min(n.report.stallDuration,e.stats_interval||0);if(e.play_time=n.pts,e.stall_count=n.report.stallCount,e.is_screen?e.stuck_length=i:e.stall_duration=i,e.pause_duration=Math.min(i,n.pauseDuration),t.stallCount=n.callback.stallCount,t.stallDuration=n.callback.stallDuration,n.stall100ms){var o=Math.min(n.stall100ms.duration,e.stats_interval||0);e.stall_duration_100ms=o,e.stall_count_100ms=n.stall100ms.count,t.stallDuration100MS=o,t.stallCount100MS=n.stall100ms.count}0===n.report.stallCount&&0===n.report.stallDuration||this.logger.print("video_stall_report",this.userId,Gg(n.report))}}},{key:"getVideoRenderInfo",value:function(){var e;return(null===(e=this._videoStallObserver)||void 0===e?void 0:e.getRecentRenderInfo4Report())||{}}},{key:"stopAudioStallObserve",value:function(){var e;this.logger.info("stopAudioStallObserve","invoke"),null===(e=this._audioStallObserver)||void 0===e||e.stop()}},{key:"updateAudioStallInfo",value:(t=Ng(Pg().mark((function e(t,r,n){var i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._audioStallObserver){e.next=6;break}this._audioStallObserver=new HH(this),this._audioStallObserver.start(n.concealedSamples,n.totalSamplesReceived),this.logger.print("startAduioObserver","start"),e.next=12;break;case 6:return e.next=8,this._audioStallObserver.getAudioStallInfo();case 8:return i=e.sent,t.concealedSamples===t.interval_concealed_samples&&t.totalSamplesReceived===t.interval_samples_received?(t.stall_count=0,t.stall_duration=0,r.stallCount=0,r.stallDuration=0):(t.stall_count=i.report.stall_count,t.stall_duration=i.report.stall_duration,r.stallCount=i.callback.stall_count,r.stallDuration=i.callback.stall_duration),0===i.report.stall_count&&0===i.report.stall_duration||this.logger.print("audio_stall_report",this.userId,Gg(Ql(Ql({},i.report),{},{callbackList:i.callback.list}))),e.abrupt("return",i.extra);case 12:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"clean",value:function(){var e,t;this.logger.info("clean",Fg(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),JN(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),MA(NA(n.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(){var e,t;this.clean(),null===(e=this._audioStallObserver)||void 0===e||e.destroy(),delete this._audioStallObserver,null===(t=this._videoStallObserver)||void 0===t||t.destroy(),delete this._videoStallObserver,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.preprocessingTrack)||void 0===r?void 0:r.id)!==e.id&&(this.audioTrack=gH(e),this.emit("ontrack",this.audioTrack))}},{key:"_setVideoTrack",value:function(e){var t,r;(null===(t=this.videoTrack)||void 0===t||null===(r=t.preprocessingTrack)||void 0===r?void 0:r.id)!==e.id&&(this.videoTrack=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:TM();return new Jj(e,t)}(e),this.emit("ontrack",this.videoTrack))}}]),n}(WH),JH=new pM("queue",4),QH=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(QH||{}),ZH=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(ZH||{}),$H=(ql(GH={},"publish","unpublish"),ql(GH,"subscribe","unsubscribe"),ql(GH,"pushtrack","removetrack"),GH),eG=(ql(zH={},"publish",0),ql(zH,"subscribe",0),ql(zH,"pushtrack",0),ql(zH,"unpublish",1),ql(zH,"unsubscribe",1),ql(zH,"removetrack",1),zH),tG=function(e){UA(r,e);var t=ew(r);function r(){var e;return Fh(this,r),ql(aA(e=t.call(this)),"_queue",void 0),e._queue=[],e}return Vh(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t,r=this._queue.length,n="";return this._queue=Ty(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==$H[t.action]||(n=t.streamId,JH.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;nL&&AL>=86&&AL<=92&&(t=Math.min(this._queue.length,5));for(var r=eG[this._queue[0].action],n=1;n<t;n++){var i;if(eG[this._queue[n].action]!==r)return{sdpStrategy:r,items:BI(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:BI(e=this._queue).call(e,0,t)}}}]),r}(SU),rG="object"==typeof global&&global&&global.Object===Object&&global,nG="object"==typeof self&&self&&self.Object===Object&&self,iG=rG||nG||Function("return this")(),oG=iG.Symbol,aG=Object.prototype,sG=aG.hasOwnProperty,cG=aG.toString,uG=oG?oG.toStringTag:void 0;var dG=Object.prototype.toString;var lG="[object Null]",hG="[object Undefined]",pG=oG?oG.toStringTag:void 0;function vG(e){return null==e?void 0===e?hG:lG:pG&&pG in Object(e)?function(e){var t=sG.call(e,uG),r=e[uG];try{e[uG]=void 0;var n=!0}catch(o){}var i=cG.call(e);return n&&(t?e[uG]=r:delete e[uG]),i}(e):function(e){return dG.call(e)}(e)}function _G(e){return null!=e&&"object"==typeof e}var fG=Array.isArray;function mG(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function gG(e){return e}var yG="[object AsyncFunction]",SG="[object Function]",bG="[object GeneratorFunction]",kG="[object Proxy]";function EG(e){if(!mG(e))return!1;var t=vG(e);return t==SG||t==bG||t==yG||t==kG}var TG,IG=iG["__core-js_shared__"],RG=(TG=/[^.]+$/.exec(IG&&IG.keys&&IG.keys.IE_PROTO||""))?"Symbol(src)_1."+TG:"";var AG=Function.prototype.toString;function wG(e){if(null!=e){try{return AG.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var CG=/^\[object .+?Constructor\]$/,xG=Function.prototype,OG=Object.prototype,PG=xG.toString,DG=OG.hasOwnProperty,NG=RegExp("^"+PG.call(DG).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function MG(e){return!(!mG(e)||(t=e,RG&&RG in t))&&(EG(e)?NG:CG).test(wG(e));var t}function LG(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return MG(r)?r:void 0}var UG=LG(iG,"WeakMap"),VG=Object.create,FG=function(){function e(){}return function(t){if(!mG(t))return{};if(VG)return VG(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();var BG=Date.now;var jG,HG,GG,zG=function(){try{var e=LG(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),KG=zG,WG=KG?function(e,t){return KG(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:gG,XG=(jG=WG,HG=0,GG=0,function(){var e=BG(),t=16-(e-GG);if(GG=e,t>0){if(++HG>=800)return arguments[0]}else HG=0;return jG.apply(void 0,arguments)}),YG=XG;var qG=9007199254740991,JG=/^(?:0|[1-9]\d*)$/;function QG(e,t){var r=typeof e;return!!(t=null==t?qG:t)&&("number"==r||"symbol"!=r&&JG.test(e))&&e>-1&&e%1==0&&e<t}function ZG(e,t,r){"__proto__"==t&&KG?KG(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function $G(e,t){return e===t||e!=e&&t!=t}var ez=Object.prototype.hasOwnProperty;function tz(e,t,r){var n=e[t];ez.call(e,t)&&$G(n,r)&&(void 0!==r||t in e)||ZG(e,t,r)}function rz(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?ZG(r,s,c):tz(r,s,c)}return r}var nz=Math.max;function iz(e,t){return YG(function(e,t,r){return t=nz(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=nz(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),function(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)}(e,this,s)}}(e,t,gG),e+"")}var oz=9007199254740991;function az(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=oz}function sz(e){return null!=e&&az(e.length)&&!EG(e)}var cz=Object.prototype;function uz(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||cz)}function dz(e){return _G(e)&&"[object Arguments]"==vG(e)}var lz=Object.prototype,hz=lz.hasOwnProperty,pz=lz.propertyIsEnumerable,vz=dz(function(){return arguments}())?dz:function(e){return _G(e)&&hz.call(e,"callee")&&!pz.call(e,"callee")},_z=vz;var fz="object"==typeof exports&&exports&&!exports.nodeType&&exports,mz=fz&&"object"==typeof module&&module&&!module.nodeType&&module,gz=mz&&mz.exports===fz?iG.Buffer:void 0,yz=(gz?gz.isBuffer:void 0)||function(){return!1},Sz={};function bz(e){return function(t){return e(t)}}Sz["[object Float32Array]"]=Sz["[object Float64Array]"]=Sz["[object Int8Array]"]=Sz["[object Int16Array]"]=Sz["[object Int32Array]"]=Sz["[object Uint8Array]"]=Sz["[object Uint8ClampedArray]"]=Sz["[object Uint16Array]"]=Sz["[object Uint32Array]"]=!0,Sz["[object Arguments]"]=Sz["[object Array]"]=Sz["[object ArrayBuffer]"]=Sz["[object Boolean]"]=Sz["[object DataView]"]=Sz["[object Date]"]=Sz["[object Error]"]=Sz["[object Function]"]=Sz["[object Map]"]=Sz["[object Number]"]=Sz["[object Object]"]=Sz["[object RegExp]"]=Sz["[object Set]"]=Sz["[object String]"]=Sz["[object WeakMap]"]=!1;var kz="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ez=kz&&"object"==typeof module&&module&&!module.nodeType&&module,Tz=Ez&&Ez.exports===kz&&rG.process,Iz=function(){try{var e=Ez&&Ez.require&&Ez.require("util").types;return e||Tz&&Tz.binding&&Tz.binding("util")}catch(t){}}(),Rz=Iz&&Iz.isTypedArray,Az=Rz?bz(Rz):function(e){return _G(e)&&az(e.length)&&!!Sz[vG(e)]},wz=Object.prototype.hasOwnProperty;function Cz(e,t){var r=fG(e),n=!r&&_z(e),i=!r&&!n&&yz(e),o=!r&&!n&&!i&&Az(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&&!wz.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||QG(u,c))||s.push(u);return s}function xz(e,t){return function(r){return e(t(r))}}var Oz=xz(Object.keys,Object),Pz=Object.prototype.hasOwnProperty;function Dz(e){return sz(e)?Cz(e):function(e){if(!uz(e))return Oz(e);var t=[];for(var r in Object(e))Pz.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var Nz=Object.prototype.hasOwnProperty;function Mz(e){if(!mG(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=uz(e),r=[];for(var n in e)("constructor"!=n||!t&&Nz.call(e,n))&&r.push(n);return r}function Lz(e){return sz(e)?Cz(e,!0):Mz(e)}var Uz,Vz=(Uz=function(e,t){rz(t,Lz(t),e)},iz((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=Uz.length>3&&"function"==typeof i?(n--,i):void 0,o&&function(e,t,r){if(!mG(r))return!1;var n=typeof t;return!!("number"==n?sz(r)&&QG(t,r.length):"string"==n&&t in r)&&$G(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&&Uz(e,a,r,i)}return e}))),Fz=LG(Object,"create");var Bz=Object.prototype.hasOwnProperty;var jz=Object.prototype.hasOwnProperty;function Hz(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 Gz(e,t){for(var r=e.length;r--;)if($G(e[r][0],t))return r;return-1}Hz.prototype.clear=function(){this.__data__=Fz?Fz(null):{},this.size=0},Hz.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Hz.prototype.get=function(e){var t=this.__data__;if(Fz){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return Bz.call(t,e)?t[e]:void 0},Hz.prototype.has=function(e){var t=this.__data__;return Fz?void 0!==t[e]:jz.call(t,e)},Hz.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Fz&&void 0===t?"__lodash_hash_undefined__":t,this};var zz=Array.prototype.splice;function Kz(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])}}Kz.prototype.clear=function(){this.__data__=[],this.size=0},Kz.prototype.delete=function(e){var t=this.__data__,r=Gz(t,e);return!(r<0)&&(r==t.length-1?t.pop():zz.call(t,r,1),--this.size,!0)},Kz.prototype.get=function(e){var t=this.__data__,r=Gz(t,e);return r<0?void 0:t[r][1]},Kz.prototype.has=function(e){return Gz(this.__data__,e)>-1},Kz.prototype.set=function(e,t){var r=this.__data__,n=Gz(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var Wz=LG(iG,"Map");function Xz(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 Yz(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 qz(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}Yz.prototype.clear=function(){this.size=0,this.__data__={hash:new Hz,map:new(Wz||Kz),string:new Hz}},Yz.prototype.delete=function(e){var t=Xz(this,e).delete(e);return this.size-=t?1:0,t},Yz.prototype.get=function(e){return Xz(this,e).get(e)},Yz.prototype.has=function(e){return Xz(this,e).has(e)},Yz.prototype.set=function(e,t){var r=Xz(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};var Jz=xz(Object.getPrototypeOf,Object);function Qz(e){var t=this.__data__=new Kz(e);this.size=t.size}Qz.prototype.clear=function(){this.__data__=new Kz,this.size=0},Qz.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Qz.prototype.get=function(e){return this.__data__.get(e)},Qz.prototype.has=function(e){return this.__data__.has(e)},Qz.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Kz){var n=r.__data__;if(!Wz||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Yz(n)}return r.set(e,t),this.size=r.size,this};var Zz="object"==typeof exports&&exports&&!exports.nodeType&&exports,$z=Zz&&"object"==typeof module&&module&&!module.nodeType&&module,eK=$z&&$z.exports===Zz?iG.Buffer:void 0,tK=eK?eK.allocUnsafe:void 0;function rK(){return[]}var nK=Object.prototype.propertyIsEnumerable,iK=Object.getOwnPropertySymbols,oK=iK?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}(iK(e),(function(t){return nK.call(e,t)})))}:rK;var aK=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)qz(t,oK(e)),e=Jz(e);return t}:rK;function sK(e,t,r){var n=t(e);return fG(e)?n:qz(n,r(e))}function cK(e){return sK(e,Dz,oK)}function uK(e){return sK(e,Lz,aK)}var dK=LG(iG,"DataView"),lK=LG(iG,"Promise"),hK=LG(iG,"Set"),pK="[object Map]",vK="[object Promise]",_K="[object Set]",fK="[object WeakMap]",mK="[object DataView]",gK=wG(dK),yK=wG(Wz),SK=wG(lK),bK=wG(hK),kK=wG(UG),EK=vG;(dK&&EK(new dK(new ArrayBuffer(1)))!=mK||Wz&&EK(new Wz)!=pK||lK&&EK(lK.resolve())!=vK||hK&&EK(new hK)!=_K||UG&&EK(new UG)!=fK)&&(EK=function(e){var t=vG(e),r="[object Object]"==t?e.constructor:void 0,n=r?wG(r):"";if(n)switch(n){case gK:return mK;case yK:return pK;case SK:return vK;case bK:return _K;case kK:return fK}return t});var TK=EK,IK=Object.prototype.hasOwnProperty;var RK=iG.Uint8Array;function AK(e){var t=new e.constructor(e.byteLength);return new RK(t).set(new RK(e)),t}var wK=/\w*$/;var CK=oG?oG.prototype:void 0,xK=CK?CK.valueOf:void 0;var OK="[object Boolean]",PK="[object Date]",DK="[object Map]",NK="[object Number]",MK="[object RegExp]",LK="[object Set]",UK="[object String]",VK="[object Symbol]",FK="[object ArrayBuffer]",BK="[object DataView]",jK="[object Float32Array]",HK="[object Float64Array]",GK="[object Int8Array]",zK="[object Int16Array]",KK="[object Int32Array]",WK="[object Uint8Array]",XK="[object Uint8ClampedArray]",YK="[object Uint16Array]",qK="[object Uint32Array]";function JK(e,t,r){var n,i,o,a=e.constructor;switch(t){case FK:return AK(e);case OK:case PK:return new a(+e);case BK:return function(e,t){var r=t?AK(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case jK:case HK:case GK:case zK:case KK:case WK:case XK:case YK:case qK:return function(e,t){var r=t?AK(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,r);case DK:return new a;case NK:case UK:return new a(e);case MK:return(o=new(i=e).constructor(i.source,wK.exec(i))).lastIndex=i.lastIndex,o;case LK:return new a;case VK:return n=e,xK?Object(xK.call(n)):{}}}var QK=Iz&&Iz.isMap,ZK=QK?bz(QK):function(e){return _G(e)&&"[object Map]"==TK(e)};var $K=Iz&&Iz.isSet,eW=$K?bz($K):function(e){return _G(e)&&"[object Set]"==TK(e)},tW=1,rW=2,nW=4,iW="[object Arguments]",oW="[object Function]",aW="[object GeneratorFunction]",sW="[object Object]",cW={};function uW(e,t,r,n,i,o){var a,s=t&tW,c=t&rW,u=t&nW;if(r&&(a=i?r(e,n,i,o):r(e)),void 0!==a)return a;if(!mG(e))return e;var d=fG(e);if(d){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&IK.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=TK(e),h=l==oW||l==aW;if(yz(e))return function(e,t){if(t)return e.slice();var r=e.length,n=tK?tK(r):new e.constructor(r);return e.copy(n),n}(e,s);if(l==sW||l==iW||h&&!i){if(a=c||h?{}:function(e){return"function"!=typeof e.constructor||uz(e)?{}:FG(Jz(e))}(e),!s)return c?function(e,t){return rz(e,aK(e),t)}(e,function(e,t){return e&&rz(t,Lz(t),e)}(a,e)):function(e,t){return rz(e,oK(e),t)}(e,function(e,t){return e&&rz(t,Dz(t),e)}(a,e))}else{if(!cW[l])return i?e:{};a=JK(e,l,s)}}o||(o=new Qz);var p=o.get(e);if(p)return p;o.set(e,a),eW(e)?e.forEach((function(n){a.add(uW(n,t,r,n,e,o))})):ZK(e)&&e.forEach((function(n,i){a.set(i,uW(n,t,r,i,e,o))}));var v=d?void 0:(u?c?uK:cK:c?Lz:Dz)(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]),tz(a,i,uW(n,t,r,i,e,o))})),a}cW[iW]=cW["[object Array]"]=cW["[object ArrayBuffer]"]=cW["[object DataView]"]=cW["[object Boolean]"]=cW["[object Date]"]=cW["[object Float32Array]"]=cW["[object Float64Array]"]=cW["[object Int8Array]"]=cW["[object Int16Array]"]=cW["[object Int32Array]"]=cW["[object Map]"]=cW["[object Number]"]=cW[sW]=cW["[object RegExp]"]=cW["[object Set]"]=cW["[object String]"]=cW["[object Symbol]"]=cW["[object Uint8Array]"]=cW["[object Uint8ClampedArray]"]=cW["[object Uint16Array]"]=cW["[object Uint32Array]"]=!0,cW["[object Error]"]=cW[oW]=cW["[object WeakMap]"]=!1;function dW(e){return uW(e,5)}function lW(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 hW(e){return null==e?[]:lW(e,Dz(e))}var pW,vW,_W=BB(),fW=function(e){UA(u,e);var t,r,n,i,o,a,s,c=ew(u);function u(e,t){var r;return Fh(this,u),ql(aA(r=c.call(this,e,t)),"name","chrome"),ql(aA(r),"_queueBusy",!1),ql(aA(r),"_sdpQueue",void 0),ql(aA(r),"_aSendonlyOfferTpl",void 0),ql(aA(r),"_vSendonlyOfferTpl",void 0),ql(aA(r),"_aRecvonlyOfferTpl",void 0),ql(aA(r),"_vRecvonlyOfferTpl",void 0),ql(aA(r),"_mid",10),ql(aA(r),"_inactiveMlineIndex",[]),ql(aA(r),"_mlinesCache",{}),ql(aA(r),"setDescription",void 0),r.logger=new pM("ChromeHandler",3,e.id),r.setDescription=t.setDescription.bind(t),r._sdpQueue=new tG,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(r.logger.info("dequeue start"),r.dequeue())})),r}return Vh(u,[{key:"destroy",value:function(){MA(NA(u.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(s=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M,L,U,V,F,B;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d=t.stream,l=t.enableSimulcast,h=MA(NA(u.prototype),"internalPublish",this).call(this,t),p=h.videoDescriptions,v=h.subVideoDescriptions,_=h.audioTransceiverInit,f=h.videoTransceiverInit,m=vj(this._nextSsrc),this._nextSsrc=m.next,g="".concat(this._mid++),y="".concat(this._mid++),S=Ql(Ql(Ql({},this._aSendonlyOfferTpl),this.peer._offerIce),{},{mid:g,msid:Fg(r="".concat(d.id," ")).call(r,d.id,"-audio"),ssrcs:_j(d.id,"audio",m.audio,pj)}),b=Ql(Ql(Ql({},this._vSendonlyOfferTpl),this.peer._offerIce),{},{mid:y,msid:Fg(n="".concat(d.id," ")).call(n,d.id,"-video")}),l?(this.logger.info("subVideoDesc","desc: %o ",v),delete b.ssrcGroups,delete b.ssrcs,k=[],b.rids=qg(p).call(p,(function(e){var t=e.rid;return k.unshift(t),{id:t,direction:"send"}})),b.simulcast={dir1:"send",list1:k.join(";")}):(E=fj(d.id,m,{cname:pj}),T=E.ssrcs,I=E.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=eC(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(C=BI(w=S.rtp).call(w,A,1),x=gy(C,1),O=x[0],S.rtp.unshift(O)),P=[],S.rtp.forEach((function(e){return P.push(e.payload)})),S.payloads=P.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&Ej(b,null===(D=this._context)||void 0===D||null===(N=D.serverConfig)||void 0===N?void 0:N.videoCodec),Array.isArray(b.ext)&&(KL("IOS_SAFARI_ORIENTATION")||!rL&&!vL||(b.ext=Ty(L=b.ext).call(L,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&Xy(t).call(t,"video-orientation"))}))),b.ext=Ty(M=b.ext).call(M,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&Xy(t).call(t,"framemarking"))}))),(U=null==S?void 0:aI(c=S.rtp).call(c,(function(e){return"opus"===e.codec})))&&S.fmtp&&(B=aI(V=S.fmtp).call(V,(function(e){return e.payload===U.payload})))&&null!==(F=this._context)&&void 0!==F&&F.audioProfileManager&&(B.config=this._context.audioProfileManager.getOpusConfigStr(B.config)),l||rL||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:gj(this.peer._offerSession,S,b),audioMid:g,videoMid:y,type:"incroffer",semantics:"unified-plan",videoDescriptions:p,subVideoDescriptions:v,audioTransceiverInit:_,videoTransceiverInit:f,peerConnectionMode:this.peerConnectionMode});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"subscribe",value:(a=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M,L,U;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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:return 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=Ql(Ql({},dW(this._aRecvonlyOfferTpl)),{},{mid:u})),l&&(this._mlinesCache[t.streamId][0]=p,_={track:"audio",init:{direction:"recvonly"}}),d&&(v=Ql(Ql({},dW(this._vRecvonlyOfferTpl)),{},{mid:d})),h&&(this._mlinesCache[t.streamId][1]=v,f={track:"video",init:{direction:"recvonly"}}),m=gj(this.peer._offerSession,p,v),g=void 0,y=void 0,t.enableVendorMode||r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl||(g=vj(this._nextSsrc),this._nextSsrc=g.next,A=Ql(Ql(Ql({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Fg(S=Fg(b="".concat(t.streamId)).call(b,null!==(k=this._context)&&void 0!==k&&k.avSync?"":"-audio"," ")).call(S,t.streamId,"-audio"),ssrcs:_j(t.streamId,"audio",g.audio)}),w=Ql(Ql(Ql({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:d,msid:Fg(E=Fg(T="".concat(t.streamId)).call(T,null!==(I=this._context)&&void 0!==I&&I.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},fj(t.streamId,g,{flexfec:this._enableSubFlexfec})),y={sdp:ZB.write(Ql(Ql({},this.peer._answerSession),{},{media:[A,w]})),sequenceId:t.sequenceId?++t.sequenceId:0},null===(R=g)||void 0===R||delete R.next),(C=null===(n=p)||void 0===n?void 0:aI(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=p)&&void 0!==o&&o.fmtp&&(P=null===(x=p)||void 0===x?void 0:aI(O=x.fmtp).call(O,(function(e){return e.payload===C.payload})))&&this._context&&(P.config+=";stereo=1;sprop-stereo=1"),t.isPublic&&AL>=86&&null!=(L=null===(D=v)||void 0===D?void 0:Ty(N=D.rtp).call(N,(function(e){return"H264"===e.codec})))&&L.length&&null!==(M=v)&&void 0!==M&&M.fmtp&&(null===(U=v)||void 0===U||U.fmtp.forEach((function(e){aI(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:_,videoTransceiverInit:f,allSsrc:g,peerConnectionMode:this.peerConnectionMode,signalingAck:y});case 29:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handleAck",value:(o=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("handleAck()","item: %o",t),e.abrupt("return",this._sdpQueue.enqueue(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"dequeue",value:(i=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),this.logger.info("dequeue()","ret: %o",t),t){e.next=6;break}return this._queueBusy=!1,e.abrupt("return");case 6:if(r=[],e.prev=7,n=t.items,i=t.sdpStrategy,o=[],a=[],s=[],i!==QH.ADD){e.next=16;break}return e.delegateYield(Pg().mark((function e(){var t,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=Ql({},m.peer._answerIce)).candidates,c=!1,u=!1,e.prev=4,l=NU(n);case 6:return e.next=8,l.next();case 8:if(!(c=!(h=e.sent).done)){e.next=16;break}if(i=h.value,"break"!==function(){var e=i.audioMid,n=i.videoMid,c=i.action,u=i.audioTransceiverInit,d=i.videoTransceiverInit,l=i.signalingAck,h=i.stream,p=h instanceof qH;if(i.onSuccess&&s.push(i.onSuccess),i.onFail&&r.push(i.onFail),p&&(null==l?void 0:l.sequenceId)<h.sequenceId)return"break";var v,_={},f={},g=ZB.parse(l.sdp);Array.isArray(g.media)&&Kw(v=g.media).call(v,(function(e,t){var r;return null==e||null===(r=e.type)||void 0===r?void 0:r.localeCompare(null==t?void 0:t.type)})).forEach((function(r){"audio"===(r=Ql(Ql({},r),t)).type?(_=r).mid=e:(f=r).mid=n}));var y,S=h.streamId;if(c===ZH.publish&&(S=null===(y=h.stream)||void 0===y?void 0:y.id),!m._mlinesCache[S])return"break";var b=gy(m._mlinesCache[S],2),k=b[0],E=b[1];if(u&&k){h.audioTransceiver=m._peerConnection.addTransceiver(u.track,u.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",Gg({audioStreamTrack:fx(u.track)}));var T=m._inactiveMlineIndex.shift();T||(T=m.peer._offerMlines.length),m.peer._offerMlines[T]=Ql({},k),m.peer._answerMlines[T]=_,_W&&h.initAudioEncodedTransform()}if(d&&E){var I,R;h.videoTransceiver=m._peerConnection.addTransceiver(d.track,d.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",Gg({videoStreamTrack:fx(d.track)}));var A,w,C=m._inactiveMlineIndex.shift();C||(C=m.peer._offerMlines.length),m.peer._offerMlines[C]=Ql({},E),c===ZH.publish&&null!==(I=m._context)&&void 0!==I&&null!==(R=I.serverConfig)&&void 0!==R&&R.videoCodec&&Ej(f,null===(A=m._context)||void 0===A||null===(w=A.serverConfig)||void 0===w?void 0:w.videoCodec),m.peer._answerMlines[C]=f,_W&&h.initVideoEncodedTransform()}o.push(h.streamId||""),a.push(p?h.userId:"local"),p&&(h.sequenceId=null==l?void 0:l.sequenceId),delete m._mlinesCache[S]}()){e.next=13;break}return e.abrupt("break",16);case 13:c=!1,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),u=!0,d=e.t0;case 22:if(e.prev=22,e.prev=23,!c||null==l.return){e.next=27;break}return e.next=27,l.return();case 27:if(e.prev=27,!u){e.next=30;break}throw d;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",14);case 14:e.next=21;break;case 16:f={},n.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;f[t]=t,n!==ZH.removetrack&&(f[r]=r),f[t]=t})),this.peer._offerMlines=qg(p=this.peer._offerMlines).call(p,(function(e,t){return f[e.mid]&&(e=mj(e),m._inactiveMlineIndex.push(t)),e})),Kw(v=this._inactiveMlineIndex).call(v,(function(e,t){return e-t})),this.peer._answerMlines=qg(_=this.peer._answerMlines).call(_,(function(e){return f[e.mid]&&(e=mj(e)),e}));case 21:return e.prev=21,e.next=24,this.setDescription(o.length?{streamId:o.join(","),streamUserId:a.join(",")}:void 0);case 24:e.next=32;break;case 26:if(e.prev=26,e.t1=e.catch(21),"have-local-offer"!==this._peerConnection.signalingState){e.next=31;break}return e.next=31,this._peerConnection.setLocalDescription({type:"rollback"});case 31:throw e.t1;case 32:try{s.forEach((function(e){return e()}))}catch(BZ){}this.logger.info("dequeue","loop"),e.next=40;break;case 36:e.prev=36,e.t2=e.catch(7),this.logger.error("dequeue","unknown error: %o",e.t2),r.forEach((function(t){return t(e.t2)}));case 40:return e.prev=40,this.dequeue(),e.finish(40);case 43:case"end":return e.stop()}}),e,this,[[7,36,40,43],[21,26]])}))),function(){return i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=Ng(Pg().mark((function e(){var t,r,n,i;return Pg().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=ZB.parse(r),i=[],n.media=Ty(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=Ty(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"}],zB&&Ij(n),e.abrupt("return",{sdp:ZB.write(n),semantics:"unified-plan",type:"incroffer"});case 10:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"rollback",value:(r=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.msid,delete this._mlinesCache[r];case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this,r=ZB.parse(e);r.media.forEach((function(e){if("audio"===e.type)if("sendonly"===e.direction)t._aSendonlyOfferTpl=e;else{var r;if(Array.isArray(e.ext))e.ext=Ty(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=Ty(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}})),zB&&Ij(r)}},{key:"_genOfferSdp",value:(t=Ng(Pg().mark((function e(){var t,r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,BM(!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 bC(fC.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}(Cj),mW=function(e){UA(d,e);var t,r,n,i,o,a,s,c,u=ew(d);function d(e,t){var r;return Fh(this,d),ql(aA(r=u.call(this,e,t)),"name","firefox"),ql(aA(r),"_aRecvonlyOfferTpl",void 0),r.logger=new pM("FirefoxHandler",3,e.id),r}return Vh(d,[{key:"publish",value:(c=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,_,f,m,g=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=MA(NA(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),Array.isArray(c.init.sendEncodings)&&1===c.init.sendEncodings.length&&(c.init.sendEncodings=qg(u=c.init.sendEncodings).call(u,(function(e){return delete e.rid,e}))),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),l=IM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=8,this._peerConnection.createOffer();case 8:return h=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:IM()-l}),(p=ZB.parse(h.sdp)).media=null===(r=p.media)||void 0===r?void 0:qg(r).call(r,(function(e){return Ql(Ql({},e),g.peer._offerIce)})),Ij(p),e.next=15,this.setLocalDescription(ZB.write(p));case 15:return v=t.audioTransceiver.mid,_=t.videoTransceiver.mid,f=null,m=null,p.media=null===(n=p.media)||void 0===n?void 0:qg(n).call(n,(function(e){if("".concat(e.mid)===v){var t,r,n=null===(t=f=e)||void 0===t?void 0:aI(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&f.fmtp){var i,o,a=aI(i=f.fmtp).call(i,(function(e){return e.payload===n.payload}));a&&null!==(o=g._context)&&void 0!==o&&o.audioProfileManager&&(a.config=g._context.audioProfileManager.getOpusConfigStr(a.config))}}else if("".concat(e.mid)===_){var s,c,u,d;null!==(s=g._context)&&void 0!==s&&null!==(c=s.serverConfig)&&void 0!==c&&c.videoCodec&&Ej(e,null===(u=g._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec),m=e}return e})),this.addBitrateLimit(m,t.videoEncodeConfig[0].maxKbps),e.next=23,this.setLocalDescription(ZB.write(p));case 23:return e.abrupt("return",{partialSdp:gj(p,f,m),audioMid:v,videoMid:_,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:c,peerConnectionMode:this.peerConnectionMode});case 24:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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=IM(),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 _=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:IM()-v}),(f=ZB.parse(_.sdp)).media=null===(n=f.media)||void 0===n?void 0:qg(n).call(n,(function(e){return Ql(Ql({},e),w.peer._offerIce)})),qg(i=f.media).call(i,(function(e){var t,r,n,i;"video"===e.type&&(GB?(e.ext=null===(t=e.ext)||void 0===t?void 0:Ty(t).call(t,(function(e){var t;return-1===yI(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Ty(r).call(r,(function(e){return"goog-remb"!==e.type}))):(e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:Ty(n).call(n,(function(e){return"transport-cc"!==e.type})),e.ext=null===(i=e.ext)||void 0===i?void 0:Ty(i).call(i,(function(e){var t;return-1===yI(t=e.uri).call(t,"transport")}))))})),zB&&Ij(f),e.next=22,this.setLocalDescription(ZB.write(f),{streamId:t.streamId||"",streamUserId:t.userId});case 22:return c=null===(o=t.audioTransceiver)||void 0===o?void 0:o.mid,u=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid,null===(s=f.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===c?h=e:"".concat(e.mid)===u&&(p=e)})),c&&h||(c="audio_".concat(u),h=Ql(Ql({},this._aRecvonlyOfferTpl),{},{mid:c})),t.audioMid=c,t.videoMid=u,m=void 0,g=void 0,!r.multiChatMode&&!t.virtual&&this._aSendonlyAnswerTpl&&this._aSendonlyAnswerTpl&&(m=vj(this._nextSsrc),this._nextSsrc=m.next,R=Ql(Ql(Ql({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:c,msid:Fg(y=Fg(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:_j(t.streamId,"audio",m.audio)}),A=Ql(Ql(Ql({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Fg(k=Fg(E="".concat(t.streamId)).call(E,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(k,t.streamId,"-video")},fj(t.streamId,m,{flexfec:this._enableSubFlexfec})),g={sdp:ZB.write(Ql(Ql({},this.peer._answerSession),{},{media:[R,A]})),sequenceId:t.sequenceId?++t.sequenceId:0},null===(I=m)||void 0===I||delete I.next),e.abrupt("return",{partialSdp:gj(f,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,signalingAck:g});case 32:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==ZH.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==ZH.unpublish&&i!==ZH.unsubscribe){e.next=14;break}return e.prev=4,e.next=7,this.close(n);case 7:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(4),"function"==typeof t.onFail&&t.onFail(e.t0);case 13:return e.abrupt("return",n.streamId||"");case 14:return o=ZB.parse(null==r?void 0:r.sdp),e.prev=15,e.next=18,this._internalSetRemoteDescription(o.media,n);case 18:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=24;break;case 21:e.prev=21,e.t1=e.catch(15),"function"==typeof t.onFail&&t.onFail(e.t1);case 24:return e.abrupt("return","");case 25:case"end":return e.stop()}}),e,this,[[4,10],[15,21]])}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=ZB.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=Ql(Ql({},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 YH&&kL<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=Ty(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=Ty(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=Ty(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=Ty(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=ZB.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=qg(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,qg(a=c.media).call(a,(function(e){var t,r,n,i;"video"===e.type&&(GB?(e.ext=null===(t=e.ext)||void 0===t?void 0:Ty(t).call(t,(function(e){var t;return-1===yI(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Ty(r).call(r,(function(e){return"goog-remb"!==e.type}))):(e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:Ty(n).call(n,(function(e){return"transport-cc"!==e.type})),e.ext=null===(i=e.ext)||void 0===i?void 0:Ty(i).call(i,(function(e){var t;return-1===yI(t=e.uri).call(t,"transport")}))))})),zB&&Ij(c),e.next=12,this.setRemoteDescription(ZB.write(c));case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Ng(Pg().mark((function e(){var t,r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ZB.parse(null===(t=this._peerConnection.localDescription)||void 0===t?void 0:t.sdp),this.createAVMlineOfferTpl(null===(r=this._peerConnection.localDescription)||void 0===r?void 0:r.sdp),o=[],i.media=Ty(n=i.media).call(n,(function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,o.push("".concat(e.mid)),!0)})),zB&&Ij(i),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:ZB.write(i),semantics:"unified-plan",type:"incroffer"});case 7:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.msid,r=t.stream,n=t.audioMid,i=t.videoMid,this.logger.warn("rollback()"),e.abrupt("return",this.close(r,n,i));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"close",value:(r=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("close()"),s=t.audioMid||r,c=t.videoMid||n,u={},t.audioTransceiver&&s&&(t.audioTransceiver.stop(),u[s]=s),t.videoTransceiver&&c&&(t.videoTransceiver.stop(),u[c]=c),d=[],e.next=9,this._peerConnection.createOffer();case 9:return l=e.sent,(h=ZB.parse(null==l?void 0:l.sdp)).media=qg(i=h.media).call(i,(function(e){return u[e.mid]&&(e=mj(e)),"inactive"!==e.direction&&d.push(e.mid),Ql(Ql({},e),_.peer._offerIce)})),p=ZB.parse(null===(o=this._peerConnection.remoteDescription)||void 0===o?void 0:o.sdp),v={},p.media.forEach((function(e){void 0!==e.mid&&(v[e.mid]=e)})),p.media=qg(a=h.media).call(a,(function(e){return"inactive"===e.direction?e:v[e.mid]})),h.groups&&p.groups&&(h.groups[0].mids=d.join(" "),p.groups[0].mids=d.join(" ")),e.next=19,this.setLocalDescription(ZB.write(h));case 19:return e.next=21,this.setRemoteDescription(ZB.write(p));case 21:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Ng(Pg().mark((function e(){return Pg().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,r=ZB.parse(e);r.media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)})),zB&&Ij(r)}}]),d}(Cj),gW=function(e,t){return tL?new mW(e,t):new fW(e,t)},yW=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}(yW||{}),SW=function(e){return e.PushLimitWarn="PushLimitWarn",e}(SW||{}),bW=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}(bW||{}),kW=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(kW||{}),EW=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ON_VENDOR_CONNECTION_STATE_CHANGE="onVendorConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(EW||{}),TW=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(TW||{}),IW=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(IW||{}),RW=new pM("Locker",2),AW=1,wW=function(){function e(t){var r;Fh(this,e),ql(this,"lockingPromise",jI.resolve()),ql(this,"locks",0),ql(this,"name",""),ql(this,"lockId",void 0),this.lockId=AW++,t&&(this.name=t),RW.info(Fg(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return Vh(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,RW.info(Fg(e=Fg(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new jI((function(e){r=function(){var t,r;n.locks-=1,RW.info(Fg(t=Fg(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}(),CW=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_SUBSCRIBE_RESULT="ON_SUBSCRIBE_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.PUB_RETRY="PUB_RETRY",e.SUB_RETRY="SUB_RETRY",e}(CW||{}),xW=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}(xW||{}),OW=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(OW||{}),PW=(ql(pW={},kh.communication,[0]),ql(pW,kh.chat,[0]),ql(pW,kh.chatRoom,[1,"IES_chatroom"]),ql(pW,kh.coHost,[1,"IES_PK"]),ql(pW,kh.meeting,[16]),ql(pW,kh.classRoom,[0]),pW),DW=BB(),NW=function(e){UA(s,e);var t,r,n,i,o,a=ew(s);function s(e,t){var r;return Fh(this,s),ql(aA(r=a.call(this,e,t)),"_peerConnectionId",TM()),ql(aA(r),"peerConnectionMode",1),ql(aA(r),"name","vendor"),ql(aA(r),"direction","up"),ql(aA(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:""})})),t.on("disconnect",(function(){r.emit("disconnect")})),r}return Vh(s,[{key:"publish",value:(o=Ng(Pg().mark((function e(t){var r,n,i,o,a,c,u,d,l,h,p=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.enableSimulcast=!1,this.stream=t,r=MA(NA(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),DW&&(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=IM(),d=ZB.parse(c.sdp),Array.isArray(d.media)&&(d.media=qg(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&&Ej(e,null===(i=p._context)||void 0===i||null===(o=i.serverConfig)||void 0===o?void 0:o.videoCodec),(rL||vL)&&Array.isArray(e.ext)&&(e.ext=Ty(a=e.ext).call(a,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&Xy(t).call(t,"video-orientation"))}))),rL||p.addBitrateLimit(e,t.videoEncodeConfig[0].maxKbps);else if("audio"===e.type){var s,c=null==e?void 0:aI(s=e.rtp).call(s,(function(e){return"opus"===e.codec}));if(c&&e.fmtp){var u,d,l=aI(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:ZB.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:IM()-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:IM()-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=Ng(Pg().mark((function e(t){var r,n,i,o,a,s=this;return Pg().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"}),DW&&(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=IM(),i=ZB.parse(r.sdp),Array.isArray(i.media)&&(i.media=qg(o=i.media).call(o,(function(e){if("audio"===e.type){var t,r=null==e?void 0:aI(t=e.rtp).call(t,(function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n,i=null==e?void 0:aI(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:ZB.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:IM()-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:IM()-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=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.action!==ZH.publish&&t.action!==ZH.subscribe){e.next=16;break}return n=new RTCSessionDescription({sdp:null===(r=t.signalingAck)||void 0===r?void 0:r.sdp,type:"answer"}),i=IM(),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:IM()-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:IM()-i},{type:"offer"}),e.t0;case 13:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=17;break;case 16:t.action!==ZH.unpublish&&t.action!==ZH.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(),MA(NA(s.prototype),"destroy",this).call(this)}},{key:"getDefaultSdp",value:(r=Ng(Pg().mark((function e(){return Pg().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=Ng(Pg().mark((function e(){return Pg().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)})},{key:"peerConnectionId",get:function(){return this._peerConnectionId},set:function(e){this._peerConnectionId=e}}]),s}(Cj),MW=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}(MW||{}),LW={start_interval:100,multiplier:2,max_interval:3e4},UW=function(){function e(){Fh(this,e),ql(this,"_times",0),ql(this,"_config",LW),ql(this,"initTs",IM())}return Vh(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}(),VW=function(){function e(t){Fh(this,e),ql(this,"_reconnectTimer",void 0),ql(this,"_abortControllers",[]),ql(this,"_monitor",void 0),ql(this,"logger",void 0),ql(this,"_groupConfigId",TM()),ql(this,"_retryLimiter",new UW),ql(this,"_timer",void 0),this._ctx=t,this._monitor=KN(t.id),this.logger=new pM("ICERequest",4,t.id)}var t,r,n,i;return Vh(e,[{key:"getICENode",value:(i=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 new Error("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 bC(fC.ICE_SERVER_WRONG,"get ICE config failed: ".concat(e.t0.message),e.t0);case 13:return this.logger.success("getICENode","success"),this._reportRtcInvokeStatus("es.join.getNodeSuccess",r),e.abrupt("return",r);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return i.apply(this,arguments)})},{key:"_getAccessWithRetry",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 0!==r&&this.logger.info("_getAccessWithRetry()","invoke feedbackInfo: %o, 201count: %o",e,r),new jI((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(eC(o).call(o,(function(e){return 400<=e.code&&e.code<500}))>-1)return t._retryLimiter.reset(),i(new Error("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(new Error("HTTP request failed(201)"))}var a=t._retryLimiter.getRetryDelay();t.logger.warn("_getAccessWithRetry()","_getAccessWithRetry error, will retry after ".concat(a,"ms"),o),t._reconnectTimer=self.setTimeout((function(){t._getAccessWithRetry(e,r).then(n).catch(i)}),a)}))}))}},{key:"_getAccessNode",value:(n=Ng(Pg().mark((function e(t){var r=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new jI((function(e,n){var i=LL.getAccessNode(r._ctx.appId);i?(r.logger.info("getAccessNode","use cache node."),e(Array.isArray(i)?i:[i]),r._timer=window.setTimeout((function(){r._getAccessNodeFromServer(t),r._reportRtcInvokeStatus("es.R.node.cache",i),delete r._timer}),0)):r._getAccessNodeFromServer(t).then(e).catch(n)})));case 1:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"_getAccessNodeFromServer",value:(r=Ng(Pg().mark((function e(t){var r,n,i,o=this;return Pg().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&&LL.setAccessNode(o._ctx.appId,t,e.ttl||11200),e.dispatchDomains&&!o._ctx.useCloudProxy&&LL.setAccessUrls(e.dispatchDomains),t})).catch((function(e){if(i)return o._reportRtcInvokeStatus("es.R.req.fallback",""),LL.clearAccessUrls(),o._getAccessNodeFromServer(t);throw e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_getAccessUrls",value:function(){var e=LL.getAccessUrls()||[],t=!0;return this._reportRtcInvokeStatus("es.R.req.cache.urls",e),0===e.length&&(e=GL.ICE_CONFIG_REQUEST_URLS,t=!1,this._reportRtcInvokeStatus("es.R.req.external.urls",e)),0===e.length&&(e=GL.ICE_CONFIG_REQUEST_URLS_INTERNAL,t=!1,this._reportRtcInvokeStatus("es.R.req.internal.urls",e)),{urls:e,needFallback:t}}},{key:"getICEConfigFromServer",value:(t=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=TM(),o={appID:this._ctx.appId,deviceID:LL.getDeviceId(),connectSessionID:i,os:"web",sdkVersion:GL.VERSION,isOversea:GL.OVERSEA,expectedAddr:KL("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC},r&&(o.feedbackInfo=r,"ICE_FAILED"!==(null===(a=r[0])||void 0===a||null===(s=a.feedbackReason)||void 0===s?void 0:s.type)&&delete o.expectedAddr),c=Date.now(),null===(n=this._monitor)||void 0===n||n.report("rtc_get_access",{error_code:0,message:Gg(o),elapse:0,type:"request",host:t.join(","),config_id:i,group_config_id:this._groupConfigId}),u=qg(t).call(t,function(){var e=Ng(Pg().mark((function e(t){var r,n,i,a,s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new AbortController,d._abortControllers.push(n),e.prev=2,e.next=5,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:Gg(o),signal:n.signal});case 5:i=e.sent,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(2),_x(fetch)||null===(a=d._monitor)||void 0===a||a.report("rtc_error",{error_code:MW.Fetch_MODIFY,message:"get access failed, possibly due to modifying the browser's Fetch API."},{origin_error:e.t0}),e.t0;case 12:if(d._abortControllers=Ty(r=d._abortControllers).call(r,(function(e){return e!==n})),200===i.status){e.next=15;break}throw{message:i.statusText,code:i.status};case 15:return e.next=17,i.json();case 17:if(200===(s=e.sent).code){e.next=20;break}throw s;case 20:if(0!==s.nodes.length){e.next=22;break}throw{code:s.code,message:Gg(s)};case 22:return e.abrupt("return",{url:t,result:s});case 23:case"end":return e.stop()}}),e,null,[[2,8]])})));return function(t){return e.apply(this,arguments)}}()),e.abrupt("return",jM(u).then((function(e){var t,r=e.result,n=e.url;return null===(t=d._monitor)||void 0===t||t.report("rtc_get_access",{error_code:200,message:Gg(r),elapse:Date.now()-c,type:"response",host:n,config_id:i,group_config_id:d._groupConfigId}),r})).catch((function(e){var r,n,o,a;throw null===(r=d._monitor)||void 0===r||r.report("rtc_get_access",{error_code:Number((null===(n=e[0])||void 0===n?void 0:n.code)||(null===(o=e[0])||void 0===o?void 0:o.server_code)),message:null===(a=e[0])||void 0===a?void 0:a.message,elapse:Date.now()-c,type:"response",host:t.join(","),config_id:i,group_config_id:d._groupConfigId},{error:Gg(e)}),e})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._abortControllers.forEach((function(e){return e.abort()})),this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer),this._timer&&(window.clearTimeout(this._timer),delete this._timer)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r;null===(r=this._monitor)||void 0===r||r.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:0,stream_id:"",elapse:0,group_config_id:this._groupConfigId})}}]),e}(),FW={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!BB()||void 0},BW=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}(BW||{}),jW=0,HW=function(e){UA(s,e);var t,r,n,i,o,a=ew(s);function s(e,t){var r;return Fh(this,s),ql(aA(r=a.call(this)),"uuid",(jW++).toString()),ql(aA(r),"_peerConnectionId",""),ql(aA(r),"audioTrack4ff",void 0),ql(aA(r),"_pc",void 0),ql(aA(r),"_dc",void 0),ql(aA(r),"_iceNode",void 0),ql(aA(r),"_initSctpEvents",!1),ql(aA(r),"_monitor",void 0),ql(aA(r),"_offerIce",{}),ql(aA(r),"_answerIce",{}),ql(aA(r),"_offerSession",void 0),ql(aA(r),"_answerSession",void 0),ql(aA(r),"_offerMlines",[]),ql(aA(r),"_answerMlines",[]),ql(aA(r),"_connectReject",void 0),ql(aA(r),"_logger",void 0),r._ctx=e,r._groupConnectionId=t,r._monitor=KN(e.id),r._logger=new pM("PeerConnection_".concat(r.uuid),4,e.id),r._pc=new RTCPeerConnection(FW),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",Fg(i=Fg(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(){var e;r._print("onconnectionstatechange",Fg(e="".concat(r._pc.connectionState,". ice -> ")).call(e,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 Vh(s,[{key:"getOriginRTCPeerConnection",value:function(){return this._pc}},{key:"getOriginRTCDataChannel",value:function(){return this._dc}},{key:"getConnectionId",value:function(){return this._peerConnectionId}},{key:"getGroupConnectionId",value:function(){return this._groupConnectionId}},{key:"connect",value:(o=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("connect","invoke. %o",t),this._iceNode=t,(r=this._pc.createDataChannel("signaling",{negotiated:!0,id:100})).binaryType="arraybuffer",this._dc=r,e.next=7,this._genIceInfo(t);case 7:return n=e.sent,i=n.offerIce,o=n.answerIce,this._offerIce=i,this._answerIce=o,this._peerConnectionId=o.iceUfrag||"",tL&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=16,this._pc.createOffer();case 16:if((a=e.sent).sdp){e.next=19;break}throw new bC(fC.NOT_SUPPORTED,"create offer sdp failed.");case 19:if(s=ZB.parse(a.sdp),c=gy(s.media,1),u=c[0],this._offerIce.fingerprint=s.fingerprint||u.fingerprint,!tL){e.next=35;break}return s.media=qg(d=s.media).call(d,(function(e){var t,r,n,i,o=Ql(Ql({},e),p._offerIce);return"video"===o.type&&(GB?(o.ext=null===(t=o.ext)||void 0===t?void 0:Ty(t).call(t,(function(e){var t;return-1===yI(t=e.uri).call(t,"abs-send-time")})),o.rtcpFb=null===(r=o.rtcpFb)||void 0===r?void 0:Ty(r).call(r,(function(e){return"goog-remb"!==e.type}))):(o.rtcpFb=null===(n=o.rtcpFb)||void 0===n?void 0:Ty(n).call(n,(function(e){return"transport-cc"!==e.type})),o.ext=null===(i=o.ext)||void 0===i?void 0:Ty(i).call(i,(function(e){var t;return-1===yI(t=e.uri).call(t,"transport")})))),o})),zB&&Ij(s),(h=Ql({},s)).fingerprint=this._answerIce.fingerprint,h.media=qg(l=h.media).call(l,(function(e){return delete(e=Ql(Ql({},e),p._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})),zB&&Ij(h),e.next=31,this.setLocalDescription(ZB.write(s));case 31:return e.next=33,this.setRemoteDescription(ZB.write(h));case 33:e.next=43;break;case 35:delete s.media,this._offerSession=Ql({},s),this._answerSession=Ql({},s),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),this._offerMlines=[Ql(Ql(Ql({},u),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[Ql(Ql(Ql({},u),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription();case 43:return e.next=45,new jI((function(e,t){p._connectReject=t,r.onopen=function(){p._print("connect","dataChannel open"),p._reportRtcInvokeStatus("es.dc.open",""),e(""),delete p._connectReject},r.onerror=function(e){var t,r,n,i;p._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"}),p._reportRtcInvokeStatus("es.dc.error",""),null===(n=p._connectReject)||void 0===n||n.call(p,{message:"dc.onerror, ".concat(null===(i=e.error)||void 0===i?void 0:i.errorDetail),code:0}),p.emit("disconnect","dc onerror"),delete p._connectReject},r.onclose=function(){var e;p._reportRtcInvokeStatus("es.dc.close",""),null===(e=p._connectReject)||void 0===e||e.call(p,{message:"dc.onclose",code:1}),p.emit("disconnect","dc onclose"),delete p._connectReject},p._pc.addEventListener("connectionstatechange",(function(){var e,t;"failed"!==p._pc.iceConnectionState&&"closed"!==p._pc.iceConnectionState&&"failed"!==p._pc.connectionState||(null===(e=p._connectReject)||void 0===e||e.call(p,{message:Fg(t="pc.connectionstatechange -> ".concat(p._pc.connectionState,", ice -> ")).call(t,p._pc.iceConnectionState),code:2}),delete p._connectReject)})),setTimeout((function(){var e;null===(e=p._connectReject)||void 0===e||e.call(p,{code:4,message:"connect timeout"}),delete p._connectReject}),8e3)}));case 45:return this._print("connect","dataChannel establish success"),e.abrupt("return",r);case 47:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setDescription",value:(i=Ng(Pg().mark((function e(t){var r,n;return Pg().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&&e.mid&&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=IM(),t&&this._report("rtc_begin_create_offer",{direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,pc_session_id:this._peerConnectionId,vendor_mode:0}),e.next=10,this._pc.createOffer();case 10:return t&&this._report("rtc_create_offer",{error_code:0,direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,elapse:IM()-n}),e.next=13,this.setLocalDescription(ZB.write(this._offerSession),t);case 13:return e.next=15,this.setRemoteDescription(ZB.write(this._answerSession),t);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setLocalDescription",value:(n=Ng(Pg().mark((function e(t,r){var n,i,o,a=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=IM(),e.prev=1,e.next=4,this._pc.setLocalDescription(new RTCSessionDescription({type:"offer",sdp:t}));case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:IM()-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:IM()-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=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=IM(),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:IM()-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:IM()-n},{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"disconnect",value:function(){var e,t;null===(e=this._connectReject)||void 0===e||e.call(this,{code:3,message:"invoke destroy()"}),delete this._connectReject,this._pc.close(),null===(t=this._dc)||void 0===t||t.close(),this._pc.ontrack=null}},{key:"destroy",value:function(){this._print("destroy",this._peerConnectionId),MA(NA(s.prototype),"removeAllListeners",this).call(this),this.disconnect()}},{key:"_genIceInfo",value:(t=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().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,yj(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,Fg(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,Ql(Ql({},t),{},{connection_id:this._peerConnectionId,group_connection_id:this._groupConnectionId}),Ql(Ql({},r),{},{tcp_only:null===(i=this._iceNode)||void 0===i?void 0:i.iceConfig.tcpOnly,ms_addr:Gg((null===(o=this._iceNode)||void 0===o?void 0:qg(a=o.publicIPs).call(a,(function(e){return{ip:e.ip,tcp:e.tcpPorts,udp:e.udpPorts}})))||[])}))}},{key:"_reportRtcInvokeStatus",value:function(e,t){this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:0,stream_id:"",elapse:0})}}],[{key:"checkSupported",value:function(){if(!RTCPeerConnection)throw new bC(fC.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 bC(fC.NOT_SUPPORTED,"missing peer.".concat(e," API."))}))}}]),s}(kU),GW=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(GW||{}),zW=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}(zW||{}),KW=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}(KW||{}),WW=(ql(vW={},0,[0,"success"]),ql(vW,1,[fC.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),ql(vW,2,[fC.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),ql(vW,3,[fC.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),ql(vW,4,[fC.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),ql(vW,5,[fC.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),ql(vW,17,[fC.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),ql(vW,18,[fC.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),ql(vW,100,[fC.USER_MESSAGE_NOT_JOIN,"not join room"]),ql(vW,105,[fC.USER_MESSAGE_NOT_LOGIN,"not login."]),ql(vW,106,[fC.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),ql(vW,1e3,[fC.USER_MESSAGE_UNKNOWN,"unknown."]),vW),XW=["msg"],YW=[],qW=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}(qW||{}),JW=function(e){UA(a,e);var t,r,n,i,o=ew(a);function a(e,t){var r;return Fh(this,a),ql(aA(r=o.call(this)),"_singlingCache",new cT),ql(aA(r),"_p2pCache",new cT),ql(aA(r),"_rttIds",{}),ql(aA(r),"_p2pMessageId",1),ql(aA(r),"_clearDataChannelListener",void 0),ql(aA(r),"_monitor",void 0),ql(aA(r),"logger",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=KN(e),r.logger=new pM("DataChannelSignaling",3,e),r}return Vh(a,[{key:"destroy",value:function(){var e=this;this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.forEach((function(t,r){t.error(new bC(fC.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:Gg(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new jI((function(n,a){var s,c=i._genHeader(r);c.id=CM();var u=c.id.join("-"),d="customMessage"===e;d&&MN.samplingOne2ManyMsg(i.id,Number(c.id.join("")),t);var l=setTimeout((function(){i._singlingCache.delete(u),a(new bC(fC.TIME_OUT,"".concat(e," message time out"))),d&&MN.updateOne2ManyMsgAck(i.id,t,999)}),o);i._singlingCache.set(u,{signalingType:e,success:function(e){clearTimeout(l),n(e),d&&MN.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(l),a(e),d&&MN.updateOne2ManyMsgAck(i.id,t,e.code)}}),i.logger.info("Signal",Fg(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=Ng(Pg().mark((function e(t,r){var n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=yN(t,XW),o=n instanceof ArrayBuffer,e.t0=this,e.t1=MN,e.t2=this.id,e.t3=Ql,e.t4=Ql({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:GW.SEND,type:zW.P2P,err:KW.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,wM.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 OM(e.msg)?this._rttIds[e.id]=e.id:e.dir===GW.SEND&&this.logger.info("_sendP2PMessage [DC Signaling p2p >>]",Gg(e)),new jI((function(n,i){var o=t._genHeader(Ql(Ql({needAck:!0,functionType:1},r),{},{id:CM()}));if(e.dir===GW.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new bC(fC.USER_MESSAGE_TIMEOUT,"P2P message timeout")),MN.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),MN.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),MN.updateP2PMsgAck(t.id,e,r.err);var o=gy(WW[r.err]||[fC.USER_MESSAGE_UNKNOWN,Fg(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===fC.NOT_CONNECTED_YET&&(s.code=fC.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new bC(fC.NOT_CONNECTED_YET,"DataChannel not open");var i=KL("SIGNAL_COMPRESSION")||t.zip,o=t.version+(Number(i)<<4)+(Number(t.encrypt)<<5),a=Number(t.needAck)+(Number(t.direction)<<1)+(Number(t.functionType)<<2)+(Number(t.binary)<<6),s=wM.str2ab(Gg([e,r])),c=AM(Uint8Array,Fg(n=[o,a]).call(n,tR(t.id||[])),i||t.zip?pN.deflate(new Uint8Array(s)):new Uint8Array(s));try{this._dataChannel.send(c.buffer)}catch(d){var u;throw null===(u=this._monitor)||void 0===u||u.report("rtc_error",{message:"datachannel send error: ".concat(d.message),error_code:MW.DC_SEND_ERROR}),d}"p2p"===e?MN.updateP2PMsgReq(this.id,r,c.buffer.byteLength):"customMessage"===e&&MN.updateOne2ManyMsgReq(this.id,r,c.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=KC(sI(t).call(t,2,r))}return{header:o,data:sI(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:qg(n=e.split("-")).call(n,(function(e){return Number(e)}))});Xy(YW).call(YW,t)||this.logger.info("Signal",Fg(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d;return Pg().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 pN.Inflate).push(o,!0),o=s.result),c=wM.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=Ng(Pg().mark((function e(t,r,n,i,o){var a,s,c,u,d;return Pg().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],Xy(YW).call(YW,u)||this.logger.info("Signal","<<<<<< ".concat(u),r,s),this._feedbackSignaling(s,u,u===bW.ON_CUSTOM_MESSAGE?Ql(Ql({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,wM.b64str2ab(r.message,this._monitor);case 13:r.message=e.sent;case 14:d=Date.now(),this.emit(u,Ql({},r)),u===bW.ON_CUSTOM_MESSAGE&&MN.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=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f;return Pg().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)===GW.FEEDBACK||OM(null===(a=t)||void 0===a?void 0:a.msg)?delete this._rttIds[c]:this.logger.info("Signal","<<<<<< p2p response",t),e.t0=t.dir,e.next=e.t0===GW.SEND?6:e.t0===GW.FEEDBACK?46:48;break;case 6:if(u=Date.now(),OM(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,_=d.from,f=""===p?l?bW.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:bW.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:l?bW.USER_BINARY_MESSAGE_RECEIVED:bW.USER_MESSAGE_RECEIVED,v){e.next=27;break}if(e.t1=this,e.t2=bW.ON_CUSTOM_MESSAGE,e.t3=_,e.t4=l,!l){e.next=21;break}return e.next=18,wM.b64str2ab(h,this._monitor);case 18:e.t5=e.sent,e.next=22;break;case 21:e.t5=h;case 22:e.t6=e.t5,e.t7={clientId:e.t3,binary:e.t4,message:e.t6},e.t1.emit.call(e.t1,e.t2,e.t7),e.next=43;break;case 27:if(e.t8=this,e.t9=f,e.t10=Ql,e.t11=Ql({},t),e.t12={},!l){e.next=38;break}return e.next=35,wM.b64str2ab(h,this._monitor);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(Ql(Ql({},t),{},{dir:GW.FEEDBACK,msg:""})),MN.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=gy(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(_){}break;case"RTT":try{var p=JSON.parse(l);p.length&&this.emit(d,p[0])}catch(_){}break;case"SSC":try{var v=JSON.parse(l);v.length&&this.emit(d,v[0])}catch(_){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(t){e.logger.warn("_handleHandler","dataChannel close",t)},r=function(t){e.logger.error("_handleHandler","dataChannel error",t)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){return Ql({version:2,zip:!1,encrypt:!1,needAck:!0,direction:0,functionType:0,binary:!1},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{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),this.logger.info("Signal",Fg(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===KW.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(yU.EventEmitter),QW=function(e){UA(o,e);var t,r,n,i=ew(o);function o(e){var t;return Fh(this,o),ql(aA(t=i.call(this)),"id",void 0),ql(aA(t),"_monitor",void 0),ql(aA(t),"logger",void 0),ql(aA(t),"_getAccessManager",void 0),ql(aA(t),"_connectionPool",new cT),ql(aA(t),"_curConnection",void 0),ql(aA(t),"_hasReportBrowerWarning",!1),ql(aA(t),"_reconnectTimer",void 0),ql(aA(t),"_connecting",!1),ql(aA(t),"_isFirstTimeConnected",!0),ql(aA(t),"_feedbackNodes",[]),ql(aA(t),"_preIceStartTime",-1),ql(aA(t),"_tcpOnlyTimer",void 0),ql(aA(t),"_destroyed",!1),t._ctx=e,t.id=e.id,t._monitor=KN(t.id),t.logger=new pM("ConnectionManager",3,t.id),t.logger.info("constructor","invoke"),t._getAccessManager=new VW(e),t}return Vh(o,[{key:"connect",value:function(){var e=this;this.logger.info("connect","invoke");try{HW.checkSupported()}catch(t){this.safeEmit("disconnected",t)}this._connecting||(this._onConnectStart("init"),jI.resolve().then((function(){return e.emit("__onGetIceConfigHook")})),this._getAccess())}},{key:"reconnectByNodeChange",value:(n=Ng(Pg().mark((function e(t){var r,n,i,o,a,s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.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:Gg(t),reason:Gg(a)}),LL.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=Ng(Pg().mark((function e(t){var r,n=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.logger.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(){this.logger.info("destroy","invoke"),this._destroyed=!0,this.safeEmit("disconnected",new bC(fC.OPERATION_CANCEL,"destroy")),MA(NA(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){this.logger.info("_startIceConnect","invoke");var n=px();this._preIceStartTime=IM();var i=this._ctx.joinRoomConfig.useTcpJoin,o=this._ctx.joinRoomConfig.useTcpJoinDelay,a=function(){var e=Ng(Pg().mark((function e(i){var o,a,s,c;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r&&((i=dW(i)).iceConfig.tcpOnly=!0),o={node:i},e.prev=2,a=new HW(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 JW(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&&(this.logger.info("_startIceConnect","tcp-only will try after ".concat(o,"ms")),this._tcpOnlyTimer=window.setTimeout((function(){t.emit("connectWidthTcp"),e.forEach((function(e){(e=dW(e)).iceConfig.tcpOnly=!0,a(e)})),delete t._tcpOnlyTimer}),o))}}},{key:"_onConnectSuccess",value:function(e){var t,r,n,i=this;(this.logger.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),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;(this.logger.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!==BW.DESTROY&&t.code!==fC.OPERATION_CANCEL)&&(this._curConnection?this._feedbackBySignaling(e.node):this._feedbackNodes.push(e.node),this.logger.info("connect","remove cache node"),LL.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||(this.logger.error("connect","establish peerConnection failed"),this._checkBrowserUA(),IM()-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=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._onConnectStart("ice failed"),this.logger.warn("reconnect","because of ice failed"),this._getAccess(qg(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:MW.BLACK_BROWSER,message:"failed to establish data-channel, and the current browser is on the browser blacklist."}))}},{key:"_onConnectStart",value:function(e){var t;this.logger.info("_onConnectStart","invoke, reason: ".concat(e)),this._connecting=!0,this.safeEmit(this._isFirstTimeConnected?"connecting":"reconnecting");var r,n=px();(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;(this.logger.info("_onConnectEnded","invoke"),this._connecting=!1,this._isFirstTimeConnected)||(null===(t=this._monitor)||void 0===t||t.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"}));this._isFirstTimeConnected=!1,this.safeEmit("connected",e),e.node.iceConfig.tcpOnly&&(this.logger.info("_onConnectEnded","use tcp only"),JN(this._ctx.id,"connected_with_tcp_only",Gg(e.node))),this._tcpOnlyTimer&&(window.clearTimeout(this._tcpOnlyTimer),delete this._tcpOnlyTimer),this._clearConnectionPool()}},{key:"_addConnectionHandler",value:function(e){var t=this;e.on("disconnect",(function(e){t._closeCurrentConnection(),t._clearReconnectTimer(),navigator.onLine?t.reconnect(e):t._reconnectTimer=window.setTimeout((function(){return t.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}(kU),ZW=uT,$W=HI,eX=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&&ZW(t,r,o),o},tX=6e4,rX=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(rX||{}),nX=function(e,t,r){r.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)},iX=function(e){UA(A,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R=ew(A);function A(e){var t;return Fh(this,A),ql(aA(t=R.call(this)),"id",void 0),ql(aA(t),"publicStream",!1),ql(aA(t),"_token",void 0),ql(aA(t),"_roomId",void 0),ql(aA(t),"_roomAttributes",void 0),ql(aA(t),"_vendorConfig",{enableMultiVendor:!1,vendorCode:0}),ql(aA(t),"_clientId",void 0),ql(aA(t),"_businessId",void 0),ql(aA(t),"_userInfo",void 0),ql(aA(t),"_authorization",void 0),ql(aA(t),"_sessionId",""),ql(aA(t),"_liveControlMessage",void 0),ql(aA(t),"isReconnecting",!1),ql(aA(t),"_ontrackCallbackMap",new cT),ql(aA(t),"_subResolves",{}),ql(aA(t),"supportConcurrent",!1),ql(aA(t),"_handler",void 0),ql(aA(t),"_pubSubLock",void 0),ql(aA(t),"_joinLeaveLock",void 0),ql(aA(t),"_state",void 0),ql(aA(t),"_dataChannelSignal",void 0),ql(aA(t),"_joinRoomStartTs",void 0),ql(aA(t),"_monitor",void 0),ql(aA(t),"logger",void 0),ql(aA(t),"_roomProfile",kh.communication),ql(aA(t),"_context",void 0),ql(aA(t),"_connectionManager",void 0),ql(aA(t),"_joinRoom5xxTimer",void 0),ql(aA(t),"_joinResolve",void 0),ql(aA(t),"_joinReject",void 0),ql(aA(t),"_pubSubBackOff",{}),t.id=e.id,t._monitor=KN(t.id),t.logger=new pM("MediaServerClient",2,t.id),t.logger.info("constructor","invoke"),t._pubSubLock=new wW("pubSubLock"),t._joinLeaveLock=new wW("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._pubSubBackOff={},t._context=e,t._connectionManager=new QW(e),t._addConnectHandler(),t}return Vh(A,[{key:"_addSignalEventHandler",value:function(){var e,t,r=this;[bW.ON_ADD_STREAM,bW.ON_ADD_STREAM_LIST,bW.ON_REMOVE_STREAM,bW.ON_REMOVE_STREAM_LIST,bW.USER_CONNECTION,bW.USER_CONNECTION_LIST,bW.USER_DISCONNECTION,bW.USER_DISCONNECTION_LIST,bW.ON_UPDATE_STREAM_ATTRIBUTES,bW.ON_UPDATE_ROOM_ATTRIBUTES,bW.ON_PUSH_TRACK,bW.ON_REMOVE_TRACK,bW.ON_CUSTOM_MESSAGE,bW.USER_MESSAGE_RECEIVED,bW.USER_BINARY_MESSAGE_RECEIVED,bW.POST_PROCESSING_MESSAGE,bW.ON_USER_TOKEN_WILL_EXPIRE,bW.STREAM_CONTROL_MESSAGE,bW.ON_UPDATE_USER_ATTRIBUTES,bW.ON_SPEAKER_CHANGE,kW.RSCP,kW.RTT,bW.ON_STREAM_FAILED,bW.ON_NOTIFY_RECONNECT,kW.SSC,bW.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(bW.NODE_CHANGE,(function(e){r._connectionManager.reconnectByNodeChange(e)})),null===(t=this._dataChannelSignal)||void 0===t||t.on(bW.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(EW.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 jI((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"join",value:(I=Ng(Pg().mark((function e(t){var r,n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 jI((function(e,t){n._joinResolve=e,n._joinReject=t,(n._handler?jI.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 I.apply(this,arguments)})},{key:"_callJoinRoom",value:(T=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T=this,I=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=I.length>0&&void 0!==I[0]&&I[0],this.logger.info("_callJoinRoom","invoke"),e.t0=wM.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,CB();case 12:if(e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=GL.VERSION,e.t9=LL.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=PW[this._roomProfile]?"".concat(PW[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},i={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17},this._context.joinRoomParams)for(o=0,a=NS(this._context.joinRoomParams);o<a.length;o++)s=gy(a[o],2),c=s[0],u=s[1],i.params[c]=u;return KL("SIGNAL_CROP_JOINROOM")&&null!==(r=i.sdpInfo)&&void 0!==r&&r.sdp&&(i.sdpInfo.sdp=Tj(i.sdpInfo.sdp)),jI.resolve().then((function(){return T.emit("onSendingJoinMessageHook")})),e.prev=29,l=n?"reconnected":"joinRoom",e.next=33,this._joinRoomWithRetry(l,i);case 33:h=e.sent,this.logger.success("join","send join message success"),p=h.config||{},v=p.engine_WEB,this.connectionState="connected",this._authorization=i.Authorization,LL.setEngineWebConfig(this._context.appId,this._roomId,v),this._context&&(this._context.serverConfig={videoCodec:(null==v?void 0:v.video_codec)||"H264",audioRed:!(null==v||!v.pub_audio_red),muteReplaceUnsub:!(null===(_=h.config)||void 0===_||!_.mute_replace_unsub),simulcastOnDemand:!(!1===(null===(f=h.config)||void 0===f||null===(m=f.engine_VPM)||void 0===m||null===(g=m.ondemand)||void 0===g?void 0:g.enable)),forceUniHandler:1===(null==h||null===(y=h.config)||void 0===y||null===(S=y.vendor_param)||void 0===S?void 0:S.vendor_stream_sub_mode)},"boolean"==typeof(null==v?void 0:v.av_sync)&&(this._context.avSync=v.av_sync)),h.vendorConfig&&(this._vendorConfig=h.vendorConfig),HH.setAudioStallConfig(v),null!=h&&null!==(d=h.relayMessage)&&void 0!==d&&d.sdp&&(null===(b=this._handler)||void 0===b||b.createAVMlineAnswerTpl(h.relayMessage.sdp)),this.emit("joinSuccess",{joinRes:h,reconnect:n}),this._joinRoomSuccess(h),e.next=51;break;case 47:e.prev=47,e.t18=e.catch(29),k={461:fC.ROOM_FORBIDDEN,462:fC.USER_FORBIDDEN},(null===e.t18||void 0===e.t18?void 0:e.t18.code)>=700&&(null===e.t18||void 0===e.t18?void 0:e.t18.code)<800?this._joinRoomFailed("token_error",fC.INVALID_TOKEN):k[null===e.t18||void 0===e.t18?void 0:e.t18.code]?this._joinRoomFailed((null===e.t18||void 0===e.t18?void 0:e.t18.message)||k[null===e.t18||void 0===e.t18?void 0:e.t18.code],k[null===e.t18||void 0===e.t18?void 0:e.t18.code]):(null===e.t18||void 0===e.t18?void 0:e.t18.code)===fC.TIME_OUT&&this._context.joinRoomConfig.useTcpAfterJoinTimeout?(E="joinRoom timeout, retry with tcp only",this.logger.error("join",E),this.safeEmit(CW.ON_REJOIN_WITH_TCP),this._connectionManager.reconnect(E,!0)):e.t18.code===fC.OPERATION_CANCEL&&"connecting"===this.connectionState||this._joinRoomFailed((null===e.t18||void 0===e.t18?void 0:e.t18.message)||"signaling_error");case 51:case"end":return e.stop()}}),e,this,[[29,47]])}))),function(){return T.apply(this,arguments)})},{key:"_getVendorPubSdpInfo",value:(E=Ng(Pg().mark((function e(t){var r,n,i,o=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new HW(this._context,""),t.vendorHandler=new NW(this._context,r),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),e.next=5,t.vendorHandler.publish(t);case 5:return n=e.sent,(i=t.vendorHandler).on("ice_state",(function(e){o.emit(EW.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:dh.CONNECTION_STATE_CONNECTING,connected:dh.CONNECTION_STATE_CONNECTED,disconnected:dh.CONNECTION_STATE_RECONNECTING}[e],userId:o._clientId})})),i.once("disconnect",Ng(Pg().mark((function e(){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i.removeAllListeners(),"connected"===(null===(r=o._handler)||void 0===r||null===(n=r.pc)||void 0===n?void 0:n.iceConnectionState)){e.next=4;break}return o.logger.info("vendor ice failed",t.streamId),e.abrupt("return");case 4:return e.next=6,o.unpublish(t);case 6:return e.next=8,o.publish(t);case 8:t.vendorHandler&&t.statsReport.setVar(t.vendorHandler);case 9:case"end":return e.stop()}}),e)})))),e.abrupt("return",[i,n]);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"publish",value:(k=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._publish(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"_publish",value:(b=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M,L,U,V=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publish()","localStream: %o",t),g=t.videoTrack,y=t.audioTrack,S=IM(),b="",k="",E=this._handler,"H264"!==(null===(r=this._context)||void 0===r||null===(n=r.serverConfig)||void 0===n?void 0:n.videoCodec)){e.next=17;break}return e.next=10,LB();case 10:if(e.sent){e.next=17;break}if("VP8"!==KL("FALLBACK_ENCODE_CODEC")){e.next=16;break}this._context.serverConfig.videoCodec="VP8",e.next=17;break;case 16:throw new bC(fC.PUBLISH_FAILED,"h264 is not supported");case 17:if(!this._vendorConfig.enableMultiVendor){e.next=26;break}return e.next=20,this._getVendorPubSdpInfo(t);case 20:I=e.sent,R=gy(I,2),E=R[0],T=R[1],e.next=29;break;case 26:return e.next=28,this._handler.publish(t);case 28:T=e.sent;case 29:return null===(i=t.observer)||void 0===i||i.setHandler(E),this.emit("_test_pub_sdpInfo_",T),b=T.audioMid,k=T.videoMid,t.pubAttributes={localaudio:!!y,localvideo:!!g,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(g instanceof eH),extaudio:!!(y instanceof tH),videoDescriptions:T.videoDescriptions},A={attributes:Ql({},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:b,videoMid:k,sdpInfo:{msid:t.stream.id,type:T.type,sdp:T.partialSdp,semantics:T.semantics},peerConnectionMode:null===(o=T)||void 0===o?void 0:o.peerConnectionMode,supportMultiVendor:!0},(w=!this._vendorConfig.enableMultiVendor&&t.enableSimulcast&&(null===(a=this._context)||void 0===a||null===(s=a.serverConfig)||void 0===s?void 0:s.simulcastOnDemand)&&(null===(c=T.subVideoDescriptions)||void 0===c?void 0:c.length))&&(A.attributes.subVideoDescriptions=T.subVideoDescriptions),null!==(u=T)&&void 0!==u&&u.peerConnectionId&&(A.peerConnectionId=T.peerConnectionId),e.prev=38,this.emit("_test_pub_body_",A),e.next=42,null===(x=this._dataChannelSignal)||void 0===x?void 0:x.sendSignaling("publish",A);case 42:C=e.sent,e.next=67;break;case 45:return e.prev=45,e.t0=e.catch(38),e.t0 instanceof Error?null===(P=this._monitor)||void 0===P||P.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:S,message:Fg(D="".concat(e.t0.name,": ")).call(D,e.t0.message)}):e.t0 instanceof bC&&(null===(N=this._monitor)||void 0===N||N.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:S,message:Fg(M="".concat(e.t0.code,": ")).call(M,e.t0.message)})),e.next=50,null===(O=E)||void 0===O?void 0:O.rollback({msid:t.stream.id,stream:t,audioMid:b,videoMid:k});case 50:if(!(e.t0.code>=500&&e.t0.code<600)){e.next=66;break}if(this.emit("_test_pub_5xx_"),!((L=this.getPubSubBackOff(t.id)).retryDuration<6e4)){e.next=64;break}return this.logger.info("pubRetry",t.id,L.retryDuration),e.next=57,new jI((function(e){return setTimeout(e,L.interval)}));case 57:return L.retryDuration+=L.interval,L.interval=L.interval>4e3?8e3:2*L.interval,t.resetStream(),this.emit(CW.PUB_RETRY,{screen:t.isScreen}),e.abrupt("return",this._publish(t));case 64:this.logger.info("pubRetry","end"),delete this._pubSubBackOff[t.id];case 66:throw e.t0;case 67:if(null===(d=this._monitor)||void 0===d||d.report("rtc_recv_answer",{error_code:0,answer_type:null===(l=C)||void 0===l?void 0:l.relayMessage.type,sequence_id:(null===(h=C)||void 0===h||null===(p=h.relayMessage)||void 0===p?void 0:p.sequenceId)||0,message:null===(v=C)||void 0===v||null===(_=v.relayMessage)||void 0===_?void 0:_.sdp,direction:"up",stream_id:"",stream_user_id:"",pc_session_id:(null===(f=E)||void 0===f?void 0:f.peerConnectionId)||""}),U=new jI((function(e,r){var n,i,o,a,s,c,u,d;null===(n=E)||void 0===n||n.handleAck({action:ZH.publish,streamId:C.streamId,audioMid:b,videoMid:k,audioTransceiverInit:null===(i=T)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=T)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:{sdp:null===(a=C)||void 0===a||null===(s=a.relayMessage)||void 0===s?void 0:s.sdp,sequenceId:null===(c=C)||void 0===c||null===(u=c.relayMessage)||void 0===u?void 0:u.sequenceId},sdp:null===(d=T)||void 0===d?void 0:d.sdp,stream:t,onSuccess:function(){V.logger.info("publish()","publish success"),e(0)},onFail:function(e){V.logger.info("publish()","publish fail"),r(e)}})})),e.t1=!tL,!e.t1){e.next=73;break}return e.next=73,U;case 73:this.emit("___afterHandleAckInPub"),w&&this.emit(kW.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}],!0),t.streamId=C.streamId,t.videoMid=k,t.audioMid=b,t.subVideoDescriptions=T.subVideoDescriptions,null===(m=this._monitor)||void 0===m||m.report("rtc_publish_stat",{result:"success",is_screen:"0",start:S,message:"unknown"});case 80:case"end":return e.stop()}}),e,this,[[38,45]])}))),function(e){return b.apply(this,arguments)})},{key:"updatePubTrack",value:(S=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C,x;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updatePubTrack()","localStream: %o",t),n=t.videoTrack,i=t.audioTrack,o=t.pubAudio,a=t.pubVideo,s=t.vendorHandler||this.handler,c=null==i?void 0:i.preprocessingTrack,u=null==n?void 0:n.preprocessingTrack,!a||!u){e.next=11;break}return e.next=8,null===(d=t.videoTransceiver)||void 0===d?void 0:d.sender.replaceTrack(u);case 8:this.updateVideoDescriptions(t),e.next=13;break;case 11:return e.next=13,null===(l=t.videoTransceiver)||void 0===l?void 0:l.sender.replaceTrack(null);case 13:if(null==s||s.updateMaxBitrate(t),!o||!c){e.next=21;break}return p=i.mixType,(v=i.mixedAudioTrack)&&p!==Dh.PLAYOUT&&c.enabled&&(c=v),e.next=19,null===(h=t.audioTransceiver)||void 0===h?void 0:h.sender.replaceTrack(c);case 19:e.next=24;break;case 21:return e.next=23,null===(_=t.audioTransceiver)||void 0===_?void 0:_.sender.replaceTrack(null);case 23:JN(this.id,"MediaClient.updatePubTrack(audio)","null");case 24:this.emit("___onAfterReplaceTrack");try{JN(this.id,"MediaClient.updatePubTrack",Gg({audioStreamTrack:fx(c),videoStreamTrack:fx(u)}))}catch(BZ){}for(m={},g=0,y=NS(f={localaudio:!!i,localvideo:!!n,videostream:a,audiostream:o,extvideo:!!(n instanceof eH),extaudio:!!(i instanceof tH)});g<y.length;g++)S=gy(y[g],2),b=S[0],(k=S[1])!==EU(t.pubAttributes,b)&&PU(m,b,k);if(MS(m).length){e.next=31;break}return e.abrupt("return");case 31:return t.observer&&(E=t.observer,T=m.audiostream,I=m.videostream,R=m.localaudio,A=m.localvideo,w=m.extaudio,C=m.extvideo,void 0!==A?void 0!==C?E.setPushVideo(C):E.setEnableVideo(A):void 0!==I&&E.setUnmuteVideo(I),void 0!==R?void 0!==w?E.setPushAudio(w):E.setEnableAudio(R):void 0!==T&&E.setUnmuteAudio(T)),t.pubAttributes=Ql(Ql({},t.pubAttributes),f),x={roomId:this._roomId,streamId:t.streamId,attributes:m},e.next=36,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateStreamAttributes",x);case 36:if(this.emit("___onAfterUpdateSignaling"),!tL){e.next=40;break}return e.next=40,null==s?void 0:s.setCurrentDescription();case 40:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"updateToken",value:(y=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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:e.next=13;break;case 10:throw e.prev=10,e.t0=e.catch(5),new bC(fC.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 13:case"end":return e.stop()}}),e,this,[[5,10]])}))),function(e){return y.apply(this,arguments)})},{key:"updateVideoDescriptions",value:(g=Ng(Pg().mark((function e(t){var r,n,i,o,a;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1===t.pubAttributes.videoDescriptions.length){e.next=2;break}return e.abrupt("return");case 2:if(null!=(o=null===(r=t.videoTrack)||void 0===r||null===(n=r.preprocessingTrack)||void 0===n?void 0:n.getSettings())&&o.width&&null!=o&&o.height&&null!=o&&o.frameRate){e.next=5;break}return e.abrupt("return");case 5:if(a=t.pubAttributes.videoDescriptions[0],o.width!==a.width||o.height!==a.height||o.frameRate!==a.framerate){e.next=8;break}return e.abrupt("return");case 8:a.width=o.width,a.height=o.height,a.framerate=o.frameRate,a.maxkbps=t.videoEncodeConfig[0].maxKbps||a.maxkbps,null===(i=this._dataChannelSignal)||void 0===i||i.sendSignaling("updateStreamAttributes",{roomId:this._roomId,streamId:t.streamId,attributes:{videoDescriptions:[a]}});case 13:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"unpublish",value:(m=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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:ZH.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:"_getVendorSubSdpInfo",value:(f=Ng(Pg().mark((function e(t,r){var n,i,o,a=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new HW(this._context,""),t.vendorHandler=new NW(this._context,n),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),(i=t.vendorHandler).on("ontrack",r),e.next=7,t.vendorHandler.subscribe(t);case 7:return o=e.sent,i.on("ice_state",(function(e){a.emit(EW.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:dh.CONNECTION_STATE_CONNECTING,connected:dh.CONNECTION_STATE_CONNECTED,disconnected:dh.CONNECTION_STATE_RECONNECTING}[e],userId:t.userId})})),i.once("disconnect",Ng(Pg().mark((function e(){var r,n,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==i||i.removeAllListeners(),"connected"===(null===(r=a._handler)||void 0===r||null===(n=r.pc)||void 0===n?void 0:n.iceConnectionState)){e.next=4;break}return a.logger.info("vendor ice failed",t.streamId),e.abrupt("return");case 4:return o=t.subMediaType,e.next=7,a.unsubscribe(t);case 7:return e.next=9,a.subscribe(t,o);case 9:t.vendorHandler&&t.statsReport.setVar(t.vendorHandler),a.emit(CW.RESUBSCRIBE,{stream:t});case 11:case"end":return e.stop()}}),e)})))),e.abrupt("return",[i,o]);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"subscribe",value:(_=Ng(Pg().mark((function e(t,r,n){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._subscribe(t,r,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return _.apply(this,arguments)})},{key:"_subscribe",value:(v=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M,L,U,V,F,B,j,H,G,z,K,W,X,Y,q,J,Q,Z,$,ee,te,re,ne,ie,oe=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("subscribe()","mediaType: %o",r),nX("subscribe()",t,this.logger),t.streamState=XH.SUB_ING,R=!1,A=!1,GM(r)&&(A=!0),zM(r)&&(R=!0),R||!this.multiChatMode()){e.next=9;break}return t.streamState=XH.INIT,e.abrupt("return");case 9:if(w=IM(),C=t.subVideo,x=[],this._subResolves[t.streamId]||(this._subResolves[t.streamId]=[]),x.push(new jI((function(e,r){oe._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new bC(fC.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),tX);t.on("ontrack",(function r(i){"video"===i.mediaType&&(oe.logger.info("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),this.multiChatMode()||x.push(new jI((function(e,r){oe._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new bC(fC.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),tX);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(oe.logger.info("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),O=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",O),this._ontrackCallbackMap.set(t,O),P=this._handler,null!==(o=this._context.serverConfig)&&void 0!==o&&o.forceUniHandler||!t.enableVendorMode){e.next=28;break}return e.next=22,this._getVendorSubSdpInfo(t,O);case 22:N=e.sent,M=gy(N,2),P=M[0],D=M[1],e.next=31;break;case 28:return e.next=30,this._handler.subscribe(t,{multiChatMode:this.multiChatMode()});case 30:D=e.sent;case 31:if(null===(a=t.observer)||void 0===a||a.setHandler(P),U=(L=D).audioMid,V=L.videoMid,t.subVideo=R,F={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},B={audio:!this.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:V,audioMid:U,sdpInfo:{sdp:null===(s=D)||void 0===s?void 0:s.partialSdp,semantics:null===(c=D)||void 0===c?void 0:c.semantics,type:null===(u=D)||void 0===u?void 0:u.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!this.multiChatMode()||A,video:R},qualityLayer:F},extra:{enableSendRTT:!0},peerConnectionMode:null===(d=D)||void 0===d?void 0:d.peerConnectionMode,supportMultiVendor:!0},null!==(l=D)&&void 0!==l&&l.peerConnectionId&&(B.peerConnectionId=D.peerConnectionId),j=this._context||{},H=j.subscribeFallbackOption,G=j.userPriority,"number"==typeof H&&(B.config.fallbackOption=H),G.has(t.userId)&&(B.config.priority=G.get(t.userId)),null!==(h=D)&&void 0!==h&&h.allSsrc&&(B.extra.subscribeSSRC=D.allSsrc),null===(p=D)||void 0===p||!p.signalingAck){e.next=44;break}return e.next=44,new jI((function(e,r){var n,i,o,a;null===(n=P)||void 0===n||n.handleAck({action:ZH.subscribe,streamId:t.streamId,audioMid:U,videoMid:V,audioTransceiverInit:null===(i=D)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=D)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:null===(a=D)||void 0===a?void 0:a.signalingAck,stream:t,sdp:D.sdp,onSuccess:function(){oe.logger.info("ssrc","success"),e(0)},onFail:function(e){oe.logger.info("ssrc","fail",e),r(e)}})}));case 44:return e.prev=44,this.emit("_test_sub_body_",B),e.next=48,null===(K=this._dataChannelSignal)||void 0===K?void 0:K.sendSignaling("subscribe",B);case 48:z=e.sent,e.next=78;break;case 51:if(e.prev=51,e.t0=e.catch(44),t.streamState=XH.INIT,e.t0 instanceof Error&&(null===(Y=this._monitor)||void 0===Y||Y.report("rtc_subscribe_stat",{result:"fail",start:w,message:e.t0.message,stream_user_id:t.userId})),!(e.t0.code>=500&&e.t0.code<600)){e.next=70;break}if(this.emit("_test_sub_5xx_"),!((q=this.getPubSubBackOff(t.streamId)).retryDuration<6e4)){e.next=68;break}return this.logger.info("subRetry",t.streamId,q.retryDuration),e.next=62,new jI((function(e){return setTimeout(e,q.interval)}));case 62:return q.retryDuration+=q.interval,q.interval=q.interval>4e3?8e3:2*q.interval,this.emit(CW.SUB_RETRY,{screen:t.isScreen,userId:t.userId}),e.abrupt("return",this._subscribe(t,r,n));case 68:this.logger.info("subRetry","end",t.streamId),delete this._pubSubBackOff[t.streamId];case 70:return t.subVideo=C,e.next=73,null===(W=P)||void 0===W?void 0:W.rollback({msid:t.streamId,stream:t});case 73:return J={roomId:this._roomId,streamId:t.streamId,userId:t.userId},e.next=76,null===(X=this._dataChannelSignal)||void 0===X?void 0:X.sendSignaling("unsubscribe",J).catch((function(){}));case 76:throw t.streamState=XH.INIT,e.t0;case 78:if(z.relayMessage){e.next=81;break}throw null===(Q=this._monitor)||void 0===Q||Q.report("rtc_error",{error_code:-1009,message:"relayMessage is null"}),new bC(fC.UNEXPECTED_ERROR,"unable to subscribe");case 81:if(Z=null!==(v=null===(_=z)||void 0===_?void 0:_.relayMessage)&&void 0!==v?v:{},$=Z.audioMid,ee=Z.videoMid,ql(f={},U,$),ql(f,V,ee),te=f,this.logger.info("sub midmap",t.userId,te),t.videoMid=V,t.audioMid=U,t.subMediaType=r,t.streamState=XH.SUB_ED,t.subLayer=F,null===(m=this._monitor)||void 0===m||m.report("rtc_recv_answer",{error_code:0,answer_type:null===(g=z)||void 0===g||null===(y=g.relayMessage)||void 0===y?void 0:y.type,sequence_id:(null===(S=z)||void 0===S||null===(b=S.relayMessage)||void 0===b?void 0:b.sequenceId)||0,message:null===(k=z)||void 0===k||null===(E=k.relayMessage)||void 0===E?void 0:E.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:(null===(T=P)||void 0===T?void 0:T.peerConnectionId)||""}),e.prev=90,null!==(re=D)&&void 0!==re&&re.signalingAck){e.next=94;break}return e.next=94,new jI((function(e,r){var n,i,o,a,s,c,u;null===(n=P)||void 0===n||n.handleAck({action:ZH.subscribe,streamId:t.streamId,audioMid:U,videoMid:V,audioTransceiverInit:null===(i=D)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=D)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:{sdp:null===(a=z)||void 0===a||null===(s=a.relayMessage)||void 0===s?void 0:s.sdp,sequenceId:null===(c=z)||void 0===c||null===(u=c.relayMessage)||void 0===u?void 0:u.sequenceId},stream:t,sdp:D.sdp,onSuccess:function(){oe.logger.info("sub ack","success"),e(0)},onFail:function(e){oe.logger.info("sub ack","fail",e),r(e)}})}));case 94:return e.next=96,jI.all(x);case 96:e.next=106;break;case 98:return e.prev=98,e.t1=e.catch(90),e.t1 instanceof Error&&(null===(ie=this._monitor)||void 0===ie||ie.report("rtc_subscribe_stat",{result:"fail",start:w,message:e.t1.message,stream_user_id:t.userId})),J={roomId:this._roomId,streamId:t.streamId,userId:t.userId},e.next=104,null===(ne=this._dataChannelSignal)||void 0===ne?void 0:ne.sendSignaling("unsubscribe",J).catch((function(){}));case 104:throw t.streamState=XH.INIT,e.t1;case 106:this.multiChatMode()||(t.subAudio=A),null===(I=this._monitor)||void 0===I||I.report("rtc_subscribe_stat",{result:"success",start:w,message:"unknown",stream_user_id:t.userId}),this._context&&t.startReport((function(e){return oe.emit("onRemoteStreamStats",e)}),P);case 109:case"end":return e.stop()}}),e,this,[[44,51],[90,98]])}))),function(e,t,r){return v.apply(this,arguments)})},{key:"controlMessage",value:(p=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"updateUserAttributes",value:(h=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 h.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(l=Ng(Pg().mark((function e(t,r){var n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return this.logger.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:return this.emit("___afterUpdateSubscribeSend"),t.subLayer=r,e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"updateSubPriority",value:(d=Ng(Pg().mark((function e(t,r){var n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return this.logger.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:return t.priority=r,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"updateSubMediaType",value:(u=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=!1,a=!1,GM(r)&&(a=!0),zM(r)&&(o=!0),s={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:o,audio:!!this.multiChatMode()||a}}},e.next=6,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",s);case 6:return this.multiChatMode()||(null===(c=t.observer)||void 0===c||c.setUnmuteAudio(a),t.subAudio=a),null===(i=t.observer)||void 0===i||i.setUnmuteVideo(o),t.subVideo=o,t.subMediaType=r,e.abrupt("return",t);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(c=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("subscribe4pushTrack()","streamInfo: %o",r),nX("subscribe4pushTrack()",t,this.logger),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 bC(fC.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 8:return s=a.audioMid,c=a.videoMid,(u=[]).push(new jI((function(e,r){var n=setTimeout((function(){return r(new bC(fC.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),tX);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(l.logger.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:ZH.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,jI.all(u);case 19:this._context&&t.startReport((function(e){return l.emit("onRemoteStreamStats",e)}),this._handler);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(s=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(nX("unsubscribe4removeTrack()",t,this.logger),this.logger.info("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId,"trackType: ",n),!(r.sequenceId<t.sequenceId)){e.next=5;break}return this.logger.warn("unsubscribe4removeTrack()","sequenceId return"),e.abrupt("return");case 5:return u=!!((c=n+1)&ch.AUDIO),d=!!(c&ch.VIDEO),e.next=10,null===(i=this._handler)||void 0===i?void 0:i.handleAck({action:ZH.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 s.apply(this,arguments)})},{key:"unsubscribe",value:(a=Ng(Pg().mark((function e(t){var r,n,i,o,a,s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nX("unsubscribe()",t,this.logger),o={roomId:this._roomId,streamId:t.streamId,userId:t.userId},a=t.vendorHandler||this.handler,null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unsubscribe",o).catch((function(){})),t.streamState=XH.INIT,t.subVideo=!1,null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(i=t.observer)||void 0===i||i.setSubscribeAudio(!1)),e.next=10,null==a?void 0:a.handleAck({action:ZH.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:s=e.sent,this._subResolves[s]&&this._subResolves[s].forEach((function(e){return e(0)})),this.logger.info("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),t.subMediaType=CH.NONE,this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this)}))),function(e){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=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(nX("handleRemoveStream()",t,this.logger),t.subVideo=!1,t.streamState!==XH.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"leave",value:(i=Ng(Pg().mark((function e(){var t,r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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",jI.reject(new bC(fC.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=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g=this;return Pg().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 bC(fC.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=IM(),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,CB();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=GL.VERSION,e.t8=LL.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 jI((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new bC(fC.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),tX);t.on("ontrack",(function r(i){"video"===i.mediaType&&(g.logger.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p.push(new jI((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new bC(fC.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),tX);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(g.logger.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),_=null==h?void 0:h.relayMessage,f=_.sequenceId,m=_.sdp,t.videoMid=d,t.audioMid=u,t.sequenceId=f,t.streamState=XH.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:ZH.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:m,sequenceId:f},stream:t});case 44:return e.next=46,jI.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.startReport((function(e){return g.emit("onRemoteStreamStats",e)}),this._handler);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(r=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nX("unsubscribePublicStream()",t,this.logger),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=XH.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:ZH.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),t.subMediaType=CH.NONE,this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;this.logger.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._pubSubBackOff={},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 jI((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 UW,a.code>=500&&a.code<600&&IM()-r.initTs<6e4){var s,c=r.getRetryDelay();return n.logger.warn("_joinRoomWithRetry",Fg(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;e.logger.info("connectStateChange","connected"),null===(r=e._dataChannelSignal)||void 0===r||r.destroy(),null===(n=e._handler)||void 0===n||n.destroy(),e._handler=gW(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.publicStream?e.emit("connectSuccess",{reconnect:!0}):(e._reportJoinRoomStart(),e._callJoinRoom(!0)))})),this._connectionManager.on("disconnected",(function(t){e.connectionState="disconnected",e.logger.error("connectStateChange","disconnected. %o",t),e.isReconnecting&&e.safeEmit(CW.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",e.logger.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",e.logger.warn("connectStateChange","reconnecting"),e.safeEmit("reconnecting")})),this._connectionManager.on("connectWidthTcp",(function(){e.safeEmit(CW.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=IM(),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:"getPubSubBackOff",value:function(e){return this._pubSubBackOff[e]||(this._pubSubBackOff[e]={interval:1e3,retryDuration:0}),this._pubSubBackOff[e]}},{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:IM()-this._joinRoomStartTs}),delete this._joinRoomStartTs)}},{key:"_joinRoomFailed",value:function(e,t){var r;(this._joinReject&&this._joinResolve&&(this._joinReject(new bC(t||fC.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=Ng(Pg().mark((function e(t,r,n){var i,o,a=this;return Pg().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:qg(n).call(n,(function(e){return{dstRoomId:e.roomId,dstToken:wM.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}}]),A}(kU);function oX(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var r,i,o,a=arguments;return Pg().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 bC(fC.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function aX(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var t,r,i,o,a=arguments;return Pg().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}eX([function(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var t,r,i,o,a=this,s=arguments;return Pg().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 jI(function(){var e=Ng(Pg().mark((function e(t,i){var s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new bC(fC.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}],iX.prototype,"join",1),eX([aX,oX],iX.prototype,"publish",1),eX([aX,oX],iX.prototype,"updatePubTrack",1),eX([oX],iX.prototype,"updateVideoDescriptions",1),eX([aX,oX],iX.prototype,"unpublish",1),eX([aX,oX],iX.prototype,"subscribe",1),eX([oX],iX.prototype,"controlMessage",1),eX([oX],iX.prototype,"updateUserAttributes",1),eX([oX],iX.prototype,"updateSubTrackLayer",1),eX([oX],iX.prototype,"updateSubPriority",1),eX([aX,oX],iX.prototype,"subscribe4pushTrack",1),eX([aX,oX],iX.prototype,"unsubscribe4removeTrack",1),eX([aX,oX],iX.prototype,"unsubscribe",1),eX([oX],iX.prototype,"handleRemoveStream",1),eX([aX],iX.prototype,"subscribePublicStream",1),eX([aX],iX.prototype,"unsubscribePublicStream",1);var sX,cX=function(){var e=Ng(Pg().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,_,f,m,g;return Pg().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.originTrack:null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.originTrack,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,qB(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,_=aI(p=v||[]).call(p,(function(e){return"inbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(f=e.sent,m=[],null==f||f.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==(null==v?void 0:v.length)||0===m.length){e.next=22;break}return e.next=21,qB(r.pc);case 21:g=e.sent;case 22:u=Gg({type:t,reports:qg(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==_?void 0:_.bytesReceived,framesReceived:null==_?void 0:_.framesReceived,packetsReceived:null==_?void 0:_.packetsReceived,allReports:g}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Gg(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)}}(),uX=function(){var e=Ng(Pg().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,_,f,m,g;return Pg().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.preprocessingTrack:null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.preprocessingTrack,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,qB(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,_=aI(p=v||[]).call(p,(function(e){return"outbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(f=e.sent,m=[],null==f||f.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==v.length||0===m.length){e.next=22;break}return e.next=21,qB(r.pc);case 21:g=e.sent;case 22:u=Gg({type:t,reports:qg(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==_?void 0:_.bytesSent,framesSent:null==_?void 0:_.framesSent,packetsSent:null==_?void 0:_.packetsSent,allReports:g}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Gg(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)}}(),dX=function(e){UA(a,e);var t,r,n,i,o=ew(a);function a(e,t){var r;return Fh(this,a),ql(aA(r=o.call(this)),"_audioEventSessionId",xM()),ql(aA(r),"_videoEventSessionId",xM()),ql(aA(r),"_handler",void 0),ql(aA(r),"_stream",void 0),ql(aA(r),"_firstAudioFrameTimer",void 0),ql(aA(r),"_firstVideoFrameTimer",void 0),ql(aA(r),"_transportDelayInterval",void 0),ql(aA(r),"_transportDelay",void 0),ql(aA(r),"_firstVideoFrameInterval",void 0),ql(aA(r),"_firstAudioFrameInterval",void 0),ql(aA(r),"_isScreen",!1),ql(aA(r),"_audioFirstFrameState",0),ql(aA(r),"_videoFirstFrameState",0),ql(aA(r),"_timeout",1e4),ql(aA(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),ql(aA(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),ql(aA(r),"_login",!1),ql(aA(r),"_unMuteAudio",!1),ql(aA(r),"_enableAudio",!1),ql(aA(r),"_unMuteVideo",!1),ql(aA(r),"_enableVideo",!1),ql(aA(r),"_remoteUnmuteAudio",!1),ql(aA(r),"_remoteUnmuteVideo",!1),ql(aA(r),"_audioExternal",!1),ql(aA(r),"_pushAudio",!1),ql(aA(r),"_videoExternal",!1),ql(aA(r),"_pushVideo",!1),ql(aA(r),"_autoSubscribeVideo",!1),ql(aA(r),"_autoSubscribeAudio",!1),ql(aA(r),"_autoSubscribe",!1),ql(aA(r),"_publishVideo",!1),ql(aA(r),"_publishAudio",!1),ql(aA(r),"_subscribeAudio",!1),ql(aA(r),"_subscribeVideo",!1),ql(aA(r),"_subscribe",!1),ql(aA(r),"_pushTrack",!1),ql(aA(r),"_multiChatMode",!1),ql(aA(r),"_monitor",void 0),ql(aA(r),"logger",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=KN(e.engineId),r.logger=new pM("RecvFrameObserver",0,e.engineId),r}return Vh(a,[{key:"beginRecvFrame",value:(i=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,yI(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(){cX("audio",k._handler,k._stream,k._monitor),k.stopRecvFrame("audio","timeout"),k._firstAudioFrameInterval&&window.clearInterval(k._firstAudioFrameInterval)}),this._timeout),this.logger.info("rtcFirstFrameRecv",Gg(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===(_=this._currentVideoRecv)||void 0===_?void 0:_.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,transport_delay:i,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(g=this._stream)||void 0===g?void 0:g.pcSessionId)||(null===(y=this._handler)||void 0===y?void 0:y.peerConnectionId)},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){cX("video",k._handler,k._stream,k._monitor),k.stopRecvFrame("video","timeout"),k._firstVideoFrameInterval&&window.clearInterval(k._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),this.logger.info("rtcFirstFrameRecv",Gg(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,this.logger.info("rtcFirstFrameRecv",Gg(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,g;if(1!==this._videoFirstFrameState)return;var y={event_type:"recv_end",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),start:null===(h=this._currentVideoRecv)||void 0===h?void 0:h.startTime,reason:t,result:!1,stream_user_id:null===(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===(_=this._stream)||void 0===_?void 0:_.vendorCode)||0,pc_session_id:(null===(f=this._stream)||void 0===f?void 0:f.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,this.logger.info("rtcFirstFrameRecv",Gg(y)),null===(g=this._monitor)||void 0===g||g.report("rtc_first_frame",y),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T;return Pg().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,yI(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),this.logger.info("rtcFirstFrameRecv",Gg(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,k=b.type,E=b.startTime,yI(v=["login","unmute","subscribe","push_track"]).call(v,k)>=0&&(r=0),T={event_type:"recv_end",media_type:t,is_screen:!(null===(_=this._stream)||void 0===_||!_.isScreen),start:E,result:!0,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,event_session_id:this._videoEventSessionId,type:k,transport_delay:r,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(g=this._stream)||void 0===g?void 0:g.pcSessionId)||(null===(y=this._handler)||void 0===y?void 0:y.peerConnectionId)},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this.logger.info("rtcFirstFrameRecv",Gg(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.stopRecvFrame("audio","stop_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.stopRecvFrame("video","stop_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&&(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(Ng(Pg().mark((function n(){var i,o,a,s,c,u,d,l;return Pg().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.preprocessingTrack){n.next=12;break}return n.next=3,qB(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.preprocessingTrack);case 3:if(d=n.sent,!(l=aI(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(Ng(Pg().mark((function n(){var i,o,a,s,c,u,d,l;return Pg().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.originTrack){n.next=12;break}return n.next=3,qB(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.originTrack);case 3:if(d=n.sent,!(l=aI(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=Ng(Pg().mark((function e(){var t=this;return Pg().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(Ng(Pg().mark((function e(){return Pg().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=Ng(Pg().mark((function e(){var t,r,n,i,o;return Pg().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,qB(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=aI(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=aI(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}(yU.EventEmitter),lX=function(){function e(t,r){Fh(this,e),ql(this,"_audioEventSessionId",xM()),ql(this,"_videoEventSessionId",xM()),ql(this,"_pcSessionId",void 0),ql(this,"_handler",void 0),ql(this,"_firstAudioFrameTimer",void 0),ql(this,"_firstVideoFrameTimer",void 0),ql(this,"_stream",void 0),ql(this,"_firstVideoFrameInterval",void 0),ql(this,"_firstAudioFrameInterval",void 0),ql(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),ql(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),ql(this,"_login",!1),ql(this,"_publisher",!1),ql(this,"_unMuteAudio",!1),ql(this,"_enableAudio",!1),ql(this,"_unMuteVideo",!1),ql(this,"_enableVideo",!1),ql(this,"_audioExternal",!1),ql(this,"_pushAudio",!1),ql(this,"_videoExternal",!1),ql(this,"_pushVideo",!1),ql(this,"_autoPublish",!1),ql(this,"_publish",!1),ql(this,"_timeout",1e4),ql(this,"_audioFirstFrameState",0),ql(this,"_videoFirstFrameState",0),ql(this,"_monitor",void 0),ql(this,"logger",void 0),this._stream=t,this._handler=r,this._monitor=KN(t.engineId),this.logger=new pM("SendFrameObserver",0,t.engineId)}var t,r;return Vh(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(){uX("audio",r._handler,r._stream,r._monitor),r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),this.logger.info("rtcFirstFrameSend",Gg(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 g={event_type:"begin_send",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),type:t,start:this._currentVideoSend.startTime,event_session_id:this._videoEventSessionId,vendor_mode:(null===(h=this._stream)||void 0===h?void 0:h.vendorCode)||0,pc_session_id:(null===(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===(_=this._stream)||void 0===_||null===(f=_.videoTrack)||void 0===f?void 0:f.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){uX("video",r._handler,r._stream,r._monitor),r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),this.logger.info("rtcFirstFrameSend",Gg(g)),null===(m=this._monitor)||void 0===m||m.report("rtc_first_frame",g),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u,d;if(1!==this._audioFirstFrameState)return;var l={event_type:"sent_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioSend)||void 0===i?void 0:i.type,vendor_mode:(null===(o=this._stream)||void 0===o?void 0:o.vendorCode)||0,pc_session_id:(null===(a=this._stream)||void 0===a?void 0:a.pcSessionId)||(null===(s=this._handler)||void 0===s?void 0:s.peerConnectionId),capture_session_id:null===(c=this._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,this.logger.info("rtcFirstFrameSend",Gg(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,g,y,S;if(1!==this._videoFirstFrameState)return;var b={event_type:"sent_end",media_type:e,start:null===(h=this._currentVideoSend)||void 0===h?void 0:h.startTime,is_screen:!(null===(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===(_=this._stream)||void 0===_?void 0:_.vendorCode)||0,pc_session_id:(null===(f=this._stream)||void 0===f?void 0:f.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId),capture_session_id:null===(g=this._stream)||void 0===g||null===(y=g.videoTrack)||void 0===y?void 0:y.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,this.logger.info("rtcFirstFrameSend",Gg(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),this.logger.info("rtcFirstFrameSend",Gg(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,g;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var y=this._currentVideoSend,S=y.type,b=y.startTime,k={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===(_=this._handler)||void 0===_?void 0:_.peerConnectionId),capture_session_id:null===(f=this._stream)||void 0===f||null===(m=f.videoTrack)||void 0===m?void 0:m.captureSessionId};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this.logger.info("rtcFirstFrameSend",Gg(k)),null===(g=this._monitor)||void 0===g||g.report("rtc_first_frame",k),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._stream.pubVideo&&this.beginSendFrame("video","login"),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this._stream.pubAudio&&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=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s;return Pg().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.preprocessingTrack){e.next=6;break}return e.next=3,qB(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o?void 0:o.videoTrack.preprocessingTrack);case 3:return a=e.sent,s=Ty(a).call(a,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",s);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=Ng(Pg().mark((function e(){var t,r,n,i,o,a;return Pg().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.preprocessingTrack){e.next=5;break}return e.next=3,qB(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o?void 0:o.audioTrack.preprocessingTrack);case 3:return a=e.sent,e.abrupt("return",aI(a).call(a,(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(Ng(Pg().mark((function n(){var i,o,a;return Pg().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||qg(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(Ng(Pg().mark((function r(){var n;return Pg().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}(),hX=(ql(sX={},"audio",{delay:1200,stallRadio:.3}),ql(sX,"video",{delay:1200,stallRadio:.6}),ql(sX,"screen_audio",{delay:1600,stallRadio:.8}),ql(sX,"screen_video",{delay:1600,stallRadio:.8}),sX),pX=function(){function e(){Fh(this,e),ql(this,"_preUplinkStats",new cT),ql(this,"_preDownlinkStats",new cT),ql(this,"_timer",void 0),ql(this,"_delayTimer",void 0),ql(this,"_msc",void 0),ql(this,"reportor",void 0)}return Vh(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,sI(i=Fg(o=[]).call(o,tR(l),[d])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var h,p,v=n?"screen_video":"video",_=r._fractionLost,f=r.rtt,m=r._sendBandWidth,g=r._retransmittedRate;0===m&&(_=Math.max(.65,_));var y=this._getQosLevel(f,_||0,g||0),S=this._preUplinkStats.get(v)||[y];this._preUplinkStats.set(v,sI(h=Fg(p=[]).call(p,tR(S),[y])).call(h,-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){var r;if(t){var n,i,o=this._getStreamActiveState(t),a=o.audioActive,s=o.videoActive,c=e.audioStats,u=e.videoStats,d=e.isScreen,l=e.userId,h=!0,p=!0;if(a)if(0===c.receivedKBitrate)h=!1;else{var v=c.rtt,_=c.audioLossRate,f=c.stallDuration,m=c.statsInterval,g=c.e2eDelay,y=f/m,S=d?"screen_audio":"audio",b=this._getQosLevel(v,_||0,u._retransmittedRate||0),k=this._getDownlinkQoE(S,y,g);n=this._getNetworkQuality(b,k)}if(s)if(0===u.receivedKBitrate||0===u.rtt)p=!1;else{var E=u.rtt,T=u.videoLossRate,I=u.stallDuration,R=u.statsInterval,A=u.e2eDelay,w=u._retransmittedRate,C=I/R,x=d?"screen_video":"video",O=this._getQosLevel(E,T||0,w||0),P=this._getDownlinkQoE(x,C,A);i=this._getNetworkQuality(O,P)}var D=Fg(r="".concat(l)).call(r,d?"_screen":"");if(h||p){var N=n&&i?Math.ceil((n+i)/2):n||i;if(N){var M,L,U=this._preDownlinkStats.get(D)||[N];this._preDownlinkStats.set(D,sI(M=Fg(L=[]).call(L,tR(U),[N])).call(M,-2)),this._startNetworkQualityReport()}}else this._preDownlinkStats.delete(D)}}},{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(Xy(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")||Sh.EXCELLENT;var l=Ty(a=qg(s=KC(ix(c=this._preDownlinkStats).call(c))).call(s,(function(e){return o._getBetterQualityAndRemoveOldest(e,"down")}))).call(a,(function(e){return e}));i=Math.ceil(oS(l).call(l,(function(e,t){return t+e}),0)/l.length)||Sh.UNKNOWN}else n=i=Sh.DOWN;navigator.onLine||(n=Sh.DOWN,i=Sh.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=hX[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=Sh.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=Ty(i).call(i,(function(e){return e}));o.length>0&&(r=Math.min.apply(Math,tR(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&&GM(t)&&r.localaudio&&r.audiostream,videoActive:n&&zM(t)&&r.localvideo&&r.videostream}}}]),e}(),vX=function(){function e(t){Fh(this,e),ql(this,"_timer",void 0),ql(this,"_remoteVideoSizeCache",{}),ql(this,"_remoteScreenSizeCache",{}),ql(this,"onchange",void 0),this._room=t,this._start()}return Vh(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.preprocessingTrack;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=0,v=0;if(tL){var _,f,m=null==n||null===(_=n.videoTrack)||void 0===_||null===(f=_.videoPlayer)||void 0===f?void 0:f.domElement;m&&(p=m.videoWidth,v=m.videoHeight)}else{var g=a.getSettings();p=g.width||0,v=g.height||0}h===v&&d===p||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,p,v),delete s[i],(n.isScreen?r:t)[i]={width:p,height:v}}}))})),MS(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),MS(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),_X=KC((new TextEncoder).encode("subt")),fX={1:fC.SUBTITLE_ERR_POSTPROCESS,2:fC.SUBTITLE_ERR_CONNECTION_ERROR,3:fC.SUBTITLE_ERR_PROCESS_ERROR},mX=new pM("SubtitleTool",1),gX=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&yI(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))||"";yI(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=Gg({source_language:o}))}},yX=function(){function e(t){var r,n,i;Fh(this,e),ql(this,"_taskId",void 0),ql(this,"_appId",void 0),ql(this,"_roomId",void 0),ql(this,"_userId",void 0),ql(this,"onEvent",void 0),ql(this,"onMessage",void 0),ql(this,"_preConfig",void 0),ql(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 Vh(e,[{key:"start",value:(n=Ng(Pg().mark((function e(t){var r=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(mX.info("start","Invoke config: %o",t),eU(t.mode,"mode",[Ah.ASR_ONLY,Ah.ASR_AND_TRANSLATION]),t.mode!==Ah.ASR_AND_TRANSLATION||-1!==yI(bX).call(bX,t.targetLanguage||"")){e.next=4;break}throw new bC(fC.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new bC(fC.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:wh.ERROR,errorCode:fC.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=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(eU(t.mode,"mode",[Ah.ASR_ONLY,Ah.ASR_AND_TRANSLATION]),t.mode!==Ah.ASR_AND_TRANSLATION||-1!==yI(bX).call(bX,t.targetLanguage||"")){e.next=3;break}throw new bC(fC.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new bC(fC.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new bC(fC.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;mX.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:wh.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(t=Ng(Pg().mark((function e(){return Pg().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(){mX.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 bC(fX[r]||fC.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:wh.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:wh.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(this._taskId&&this._preConfig){var t=SX(e);if(t&&t.length>0){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){i===Ah.ASR_ONLY?e.mode===i&&a.push(e):i===Ah.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==Ah.ASR_ONLY||a.push(e),e.mode===Ah.ASR_ONLY&&e.language===o&&a.push(Ql(Ql({},e),{},{mode:Ah.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}(),SX=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(_X.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=wM.ab2str(sI(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(c){}return!1},bX=["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"],kX=uT,EX=HI,TX=function(e,t,r,n){for(var i,o=n>1?void 0:n?EX(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&&kX(t,r,o),o},IX=function(){function e(t){Fh(this,e),ql(this,"_forwardDstRooms",new cT),ql(this,"forwardStreamState","stopped"),ql(this,"_monitor",void 0),this._room=t,this._monitor=KN(this._room.id)}var t,r,n,i,o,a;return Vh(e,[{key:"startForwardStream2Rooms",value:(a=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!==this.forwardStreamState&&"paused"!==this.forwardStreamState){e.next=2;break}throw new bC(fC.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=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new bC(fC.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=Ng(Pg().mark((function e(){var t,r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new bC(fC.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),!(tR(ix(t=this._forwardDstRooms).call(t)).length>0)){e.next=10;break}throw new bC(fC.UNEXPECTED_ERROR,"stopforwardstream failed: ".concat(Gg(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=Ng(Pg().mark((function e(){var t,r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("paused"!==this.forwardStreamState&&"stopped"!==this.forwardStreamState){e.next=2;break}throw new bC(fC.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=Ng(Pg().mark((function e(){var t,r,n,i,o=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o.length>0&&void 0!==o[0]&&o[0]||!Xy(t=["running","stopped"]).call(t,this.forwardStreamState)){e.next=3;break}throw new bC(fC.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===Ch.FORWARD_STREAM_STATE_FAILURE&&e._room.safeEmit(CW.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(CW.ON_FORWARD_STREAM_ERROR,{roomId:e.dstRoomId,state:Ch.FORWARD_STREAM_STATE_FAILURE,error:xh.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=eC(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=my(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=i.dstRoomId,a=i.code,s={roomId:o,state:Ch.FORWARD_STREAM_STATE_SUCCESS,error:xh.FORWARD_STREAM_ERROR_OK};200===a||(400===a?(s.state=Ch.FORWARD_STREAM_STATE_FAILURE,s.error=xh.FORWARD_STREAM_ERROR_REMOTE_KICKED):a>=700&&a<800?(s.state=Ch.FORWARD_STREAM_STATE_FAILURE,s.error=xh.FORWARD_STREAM_ERROR_INVALID_TOKEN):(s.state=Ch.FORWARD_STREAM_STATE_FAILURE,s.error=xh.FORWARD_STREAM_ERROR_RESPONSE)),r.push(s)}}catch(jZ){n.e(jZ)}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=aI(e).call(e,(function(e){return e.roomId===n}));if(!s&&!t._forwardDstRooms.has(n))throw new bC(fC.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=TT(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=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="".concat(xM()),"stop"!==t&&(a=qg(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(qg(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:Gg(c),event_session_id:i})),new bC(fC.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=aI(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:Gg(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 RX(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var r,i,o,a,s=arguments;return Pg().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 bC(fC.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 8:case"end":return e.stop()}}),e,this)}))),r}TX([RX],IX.prototype,"startForwardStream2Rooms",1),TX([RX],IX.prototype,"updateForwardStream2Rooms",1),TX([RX],IX.prototype,"stopForwardStream2Rooms",1),TX([RX],IX.prototype,"pauseForwardStream2AllRooms",1),TX([RX],IX.prototype,"resumeForwardStream2AllRooms",1);var AX={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},wX=function(e){UA(x,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C=ew(x);function x(e,t){var r;return Fh(this,x),ql(aA(r=C.call(this)),"id",void 0),ql(aA(r),"_mediaServerClient",void 0),ql(aA(r),"_localStream",void 0),ql(aA(r),"_localScreenStream",void 0),ql(aA(r),"_remoteUsers",new cT),ql(aA(r),"_remoteStreams",new cT),ql(aA(r),"_remoteStreamStreamIdUserIdMap",{}),ql(aA(r),"_virtualStreams",[]),ql(aA(r),"_context",void 0),ql(aA(r),"_sessionId",void 0),ql(aA(r),"_connectionLostTimer",void 0),ql(aA(r),"_serverConfig",void 0),ql(aA(r),"_roomConfig",void 0),ql(aA(r),"_roomInfo",void 0),ql(aA(r),"_userDuplicateLoginTimerMap",new cT),ql(aA(r),"_networkQualityManager",void 0),ql(aA(r),"_videoSizeObserver",void 0),ql(aA(r),"_hasPublished",!1),ql(aA(r),"_subtitleTool",void 0),ql(aA(r),"_csrcUserIdMap",void 0),ql(aA(r),"_publishOnDemandItem",void 0),ql(aA(r),"_onceTriggerBySignal",!1),ql(aA(r),"_pubTransceiverReady",!1),ql(aA(r),"_publishOnDemandBusy",!1),ql(aA(r),"_monitor",void 0),ql(aA(r),"logger",void 0),ql(aA(r),"_forwardStreamManager",void 0),r.id=t.id,r.logger=new pM("Room",1,t.id),r.logger.info("constructor","invoke"),r._roomConfig=e,r._mediaServerClient=new iX(t),r._networkQualityManager=new pX,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(aA(r)),r._videoSizeObserver=new vX(aA(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(aA(r)),r._context=t,r._csrcUserIdMap={},r._monitor=KN(r.id),r._forwardStreamManager=new IX(aA(r)),r._addHandlerEventHandler(),r}return Vh(x,[{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,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M=this;null===(e=this._mediaServerClient)||void 0===e||e.on(bW.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(bW.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return M._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(bW.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(bW.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return M._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(bW.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(bW.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return M._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(bW.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(bW.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return M._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(bW.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(bW.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(bW.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(bW.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(bW.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(bW.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(bW.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(bW.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(bW.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(bW.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(bW.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(bW.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(kW.RSCP,(function(e,t){!!aI(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:Xy(t).call(t,null===(r=M._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(t?M._pubTransceiverReady=!0:M._onceTriggerBySignal=!0,t&&M._onceTriggerBySignal||(M._publishOnDemandItem=e),M._pubTransceiverReady&&M._onPublishOnDemand())})),null===(b=this._mediaServerClient)||void 0===b||b.on(kW.RTT,this._onRTT.bind(this)),null===(k=this._mediaServerClient)||void 0===k||k.on(kW.SSC,this._onSSC.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(EW.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(EW.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return M.emit(EW.ON_VENDOR_CONNECTION_STATE_CHANGE,e)})),null===(I=this._mediaServerClient)||void 0===I||I.on(bW.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){M._networkQualityManager.updateDownlinkStats(e,M._findRemoteStreamByScreen(e.userId,e.isScreen)),M.emit(CW.ON_REMOTE_STREAM_STATS,KM(e))})),null===(A=this._mediaServerClient)||void 0===A||A.on(CW.RESUBSCRIBE,(function(e){M.emit(CW.RESUBSCRIBE,e)})),null===(w=this._mediaServerClient)||void 0===w||w.on(CW.RECONNECT_FAILED,(function(){M.emit(CW.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(bW.ON_FORWARD_DST_ROOM_USER_KICK,this._forwardStreamManager.onForwardDstRoomUserKick.bind(this._forwardStreamManager)),null===(O=this._mediaServerClient)||void 0===O||O.on(CW.ON_REJOIN_WITH_TCP,(function(){M.emit(CW.ON_REJOIN_WITH_TCP)})),null===(P=this._mediaServerClient)||void 0===P||P.on(CW.ON_ICE_CONNECT_WITH_TCP,(function(){M.emit(CW.ON_ICE_CONNECT_WITH_TCP)})),null===(D=this._mediaServerClient)||void 0===D||D.on(CW.PUB_RETRY,(function(e){M.emit(CW.PUB_RETRY,e)})),null===(N=this._mediaServerClient)||void 0===N||N.on(CW.SUB_RETRY,(function(e){M.emit(CW.SUB_RETRY,e)}))}},{key:"_onLocalStreamStats",value:function(e){this._networkQualityManager.updateUplinkStats(e),this.emit(CW.ON_LOCAL_STREAM_STATS,KM(e))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(w=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setSessionId(),e.next=3,this._mediaServerClient.connect();case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"join",value:(A=Ng(Pg().mark((function e(t,r,n,i,o){var a,s,c;return Pg().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}),this.logger.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===fC.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 A.apply(this,arguments)})},{key:"publishScreen",value:(R=Ng(Pg().mark((function e(t,r,n,i,o){var a,s,c,u,d,l,h,p,v,_,f,m;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishScreen()"),this._localScreenStream||(this._localScreenStream=new YH(this._context),null!==(a=this._mediaServerClient)&&void 0!==a&&null!==(s=a.vendorConfig)&&void 0!==s&&s.enableMultiVendor&&(this._localScreenStream.pcSessionId=px()),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new lX(this._localScreenStream,this._mediaServerClient.handler))),c=!1,u=!1,d=!1,l=!1,!this._localScreenStream.videoTrack&&r?(r instanceof eH&&(u=!0),c=!0):this._localScreenStream.videoTrack&&!r&&(c=!1),!this._localScreenStream.audioTrack&&n?(n instanceof tH&&(l=!0),d=!0):this._localScreenStream.audioTrack&&!n&&(d=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(GM(i)&&(this._localScreenStream.pubAudio=o===OW.PUB),zM(i)&&(this._localScreenStream.pubVideo=o===OW.PUB),this.logger.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===(_=this._localScreenStream.observer)||void 0===_||_.setEnableVideo(c),l?null===(f=this._localScreenStream.observer)||void 0===f||f.setPushAudio(d):null===(m=this._localScreenStream.observer)||void 0===m||m.setEnableAudio(d),e.next=28,this.updatePubScreenTrack();case 28:this._localScreenStream.pubAudio||this._localScreenStream.pubVideo?this._mediaServerClient.handler&&this._localScreenStream.startReport(this._onLocalStreamStats.bind(this),this._localScreenStream.vendorHandler||this._mediaServerClient.handler):this._localScreenStream.stopReport("unpublish screen");case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return R.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(I=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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 I.apply(this,arguments)})},{key:"unpublishScreen",value:(T=Ng(Pg().mark((function e(){var t;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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 T.apply(this,arguments)})},{key:"liveControlMessage",value:(E=Ng(Pg().mark((function e(t){var r,n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 E.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(k=Ng(Pg().mark((function e(t){return Pg().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:(b=Ng(Pg().mark((function e(t){return Pg().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 b.apply(this,arguments)})},{key:"updateUserAttributes",value:(S=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 S.apply(this,arguments)})},{key:"publish",value:(y=Ng(Pg().mark((function e(t,r,n,i,o,a){var s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=I.length>6&&void 0!==I[6]&&I[6],this.logger.info("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new YH(this._context),null!==(u=this._mediaServerClient)&&void 0!==u&&null!==(d=u.vendorConfig)&&void 0!==d&&d.enableMultiVendor&&(this._localStream.pcSessionId=px()),this._mediaServerClient.handler&&(this._localStream.observer=new lX(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,h=this._localStream,p=h.pubAudio,v=h.pubVideo,o&&(GM(o)&&(this._localStream.pubAudio=a===OW.PUB),zM(o)&&(this._localStream.pubVideo=a===OW.PUB),this.logger.info("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=29;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=13;break}return e.abrupt("return");case 13:return e.prev=13,s?null===(_=this._localStream.observer)||void 0===_||_.setLogin(!0):c&&(f=!!this._localStream.videoTrack,m=!!this._localStream.audioTrack,g=this._localStream.videoTrack instanceof eH,y=this._localStream.audioTrack instanceof tH,this._roomConfig.isAutoPublish&&!this._hasPublished?(f&&(g?null===(S=this._localStream.observer)||void 0===S||S.setPushVideo(!0):null===(b=this._localStream.observer)||void 0===b||b.setEnableVideo(!0)),m&&(y?null===(k=this._localStream.observer)||void 0===k||k.setPushAudio(!0):null===(E=this._localStream.observer)||void 0===E||E.setEnableAudio(!0))):null===(T=this._localStream.observer)||void 0===T||T.setPublish(!0)),this.emit("___onMediaServerClientPublish"),e.next=18,this._mediaServerClient.publish(this._localStream);case 18:this._hasPublished=!0,this.emit(CW.ON_PUBLISH_RESULT,{isScreen:!1,state:ih.PUBLISH_SUCC}),e.next=27;break;case 22:throw e.prev=22,e.t0=e.catch(13),this.emit(CW.ON_PUBLISH_RESULT,{isScreen:!1,state:ih.PUBLISH_FAIL}),delete this._localStream,e.t0;case 27:e.next=40;break;case 29:return e.prev=29,this.emit("___onMediaServerClientPublish"),e.next=33,this.updatePubTrack();case 33:e.next=40;break;case 35:throw e.prev=35,e.t1=e.catch(29),this._localStream.pubAudio=p,this._localStream.pubVideo=v,e.t1;case 40:this._localStream.pubAudio||this._localStream.pubVideo?this._mediaServerClient.handler&&this._localStream.startReport(this._onLocalStreamStats.bind(this),this._localStream.vendorHandler||this._mediaServerClient.handler):this._localStream.stopReport("unpublish");case 41:case"end":return e.stop()}}),e,this,[[13,22],[29,35]])}))),function(e,t,r,n,i,o){return y.apply(this,arguments)})},{key:"updatePubTrack",value:(g=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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:(m=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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 m.apply(this,arguments)})},{key:"subscribe",value:(f=Ng(Pg().mark((function e(t,r,n){var i,o,a;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("subscribe","remoteStream %o",t),!t.hasSubscribed){e.next=8;break}if((i=t.subMediaType|r)===t.subMediaType){e.next=7;break}return e.next=6,null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubMediaType(t,i);case 6:return e.abrupt("return",e.sent);case 7:return e.abrupt("return");case 8:return a=void 0,n&&(a=this._getSubLayer(n,t)),e.next=12,this._mediaServerClient.subscribe(t,r,a);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return f.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(_=Ng(Pg().mark((function e(t,r){var n,i,o,a,s;return Pg().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 _.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,_;if(h>=(null===(v=d[p])||void 0===v?void 0:v.width)*(null===(_=d[p])||void 0===_?void 0:_.height)){l=p;break}}var f=d[0];if(-1===l)f=d[l=d.length-1];else if(0!==l){var m=d[l-1].width*d[l-1].height,g=(m-h)/(m-d[l].width*d[l].height);f=g<.1?d[l-1]:d[l],l=g<.1?l-1:l}return a=null!==(r=null===(n=f)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=f)||void 0===o?void 0:o.video_index)&&void 0!==i?i:l,spatialSubLayer:a}}},{key:"unsubscribe",value:(v=Ng(Pg().mark((function e(t,r){var n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("unsubscribe","Invoke unsubscribe"),t.hasSubscribed){e.next=3;break}return e.abrupt("return");case 3:if(o=t.subMediaType-(t.subMediaType&r),null!==(n=this._context.serverConfig)&&void 0!==n&&n.muteReplaceUnsub||!(o===CH.NONE||this.multiChatMode&&o===ch.AUDIO)){e.next=8;break}return e.next=7,this._mediaServerClient.unsubscribe(t);case 7:return e.abrupt("return",e.sent);case 8:return e.next=10,null===(i=this._mediaServerClient)||void 0===i?void 0:i.updateSubMediaType(t,o);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"startSubtitle",value:(p=Ng(Pg().mark((function e(t){return Pg().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 bC(fC.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=Ng(Pg().mark((function e(){var t;return Pg().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=Ng(Pg().mark((function e(t){return Pg().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=Ng(Pg().mark((function e(t){return Pg().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=Ng(Pg().mark((function e(){return Pg().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=Ng(Pg().mark((function e(){return Pg().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=Ng(Pg().mark((function e(){return Pg().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=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=h.length>0&&void 0!==h[0]&&h[0],this.logger.info("leave","Invoke leave"),n=IM(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,delete this._sessionId,e.prev=6,s=my(cw(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(jZ){s.e(jZ)}finally{s.f()}return this._localStream&&(null===(d=this._localStream.observer)||void 0===d||d.setLogin(!1)),e.next=12,this._mediaServerClient.leave().catch((function(){}));case 12:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:IM()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=25;break;case 17:if(e.prev=17,e.t0=e.catch(6),!r){e.next=23;break}throw e.t0;case 23:this.destroy();case 24:e.t0 instanceof Error&&(null===(l=this._monitor)||void 0===l||l.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:IM()-n}));case 25:case"end":return e.stop()}}),e,this,[[6,17]])}))),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;this.logger.info("destroy","Invoke destroy"),JN(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 cT;var t,r,n,i=my(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=gy(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.destroy()}))}}catch(jZ){i.e(jZ)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new cT,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=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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(CW.ON_ROOM_ERROR,{errorCode:fC.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||(this._sessionId=bM(),this._mediaServerClient._sessionId=this._sessionId,null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId}))}},{key:"sendRoomMessage",value:(i=Ng(Pg().mark((function e(t){var r,n,i,o,a,s=arguments;return Pg().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,wM.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;this.logger.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(CW.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&i.safeEmit(CW.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=my(cw(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(jZ){p.e(jZ)}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=my(cw(n=this._remoteStreams).call(n));try{for(f.s();!(_=f.n()).done;){var m=_.value;Array.isArray(m)&&m.forEach((function(e){e.stillExist?delete e.stillExist:u.push({clientId:e.userId,streamId:e.streamId,message:yW.clientDisconnected})}))}}catch(jZ){f.e(jZ)}finally{f.f()}c.forEach((function(e){return i._onUserDisconnection(e)})),s.forEach((function(e){return i._onUserConnection(e)})),u.forEach((function(e){return i._onRemoveStream(e)})),d.forEach((function(e){return i._onAddStream(e,{fromSignal:!1})})),l.forEach((function(e){return i._onUpdateStreamAttributes(e)})),a&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r,n,i,o=this;this._localStream&&(this._localStream.clean(),this._localStream.vendorCode=(null===(r=this._mediaServerClient.vendorConfig)||void 0===r?void 0:r.vendorCode)||0,null===(n=this._localStream.observer)||void 0===n||n.setLogin(!0),this._mediaServerClient.publish(this._localStream).then((function(){var e;o._mediaServerClient.handler&&(null===(e=o._localStream)||void 0===e||e.startReport(o._onLocalStreamStats.bind(o),o._localStream.vendorHandler||o._mediaServerClient.handler)),o.emit(CW.ON_PUBLISH_RESULT,{isScreen:!1,state:ih.PUBLISH_SUCC,retry:!0})})).catch((function(e){o.logger.error("failed repub error:".concat(e)),o.emit(CW.ON_PUBLISH_RESULT,{isScreen:!1,state:ih.PUBLISH_FAIL,errorCode:e.code,retry:!0})})));this._localScreenStream&&(this._localScreenStream.clean(),null===(i=this._localScreenStream.observer)||void 0===i||i.setLogin(!0),this._mediaServerClient.publish(this._localScreenStream).then((function(){var e;o._mediaServerClient.handler&&(null===(e=o._localScreenStream)||void 0===e||e.startReport(o._onLocalStreamStats.bind(o),o._localScreenStream.vendorHandler||o._mediaServerClient.handler)),o.emit(CW.ON_PUBLISH_RESULT,{isScreen:!0,state:ih.PUBLISH_SUCC,retry:!0})})).catch((function(e){o.logger.error("failed repub screen stream error:".concat(e)),o.emit(CW.ON_PUBLISH_RESULT,{isScreen:!0,state:ih.PUBLISH_FAIL,errorCode:e.code,retry:!0})})));var a,s=my(cw(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=Ng(Pg().mark((function e(t){var r,n,i,a,s,c;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=22;break}return t.resetHasSubscribed(),e.prev=2,o.logger.info(Fg(r="start resubscribe ".concat(t.userId," with ")).call(r,t.subMediaType)),zM(t.subMediaType)&&(null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!0)),GM(t.subMediaType)&&(null===(i=t.observer)||void 0===i||i.setSubscribeAudio(!0)),e.next=8,o._mediaServerClient.subscribe(t,t.subMediaType);case 8:o.logger.info(Fg(a="success resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType)),o.safeEmit(CW.RESUBSCRIBE,{stream:t}),o.emit(CW.ON_SUBSCRIBE_RESULT,{userId:t.userId,isScreen:t.isScreen,retry:!0}),e.next=22;break;case 13:if(e.prev=13,e.t0=e.catch(2),o.emit(CW.ON_SUBSCRIBE_RESULT,{userId:t.userId,isScreen:t.isScreen,errorCode:e.t0.code,retry:!0}),o.logger.error(Fg(s=Fg(c="failed resubscribe ".concat(t.userId," with ")).call(c,t.subMediaType,", error:")).call(s,e.t0)),e.t0.code!==fC.NOT_CONNECTED_YET){e.next=20;break}return t.streamState=XH.SUB_ED,e.abrupt("return");case 20:t.clean(),null==t||t.resetHasSubscribed();case 22:case"end":return e.stop()}}),e,null,[[2,13]])})));return function(t){return e.apply(this,arguments)}}())}}catch(jZ){s.e(jZ)}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=aI(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 qH(this._context,"ff-stream","ff-stream",!1,!1,AX);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=gH(i),this._virtualStreams.push(s),this.safeEmit(CW.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?aI(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)?aI(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:Ty(p).call(p,(function(e){return e.streamId!==h.streamId}));h.clean(),this._remoteStreams.set(e.clientId,v||[])}var _=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,_)_.attributes=e.attributes;else if((_=new qH(this._context,e.clientId,e.streamId,e.screen,!1,e.attributes)).virtual=c,this._initStreamListeners(_),!c){var f=this._remoteStreams.get(e.clientId);f?f.push(_):this._remoteStreams.set(e.clientId,[_])}if(this._mediaServerClient.handler&&(_.observer=new dX(_,this._mediaServerClient.handler)),!_.isScreen&&l){var m,g,y,S,b,k,E,T;if(a&&_.hasVideo)if(_.attributes.extvideo)null===(m=_.observer)||void 0===m||m.setExternalVideoSource(!0),null===(g=_.observer)||void 0===g||g.setPushVideo(!0);else null===(y=_.observer)||void 0===y||y.setExternalVideoSource(!1),null===(S=_.observer)||void 0===S||S.setPublishVideo(!0);if(a&&_.hasAudio&&d&&!this._mediaServerClient.roomAttributes.multiChatMode)if(_.attributes.extaudio)null===(b=_.observer)||void 0===b||b.setExternalAudioSource(!0),null===(k=_.observer)||void 0===k||k.setPushAudio(!0);else null===(E=_.observer)||void 0===E||E.setExternalAudioSource(!1),null===(T=_.observer)||void 0===T||T.setPublishAudio(!0);if(i&&!a){var I,R=this._roomConfig,A=R.isAutoSubscribeAudio,w=R.isAutoSubscribeVideo;null===(I=_.observer)||void 0===I||I.setLogin(!0,{audio:!!A&&!this.multiChatMode,video:!!w})}}return i&&this.safeEmit(bW.ON_ADD_STREAM,{stream:_}),_}}},{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,Ql({},n)),this.safeEmit(bW.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(CW.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(CW.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code,a=e.forbiddenTime;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var s=null;i===TW.kickedByAdmin?s=fC.KICKED_OUT:i===TW.onUserTokenDidExpire?s=fC.TOKEN_EXPIRED:i===TW.userDuplicateLogin&&(s=fC.DUPLICATE_LOGIN),o===IW.roomDismissByAdmin&&(s=fC.ROOM_DISMISS),s&&this.safeEmit(CW.ON_ROOM_ERROR,{errorCode:s,forbiddenTime:a})}else{var c=eh.DROPPED;i===TW.userLeave?c=eh.QUIT:i===TW.kickedByAdmin?c=eh.KICKED_BY_ADMIN:i===TW.roleChanged&&(c=eh.SWITCH_TO_INVISIBLE);var u=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:yW.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(CW.ON_USER_LEAVE,{userInfo:{userId:n},reason:c})};if(i===TW.userDuplicateLogin){var d=this._userDuplicateLoginTimerMap.get(n);d&&self.clearTimeout(d);var l=self.setTimeout(u,5e3);this._userDuplicateLoginTimerMap.set(n,l)}else u()}}},{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=aI(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).then((function(){var t=r._remoteStreams.get(e.clientId);t&&(t=Ty(t).call(t,(function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),r._remoteStreams.set(e.clientId,t))})).finally((function(){r.safeEmit(bW.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(CW.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(CW.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=Ql(Ql({},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=Ql(Ql({},d),a),h=!1,p=l.localaudio!==d.localaudio,v=!1,_=!1,f=l.localvideo!==d.localvideo,m=!1,g=CH.NONE,y=CH.NONE;if(l.audiostream!==d.audiostream&&(h=l.localaudio,v=!!l.audiostream,l.audiostream?g|=ch.AUDIO:y|=ch.AUDIO),l.videostream!==d.videostream&&(_=l.localvideo,m=!!l.videostream,l.videostream?g|=ch.VIDEO:y|=ch.VIDEO),g&&this.safeEmit(CW.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:OW.PUB,remoteStream:s}),y&&this.safeEmit(CW.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:OW.UNPUB,remoteStream:s}),s.attributes=l,l.localaudio!==d.localaudio)if(l.localaudio){var S,b,k,E;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===(k=s.observer)||void 0===k||k.setExternalAudioSource(!1),null===(E=s.observer)||void 0===E||E.setEnableAudio(!0);this.safeEmit(CW.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(CW.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(CW.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var P,D,N,M;if(l.extvideo)null===(P=s.observer)||void 0===P||P.setExternalVideoSource(!0),null===(D=s.observer)||void 0===D||D.setPushVideo(!1);else null===(N=s.observer)||void 0===N||N.setExternalVideoSource(!1),null===(M=s.observer)||void 0===M||M.setEnableVideo(!1);!s.isScreen&&this.safeEmit(CW.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!p&&r)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(v);if(_&&!f&&n)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&&_C(t).call(t,"audio_mux")){var n=this._onAddStream(Ql(Ql({},e),{},{attributes:AX}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(CW.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){r.logger.error("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:Fg(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:MW.TRACK_ERROR})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message,o=e.trackType;this.logger.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(CW.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&&Xy(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=gy(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&&Kw(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=my(cw(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(jZ){u.e(jZ)}finally{u.f()}this._virtualStreams.forEach((function(e){var t;s.emit(CW.REMOVE_PUSH_TRACK,{stream:e,mediaType:ch.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===rX.DISCONNECTED)t=dh.CONNECTION_STATE_DISCONNECTED;else if(e.next===rX.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._mediaServerClient.isReconnecting?dh.CONNECTION_STATE_RECONNECTED:dh.CONNECTION_STATE_CONNECTED;else{if(e.next!==rX.CONNECTING)return;this._mediaServerClient.isReconnecting?(t=dh.CONNECTION_STATE_RECONNECTING,this._onReconnecting()):t=dh.CONNECTION_STATE_CONNECTING}e.prev===rX.CONNECTED&&e.next===rX.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(EW.ON_CONNECTION_STATE_CHANGE,{state:dh.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setMSC(this._mediaServerClient),this.safeEmit(EW.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(CW.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?sh.STREAM_INDEX_SCREEN:sh.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(bW.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(bW.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(bW.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new yX(this),this._subtitleTool.onEvent=function(t){e.emit(CW.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(CW.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=xW.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=xW.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?xW.START_FAILED:xW.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?xW.STOP_FAILED:xW.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?xW.UPDATE_FAILED:xW.UPDATE_SUCCESS}this.safeEmit(bW.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(bW.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(bW.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(n=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p;return Pg().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=22;break;case 11:if("subscribe"!==t.type){e.next=22;break}if(c=this._remoteStreamStreamIdUserIdMap[t.streamId],!(u=this._findRemoteStream(c,t.streamId))){e.next=22;break}return h=u.subMediaType,p=u.subLayer,e.next=19,null===(d=this._mediaServerClient)||void 0===d?void 0:d.unsubscribe(u);case 19:return e.next=21,null===(l=this._mediaServerClient)||void 0===l?void 0:l.subscribe(u,h,p);case 21:this.safeEmit(CW.RESUBSCRIBE,{stream:u});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===SW.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=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_;return Pg().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)&&(_={},this.logger.info("_onPublishOnDemand exec","usedDescriptions: %o",u),u.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&Xy(t).call(t,l)){var r=null==e?void 0:e.Metadata.VideoIndex;_[r]=!0}})),p.encodings=qg(v=p.encodings).call(v,(function(e){if(e.rid){_[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(CW.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(CW.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(CW.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?sh.STREAM_INDEX_SCREEN:sh.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=Ng(Pg().mark((function e(t,r){var n,i,o,a;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(n=t===sh.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)})}]),x}(kU),CX=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&&TT(r.style,t.style),t.attributes&&NS(t.attributes).forEach((function(e){var t=gy(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},xX=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],OX={playsinline:"","webkit-playsinline":""},PX={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},DX=function(e){UA(n,e);var t,r=ew(n);function n(e,t){var i;Fh(this,n),ql(aA(i=r.call(this)),"_containerDom",void 0),ql(aA(i),"_videoDom",void 0),ql(aA(i),"userId",void 0),ql(aA(i),"renderMode",void 0),ql(aA(i),"mirrorType",lh.MIRROR_TYPE_NONE),ql(aA(i),"isScreen",void 0),ql(aA(i),"isLocal",void 0),ql(aA(i),"played",!1),ql(aA(i),"_needLoad",!1),ql(aA(i),"_emitPlayFailed",!1),ql(aA(i),"_videoContainer",void 0),ql(aA(i),"_safari15VideoTimer",void 0),ql(aA(i),"_monitor",void 0),ql(aA(i),"logger",void 0),ql(aA(i),"_onLocalTrackMute",void 0),ql(aA(i),"_onInterruptionEnd",void 0),ql(aA(i),"_needResume",!1),ql(aA(i),"_rotate",0),ql(aA(i),"_rotateDom",void 0),ql(aA(i),"_resizeObserver",void 0),ql(aA(i),"_hasManuallyPaused",!1),ql(aA(i),"_stream",void 0),ql(aA(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":i.refreshRenderSize("the video started playing."),i._internalPlay();break;case"loadeddata":i._internalPlay();break;case"playing":i.logger.info("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"));break;case"pause":i.logger.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element pause")),i._needResume&&(i.logger.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element resume")),i._internalPlay(),i._needResume=!1)}})),ql(aA(i),"_internalPlay",(function(){var e,t;if(JN(i.engineId,"video _internalPlay",{paused:null===(e=i._videoDom)||void 0===e?void 0:e.paused,hasManuallyPaused:i._hasManuallyPaused}),!i._hasManuallyPaused&&null!==(t=i._videoDom)&&void 0!==t&&t.paused){var r=i._videoDom.play();null!=r&&r.then&&r.then((function(){var e;i.isLocal&&iL&&!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:Fg(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:MW.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:Fg(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:MW.AUTOPLAY_FAILED}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=KN(e),i.logger=new pM("Player",0,e);var a=t.userId,s=t.isScreen?ah.RENDER_MODE_FIT:ah.RENDER_MODE_HIDDEN;i.renderMode=void 0!==t.renderMode?t.renderMode:s,i._rotate=Number(t.rotation||0);var c="string"==typeof o?document.getElementById(o):o;if(!c)throw new bC(fC.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.isLocal||15!==(null==TL?void 0:TL[0])&&15!==bL||(i._safari15VideoTimer=window.setTimeout((function(){try{i._videoContainer.style.display="block",setTimeout((function(){i._videoContainer.style.display="flex"}),500)}catch(BZ){}}),1e3)),i}return Vh(n,[{key:"_initVideo",value:function(){var e,t,r=this;this._videoDom||(this._videoDom=CX("video",{style:{width:"100%",height:"100%"},attributes:PX}),this._videoDom.id=Fg(t="".concat(this.userId,"_")).call(t,TM()),this.setRenderMode(this.renderMode),this.mirror(this.mirrorType===lh.MIRROR_TYPE_RENDER));this._containerDom.appendChild(this._videoContainer),yI(e=[90,270]).call(e,this._rotate)>-1?(this._rotateDom=this._createRotationDiv(),this._rotateDom.appendChild(this._videoDom),this._videoContainer.appendChild(this._rotateDom)):(180===this._rotate&&(this._videoContainer.style.transform="rotate(180deg)"),this._videoContainer.appendChild(this._videoDom)),this._initListeners(),this._onLocalTrackMute=function(){r._needResume=!0},this._onInterruptionEnd=function(){r.logger.warn("resume player after iOS interruption"),r._internalPlay()},Mj.on(Dj.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),Mj.on(Dj.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),Mj.on(Dj.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd)}},{key:"_createRotationDiv",value:function(){var e=this,t=document.createElement("div");return t.style.transform="rotate(".concat(this._rotate,"deg)"),180!==this._rotate&&(t.style.position="absolute",this.refreshRenderSize("init"),window.ResizeObserver&&(this._resizeObserver=new ResizeObserver((function(){e.refreshRenderSize("the container size has changed.")})),this._resizeObserver.observe(this._containerDom))),t}},{key:"refreshRenderSize",value:function(e){if(this._rotateDom){var t,r;this.logger.print("refreshRenderSize","Because ".concat(e));var n=Number(window.getComputedStyle(this._containerDom).width.replace("px","")),i=Number(window.getComputedStyle(this._containerDom).height.replace("px","")),o=null===(t=this._videoDom)||void 0===t?void 0:t.videoWidth,a=null===(r=this._videoDom)||void 0===r?void 0:r.videoHeight;if(n&&i&&a&&o){var s,c;if(this.renderMode===ah.RENDER_MODE_FILL)s=i,c=n;else{var u=this.renderMode===ah.RENDER_MODE_HIDDEN?Math.max(n/a,i/o):Math.min(n/a,i/o);s=o*u,c=a*u}this._rotateDom.style.width="".concat(s,"px"),this._rotateDom.style.height="".concat(c,"px"),this._rotateDom.style.left="".concat((n-s)/2,"px"),this._rotateDom.style.top="".concat((i-c)/2,"px")}}}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&xX.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&&xX.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.removeEventListener(t,e.emitVideoEvent)}))}},{key:"setRenderMode",value:function(e){this.renderMode=e,this._videoDom&&(this.renderMode===ah.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this.renderMode===ah.RENDER_MODE_FILL?this._videoDom.style.objectFit="fill":this._videoDom.style.objectFit="cover")}},{key:"playVideo",value:(t=Ng(Pg().mark((function e(t,r){var n,i,o,a,s=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,this._stream=r,this.logger.info("playVideo","play video track: ".concat(this.userId)),!(o&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(n=t.preprocessingTrack)||void 0===n?void 0:n.id))){e.next=6;break}try{JN(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(BZ){}return e.abrupt("return");case 6:o||(this._initVideo(),o=this._videoDom),this.logger.info("playVideo","play video by dom: ".concat(null===(i=o)||void 0===i?void 0:i.id)),a=new MediaStream,t.videoPlayer=this,a.addTrack(t.preprocessingTrack),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&&GL.VIDEO_STALL&&r.startVideoStallObserve(this),this.played=!0;case 17:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"updateSrcObject",value:function(e){var t=e.preprocessingTrack;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(this.logger.info("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,this._hasManuallyPaused=!1,!this._videoDom)throw new bC(fC.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||hL?this._videoDom.play():jI.resolve()}},{key:"manuallyPause",value:function(){if(this.logger.print("Invoke VideoPlayer.manuallyPause",this.userId,this.isScreen),this.played){if(this._hasManuallyPaused=!0,!this._videoDom)throw new bC(fC.INVALID_PARAMS,"Player not found");return this._videoDom.pause()}}},{key:"mirror",value:function(e){var t;this.logger.info("mirror",Fg(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?lh.MIRROR_TYPE_RENDER:lh.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e,t,r,n=this,i=arguments.length>0&&void 0!==arguments[0]&&arguments[0],o=this._containerDom;(this.logger.info("stop","stop video track: ".concat(this.userId)),null===(e=this._stream)||void 0===e||e.stopVideoStallObserve(),this._videoDom)&&(i||(this._videoDom.srcObject=null),null!=o&&o.contains(this._videoContainer)&&o.removeChild(this._videoContainer),null===(t=this._videoContainer)||void 0===t||t.childNodes.forEach((function(e){e!==n._videoDom&&e!==n._rotateDom||n._videoContainer.removeChild(e)})),null!==(r=this._rotateDom)&&void 0!==r&&r.contains(this._videoDom)&&this._rotateDom.removeChild(this._videoDom));this._hasManuallyPaused=!1,this.played=!1}},{key:"destroy",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.logger.info("destroy","video player: ".concat(this.userId)),this.stop(t),null===(e=this._resizeObserver)||void 0===e||e.disconnect(),MA(NA(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),Mj.off(Dj.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),Mj.off(Dj.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),Mj.off(Dj.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}(yU.EventEmitter),NX=function(e){UA(i,e);var t,r,n=ew(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(Fh(this,i),ql(aA(r=n.call(this)),"_containerDom",void 0),ql(aA(r),"_audioDom",void 0),ql(aA(r),"_fakeAudioDom",void 0),ql(aA(r),"userId",void 0),ql(aA(r),"muted",!1),ql(aA(r),"_emitPlayFailed",!1),ql(aA(r),"played",!1),ql(aA(r),"isScreen",void 0),ql(aA(r),"_wechatTimer",void 0),ql(aA(r),"_edgeTimer",void 0),ql(aA(r),"_monitor",void 0),ql(aA(r),"logger",void 0),ql(aA(r),"_pasued",!0),ql(aA(r),"emitAudioEvent",(function(e){var t,n,i,o,a={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&&r.logger.info("AudioPlayerPlaying","[userId-".concat(r.userId,"] audio element playing")),"pause"===e.type)&&(r.logger.info("AudioPlayerPause","[userId-".concat(r.userId,"] audio element pause")),!r._pasued&&null!==(i=r._audioDom)&&void 0!==i&&null!==(o=i.srcObject)&&void 0!==o&&o.active&&r._internalPlay());_L&&hL&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),pL&&cL&&"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",a)})),ql(aA(r),"_internalPlay",(function(){var e,t;if(JN(r.engineId,"audio _internalPlay",{paused:null===(e=r._audioDom)||void 0===e?void 0:e.paused,userId:r.userId,screen:r.isScreen}),null!==(t=r._audioDom)&&void 0!==t&&t.paused)try{var n,i=r._audioDom.play(),o=Fj.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:Fg(n=Fg(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&&(_L&&pL&&(i=i.then((function(){return new jI((function(e){setTimeout(Ng(Pg().mark((function t(){var n;return Pg().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(){JN(r.engineId,"_internalPlay successfully",{userId:r.userId,screen:r.isScreen}),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:Fg(n=Fg(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:MW.AUTOPLAY_FAILED})})))}catch(l){var c,u,d;r._autoPlayError(l),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:Fg(u=Fg(d="audio autoplay failed, userId: ".concat(r.userId,": ")).call(d,l.message," ")).call(u,l.name),error_code:MW.AUTOPLAY_FAILED})}})),r.engineId=e,a){var u=document.getElementById(a);if(!u)throw new bC(fC.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=KN(e),r.logger=new pM("Player",0,e),r._initAudio(),r}return Vh(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=CX("audio",{style:{display:"none"},attributes:OX}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Fg(e="".concat(this.userId,"_")).call(e,TM()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&xX.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&&(xX.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=Ng(Pg().mark((function e(t){var r,n,i,o,a,s=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("playAudio","play audio track: ".concat(this.userId)),!((o=this._audioDom)&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(r=t.preprocessingTrack)||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 wH?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.originTrack]),a.addTrack(t.preprocessingTrack)):a.addTrack(t.preprocessingTrack),_L&&pL&&(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 bC(fC.INVALID_PARAMS,"Player not found");this._pasued=!0,this._audioDom.pause()}},{key:"manuallyPause",value:function(){return this.pause()}},{key:"manuallyPlay",value:function(){var e,t=this;if(this.logger.info("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new bC(fC.INVALID_PARAMS,"Player not found");if(!this.played)return jI.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=Fj.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?jI.all(r):jI.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,Oj.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=qg(r).call(r,(function(e){return e.deviceId})),Xy(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;this.logger.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(){this.logger.info("destroy","audio player: ".concat(this.userId)),this.stop(),MA(NA(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom),this._edgeTimer&&clearTimeout(this._edgeTimer)}}]),i}(yU.EventEmitter);function MX(e,t,r,n){var i=function(){var e=Ng(Pg().mark((function e(t,i){var o,a;return Pg().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:aI(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 DX&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof NX&&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))})),jI.all(o)}var LX=o,UX=ht("iterator"),VX=!LX((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r=new URLSearchParams("a=1&a=2&b=3"),n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),r.delete("a",2),r.delete("b",void 0),!e.toJSON||!r.has("a",1)||r.has("a",2)||!r.has("a",void 0)||r.has("b")||!t.size&&true||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[UX]||"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"!==n||"x"!==new URL("http://x",void 0).host})),FX=wr,BX=i,jX=P,HX=f,GX=C,zX=VX,KX=vi,WX=fi,XX=ok,YX=Bi,qX=uu,JX=ro,QX=kv,ZX=A,$X=Ze,eY=Jt,tY=mn,rY=rr,nY=ee,iY=Sn,oY=Wn,aY=F,sY=Ap,cY=Sp,uY=Dv,dY=vw,lY=ht("iterator"),hY="URLSearchParams",pY=hY+"Iterator",vY=JX.set,_Y=JX.getterFor(hY),fY=JX.getterFor(pY),mY=Object.getOwnPropertyDescriptor,gY=function(e){if(!GX)return BX[e];var t=mY(BX,e);return t&&t.value},yY=gY("fetch"),SY=gY("Request"),bY=gY("Headers"),kY=SY&&SY.prototype,EY=bY&&bY.prototype,TY=BX.RegExp,IY=BX.TypeError,RY=BX.decodeURIComponent,AY=BX.encodeURIComponent,wY=HX("".charAt),CY=HX([].join),xY=HX([].push),OY=HX("".replace),PY=HX([].shift),DY=HX([].splice),NY=HX("".split),MY=HX("".slice),LY=/\+/g,UY=Array(4),VY=function(e){return UY[e-1]||(UY[e-1]=TY("((?:%[\\da-f]{2}){"+e+"})","gi"))},FY=function(e){try{return RY(e)}catch(BZ){return e}},BY=function(e){var t=OY(e,LY," "),r=4;try{return RY(t)}catch(BZ){for(;r;)t=OY(t,VY(r--),FY);return t}},jY=/[!'()~]|%20/g,HY={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},GY=function(e){return HY[e]},zY=function(e){return OY(AY(e),jY,GY)},KY=qX((function(e,t){vY(this,{type:pY,iterator:sY(_Y(e).entries),kind:t})}),"Iterator",(function(){var e=fY(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),WY=function(e){this.entries=[],this.url=null,void 0!==e&&(nY(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===wY(e,0)?MY(e,1):e:iY(e)))};WY.prototype={type:hY,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=cY(e);if(c)for(r=(t=sY(e,c)).next;!(n=jX(r,t)).done;){if(o=(i=sY(rY(n.value))).next,(a=jX(o,i)).done||(s=jX(o,i)).done||!jX(o,i).done)throw IY("Expected sequence with length 2");xY(this.entries,{key:iY(a.value),value:iY(s.value)})}else for(var u in e)$X(e,u)&&xY(this.entries,{key:u,value:iY(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=NY(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=NY(t,"="),xY(this.entries,{key:BY(PY(r)),value:BY(CY(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],xY(r,zY(e.key)+"="+zY(e.value));return CY(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var XY=function(){QX(this,YY);var e=vY(this,new WY(arguments.length>0?arguments[0]:void 0));GX||(this.size=e.entries.length)},YY=XY.prototype;if(XX(YY,{append:function(e,t){var r=_Y(this);uY(arguments.length,2),xY(r.entries,{key:iY(e),value:iY(t)}),GX||this.length++,r.updateURL()},delete:function(e){for(var t=_Y(this),r=uY(arguments.length,1),n=t.entries,i=iY(e),o=r<2?void 0:arguments[1],a=void 0===o?o:iY(o),s=0;s<n.length;){var c=n[s];if(c.key!==i||void 0!==a&&c.value!==a)s++;else if(DY(n,s,1),void 0!==a)break}GX||(this.size=n.length),t.updateURL()},get:function(e){var t=_Y(this).entries;uY(arguments.length,1);for(var r=iY(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){var t=_Y(this).entries;uY(arguments.length,1);for(var r=iY(e),n=[],i=0;i<t.length;i++)t[i].key===r&&xY(n,t[i].value);return n},has:function(e){for(var t=_Y(this).entries,r=uY(arguments.length,1),n=iY(e),i=r<2?void 0:arguments[1],o=void 0===i?i:iY(i),a=0;a<t.length;){var s=t[a++];if(s.key===n&&(void 0===o||s.value===o))return!0}return!1},set:function(e,t){var r=_Y(this);uY(arguments.length,1);for(var n,i=r.entries,o=!1,a=iY(e),s=iY(t),c=0;c<i.length;c++)(n=i[c]).key===a&&(o?DY(i,c--,1):(o=!0,n.value=s));o||xY(i,{key:a,value:s}),GX||(this.size=i.length),r.updateURL()},sort:function(){var e=_Y(this);dY(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=_Y(this).entries,n=eY(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 KY(this,"keys")},values:function(){return new KY(this,"values")},entries:function(){return new KY(this,"entries")}},{enumerable:!0}),KX(YY,lY,YY.entries,{name:"entries"}),KX(YY,"toString",(function(){return _Y(this).serialize()}),{enumerable:!0}),GX&&WX(YY,"size",{get:function(){return _Y(this).entries.length},configurable:!0,enumerable:!0}),YX(XY,hY),FX({global:!0,constructor:!0,forced:!zX},{URLSearchParams:XY}),!zX&&ZX(bY)){var qY=HX(EY.has),JY=HX(EY.set),QY=function(e){if(nY(e)){var t,r=e.body;if(tY(r)===hY)return t=e.headers?new bY(e.headers):new bY,qY(t,"content-type")||JY(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),oY(e,{body:aY(0,iY(r)),headers:aY(0,t)})}return e};if(ZX(yY)&&FX({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return yY(e,arguments.length>1?QY(arguments[1]):{})}}),ZX(SY)){var ZY=function(e){return QX(this,kY),new SY(e,arguments.length>1?QY(arguments[1]):{})};kY.constructor=ZY,ZY.prototype=kY,FX({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:ZY})}}var $Y,eq={URLSearchParams:XY,getState:_Y},tq=f,rq=2147483647,nq=/[^\0-\u007E]/,iq=/[.\u3002\uFF0E\uFF61]/g,oq="Overflow: input needs wider integers to process",aq=RangeError,sq=tq(iq.exec),cq=Math.floor,uq=String.fromCharCode,dq=tq("".charCodeAt),lq=tq([].join),hq=tq([].push),pq=tq("".replace),vq=tq("".split),_q=tq("".toLowerCase),fq=function(e){return e+22+75*(e<26)},mq=function(e,t,r){var n=0;for(e=r?cq(e/700):e>>1,e+=cq(e/t);e>455;)e=cq(e/35),n+=36;return cq(n+36*e/(e+38))},gq=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=dq(e,r++);if(i>=55296&&i<=56319&&r<n){var o=dq(e,r++);56320==(64512&o)?hq(t,((1023&i)<<10)+(1023&o)+65536):(hq(t,i),r--)}else hq(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&&hq(t,uq(n));var c=t.length,u=c;for(c&&hq(t,"-");u<i;){var d=rq;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=u+1;if(d-o>cq((rq-a)/l))throw aq(oq);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>rq)throw aq(oq);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 _=h-v,f=36-v;hq(t,uq(fq(v+_%f))),h=cq(_/f),p+=36}hq(t,uq(fq(h))),s=mq(a,l,u===c),a=0,u++}}a++,o++}return lq(t,"")},yq=wr,Sq=C,bq=VX,kq=i,Eq=Jt,Tq=f,Iq=vi,Rq=fi,Aq=kv,wq=Ze,Cq=kT,xq=ly,Oq=ai,Pq=Ll.codeAt,Dq=function(e){var t,r,n=[],i=vq(pq(_q(e),iq,"."),".");for(t=0;t<i.length;t++)r=i[t],hq(n,sq(nq,r)?"xn--"+gq(r):r);return lq(n,".")},Nq=Sn,Mq=Bi,Lq=Dv,Uq=eq,Vq=ro,Fq=Vq.set,Bq=Vq.getterFor("URL"),jq=Uq.URLSearchParams,Hq=Uq.getState,Gq=kq.URL,zq=kq.TypeError,Kq=kq.parseInt,Wq=Math.floor,Xq=Math.pow,Yq=Tq("".charAt),qq=Tq(/./.exec),Jq=Tq([].join),Qq=Tq(1..toString),Zq=Tq([].pop),$q=Tq([].push),eJ=Tq("".replace),tJ=Tq([].shift),rJ=Tq("".split),nJ=Tq("".slice),iJ=Tq("".toLowerCase),oJ=Tq([].unshift),aJ="Invalid scheme",sJ="Invalid host",cJ="Invalid port",uJ=/[a-z]/i,dJ=/[\d+-.a-z]/i,lJ=/\d/,hJ=/^0x/i,pJ=/^[0-7]+$/,vJ=/^\d+$/,_J=/^[\da-f]+$/i,fJ=/[\0\t\n\r #%/:<>?@[\\\]^|]/,mJ=/[\0\t\n\r #/:<>?@[\\\]^|]/,gJ=/^[\u0000-\u0020]+/,yJ=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,SJ=/[\t\n\r]/g,bJ=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)oJ(t,e%256),e=Wq(e/256);return Jq(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+=Qq(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},kJ={},EJ=Cq({},kJ,{" ":1,'"':1,"<":1,">":1,"`":1}),TJ=Cq({},EJ,{"#":1,"?":1,"{":1,"}":1}),IJ=Cq({},TJ,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),RJ=function(e,t){var r=Pq(e,0);return r>32&&r<127&&!wq(t,e)?e:encodeURIComponent(e)},AJ={ftp:21,file:null,http:80,https:443,ws:80,wss:443},wJ=function(e,t){var r;return 2===e.length&&qq(uJ,Yq(e,0))&&(":"===(r=Yq(e,1))||!t&&"|"===r)},CJ=function(e){var t;return e.length>1&&wJ(nJ(e,0,2))&&(2===e.length||"/"===(t=Yq(e,2))||"\\"===t||"?"===t||"#"===t)},xJ=function(e){return"."===e||"%2e"===iJ(e)},OJ={},PJ={},DJ={},NJ={},MJ={},LJ={},UJ={},VJ={},FJ={},BJ={},jJ={},HJ={},GJ={},zJ={},KJ={},WJ={},XJ={},YJ={},qJ={},JJ={},QJ={},ZJ=function(e,t,r){var n,i,o,a=Nq(e);if(t){if(i=this.parse(a))throw zq(i);this.searchParams=null}else{if(void 0!==r&&(n=new ZJ(r,!0)),i=this.parse(a,null,n))throw zq(i);(o=Hq(new jq)).bindURL(this),this.searchParams=o}};ZJ.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||OJ,d=0,l="",h=!1,p=!1,v=!1;for(e=Nq(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=eJ(e,gJ,""),e=eJ(e,yJ,"$1")),e=eJ(e,SJ,""),n=xq(e);d<=n.length;){switch(i=n[d],u){case OJ:if(!i||!qq(uJ,i)){if(t)return aJ;u=DJ;continue}l+=iJ(i),u=PJ;break;case PJ:if(i&&(qq(dJ,i)||"+"===i||"-"===i||"."===i))l+=iJ(i);else{if(":"!==i){if(t)return aJ;l="",u=DJ,d=0;continue}if(t&&(c.isSpecial()!==wq(AJ,l)||"file"===l&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=l,t)return void(c.isSpecial()&&AJ[c.scheme]===c.port&&(c.port=null));l="","file"===c.scheme?u=zJ:c.isSpecial()&&r&&r.scheme===c.scheme?u=NJ:c.isSpecial()?u=VJ:"/"===n[d+1]?(u=MJ,d++):(c.cannotBeABaseURL=!0,$q(c.path,""),u=qJ)}break;case DJ:if(!r||r.cannotBeABaseURL&&"#"!==i)return aJ;if(r.cannotBeABaseURL&&"#"===i){c.scheme=r.scheme,c.path=Oq(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=QJ;break}u="file"===r.scheme?zJ:LJ;continue;case NJ:if("/"!==i||"/"!==n[d+1]){u=LJ;continue}u=FJ,d++;break;case MJ:if("/"===i){u=BJ;break}u=YJ;continue;case LJ:if(c.scheme=r.scheme,i===$Y)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=Oq(r.path),c.query=r.query;else if("/"===i||"\\"===i&&c.isSpecial())u=UJ;else if("?"===i)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=Oq(r.path),c.query="",u=JJ;else{if("#"!==i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=Oq(r.path),c.path.length--,u=YJ;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=Oq(r.path),c.query=r.query,c.fragment="",u=QJ}break;case UJ:if(!c.isSpecial()||"/"!==i&&"\\"!==i){if("/"!==i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=YJ;continue}u=BJ}else u=FJ;break;case VJ:if(u=FJ,"/"!==i||"/"!==Yq(l,d+1))continue;d++;break;case FJ:if("/"!==i&&"\\"!==i){u=BJ;continue}break;case BJ:if("@"===i){h&&(l="%40"+l),h=!0,o=xq(l);for(var _=0;_<o.length;_++){var f=o[_];if(":"!==f||v){var m=RJ(f,IJ);v?c.password+=m:c.username+=m}else v=!0}l=""}else if(i===$Y||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(h&&""===l)return"Invalid authority";d-=xq(l).length+1,l="",u=jJ}else l+=i;break;case jJ:case HJ:if(t&&"file"===c.scheme){u=WJ;continue}if(":"!==i||p){if(i===$Y||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(c.isSpecial()&&""===l)return sJ;if(t&&""===l&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(l))return a;if(l="",u=XJ,t)return;continue}"["===i?p=!0:"]"===i&&(p=!1),l+=i}else{if(""===l)return sJ;if(a=c.parseHost(l))return a;if(l="",u=GJ,t===HJ)return}break;case GJ:if(!qq(lJ,i)){if(i===$Y||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()||t){if(""!==l){var g=Kq(l,10);if(g>65535)return cJ;c.port=c.isSpecial()&&g===AJ[c.scheme]?null:g,l=""}if(t)return;u=XJ;continue}return cJ}l+=i;break;case zJ:if(c.scheme="file","/"===i||"\\"===i)u=KJ;else{if(!r||"file"!==r.scheme){u=YJ;continue}switch(i){case $Y:c.host=r.host,c.path=Oq(r.path),c.query=r.query;break;case"?":c.host=r.host,c.path=Oq(r.path),c.query="",u=JJ;break;case"#":c.host=r.host,c.path=Oq(r.path),c.query=r.query,c.fragment="",u=QJ;break;default:CJ(Jq(Oq(n,d),""))||(c.host=r.host,c.path=Oq(r.path),c.shortenPath()),u=YJ;continue}}break;case KJ:if("/"===i||"\\"===i){u=WJ;break}r&&"file"===r.scheme&&!CJ(Jq(Oq(n,d),""))&&(wJ(r.path[0],!0)?$q(c.path,r.path[0]):c.host=r.host),u=YJ;continue;case WJ:if(i===$Y||"/"===i||"\\"===i||"?"===i||"#"===i){if(!t&&wJ(l))u=YJ;else if(""===l){if(c.host="",t)return;u=XJ}else{if(a=c.parseHost(l))return a;if("localhost"===c.host&&(c.host=""),t)return;l="",u=XJ}continue}l+=i;break;case XJ:if(c.isSpecial()){if(u=YJ,"/"!==i&&"\\"!==i)continue}else if(t||"?"!==i)if(t||"#"!==i){if(i!==$Y&&(u=YJ,"/"!==i))continue}else c.fragment="",u=QJ;else c.query="",u=JJ;break;case YJ:if(i===$Y||"/"===i||"\\"===i&&c.isSpecial()||!t&&("?"===i||"#"===i)){if(".."===(s=iJ(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"===i||"\\"===i&&c.isSpecial()||$q(c.path,"")):xJ(l)?"/"===i||"\\"===i&&c.isSpecial()||$q(c.path,""):("file"===c.scheme&&!c.path.length&&wJ(l)&&(c.host&&(c.host=""),l=Yq(l,0)+":"),$q(c.path,l)),l="","file"===c.scheme&&(i===$Y||"?"===i||"#"===i))for(;c.path.length>1&&""===c.path[0];)tJ(c.path);"?"===i?(c.query="",u=JJ):"#"===i&&(c.fragment="",u=QJ)}else l+=RJ(i,TJ);break;case qJ:"?"===i?(c.query="",u=JJ):"#"===i?(c.fragment="",u=QJ):i!==$Y&&(c.path[0]+=RJ(i,kJ));break;case JJ:t||"#"!==i?i!==$Y&&("'"===i&&c.isSpecial()?c.query+="%27":c.query+="#"===i?"%23":RJ(i,kJ)):(c.fragment="",u=QJ);break;case QJ:i!==$Y&&(c.fragment+=RJ(i,EJ))}d++}},parseHost:function(e){var t,r,n;if("["===Yq(e,0)){if("]"!==Yq(e,e.length-1))return sJ;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 Yq(e,l)};if(":"===h()){if(":"!==Yq(e,1))return;l+=2,d=++u}for(;h();){if(8===u)return;if(":"!==h()){for(t=r=0;r<4&&qq(_J,h());)t=16*t+Kq(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(!qq(lJ,h()))return;for(;qq(lJ,h());){if(o=Kq(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}(nJ(e,1,-1)),!t)return sJ;this.host=t}else if(this.isSpecial()){if(e=Dq(e),qq(fJ,e))return sJ;if(t=function(e){var t,r,n,i,o,a,s,c=rJ(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"===Yq(i,0)&&(o=qq(hJ,i)?16:8,i=nJ(i,8===o?1:2)),""===i)a=0;else{if(!qq(10===o?vJ:8===o?pJ:_J,i))return e;a=Kq(i,o)}$q(r,a)}for(n=0;n<t;n++)if(a=r[n],n===t-1){if(a>=Xq(256,5-t))return null}else if(a>255)return null;for(s=Zq(r),n=0;n<r.length;n++)s+=r[n]*Xq(256,3-n);return s}(e),null===t)return sJ;this.host=t}else{if(qq(mJ,e))return sJ;for(t="",r=xq(e),n=0;n<r.length;n++)t+=RJ(r[n],kJ);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return wq(AJ,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&wJ(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+=bJ(i),null!==o&&(u+=":"+o)):"file"===t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+Jq(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw zq(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new $J(e.path[0]).origin}catch(BZ){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+bJ(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Nq(e)+":",OJ)},getUsername:function(){return this.username},setUsername:function(e){var t=xq(Nq(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=RJ(t[r],IJ)}},getPassword:function(){return this.password},setPassword:function(e){var t=xq(Nq(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=RJ(t[r],IJ)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?bJ(e):bJ(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,jJ)},getHostname:function(){var e=this.host;return null===e?"":bJ(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,HJ)},getPort:function(){var e=this.port;return null===e?"":Nq(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=Nq(e))?this.port=null:this.parse(e,GJ))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+Jq(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,XJ))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=Nq(e))?this.query=null:("?"===Yq(e,0)&&(e=nJ(e,1)),this.query="",this.parse(e,JJ)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=Nq(e))?("#"===Yq(e,0)&&(e=nJ(e,1)),this.fragment="",this.parse(e,QJ)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var $J=function(e){var t=Aq(this,eQ),r=Lq(arguments.length,1)>1?arguments[1]:void 0,n=Fq(t,new ZJ(e,!1,r));Sq||(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())},eQ=$J.prototype,tQ=function(e,t){return{get:function(){return Bq(this)[e]()},set:t&&function(e){return Bq(this)[t](e)},configurable:!0,enumerable:!0}};if(Sq&&(Rq(eQ,"href",tQ("serialize","setHref")),Rq(eQ,"origin",tQ("getOrigin")),Rq(eQ,"protocol",tQ("getProtocol","setProtocol")),Rq(eQ,"username",tQ("getUsername","setUsername")),Rq(eQ,"password",tQ("getPassword","setPassword")),Rq(eQ,"host",tQ("getHost","setHost")),Rq(eQ,"hostname",tQ("getHostname","setHostname")),Rq(eQ,"port",tQ("getPort","setPort")),Rq(eQ,"pathname",tQ("getPathname","setPathname")),Rq(eQ,"search",tQ("getSearch","setSearch")),Rq(eQ,"searchParams",tQ("getSearchParams")),Rq(eQ,"hash",tQ("getHash","setHash"))),Iq(eQ,"toJSON",(function(){return Bq(this).serialize()}),{enumerable:!0}),Iq(eQ,"toString",(function(){return Bq(this).serialize()}),{enumerable:!0}),Gq){var rQ=Gq.createObjectURL,nQ=Gq.revokeObjectURL;rQ&&Iq($J,"createObjectURL",Eq(rQ,Gq)),nQ&&Iq($J,"revokeObjectURL",Eq(nQ,Gq))}Mq($J,"URL"),yq({global:!0,constructor:!0,forced:!bq,sham:!Sq},{URL:$J});var iQ=wr,oQ=o,aQ=Dv,sQ=Sn,cQ=VX,uQ=ae("URL");iQ({target:"URL",stat:!0,forced:!(cQ&&oQ((function(){uQ.canParse()})))},{canParse:function(e){var t=aQ(arguments.length,1),r=sQ(e),n=t<2||void 0===arguments[1]?void 0:sQ(arguments[1]);try{return!!new uQ(r,n)}catch(BZ){return!1}}});var dQ=r(te.URL),lQ=function(){var e=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(dQ.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)}}(),hQ=uT,pQ=HI,vQ=function(e,t,r,n){for(var i,o=n>1?void 0:n?pQ(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&&hQ(t,r,o),o},_Q=function(){function e(t,r){Fh(this,e),ql(this,"_sharedAudioContext",new AudioContext),ql(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),ql(this,"_localGainNode",this._sharedAudioContext.createGain()),ql(this,"_bufferGainNode",this._sharedAudioContext.createGain()),ql(this,"_audioBufferSource",void 0),ql(this,"_localSource",void 0),ql(this,"_context",void 0),ql(this,"_failedAudioList",[]),ql(this,"_startingIds",new cT),ql(this,"_revokeURLs",new AB),ql(this,"mixingMap",new cT),ql(this,"resourcesCache",new cT),ql(this,"volumeConfig",new cT),ql(this,"cachedBuffer",[]),ql(this,"id","AudioMixingManager"),this.engineId=r,this._context=t,this._localGainNode.gain.value=1}var t,r,n;return Vh(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=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m=this;return Pg().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,eU(o=n.type,"mixingType",hW(Dh)),a=this._context.getLocalAudioTrack()){e.next=9;break}return e.abrupt("return");case 9:if((s=a.preprocessingTrack)&&this.mixMediaStream(new MediaStream([s])),a.once("needReplaceTrack",(function(){m.mixMediaStream(new MediaStream([a.preprocessingTrack]))})),null!=(c=this.mixingMap.get(t))&&c.audioNode){c.audioNode.pause(),this._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_STOPPED,error:mC.AUDIO_MIXING_ERROR_OK});try{c.gainNode.disconnect(this._audioDestination),c.audioSource.disconnect(c.gainNode)}catch(g){}}if(!(d=this.resourcesCache.get(t))||d.filePath!==r){e.next=19;break}u=d.getAudioNode(),e.next=32;break;case 19:return e.next=21,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw m._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_FAILED,error:mC.AUDIO_MIXING_ERROR_START_FAILED}),new bC(fC.LOAD_RESOURCES_FAILED,e.statusText)}));case 21:return l=e.sent,FT(r).call(r,"mp3")?h={type:"audio/mpeg"}:FT(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=25,lQ(l,h);case 25:if(e.sent){e.next=29;break}throw this._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_FAILED,error:mC.AUDIO_MIXING_ERROR_START_FAILED}),new bC(fC.LOAD_RESOURCES_FAILED,"invalid audio resource");case 29:(u=new Audio).crossOrigin="anonymous",u.src=dQ.createObjectURL(new Blob([l],h));case 32: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:Nh.AUDIO_MIXING_STATE_FINISHED,error:mC.AUDIO_MIXING_ERROR_OK}))}),e.prev=33,e.next=36,u.play();case 36:e.next=43;break;case 38:e.prev=38,e.t0=e.catch(33),console.error(e.t0),this._failedAudioList.push(u),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:sh.STREAM_INDEX_MAIN,mediaType:ch.AUDIO});case 43:if(this._startingIds.delete(t),v=this._sharedAudioContext.createMediaElementSource(u),_=this._sharedAudioContext.createGain(),f=this.volumeConfig.get(t),_.gain.value=f?f/100:1,v.connect(_).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:v,audioNode:u,gainNode:_,type:"file"}),o===Dh.PUBLISH)try{_.disconnect(this._sharedAudioContext.destination)}catch(g){}else _.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_PLAYING,error:mC.AUDIO_MIXING_ERROR_OK});case 53:case"end":return e.stop()}}),e,this,[[33,38]])}))),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:Nh.AUDIO_MIXING_STATE_STOPPED,error:mC.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Nh.AUDIO_MIXING_STATE_PAUSED,error:mC.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:Nh.AUDIO_MIXING_STATE_PLAYING,error:mC.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=Ng(Pg().mark((function e(t,r){var n,i,o=this;return Pg().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 bC(fC.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_FAILED,error:mC.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof bC)throw e;throw new bC(fC.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,FT(r).call(r,"mp3")?i={type:"audio/mpeg"}:FT(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,lQ(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_FAILED,error:mC.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new bC(fC.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_PRELOADED,error:mC.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=dQ.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new jI((function(e){var r=dQ.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)),dQ.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){eU(e,"type",hW(Dh));var t=this._context.getLocalAudioTrack();if(t){var r=t.preprocessingTrack;if(r&&this.mixMediaStream(new MediaStream([r])),e===Dh.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:Nh.AUDIO_MIXING_STATE_PCM_ENABLED,error:mC.AUDIO_MIXING_ERROR_OK})}}},{key:"disableAudioMixingBuffer",value:function(){if(this.cachedBuffer=[],this._audioBufferSource){try{this._audioBufferSource.onended=null,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:Nh.AUDIO_MIXING_STATE_PCM_DISABLED,error:mC.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=Ng(Pg().mark((function e(){var t,r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=my(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:sh.STREAM_INDEX_MAIN,mediaType:ch.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 cT,this._revokeURLs.forEach((function(e){dQ.revokeObjectURL(e)}))}}]),e}();vQ([XN("id","filePath","options")],_Q.prototype,"startAudioMixing",1),vQ([XN("id")],_Q.prototype,"stopAudioMixing",1),vQ([XN("id")],_Q.prototype,"pauseAudioMixing",1),vQ([XN("id")],_Q.prototype,"resumeAudioMixing",1),vQ([XN("id")],_Q.prototype,"preloadAudioMixing",1),vQ([XN("id")],_Q.prototype,"unloadAudioMixing",1),vQ([XN("id")],_Q.prototype,"getAudioMixingVolume",1),vQ([XN("id","volume")],_Q.prototype,"setAudioMixingVolume",1),vQ([XN("id")],_Q.prototype,"getAudioMixingDuration",1),vQ([XN("id")],_Q.prototype,"getAudioMixingCurrentPosition",1),vQ([XN("id","position")],_Q.prototype,"setAudioMixingPosition",1),vQ([XN("type")],_Q.prototype,"enableAudioMixingBuffer",1),vQ([XN()],_Q.prototype,"disableAudioMixingBuffer",1),vQ([XN("buffer")],_Q.prototype,"pushAudioMixingBuffer",1);var fQ=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(fQ||{}),mQ=function(e){UA(c,e);var t,r,n,i,o,a,s=ew(c);function c(e){var t;return Fh(this,c),ql(aA(t=s.call(this)),"_dataChannelSignal",void 0),ql(aA(t),"_handler",void 0),ql(aA(t),"_dataChannelSignalState",rX.DISCONNECTED),ql(aA(t),"_loginSessionId",null),ql(aA(t),"_userId",null),ql(aA(t),"_token",null),ql(aA(t),"_loginResolveCallback",void 0),ql(aA(t),"_loginRejectCallback",void 0),ql(aA(t),"_wait_login_token",!1),ql(aA(t),"_serverParamsCache",void 0),ql(aA(t),"id",void 0),ql(aA(t),"_connectionManager",void 0),ql(aA(t),"isReconnecting",!1),ql(aA(t),"logger",void 0),t._ctx=e,t.id=e.id,t.logger=new pM("RTMClient",1,e.id),t._connectionManager=new QW(e),t._addConnectHandler(),t}return Vh(c,[{key:"login",value:function(e,t){var r=this;return new jI((function(n,i){var o;if(r.logger.info("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new bC(fC.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new bC(fC.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=KN(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=Ng(Pg().mark((function e(){var t;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new bC(fC.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:qW.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=Ng(Pg().mark((function e(t){var r=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new jI((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=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new bC(fC.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:qW.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=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new bC(fC.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=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,$L(t,"signature"),$L(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new bC(fC.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:qW.C2RTM}).catch((function(e){throw new bC(fC.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=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new bC(fC.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:zW.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;this.logger.info("destroy","invoke."),MA(NA(c.prototype),"removeAllListeners",this).call(this),this._loginResolveCallback&&this._loginRejectCallback&&(this._loginRejectCallback(new bC(fC.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=TM();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:wM.token2auth(this._ctx.appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:GL.VERSION,deviceId:LL.getDeviceId(),appId:this._ctx.appId,userId:this._userId}},{functionType:qW.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,MN.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=fC.INVALID_PARAMS,n="Invalid userId"):(r=fC.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=fC.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new bC(r,a||n))})).finally((function(){delete e._loginResolveCallback,delete e._loginRejectCallback}))}}},{key:"connect",value:function(){var e=this;return new jI((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!==rX.CONNECTED)throw new bC(fC.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n;e._dataChannelSignalState=rX.CONNECTED,e.logger.info("connectStateChange","connected"),null===(r=e._handler)||void 0===r||r.destroy(),null===(n=e._dataChannelSignal)||void 0===n||n.destroy(),e._handler=gW(e._ctx,t.pc),e._dataChannelSignal=t.signaling,e._addSignalEventHandler(),e.isReconnecting&&e._login()})),this._connectionManager.on("disconnected",(function(t){e._dataChannelSignalState=rX.DISCONNECTED,e.logger.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=rX.CONNECTING,e.logger.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=rX.CONNECTING,e.logger.warn("connectStateChange","reconnecting")}))}},{key:"_addSignalEventHandler",value:function(){var e,t,r,n=this;null===(e=this._dataChannelSignal)||void 0===e||e.on(bW.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(bW.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(bW.USER_DISCONNECTION,(function(){n.emit("onUserDisconnection"),n._clearState()}))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,MN.setRtsSessionId(this.id,"")}}]),c}(yU.EventEmitter),gQ=function(){function e(t){Fh(this,e),ql(this,"_roomId",void 0),ql(this,"_constraints",{}),ql(this,"_profile",void 0),ql(this,"_customMaxBitrate",0),this._appId=t}return Vh(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=LL.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=LL.getEngineWebConfig(this._appId,this._roomId||"").audio_encode,n=this.getConstraints(),i=n.sampleRate,o=n.channelCount,a="number"==typeof i?i:null==i?void 0:i.exact,s="number"==typeof o?o:null==o?void 0:o.exact,c={};t.split(";").forEach((function(e){var t=gy(e.split("="),2),r=t[0],n=t[1];r&&n&&(c[r]=n)}));var u=(null==r?void 0:r.bitrate)||this._customMaxBitrate||this._getConfigByAudioProfile().bitrate;u&&(c.maxaveragebitrate=u);var d=(null==r?void 0:r.enc_sample_rate)||a;d&&(c["sprop-maxcapturerate"]=d);var l=(null==r?void 0:r.playback_rate)||a;return l&&(c.maxplaybackrate=l),(s&&s>1||null!=r&&r.stereo)&&(c["sprop-stereo"]=1,c.stereo=1),null!=r&&r.dtx&&(c.usedtx=1),qg(e=MS(c)).call(e,(function(e){var t;return Fg(t="".concat(e,"=")).call(t,c[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=Ql(Ql({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=Ql({},this._constraints),t=LL.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;XM(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),XM(null==t?void 0:t.channel)||(e.channelCount=t.channel),XM(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),XM(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),XM(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return XM(e.sampleRate)&&!XM(n)&&(e.sampleRate=n),XM(e.channelCount)&&!XM(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case Eh.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case Eh.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case Eh.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case Eh.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case Eh.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),yQ=function(e){UA(o,e);var t,r,n,i=ew(o);function o(e,t,r){var n,a=r.businessId;return Fh(this,o),ql(aA(n=i.call(this)),"_mediaServerClient",void 0),ql(aA(n),"_appId",void 0),ql(aA(n),"remoteStreams",void 0),ql(aA(n),"_businessId",void 0),ql(aA(n),"_ctx",void 0),n.id=e,n._appId=t,n.remoteStreams=new cT,n._businessId=a,n._ctx={id:n.id,appId:n._appId,avSync:!0,audioProfileManager:new gQ(n._appId),useCloudProxy:!1,userPriority:new cT,joinRoomConfig:new VL(n.id)},n}return Vh(o,[{key:"connect",value:(n=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new iX(this._ctx),this._mediaServerClient.publicStream=!0,this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=6,this._mediaServerClient.connect();case 6:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=Ng(Pg().mark((function e(t){var r,n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new bC(fC.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new qH(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=WM(e),i=0;i<t.seiCount;i++)n.emit(CW.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 cT,null===(e=this._mediaServerClient)||void 0===e||e.destroy(),this.removeAllListeners()}},{key:"_handleReconnected",value:(t=Ng(Pg().mark((function e(){var t,r,n,i=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=my(this.remoteStreams);try{for(n=function(){var e=gy(r.value,2),t=e[0],n=e[1];n.clean(),n.statsReport.unsubscribe(),i.remoteStreams.delete(t),i.startPlayPublicStream(t).then((function(){var e=i.remoteStreams.get(t);i.safeEmit(CW.RESUBSCRIBE,{stream:e})}))},t.s();!(r=t.n()).done;)n()}catch(jZ){t.e(jZ)}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("connectSuccess",(function(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).reconnect&&r._handleReconnected()})),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}(kU),SQ=new pM("AudioDeviceManager",1),bQ=function(e){UA(c,e);var t,r,n,i,o,a,s=ew(c);function c(e){var t;return Fh(this,c),ql(aA(t=s.call(this)),"_audioLevelFetcher",void 0),ql(aA(t),"_playbackDeviceTestTimer",void 0),ql(aA(t),"_audioElement",void 0),ql(aA(t),"_audioTrack",void 0),ql(aA(t),"_mediaRecorder",void 0),ql(aA(t),"_recoderTimer",void 0),ql(aA(t),"_isAudioPlaybackDeviceTesting",!1),ql(aA(t),"_isAudioDeviceRecordTesting",!1),ql(aA(t),"_audioCaptureAndRecoderResolve",void 0),ql(aA(t),"_onAutoplayFailed",void 0),ql(aA(t),"_audioPlaybackDeviceId",void 0),t._extensionManager=e,t}return Vh(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new bC(fC.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,SQ.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),SQ.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&&(SQ.info("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=Ng(Pg().mark((function e(t,r,n){var i,o=this,a=arguments;return Pg().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 bC(fC.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 3:if(!this._isAudioDeviceRecordTesting&&!this._isAudioPlaybackDeviceTesting){e.next=5;break}throw new bC(fC.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 5:return this._isAudioDeviceRecordTesting=!0,SQ.info("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){SQ.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(){SQ.info("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(SQ.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=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(SQ.info("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new bC(fC.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,Oj.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new bC(fC.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(){SQ.info("destroy()","Invoke"),MA(NA(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=Ng(Pg().mark((function e(t,r){var n,i=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return SQ.info("_playAudioFile()",Fg(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new jI((function(e,n){var o=CX("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new Vj(o),o.onplaying=function(){o.onplaying=null,SQ.info("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=Ng(Pg().mark((function e(t){var r,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:SQ.error("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new bC(fC.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;SQ.warn("_playAudioFile()","autoplay error",e);var r=Fg(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return jI.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new bC(fC.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&&(SQ.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&&(SQ.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&&(SQ.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=Ng(Pg().mark((function e(t,r){var n,i=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,hH({},this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r+.01),n=new MediaStream([this._audioTrack.preprocessingTrack]),SQ.info("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new jI((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=aI(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),SQ.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=Ng(Pg().mark((function n(o){var a,c;return Pg().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return SQ.info("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(dQ.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 bC(fC.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=Ng(Pg().mark((function e(){var t,r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=Fj.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),SQ.info("setSinkId","ctx.sinkId=".concat(t))}catch(o){SQ.error("setSinkId",Fg(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}(yU.EventEmitter),kQ=new pM("VideoSnapshot",1),EQ=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},TQ=function(){var e=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return Pg().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=EQ(n))){e.next=16;break}return kQ.info("takeSnapshot","VideoPlayer already set."),e.next=11,a(c,c.videoWidth,c.videoHeight);case 11:return u=e.sent,kQ.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 kQ.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,kQ.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 29:return kQ.info("takeSnapshot","use temp video"),e.abrupt("return",new jI((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);kQ.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)}}(),IQ=function(){return{url:"",video:{codec:Rh.H264,width:640,height:360,fps:15,gop:2,kBitRate:RQ(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:Ih.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function RQ(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 AQ(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new bC(fC.INVALID_PARAMS,"Invalid rtmp address")}function wQ(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new bC(fC.INVALID_PARAMS,"regions should not be empty.");var t,r=my(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new bC(fC.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new bC(fC.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(jZ){r.e(jZ)}finally{r.f()}}function CQ(e,t){var r,n,i,o=function(e,r){var n=oS(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=oS(e).call(e,(function(e,t){return null==e?void 0:e[t]}),IQ());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!!aI(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 Xy(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return Xy(t=[Ih.LC,Ih.HEv1,Ih.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return Xy(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:RQ(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:qg(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&&Xy(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&Xy(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 xQ,OQ={getDefaultValue:IQ,checkStartParams:function(e){var t;AQ(e.url),wQ(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&AQ(e.url),wQ(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return CQ("started",e)},getUpdateParams:function(e){return CQ("layoutChanged",e)}},PQ=Kp,DQ=ei;wr({target:"Object",stat:!0},{fromEntries:function(e){var t={};return PQ(e,(function(e,r){DQ(t,e,r)}),{AS_ENTRIES:!0}),t}});var NQ,MQ=r(te.Object.fromEntries),LQ=["ele","fakeEle"],UQ=["orgTrack","mediaTrack","preprocessingTrack"],VQ=["orgTrack","mediaTrack","preprocessingTrack"],FQ=["currentTime","duration","ended","error","muted","networkState","paused","readyState","seekable","sinkId","src","volume"],BQ=["currentTime","sampleRate","state","baseLatency","outputLatency","sinkId"],jQ=["contentHint","enabled","id","kind","label","muted","readyState"],HQ=["currentDirection","direction","mid","stopped"];function GQ(e){return zQ.apply(this,arguments)}function zQ(){return(zQ=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Date.now(),n=[],!(t&&t._room&&t._room._mediaServerClient&&t._room._mediaServerClient._handler&&t._room._mediaServerClient._handler._peerConnection)){e.next=6;break}return e.next=5,t._room._mediaServerClient._handler._peerConnection.getStats();case 5:n=e.sent;case 6:return i=[],n.forEach((function(e){i.push(e)})),e.abrupt("return",{timestamp:r,stats:i});case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function KQ(e){var t={};if(e instanceof MediaStream){t.id=e.id,t.active=e.active;var r=e.getTracks();t.tracks=qg(r).call(r,(function(e){return MQ(qg(jQ).call(jQ,(function(t){return[t,e[t]]})))}))}return t}function WQ(e){return XQ.apply(this,arguments)}function XQ(){return(XQ=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Date.now(),n=[],t._videoPlayer&&n.push({userId:"__local__",mediaType:"video",isScreen:!1,isPublic:!1,ele:t._videoPlayer._videoDom}),t._screenPlayer&&n.push({userId:"__local__",mediaType:"video",isScreen:!0,isPublic:!1,ele:t._screenPlayer._videoDom}),t._remoteVideoPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"video",isScreen:!1,isPublic:!1,ele:e?e._videoDom:void 0})})),t._remoteScreenPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"video",isScreen:!0,isPublic:!1,ele:e?e._videoDom:void 0})})),t._remoteAudioPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"audio",isScreen:!1,isPublic:!1,ele:e?e._audioDom:void 0,fakeEle:e?e._fakeAudioDom:void 0})})),t._remoteScreenAudioPlayer&&t._remoteScreenAudioPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"audio",isScreen:!0,isPublic:!1,ele:e?e._audioDom:void 0,fakeEle:e?e._fakeAudioDom:void 0})})),t._publicStreamVideoPlayer&&t._publicStreamVideoPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"video",isScreen:!1,isPublic:!0,ele:e?e._videoDom:void 0})})),t._publicStreamAudioPlayer&&t._publicStreamAudioPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"audio",isScreen:!1,isPublic:!0,ele:e?e._audioDom:void 0,fakeEle:e?e._fakeAudioDom:void 0})})),i=qg(n).call(n,(function(e){var t=e.ele,r=e.fakeEle,n=yN(e,LQ),i=Ql({ele:Ql({srcObject:t?KQ(t.srcObject):void 0},MQ(qg(FQ).call(FQ,(function(e){return[e,t[e]]}))))},n);return r&&(i.fakeEle=Ql({srcObject:KQ(r.srcObject)},MQ(qg(FQ).call(FQ,(function(e){return[e,r[e]]}))))),i})),e.abrupt("return",{timestamp:r,elementStats:i});case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function YQ(e){var t,r=[],n=[];e&&e._room&&e._room._remoteStreams&&(n=cw(t=e._room._remoteStreams).call(t));var i,o=my(n);try{for(o.s();!(i=o.n()).done;){i.value.forEach((function(e){e.audioTrack&&r.push(e.audioTrack)}))}}catch(jZ){o.e(jZ)}finally{o.f()}e._localAudioTrack&&r.push(e._localAudioTrack),e._localScreenAudioTrack&&r.push(e._localScreenAudioTrack);for(var a=0,s=r;a<s.length;a++){var c,u,d=s[a];if(d._audioLevelFetcher&&d._audioLevelFetcher._ctx)return d._audioLevelFetcher._ctx;if(d._ac)return d._ac;if(d._audioFetchMap)if(KC(cw(c=d._audioFetchMap).call(c)).length)return KC(cw(u=d._audioFetchMap).call(u))[0]._ctx;if(d._ap&&d._ap._ac)return d._ap._ac}return null}function qQ(e){return JQ.apply(this,arguments)}function JQ(){return(JQ=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Date.now(),n=YQ(t),i={},n){e.next=5;break}return e.abrupt("return",{timestamp:r,acState:void 0});case 5:return BQ.forEach((function(e){i[e]=n[e]})),e.abrupt("return",{timestamp:r,acState:i});case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function QQ(e){var t=[];e._localAudioTrack&&t.push({userId:"__local__",mediaType:"audio",isScreen:!1,isPublic:!1,isVirtual:!1,orgTrack:e._localAudioTrack._originTrack,mediaTrack:e._localAudioTrack._mediaTrack,preprocessingTrack:e._localAudioTrack._preProcessingTrack}),e._localScreenAudioTrack&&t.push({userId:"__local__",mediaType:"audio",isScreen:!0,isPublic:!1,isVirtual:!1,orgTrack:e._localScreenAudioTrack._originTrack,mediaTrack:e._localScreenAudioTrack._mediaTrack,preprocessingTrack:e._localScreenAudioTrack._preProcessingTrack}),e._localVideoTrack&&t.push({userId:"__local__",mediaType:"video",isScreen:!1,isPublic:!1,isVirtual:!1,orgTrack:e._localVideoTrack._originTrack,mediaTrack:e._localVideoTrack._mediaTrack,preprocessingTrack:e._localVideoTrack._preProcessingTrack}),e._localScreenVideoTrack&&t.push({userId:"__local__",mediaType:"video",isScreen:!0,isPublic:!1,isVirtual:!1,orgTrack:e._localScreenVideoTrack._originTrack,mediaTrack:e._localScreenVideoTrack._mediaTrack,preprocessingTrack:e._localScreenVideoTrack._preProcessingTrack}),e._room&&e._room._remoteStreams&&e._room._remoteStreams.forEach((function(e,r){e.forEach((function(e){e.audioTrack&&t.push({userId:r,mediaType:"audio",isScreen:e.isScreen,isPublic:!1,isVirtual:!1,orgTrack:e.audioTrack._originTrack,mediaTrack:e.audioTrack._mediaTrack}),e.videoTrack&&t.push({userId:r,mediaType:"video",isScreen:e.isScreen,isPublic:!1,isVirtual:!1,orgTrack:e.videoTrack._originTrack,mediaTrack:e.videoTrack._mediaTrack})}))}));var r=e._publicStreamManager;return r||(r=e._outsideRoom),r&&r.remoteStreams.forEach((function(e,r){e.audioTrack&&t.push({userId:r,mediaType:"audio",isScreen:e.isScreen,isPublic:!0,isVirtual:!1,orgTrack:e.audioTrack._originTrack,mediaTrack:e.audioTrack._mediaTrack}),e.videoTrack&&t.push({userId:r,mediaType:"video",isScreen:e.isScreen,isPublic:!0,isVirtual:!1,orgTrack:e.videoTrack._originTrack,mediaTrack:e.videoTrack._mediaTrack})})),e&&e._room&&e._room._virtualStreams&&e._room._virtualStreams.forEach((function(e,r){e.audioTrack&&t.push({userId:"virtualStream-".concat(r),mediaType:"audio",isScreen:!1,isPublic:!1,isVirtual:!0,orgTrack:e.audioTrack._originTrack,mediaTrack:e.audioTrack._mediaTrack}),e.videoTrack&&t.push({userId:"virtualStream-".concat(r),mediaType:"video",isScreen:!1,isPublic:!1,isVirtual:!0,orgTrack:e.videoTrack._originTrack,mediaTrack:e.videoTrack._mediaTrack})})),t}function ZQ(e,t){return $Q.apply(this,arguments)}function $Q(){return($Q=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=2048,i=50,o=128,a=256,s=2,t){e.next=7;break}return e.abrupt("return",void 0);case 7:return(c=new MediaStream).addTrack(t),u=r.createMediaStreamSource(c),d=r.createAnalyser(),u.connect(d),"suspended"===r.state&&(console.warn(r.state),r.resume()),l=new Uint8Array(n),d.getByteTimeDomainData(l),e.next=17,new jI((function(e){setTimeout(e,i)}));case 17:return d.getByteTimeDomainData(l),e.next=20,new jI((function(e){setTimeout(e,i)}));case 20:return h=0,l.forEach((function(e){return h=Math.max(h,Math.abs(e-o))})),v=(p=h/o*a)>s?p:0,u.disconnect(),d.disconnect(),e.abrupt("return",v);case 27:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function eZ(e){return tZ.apply(this,arguments)}function tZ(){return tZ=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1e3,n=Date.now(),NQ||(NQ=new AudioContext),"suspended"!==NQ.state){e.next=6;break}return e.next=6,new jI((function(e){var r=setTimeout((function(){console.warn("[RTC_AMBULANCE] AudioContext resume failed, try to find one in RTCEngine"),(NQ=YQ(t))&&console.warn("[RTC_AMBULANCE] find AudioContext in RTCEngine success"),e()}),1e3);NQ.resume().then((function(){clearTimeout(r),e()}),(function(){clearTimeout(r),NQ=null,e()}))}));case 6:if(NQ){e.next=9;break}return console.error("[RTC_AMBULANCE] get volume is not supported"),e.abrupt("return");case 9:return i=QQ(t),o=[],e.next=13,jI.all(qg(r=Ty(i).call(i,(function(e){return"audio"===e.mediaType}))).call(r,function(){var e=Ng(Pg().mark((function e(t){var r,n,i,a,s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.orgTrack,n=t.mediaTrack,i=t.preprocessingTrack,a=yN(t,UQ),s=Ql({},a),e.next=4,jI.all([ZQ(r,NQ).then((function(e){s.orgTrackVolume=e})),ZQ(n,NQ).then((function(e){s.mediaTrackVolume=e})),ZQ(i,NQ).then((function(e){s.preprocessingTrackVolume=e}))]);case 4:o.push(s);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 13:return e.abrupt("return",{timestamp:n,trackVolumes:o});case 14:case"end":return e.stop()}}),e)}))),tZ.apply(this,arguments)}function rZ(e){return nZ.apply(this,arguments)}function nZ(){return(nZ=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Date.now(),n=QQ(t),i=qg(n).call(n,(function(e){var t=e.orgTrack,r=e.mediaTrack,n=e.preprocessingTrack,i=yN(e,VQ);return Ql({orgTrack:t?MQ(qg(jQ).call(jQ,(function(e){return[e,t[e]]}))):void 0,mediaTrack:r?MQ(qg(jQ).call(jQ,(function(e){return[e,r[e]]}))):void 0,preprocessingTrack:n?MQ(qg(jQ).call(jQ,(function(e){return[e,n[e]]}))):void 0},i)})),e.abrupt("return",{timestamp:r,trackStates:i});case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function iZ(e){if(e){var t={track:e.track?e.track.id:void 0,transport:{state:e.transport?e.transport.state:void 0}};return e.transport&&e.transport.iceTransport&&(t.iceTransport={state:e.transport.iceTransport.state,role:e.transport.iceTransport.role,gatheringState:e.transport.iceTransport.gatheringState,component:e.transport.iceTransport.component}),t}}function oZ(e){return aZ.apply(this,arguments)}function aZ(){return(aZ=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Date.now(),n=[],t._room&&t._room._mediaServerClient&&t._room._mediaServerClient._handler&&t._room._mediaServerClient._handler._peerConnection&&(n=t._room._mediaServerClient._handler._peerConnection.getTransceivers()),i=[],n.forEach((function(e){var t=Ql({sender:iZ(e.sender),receiver:iZ(e.receiver)},MQ(qg(HQ).call(HQ,(function(t){return[t,e[t]]}))));i.push(t)})),e.abrupt("return",{timestamp:r,tranceiverStates:i});case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function sZ(e){return cZ.apply(this,arguments)}function cZ(){return(cZ=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={stats:[],mediaElementStates:[],audioContextStates:[],volumes:[],trackStates:[],tranceiverStates:[]},n=[],e.next=4,new jI((function(e){var i,o=0;i=setTimeout((function a(){n.push(GQ(t).then((function(e){r.stats.push(e)})),WQ(t).then((function(e){r.mediaElementStates.push(e)})),qQ(t).then((function(e){r.audioContextStates.push(e)})),eZ(t).then((function(e){r.volumes.push(e)})),rZ(t).then((function(e){r.trackStates.push(e)})),oZ(t).then((function(e){r.tranceiverStates.push(e)}))),++o>=10?jI.all(n).then((function(){e()})):(clearTimeout(i),i=setTimeout(a,500))}),500)}));case 4:return console.log("RTC_AMBULANCE",r),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var uZ=uT,dZ=HI,lZ=function(e,t,r,n){for(var i,o=n>1?void 0:n?dZ(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&&uZ(t,r,o),o},hZ=function(e){UA(Re,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M,L,U,V,F,B,j,H,G,z,K,W,X,Y,q,J,Q,Z,$,ee,te,re,ne,ie,oe,ae,se,ce,ue,de,le,he,pe,ve,_e,fe,me,ge,ye,Se,be,ke,Ee,Te,Ie=ew(Re);function Re(e,t,r){var n;return Fh(this,Re),ql(aA(n=Ie.call(this)),"monitor",void 0),ql(aA(n),"logger",void 0),ql(aA(n),"_room",void 0),ql(aA(n),"_publicStreamManager",void 0),ql(aA(n),"_appId",void 0),ql(aA(n),"_businessId",void 0),ql(aA(n),"_visibility",!0),ql(aA(n),"_localVideoTrack",void 0),ql(aA(n),"_localAudioTrack",void 0),ql(aA(n),"_localImgVideoTrack",void 0),ql(aA(n),"_localImgScreenTrack",void 0),ql(aA(n),"_localScreenVideoTrack",void 0),ql(aA(n),"_localScreenAudioTrack",void 0),ql(aA(n),"_tempMixingAudioTrack",void 0),ql(aA(n),"_localAudioVolume",100),ql(aA(n),"_localScreenAudioVolume",100),ql(aA(n),"_remoteAudioVolume",new cT),ql(aA(n),"_remoteScreenAudioVolume",new cT),ql(aA(n),"_publicAudioVolume",new cT),ql(aA(n),"_videoPlayer",void 0),ql(aA(n),"_screenPlayer",void 0),ql(aA(n),"_remoteVideoPlayer",new cT),ql(aA(n),"_remoteScreenPlayer",new cT),ql(aA(n),"_remoteAudioPlayer",new cT),ql(aA(n),"_remoteScreenAudioPlayer",new cT),ql(aA(n),"_publicStreamAudioPlayer",new cT),ql(aA(n),"_publicStreamVideoPlayer",new cT),ql(aA(n),"_publicStreamIds",new cT),ql(aA(n),"_roomConfig",void 0),ql(aA(n),"_videoStreamConstraints",Ql({},qL)),ql(aA(n),"_audioStreamConstraints",{}),ql(aA(n),"_enableSimulcast",!1),ql(aA(n),"_videoStreamEncodeConfig",[Ql({},qL)]),ql(aA(n),"_screenStreamEncodeConfig",[Ql({},JL)]),ql(aA(n),"_dummyMainImage",void 0),ql(aA(n),"_dummyScreenImage",void 0),ql(aA(n),"_trackSourceType",void 0),ql(aA(n),"_liveTranscodeConfig",void 0),ql(aA(n),"_startCloudProxyTimestamp",void 0),ql(aA(n),"_localVideoDeviceId",void 0),ql(aA(n),"_localAudioDeviceId",void 0),ql(aA(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),ql(aA(n),"_audioVolumeIndicationTimer",void 0),ql(aA(n),"_dummyMainTimer",void 0),ql(aA(n),"_dummyScreenTimer",void 0),ql(aA(n),"_audioPropertiesReportTimer",null),ql(aA(n),"_mirrorType",lh.MIRROR_TYPE_RENDER),ql(aA(n),"_audioMixingManager",void 0),ql(aA(n),"_pubLock",void 0),ql(aA(n),"_subLocks",void 0),ql(aA(n),"_audioCaptureLock",void 0),ql(aA(n),"_videoCaptureLock",void 0),ql(aA(n),"_screenCaptureLock",void 0),ql(aA(n),"_subScreenLocks",void 0),ql(aA(n),"_rtmClient",void 0),ql(aA(n),"_messageStatisticsObserver",void 0),ql(aA(n),"_tempRoomInfo",void 0),ql(aA(n),"_originIceConfigRequestUrls",void 0),ql(aA(n),"_originConfigServerUrls",void 0),ql(aA(n),"_originLogServerUrl",void 0),ql(aA(n),"_extensionManager",void 0),ql(aA(n),"_audioDeviceManager",void 0),ql(aA(n),"_remoteVideoConfig",new cT),ql(aA(n),"_config",void 0),ql(aA(n),"_needClosePreTrack",!1),ql(aA(n),"_ctx",void 0),ql(aA(n),"_updateMixAudioTrack",function(){var e=Ng(Pg().mark((function e(t){var r,i,o=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:Dh.PLAYOUT_AND_PUBLISH,n.logger.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)}}()),ql(aA(n),"_onAudioMixingMessage",(function(e){n.safeEmit(Lh.onAudioMixingStateChanged,e)})),ql(aA(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(Lh.onAutoplayFailed,e)})),n.id=t,n._appId=e,n._pubLock=new wW("pubLock"),n._subLocks=new cT,n._subScreenLocks=new cT,n._audioCaptureLock=new wW("audioCap"),n._videoCaptureLock=new wW("videoCap"),n._screenCaptureLock=new wW("screenCap"),n._addDeviceEventHandler(),n._extensionManager=new jj(t),n._audioDeviceManager=new bQ(n._extensionManager),n._audioMixingManager=new _Q({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 gQ(e),userPriority:new cT,expectedIDC:null==r?void 0:r.expectedIDC,joinRoomConfig:new VL(t)},window.__rtc_engine__=aA(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=aA(n),n._trackSourceType={video:Zl.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:Zl.VIDEO_SOURCE_TYPE_INTERNAL,audio:$l.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:$l.AUDIO_SOURCE_TYPE_INTERNAL},n._config=r,n._rtmClient=new mQ(n._ctx),n._handleRTMClient(n._rtmClient),n._handleAudioDeviceManager(),n._messageStatisticsObserver=new LN(t),n.monitor=KN(t),n.logger=new pM("Engine",0,t),MN.createRTSMsgReportor(n.id),n._getServerConfig(),n.monitor.reportLongString("NativeDetector",Gg(LS)),n}return Vh(Re,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(Te=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateToken()","token: %s",t),$L(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return r=this._tempRoomInfo,n=r.config,i=r.userInfo,o=r.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,o,i,n);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new bC(fC.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,this._room.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return Te.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(Ee=Ng(Pg().mark((function e(t){var r,n,i,o,a,s=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setVideoCaptureDevice()","deviceId: %s",t),$L(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:if(!hL||!_L){e.next=9;break}if(this._localVideoTrack.originTrack.getSettings().deviceId!==t){e.next=9;break}return e.abrupt("return");case 9:return n=Vz({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete n.deviceId,n.facingMode=t):!uL||vL?n.deviceId={exact:t}:delete n.deviceId,_L&&nL&&AL>=85&&AL<=91&&(null===(i=this._videoPlayer)||void 0===i||i.removeTrack()),this._needClosePreTrack=this._needClosePreTrack||KB,this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),this.logger.info("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=17,dH(n,this._extensionManager).catch((function(e){if(s._localVideoTrack&&!s._localVideoTrack.dummy)return s.logger.warn("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),s._removeLocalTrackEvents(s._localVideoTrack),s._localVideoTrack.close(),delete s._localVideoTrack,dH(n,s._extensionManager).then((function(e){return s._needClosePreTrack=!0,e})).catch(Ng(Pg().mark((function t(){var r;return Pg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.logger.error("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,dH(s._videoStreamConstraints,s._extensionManager);case 3:throw r=t.sent,s._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 17:return o=e.sent,this.logger.success("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=n,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null!==(r=this._videoStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&o.setContentHint(null===(a=this._videoStreamEncodeConfig[0])||void 0===a?void 0:a.contentHint),e.next=24,this._switchTrack(o);case 24:case"end":return e.stop()}}),e,this)}))),function(e){return Ee.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(ke=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setAudioCaptureDevice()","deviceId: %s",t),$L(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.next=10,hH(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 10:if(n=e.sent,this._initLocalTrackEvents(n),this._localAudioTrack=n,this._localAudioTrack.setVolume(this._localAudioVolume),this._room){e.next=16;break}return e.abrupt("return");case 16:if(null===(r=this._room.localStream)||void 0===r||!r.pubAudio){e.next=19;break}return e.next=19,this._updatePublish();case 19:case"end":return e.stop()}}),e,this)}))),function(e){return ke.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){Oj.on(Lh.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),Oj.on(Lh.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,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M,L,U,V=this;null===(e=this._room)||void 0===e||e.on(bW.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(bW.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(bW.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(CW.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(CW.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(CW.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(bW.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(bW.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(bW.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(bW.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(bW.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?V._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?V._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&V._onLiveTranscodingResult(e)})),null===(l=this._room)||void 0===l||l.on(EW.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(EW.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return V.safeEmit(Lh.onVendorConnectionStateChanged,e)})),null===(p=this._room)||void 0===p||p.on(CW.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(v=this._room)||void 0===v||v.on(CW.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(_=this._room)||void 0===_||_.on(CW.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(CW.ON_PUBLISH_RESULT,(function(e){var t,r=!(e.retry||null===(t=V._room)||void 0===t||!t._roomConfig.isAutoPublish);r&&V.safeEmit(Lh.onAutoPublishResult,e),V.safeEmit(Lh.onPublishResult,{isScreen:e.isScreen,isAutoPublish:r,errorCode:e.errorCode})})),null===(m=this._room)||void 0===m||m.on(CW.ON_SUBSCRIBE_RESULT,(function(e){V.safeEmit(Lh.onSubscribeResult,{userId:e.userId,isScreen:e.isScreen,isAutoSubscribe:!1,errorCode:e.errorCode})})),null===(g=this._room)||void 0===g||g.on(CW.ON_REMOTE_STREAM_STATS,(function(e){V.safeEmit(Lh.onRemoteStreamStats,e)})),null===(y=this._room)||void 0===y||y.on(CW.ON_LOCAL_STREAM_STATS,(function(e){V.safeEmit(Lh.onLocalStreamStats,e)})),null===(S=this._room)||void 0===S||S.on(CW.ON_SUBTITLE_STATE_CHANGED,(function(e){V.safeEmit(Lh.onSubtitleStateChanged,e)})),null===(b=this._room)||void 0===b||b.on(CW.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){V.safeEmit(Lh.onSubtitleMessageReceived,e)})),null===(k=this._room)||void 0===k||k.on(CW.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(E=this._room)||void 0===E||E.on(CW.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;V._updateAudioPlayerState(t),V.safeEmit(Lh.onUserStartAudioCapture,{userId:r})})),null===(T=this._room)||void 0===T||T.on(CW.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;V.safeEmit(Lh.onUserStopAudioCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(CW.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;V.safeEmit(Lh.onUserStartVideoCapture,{userId:t})})),null===(R=this._room)||void 0===R||R.on(CW.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;V.safeEmit(Lh.onUserStopVideoCapture,{userId:t})})),null===(A=this._room)||void 0===A||A.on(CW.ON_SEI_MESSAGED_RECEIVED,(function(e){V.safeEmit(Lh.onSEIMessageReceived,e)})),null===(w=this._room)||void 0===w||w.on(CW.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){V.safeEmit(Lh.onRemoteVideoSizeChanged,e,t)})),null===(C=this._room)||void 0===C||C.on(CW.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return V.safeEmit(Lh.onSimulcastSubscribeFallback,e)})),null===(x=this._room)||void 0===x||x.on(CW.RECONNECT_FAILED,(function(){V.safeEmit(Lh.onError,{errorCode:fC.RECONNECT_FAILED})})),null===(O=this._room)||void 0===O||O.on(CW.ON_VIDEO_STREAM_BANNED,(function(e){V.safeEmit(Lh.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(P=this._room)||void 0===P||P.on(CW.ON_AUDIO_STREAM_BANNED,(function(e){V.safeEmit(Lh.onAudioStreamBanned,{uid:e.uid,banned:e.banned})})),null===(D=this._room)||void 0===D||D.on(CW.ON_FORWARD_STREAM_ERROR,(function(e){V.safeEmit(Lh.onForwardStreamError,e)})),null===(N=this._room)||void 0===N||N.on(CW.ON_REJOIN_WITH_TCP,(function(){V.safeEmit(Lh.onRejoinWithTcp)})),null===(M=this._room)||void 0===M||M.on(CW.ON_ICE_CONNECT_WITH_TCP,(function(){V.safeEmit(Lh.onIceConnectWithTcp)})),null===(L=this._room)||void 0===L||L.on(CW.PUB_RETRY,(function(e){V.safeEmit(Lh.onPublishRetry,e)})),null===(U=this._room)||void 0===U||U.on(CW.SUB_RETRY,(function(e){V.safeEmit(Lh.onSubscribeRetry,e)}))}},{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 function(e){var t,r=KL("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!Xy(r).call(r,e))||!Xy(t=[Lh.onRemoteStreamStats,Lh.onLocalStreamStats,Lh.onAudioVolumeIndication,Lh.onLocalAudioPropertiesReport,Lh.onRemoteAudioPropertiesReport]).call(t,e)}(e)&&qN(this.id,e,i),(t=MA(NA(Re.prototype),"safeEmit",this)).call.apply(t,Fg(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(be=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._room){e.next=2;break}return e.abrupt("return");case 2:return this._room=new wX({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:kh.communication},this._ctx),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return be.apply(this,arguments)})},{key:"joinRoom",value:(Se=Ng(Pg().mark((function e(t,r,n,i){var o,a,s,c,u;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,i),oU(t)||$L(t,"token"),aU(r),uU(n),dU(i=Vz({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:kh.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==rX.CONNECTED){e.next=8;break}throw new bC(fC.REPEAT_JOIN,"Already joined");case 8:return this._room||(this._room=new wX(i,this._ctx),this._addHandlerEventHandler()),this._room.roomConfig=i,a=this._liveTranscodeConfig&&OQ.getStartParams(this._liveTranscodeConfig),s=Ql(Ql({},n),{},{businessId:this._businessId,role:this._visibility?fQ.NORMAL_USER:fQ.SILENT_USER}),e.prev=12,this._ctx.useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),gX(s),e.next=17,this._room.join(this._appId,r,t,s,a);case 17:return c=e.sent,this._roomConfig=i,this._ctx.audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,i.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:ch.AUDIO_AND_VIDEO}):(this.safeEmit(Lh.onAutoPublishResult,{isScreen:!1,state:ih.PUBLISH_FAIL}),this.safeEmit(Lh.onPublishResult,{isScreen:!1,isAutoPublish:!0,errorCode:fC.NO_PUBLISH_PERMISSION}))),MN.setRoomId(this.id,r),MN.setUserId(this.id,n.userId),e.abrupt("return",c);case 27:throw e.prev=27,e.t0=e.catch(12),e.t0.code===fC.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:s}),null===(u=this._room)||void 0===u||u.destroy(),delete this._room,e.t0;case 33:case"end":return e.stop()}}),e,this,[[12,27]])}))),function(e,t,r,n){return Se.apply(this,arguments)})},{key:"leaveRoom",value:(ye=Ng(Pg().mark((function e(){var t,r,n,i=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],this.logger.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._subLocks=new cT,this._subScreenLocks=new cT,this._ctx.audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new cT,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new cT,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new cT,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new cT,this._roomConfig=void 0,this._publicStreamIds=new cT,MN.setRoomId(this.id,""),MN.setUserId(this.id,"");case 26:case"end":return e.stop()}}),e,this)}))),function(){return ye.apply(this,arguments)})},{key:"_destroyLocalTrack",value:function(){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)}},{key:"destroy",value:function(){var e,t,r;this.logger.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._subLocks=new cT,this._subScreenLocks=new cT,this._audioCaptureLock=new wW("audioCap"),this._videoCaptureLock=new wW("videoCap"),this._screenCaptureLock=new wW("screenCap"),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._videoStreamEncodeConfig=[qL],this._screenStreamEncodeConfig=[JL],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),MN.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._destroyLocalTrack(),Mj.on("".concat(this.id,"capture-end"),this._destroyLocalTrack.bind(this)),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new cT,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new cT,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new cT,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new cT,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new cT,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new cT,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new cT,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new cT,this._ctx.userPriority.clear(),this._extensionManager.destroy(),this._ctx.avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(ge=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!zM(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,aH(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 ge.apply(this,arguments)})},{key:"unpublishStream",value:(me=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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:OW.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return me.apply(this,arguments)})},{key:"publishScreen",value:(fe=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!zM(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,cH(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:OW.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof bC)){e.next=18;break}throw e.t0;case 18:throw new bC(fC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return fe.apply(this,arguments)})},{key:"unpublishScreen",value:(_e=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:OW.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return _e.apply(this,arguments)})},{key:"subscribeStream",value:(ve=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 ve.apply(this,arguments)})},{key:"_subscribe",value:(pe=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n!==ch.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=3;break}return this.logger.warn("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 3:if(s=this._room.remoteStreams.get(r),c=null==s?void 0:aI(s).call(s,(function(e){return e.isScreen===t}))){e.next=7;break}throw new bC(fC.STREAM_NOT_EXIST,"stream not exist");case 7:return u=this._pauseAllSubscribeState.audio,d=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&ch.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&ch.VIDEO),this.logger.warn("subscribeStream()","due to pauseAll mediaType: %o",n),l=c.hasSubscribed,h=this._remoteVideoConfig.get(r)||(null===(o=this._roomConfig)||void 0===o?void 0:o.remoteVideoConfig),c.originalMediaType=n,e.next=17,this._room.subscribe(c,n,h);case 17:GM(n)&&this._updateAudioPlayerState(c),zM(n)&&this._updateVideoPlayerState(c),p=0,v=0,u!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?p|=ch.AUDIO:v|=ch.AUDIO),d!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?p|=ch.VIDEO:v|=ch.VIDEO),p&&this.pauseAllSubscribedStream(p),v&&this.resumeAllSubscribedStream(v),this._pauseAllSubscribeState.resumeStreamIds[c.streamId]=c.streamId,(c.audioTrack||c.videoTrack)&&(m=!(t||!(null!==(_=this._roomConfig)&&void 0!==_&&_.isAutoSubscribeAudio||null!==(f=this._roomConfig)&&void 0!==f&&f.isAutoSubscribeVideo)),g={userId:r,isScreen:!1,state:nh.SUBSCRIBE_SUCC},m&&this.safeEmit(Lh.onAutoSubscribeResult,g),this.safeEmit(Lh.onSubscribeResult,{userId:r,isScreen:t,isAutoSubscribe:m})),null!==(a=this._room)&&void 0!==a&&a.multiChatMode||l||!GM(n)||!c.hasAudio||null===(y=c.observer)||void 0===y||y.setSubscribeAudio(!0),!l&&zM(n)&&c.hasVideo&&(null===(S=c.observer)||void 0===S||S.setSubscribeVideo(!0));case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return pe.apply(this,arguments)})},{key:"unsubscribeStream",value:(he=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("unsubscribeStream()","userId: %o, mediaType: %o",t,r),e.abrupt("return",this._unsubscribe(!1,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return he.apply(this,arguments)})},{key:"subscribeScreen",value:(le=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 le.apply(this,arguments)})},{key:"unsubscribeScreen",value:(de=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("unsubscribeScreen() userId: %o, mediaType: %o",t,r),e.abrupt("return",this._unsubscribe(!0,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return de.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(r!==ch.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a,s=this._room.remoteStreams.get(t),c=null==s?void 0:aI(s).call(s,(function(t){return t.isScreen===e}));if(!c)throw new bC(fC.STREAM_NOT_EXIST,"stream not exist");if(_L&&AL&&AL>=85&&AL<=91&&r!==ch.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]}))}this.logger.warn("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(ue=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),sU(t),pU(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 ue.apply(this,arguments)})},{key:"startVideoCapture",value:(ce=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startVideoCapture()","deviceId: %s",t),oU(t)||$L(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==Zl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!this._localVideoTrack||this._localVideoTrack.dummy){e.next=8;break}throw new bC(fC.REPEAT_CAPTURE,"Has already capture");case 8:return s=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?(s.facingMode=t,delete s.deviceId):!uL||vL?s.deviceId={exact:t}:delete s.deviceId,this._videoStreamConstraints=s),c={},e.next=13,dH(s,this._extensionManager);case 13:if(u=e.sent,null!==(r=this._videoStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&u.setContentHint(null===(d=this._videoStreamEncodeConfig[0])||void 0===d?void 0:d.contentHint),this._initLocalTrackEvents(u),this._localVideoTrack=u,null===(n=this._videoPlayer)||void 0===n||n.playVideo(u),(l=u.originTrack)&&(c=l.getSettings(),h={width:c.width,height:c.height},this._localVideoTrack.resolution=h,this.autoResetVideoEncoderConfig(c),setTimeout((function(){return v.safeEmit(Lh.onLocalVideoSizeChanged,{streamIndex:sh.STREAM_INDEX_MAIN,info:h})}))),Mj.emit("".concat(this.id,"capture-end")),this._room){e.next=23;break}return e.abrupt("return",c);case 23:return p=this._room._roomConfig.isAutoPublish,(null!==(i=this._room.localStream)&&void 0!==i&&i.pubVideo||p)&&this._visibility&&this._updatePublish(),null===(o=this._room.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setEnableVideo(!0),e.abrupt("return",c);case 27:case"end":return e.stop()}}),e,this)}))),function(e){return ce.apply(this,arguments)})},{key:"stopVideoCapture",value:(se=Ng(Pg().mark((function e(){var t,r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopVideoCapture()"),this._trackSourceType.video!==Zl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=3;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 3:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),this._localVideoTrack&&(this._localVideoTrack.dummy||((o=this._extensionManager.getPluginByName(Bj.PRE_PROCESSING,"RTCBeautyExtension"))&&o.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(this._localVideoTrack.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=7;break}return e.abrupt("return");case 7:if(null===(r=this._room.localStream)||void 0===r||!r.pubVideo){e.next=10;break}return e.next=10,this._updatePublish();case 10:null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableVideo(!1);case 11:case"end":return e.stop()}}),e,this)}))),function(){return se.apply(this,arguments)})},{key:"startAudioCapture",value:(ae=Ng(Pg().mark((function e(t){var r,n,i,o,a,s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startAudioCapture()","deviceId: $o",t),oU(t)||$L(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,this._trackSourceType.audio!==$l.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:if(!this._localAudioTrack){e.next=8;break}throw new bC(fC.REPEAT_CAPTURE,"Has already capture");case 8:return t&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),o={},e.next=12,hH(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 12:if((a=e.sent).originTrack&&(o=a.originTrack.getSettings()),this._initLocalTrackEvents(a),this._localAudioTrack=a,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),Mj.emit("".concat(this.id,"capture-end")),this._room){e.next=21;break}return e.abrupt("return",o);case 21:return s=this._room._roomConfig.isAutoPublish,(null!==(r=this._room.localStream)&&void 0!==r&&r.pubAudio||s)&&this._visibility&&this._updatePublish(),null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableAudio(!0),e.abrupt("return",o);case 25:case"end":return e.stop()}}),e,this)}))),function(e){return ae.apply(this,arguments)})},{key:"stopAudioCapture",value:(oe=Ng(Pg().mark((function e(){var t,r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopAudioCapture()"),this._trackSourceType.audio!==$l.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=3;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 3:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._room){e.next=8;break}return e.abrupt("return");case 8:if(null===(t=this._room.localStream)||void 0===t||!t.pubAudio){e.next=11;break}return e.next=11,this._updatePublish();case 11:null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableAudio(!1);case 12:case"end":return e.stop()}}),e,this)}))),function(){return oe.apply(this,arguments)})},{key:"checkAudioAndVideoDeviceId",value:function(e,t){var r;return this.logger.print("startAudioAndVideoCapture","optionsOrAudioDeviceId: $o",e,"videoDeviceId: $o",t),oU(t)||$L(t,"videoDeviceId"),oU(e)||("string"==typeof e?($L(e,"audioDeviceId"),r=e):(r=null==e?void 0:e.audioDeviceId,t=null==e?void 0:e.videoDeviceId,$L(r,"audioDeviceId"),$L(t,"videoDeviceId"))),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,r=r||this._localAudioDeviceId,this._localAudioDeviceId=r,{audioDeviceId:r,videoDeviceId:t}}},{key:"startAudioAndVideoCapture",value:(ie=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("startAudioAndVideoCapture","optionsOrAudioDeviceId: $o",t,"videoDeviceId: $o",r),l=this.checkAudioAndVideoDeviceId(t,r),h=l.audioDeviceId,p=l.videoDeviceId,r=p,this._trackSourceType.video!==Zl.VIDEO_SOURCE_TYPE_EXTERNAL&&this._trackSourceType.audio!==$l.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,this._trackSourceType.video===Zl.VIDEO_SOURCE_TYPE_EXTERNAL?"setVideoSourceType as internal first":"setAudioSourceType as internal first");case 5:if(!this._localVideoTrack||this._localVideoTrack.dummy){e.next=7;break}throw new bC(fC.REPEAT_CAPTURE,"video has already capture");case 7:if(!this._localAudioTrack){e.next=9;break}throw new bC(fC.REPEAT_CAPTURE,"audio has already capture");case 9:return v=this._videoStreamConstraints,r&&("user"===r||"environment"===r||"left"===r||"right"===r?(v.facingMode=r,delete v.deviceId):!uL||vL?v.deviceId={exact:r}:delete v.deviceId,this._videoStreamConstraints=v),h&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:h}}),_={},f={},e.next=16,vH(this._ctx.audioProfileManager.getConstraints(),v,this._extensionManager);case 16:if(m=e.sent,g=m.audioTrack,y=m.videoTrack,null!==(n=this._videoStreamEncodeConfig[0])&&void 0!==n&&n.contentHint&&y.setContentHint(null===(S=this._videoStreamEncodeConfig[0])||void 0===S?void 0:S.contentHint),this._initLocalTrackEvents(y),this._localVideoTrack=y,null===(i=this._videoPlayer)||void 0===i||i.playVideo(y),this._initLocalTrackEvents(g),this._localAudioTrack=g,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),b=y.originTrack,_=b.getSettings(),k={width:_.width||0,height:_.height||0},this._localVideoTrack.resolution=k,this.autoResetVideoEncoderConfig(_),setTimeout((function(){return T.safeEmit(Lh.onLocalVideoSizeChanged,{streamIndex:sh.STREAM_INDEX_MAIN,info:k})})),b=g.originTrack,f=b.getSettings(),Mj.emit("".concat(this.id,"capture-end")),this._room){e.next=38;break}return e.abrupt("return",{audioTrackSettings:f,videoTrackSettings:_});case 38:return E=this._room._roomConfig.isAutoPublish,(null!==(o=this._room.localStream)&&void 0!==o&&o.pubVideo||null!==(a=this._room.localStream)&&void 0!==a&&a.pubAudio||E)&&this._visibility&&this._updatePublish(),null===(s=this._room.localStream)||void 0===s||null===(c=s.observer)||void 0===c||c.setEnableVideo(!0),null===(u=this._room.localStream)||void 0===u||null===(d=u.observer)||void 0===d||d.setEnableAudio(!0),e.abrupt("return",{audioTrackSettings:f,videoTrackSettings:_});case 43:case"end":return e.stop()}}),e,this)}))),function(e,t){return ie.apply(this,arguments)})},{key:"startVideoAndAudioCapture",value:(ne=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.startAudioAndVideoCapture(r,t));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return ne.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return this.logger.info("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(re=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m=this,g=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=g.length>0&&void 0!==g[0]?g[0]:{},this.logger.info("startScreenCapture()","config: %o",c),u=c.enableAudio,d=void 0!==u&&u,this._trackSourceType.screenVideo!==Zl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==$l.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,fH(d,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(l=e.sent,h=gy(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===(_=this._screenStreamEncodeConfig[0])||void 0===_?void 0:_.contentHint),(f=p.originTrack)&&setTimeout((function(){var e=f.getSettings(),t={width:e.width,height:e.height};p.resolution=t,m.safeEmit(Lh.onLocalVideoSizeChanged,{streamIndex:sh.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 re.apply(this,arguments)})},{key:"stopScreenCapture",value:(te=Ng(Pg().mark((function e(){var t,r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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&&(this._localScreenVideoTrack.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 te.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(this.logger.info("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),eU(e,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),null!=t&&t.renderDom){var r,n,i=Ql(Ql({userId:this._getUserId()},t),{},{isLocal:!0});if(delete i.rotation,lU(i),e===sh.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new DX(this.id,i),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)!==Th.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),this._videoPlayer.domElement;if(e===sh.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new DX(this.id,Ql(Ql({},i),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==Th.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),this._screenPlayer.domElement;if(void 0!==t.renderMode){var o=e===sh.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer;null==o||o.setRenderMode(t.renderMode)}}else{var a,s;e===sh.STREAM_INDEX_MAIN?(null===(a=this._videoPlayer)||void 0===a||a.destroy(!0),delete this._videoPlayer):(null===(s=this._screenPlayer)||void 0===s||s.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:(ee=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startLiveTranscoding()","transcode: %o",t),OQ.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 bC(fC.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(Lh.onStreamMixingEvent,{event:xW.START,error:0,message:""}),!this._room||this._room.connectionState!==rX.CONNECTED){e.next=11;break}return e.next=11,this._room.liveControlMessage(OQ.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof bC)){e.next=19;break}throw e.t0;case 19:throw new bC(fC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return ee.apply(this,arguments)})},{key:"updateLiveTranscoding",value:($=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=Vz({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,OQ.checckUpdateParams(i),this._liveTranscodeConfig=Vz(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(Lh.onStreamMixingEvent,{event:xW.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(OQ.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof bC)){e.next=21;break}throw e.t0;case 21:throw new bC(fC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return $.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(Z=Ng(Pg().mark((function e(){var t;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(Lh.onStreamMixingEvent,{event:xW.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 bC)){e.next=16;break}throw e.t0;case 16:throw new bC(fC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return Z.apply(this,arguments)})},{key:"startSubtitle",value:(Q=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 Q.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;this.logger.info("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return this.logger.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:(J=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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:return this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),t||(this._room.unpublish(),this._room.unpublishScreen()),e.next=12,this._room.updateUserAttributes({role:t?fQ.NORMAL_USER:fQ.SILENT_USER});case 12:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:ch.AUDIO_AND_VIDEO});case 14:case"end":return e.stop()}}),e,this)}))),function(e){return J.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]:sh.STREAM_INDEX_MAIN)===sh.STREAM_INDEX_SCREEN;e.on("playback_event",(function(i){switch(i.eventName){case"timeupdate":return;case"loadeddata":if("audio"===i.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:aI(a).call(a,(function(e){return e.isScreen===n})),u=function(){r?t.safeEmit(Lh.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(Lh.onAudioFirstFrameDecoded,{userId:s,isScreen:n}),t.safeEmit(Lh.onRemoteAudioFirstFrame,{userId:s,isScreen:n})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:n})};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:n};r?(h.publicStreamId=h.userId,delete h.userId,delete h.isScreen,t.safeEmit(Lh.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(Lh.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(Lh.onVideoFirstFrameRendered,h),t.safeEmit(Lh.onVideoFirstFrameDecoded,h),t.safeEmit(Lh.onRemoteVideoFirstFrame,h)),t.monitor.report("first_remote_video_render",{stream_id:"",stream_user_id:i.userId||""},{isScreen:n})}break;case"autoplay-error":return r&&(i.publicStreamId=i.userId),JN(t.id,"autoplay-error",e instanceof DX?"video":"audio",0,i.userId||""),void t.safeEmit(Lh.onAutoplayFailed,{userId:i.userId,kind:e instanceof DX?"video":"audio",mediaType:e instanceof DX?ch.VIDEO:ch.AUDIO,streamIndex:e.isScreen?sh.STREAM_INDEX_SCREEN:sh.STREAM_INDEX_MAIN})}t.safeEmit(Lh.onPlayerEvent,i)}))}},{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=Ng(Pg().mark((function e(n){var i,o,a;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.monitor.report("rtc_error",{message:Fg(i="track-".concat(r," mediaType: ")).call(i,n.originTrack.kind),error_code:MW.TRACK_ERROR,capture_session_id:n.captureSessionId,media_type:r,reason:r}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),a=n.originTrack.kind,t.safeEmit({"track-ended":Lh.onTrackEnded,"track-mute":Lh.onTrackMute,"track-unmute":Lh.onTrackUnmute}[r],{kind:a,isScreen:o}),!vL&&!dL){e.next=13;break}if("track-mute"!==r){e.next=12;break}if(Mj.emit(Dj.ON_IOS_LOCAL_TRACK_MUTE,a),"audio"!==a){e.next=12;break}return e.next=11,t.stopAudioCapture();case 11:t.startAudioCapture();case 12:"track-unmute"===r&&Mj.emit(Dj.ON_IOS_LOCAL_TRACK_UNMUTE,a);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(Bj.PRE_PROCESSING).forEach((function(t){var n;null==t||null===(n=t.applyConstraints)||void 0===n||n.call(t,r?sh.STREAM_INDEX_SCREEN:sh.STREAM_INDEX_MAIN,e)})),t.safeEmit(Lh.onLocalVideoSizeChanged,{streamIndex:r?sh.STREAM_INDEX_SCREEN:sh.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){this.logger.info("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),eU(e,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),lU(t);var r,n,i,o=t.userId;if(e===sh.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 DX(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:aI(c).call(c,(function(e){return!e.isScreen}));return d&&this._updateVideoPlayerState(d),u.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var l=new DX(this.id,Ql(Ql({},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:aI(i).call(i,(function(e){return e.isScreen}));return h&&this._updateVideoPlayerState(h),l.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){this.logger.info("setLocalVideoMirrorType()","mirrorType: %o",e),eU(e,"mirrorType",[lh.MIRROR_TYPE_NONE,lh.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(q=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setAudioPlaybackDevice()","deviceId: %s",t),$L(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(Lh.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:Gg(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return q.apply(this,arguments)})},{key:"play",value:(Y=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=m.length>1&&void 0!==m[1]?m[1]:ch.AUDIO_AND_VIDEO,o=m.length>2?m[2]:void 0,this.logger.info("play()","userId: %s, mediaType: %s, streamIndex: %s",t,i,o),a=!t||t===this._getUserId()||"local_user"===t,s=void 0===o||o===sh.STREAM_INDEX_MAIN,c=void 0===o||o===sh.STREAM_INDEX_SCREEN,u=i!==ch.VIDEO,d=i!==ch.AUDIO,l=[],a&&d&&(s&&this._localVideoTrack&&(null===(h=this._videoPlayer)||void 0===h||h.mirror(!!this._mirrorType),l.push(null===(p=this._videoPlayer)||void 0===p?void 0:p.manuallyPlay())),c&&this._localScreenVideoTrack&&l.push(null===(v=this._screenPlayer)||void 0===v?void 0:v.manuallyPlay())),t===this._audioMixingManager.id&&l.push(this._audioMixingManager.resumeLocalPlay()),_=null===(r=this._room)||void 0===r?void 0:r.remoteStreams,d&&s&&l.push(MX(this._remoteVideoPlayer,t,!1,_)),d&&c&&l.push(MX(this._remoteScreenPlayer,t,!0,_)),u&&s&&l.push(MX(this._remoteAudioPlayer,t,!1,_)),d&&c&&l.push(MX(this._remoteScreenAudioPlayer,t,!0,_)),f=null===(n=this._publicStreamManager)||void 0===n?void 0:n.remoteStreams,u&&l.push(MX(this._publicStreamVideoPlayer,t,!1,f)),d&&l.push(MX(this._publicStreamAudioPlayer,t,!1,f)),e.abrupt("return",jI.all(l).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return Y.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(X=Ng(Pg().mark((function e(t){var r,n,i,o,a,s=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),GM(t)&&(s._pauseAllSubscribeState.audio=!0),zM(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",jI.resolve());case 6:n=[],i=my(cw(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(jZ){i.e(jZ)}finally{i.f()}return e.abrupt("return",jI.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return X.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(W=Ng(Pg().mark((function e(t){var r,n,i,o,a,s=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),GM(t)&&(s._pauseAllSubscribeState.audio=!1),zM(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",jI.resolve());case 6:n=[],i=my(cw(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(jZ){i.e(jZ)}finally{i.f()}return e.abrupt("return",jI.all(n).then((function(){var e;null===(e=s._room)||void 0===e||e.remoteStreams.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 W.apply(this,arguments)})},{key:"sendUserMessage",value:(K=Ng(Pg().mark((function e(t,r){var n,i,o,a=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sU(t),hU(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 K.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(z=Ng(Pg().mark((function e(t,r){var n,i,o,a=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sU(t),nU(r,"message"),hU(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 z.apply(this,arguments)})},{key:"sendRoomMessage",value:(G=Ng(Pg().mark((function e(t){var r,n,i,o=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return hU(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return G.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(H=Ng(Pg().mark((function e(t){var r,n,i,o=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return hU(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 H.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(j=Ng(Pg().mark((function e(){var t,r=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.length>0&&void 0!==r[0]?r[0]:{},this.logger.info("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,iU(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._ctx.audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return j.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(B=Ng(Pg().mark((function e(){var t,r=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},this.logger.info("setVideoCaptureConfig()","config: %o",t),e.abrupt("return",this._setVideoCaptureConfig(t));case 3:case"end":return e.stop()}}),e,this)}))),function(){return B.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(F=Ng(Pg().mark((function e(){var t,r,n,i=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,iU(r),n=Ql(Ql({},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.originTrack.getSettings())||{});case 9:case"end":return e.stop()}}),e,this)}))),function(){return F.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return this.logger.info("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==TL[0]&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&qM("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(V=Ng(Pg().mark((function e(t){var r,n,i,o,a;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(this.logger.info("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),_U(t=Ty(t).call(t,(function(e){return!!e}))),t.length>3&&(qM("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=sI(t).call(t,0,3)),n=1;n<t.length;n++)i=JM(t[0].width)/JM(t[n].width)||1,Math.floor(i)!==i&&qM("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");return Kw(t).call(t,(function(e,t){return t.maxKbps-e.maxKbps})),this._localVideoTrack&&null!==(o=t[0])&&void 0!==o&&o.contentHint&&this._localVideoTrack.setContentHint(null===(a=t[0])||void 0===a?void 0:a.contentHint),e.next=10,this._setVideoCaptureConfig(Ql({},t[0]));case 10:this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(sh.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 13:case"end":return e.stop()}}),e,this)}))),function(e){return V.apply(this,arguments)})},{key:"setVideoEncoderAutoConfigList",value:function(e){if(Array.isArray(e))return Kw(e).call(e,(function(e,t){return e.maxKbps-t.maxKbps})),YL(e)}},{key:"autoResetVideoEncoderConfig",value:function(e){var t,r=XL;if(r.length){this._videoStreamEncodeConfig.length||(this._videoStreamEncodeConfig=[qL]);var n=this._videoStreamEncodeConfig[0],i=e.width||JM(n.width),o=e.height||JM(n.height),a=i*o;if(!(JM(n.width)*JM(n.height)<=a)){var s,c,u=r[0];r.forEach((function(e){var t=JM(e.width)*JM(e.height);s||(a<t?s=e:u=e)})),c=s&&JM(s.width)*JM(s.height)-a<a-JM(u.width)*JM(u.height)?TT({},s):TT({},u),this._videoStreamEncodeConfig=Ty(t=this._videoStreamEncodeConfig).call(t,(function(e){return!(c&&JM(e.width)*JM(e.height)>=a)||(c.maxKbps=Math.min(e.maxKbps,c.maxKbps),!1)})),this._videoStreamEncodeConfig.unshift({width:i,height:o,frameRate:e.frameRate?Math.round(e.frameRate):this._videoStreamEncodeConfig[0].frameRate,maxKbps:c.maxKbps}),this.logger.print("autoResetVideoEncoderConfig() result",Gg(this._videoStreamEncodeConfig)),JN(this.id,"autoResetVideoEncoderConfig",Gg(this._videoStreamEncodeConfig))}}}},{key:"setScreenEncoderConfig",value:(U=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],!this._localScreenVideoTrack){e.next=7;break}if("16.1"===EL){e.next=6;break}return e.next=6,this._localScreenVideoTrack.updateVideoCaptureConfig(t);case 6:t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint);case 7:this._updateDummyCaptureImage(sh.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 9:case"end":return e.stop()}}),e,this)}))),function(e){return U.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(this.logger.info("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!BB())throw new bC(fC.NOT_SUPPORTED,"Browser does not support sending SEI");eU(e,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),ZL(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(wM.str2ab(t)):t;if(t.length){var i;if(e===sh.STREAM_INDEX_MAIN){var o,a;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=this._room.localStream}else{var s,c;if(null===(s=this._room)||void 0===s||null===(c=s.localScreenStream)||void 0===c||!c.hasPublished)return;i=this._room.localScreenStream}if(n.byteLength>4096)this.logger.warn("sei size must not bigger than 4KB");else{var u=TM();i.seiList.push({content:n,uuid:u,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=eC(e=i.seiList).call(e,(function(e){return e.uuid===u}));if(r>=0)BI(t=i.seiList).call(t,r,1)}}),2e3)}}else this.logger.warn("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;this.logger.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=aI(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(Lh.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=oS(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(Lh.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger.info("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.localMainReportMode,o=void 0===i?hh.NORMAL:i,a=t.audioReportMode,s=void 0===a?ph.MICROPHONE:a,c=t.interval,u=void 0===c?100:c;this._stopAudioPropertiesReport(),u<=0||(u=Math.max(100,u),this._audioPropertiesReportTimer=self.setInterval((function(){if(n||"hidden"!==document.visibilityState){var t=[],r=e._audioDeviceManager.getRecordTrack()||e._localAudioTrack;if(r){var i,a,c=null===(i=e._room)||void 0===i||null===(a=i.localStream)||void 0===a?void 0:a.audioHasPublish,u=!!e._audioDeviceManager.getRecordTrack(),d=r.getAudioLevel(s),l=HM(d),h={streamIndex:sh.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:d,nonlinearVolume:l}};if(c||u)t.push(h);else switch(o){case hh.DISCONNECT:break;case hh.RESET:h.audioPropertiesInfo.linearVolume=0,h.audioPropertiesInfo.nonlinearVolume=-127,t.push(h);break;case hh.NORMAL:t.push(h);break;default:throw new bC(fC.INVALID_PARAMS,"invalid localMainReportMode: ".concat(o," in config"))}}if(e._localScreenAudioTrack){var p=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:sh.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:p,nonlinearVolume:HM(p)}})}if(e.safeEmit(Lh.onLocalAudioPropertiesReport,t),e._room){var v=[];if(e._room.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i,o=255*t.audioLevel;v.push({streamKey:{userId:t.userId,streamIndex:sh.STREAM_INDEX_MAIN,roomId:null!==(r=null===(n=e._room)||void 0===n||null===(i=n._roomInfo)||void 0===i?void 0:i.roomId)&&void 0!==r?r:""},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:HM(o)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o,a=t.audioTrack.getAudioLevel();v.push({streamKey:{userId:r,streamIndex:t.isScreen?sh.STREAM_INDEX_SCREEN:sh.STREAM_INDEX_MAIN,roomId:null!==(n=null===(i=e._room)||void 0===i||null===(o=i.roomInfo)||void 0===o?void 0:o.roomId)&&void 0!==n?n:""},audioPropertiesInfo:{linearVolume:a,nonlinearVolume:HM(a)}})}}))}));e.safeEmit(Lh.onRemoteAudioPropertiesReport,v),e._sendActiveSpeaker(t,Ty(v).call(v,(function(e){return e.streamKey.streamIndex!==sh.STREAM_INDEX_SCREEN})))}}}),u))}},{key:"setVideoSourceType",value:(L=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),eU(t,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),eU(r,"VideoSourceType",[Zl.VIDEO_SOURCE_TYPE_EXTERNAL,Zl.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===sh.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,this.logger.print("setVideoSourceType",Fg(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==sh.STREAM_INDEX_MAIN){e.next=17;break}if(u=!1,r===Zl.VIDEO_SOURCE_TYPE_EXTERNAL&&(u=!0,(d=this._extensionManager.getPluginByName(Bj.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===(_=this._room)||void 0===_||null===(f=_.localStream)||void 0===f||null===(m=f.observer)||void 0===m||m.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubVideo||l)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==sh.STREAM_INDEX_SCREEN){e.next=26;break}if(b=!1,r===Zl.VIDEO_SOURCE_TYPE_EXTERNAL&&(b=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(g=this._screenPlayer)||void 0===g||g.stop(),this._localScreenVideoTrack=void 0,b?null===(k=this._room)||void 0===k||null===(E=k.localScreenStream)||void 0===E||null===(T=E.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===(y=this._room)||void 0===y||null===(S=y.localScreenStream)||void 0===S||!S.pubVideo){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return L.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(M=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setExternalVideoTrack()","index: %o, track: %o",t,r),eU(t,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),tU(r),t!==sh.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.video===Zl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,yH(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,!r.contentHint&&null!==(n=this._videoStreamEncodeConfig[0])&&void 0!==n&&n.contentHint&&this._localVideoTrack.setContentHint(null===(c=this._videoStreamEncodeConfig[0])||void 0===c?void 0:c.contentHint),this._initLocalTrackEvents(this._localVideoTrack),null===(i=this._videoPlayer)||void 0===i||i.playVideo(this._localVideoTrack),u=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubVideo||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==sh.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenVideo===Zl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 19:return e.next=21,EH(r,this._extensionManager);case 21:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(d=this._screenPlayer)||void 0===d||d.playVideo(this._localScreenVideoTrack),null===(l=this._room)||void 0===l||null===(h=l.localScreenStream)||void 0===h||null===(p=h.observer)||void 0===p||p.setPushVideo(!0),null===(v=this._room)||void 0===v||null===(_=v.localScreenStream)||void 0===_||!_.pubVideo){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:"setAudioSourceType",value:(N=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),eU(t,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),eU(r,"audioSourceType",[$l.AUDIO_SOURCE_TYPE_EXTERNAL,$l.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===sh.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,this.logger.print("setVideoSourceType",Fg(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==sh.STREAM_INDEX_MAIN){e.next=16;break}if(c=!1,this._trackSourceType.audio===$l.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===(_=v.observer)||void 0===_||_.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!==sh.STREAM_INDEX_SCREEN){e.next=24;break}if(g=!1,this._trackSourceType.audio===$l.AUDIO_SOURCE_TYPE_EXTERNAL&&(g=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,g?null===(y=this._room)||void 0===y||null===(S=y.localScreenStream)||void 0===S||null===(b=S.observer)||void 0===b||b.setEnableAudio(!1):null===(k=this._room)||void 0===k||null===(E=k.localScreenStream)||void 0===E||null===(T=E.observer)||void 0===T||T.setPushAudio(!1),null===(f=this._room)||void 0===f||null===(m=f.localScreenStream)||void 0===m||!m.pubAudio){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return N.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(D=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setExternalAudioTrack()","index: %o, track: %o",t,r),eU(t,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),tU(r),t!==sh.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===$l.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,bH(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!==sh.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===$l.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,IH(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(d=this._room)||void 0===d||null===(l=d.localScreenStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setPushAudio(!0),null===(p=this._room)||void 0===p||null===(v=p.localScreenStream)||void 0===v||!v.pubAudio){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return D.apply(this,arguments)})},{key:"login",value:(P=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("login()","token: %o, userInfo: %o",t,r),oU(t)||$L(t,"token"),sU(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return P.apply(this,arguments)})},{key:"logout",value:(O=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return O.apply(this,arguments)})},{key:"updateLoginToken",value:(x=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateLoginToken()","token: %o",t),oU(t)||$L(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return x.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(C=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("getPeerOnlineStatus()","userId: %o",t),sU(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(w=Ng(Pg().mark((function e(t,r){var n,i=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sU(t),hU(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 w.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(A=Ng(Pg().mark((function e(t,r){var n,i=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sU(t),nU(r,"message"),hU(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 A.apply(this,arguments)})},{key:"setServerParams",value:(R=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 R.apply(this,arguments)})},{key:"sendServerMessage",value:(I=Ng(Pg().mark((function e(t){var r,n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $L(t,"message"),hU(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 I.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(T=Ng(Pg().mark((function e(t){var r,n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nU(t,"message"),hU(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!0,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new bC(fC.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");this.logger.info("startCloudProxy()",e),$L(e.logProxy,"logProxy"),$L(e.accessProxy,"accessProxy"),$L(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=KL("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=KL("LOG_SERVER_URL"),this._originConfigServerUrls=KL("CONFIG_REQUEST_DOMAINS"),zL("ICE_CONFIG_REQUEST_URLS",e.accessProxy),zL("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)),zL("CONFIG_REQUEST_DOMAINS",[e.configProxy]),LL.clearAccessNode(this._appId),LL.clearAccessUrls(),this._ctx.useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){var e,t,r;if(this._room)throw new bC(fC.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");this.logger.info("stopCloudProxy()");var n=null===(e=this._originIceConfigRequestUrls)||void 0===e?void 0:qg(e).call(e,(function(e){return e.replace("https://","").replace("/dispatch/v1/AccessInfo?Action=GetAccessInfo","")}));zL("ICE_CONFIG_REQUEST_URLS",null!=n?n:[]),zL("LOG_SERVER_URL",null!==(t=this._originLogServerUrl)&&void 0!==t?t:""),zL("CONFIG_REQUEST_DOMAINS",null!==(r=this._originConfigServerUrls)&&void 0!==r?r:[]),LL.clearAccessNode(this._appId),LL.clearAccessUrls(),this._ctx.useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(E=Ng(Pg().mark((function e(t,r){var n,i,o,a=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),cU(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new bC(fC.REPEAT_PUSH,"repeat push public media stream");case 5:return o=WL(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:(k=Ng(Pg().mark((function e(t,r){var n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),cU(t),this._assertNotInRoom(),i=WL(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 k.apply(this,arguments)})},{key:"stopPushPublicStream",value:(b=Ng(Pg().mark((function e(t){var r,n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startPushPublicStream()","publicStreamId: %o",t),cU(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 b.apply(this,arguments)})},{key:"startPlayPublicStream",value:(S=Ng(Pg().mark((function e(t){var r,n,i,o,a=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(cU(t),this._publicStreamManager){e.next=8;break}return this._publicStreamManager=new yQ(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.on(CW.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=a._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=a._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),this._publicStreamManager.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,a.safeEmit(Lh.onPublicStreamStats,e)})),this._publicStreamManager.on(CW.ON_SEI_MESSAGED_RECEIVED,(function(e){a.safeEmit(Lh.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._publicStreamManager.connect();case 8:return e.next=10,this._publicStreamManager.startPlayPublicStream(t);case 10:r=e.sent,(n=this._publicStreamVideoPlayer.get(t))&&r.videoTrack&&n.playVideo(r.videoTrack,r),!(i=this._publicStreamAudioPlayer.get(t))&&r.audioTrack&&(i=new NX(this.id,t,{muted:(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)===Th.VIDEO_ONLY,isScreen:!1}),r.audioTrack.setPlayer(i),this._initPlayerEvents(i,!0),i.playAudio(r.audioTrack),this._publicStreamAudioPlayer.set(t,i));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(y=Ng(Pg().mark((function e(t){var r;return Pg().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:(g=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.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 g.apply(this,arguments)})},{key:"setAudioEncodeMaxBitrate",value:(m=Ng(Pg().mark((function e(t){var r,n,i,o,a,s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setAudioEncodeMaxBitrate()",t),ZL(t,"maxBitrate",6,256),this._ctx.audioProfileManager.setCustomMaxBitrate(t),!this._ctx.audioProfileManager.customMaxBitrate){e.next=10;break}if(!tL||!(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 bC(fC.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(sh.STREAM_INDEX_MAIN,t);case 8:return e.next=10,null===(s=this._room)||void 0===s?void 0:s.setAudioEncodeMaxBitrate(sh.STREAM_INDEX_SCREEN,t);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i;this.logger.print("setPublicStreamVideoPlayer()","publicStreamId: %o, videoPlayerOption: %o",e,t);var o=this._publicStreamVideoPlayer.get(e);if(null===(r=o)||void 0===r||r.destroy(),t.renderDom){o=new DX(this.id,Ql(Ql({},t),{},{userId:e})),this._initPlayerEvents(o,!0),this._publicStreamVideoPlayer.set(e,o);var a=null===(n=this._publicStreamManager)||void 0===n?void 0:n.remoteStreams.get(e);null!=a&&a.videoTrack&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==Th.PLAY_MANUALLY&&o.playVideo(a.videoTrack,a)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(f=Ng(Pg().mark((function e(t,r){var n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new jI((function(e,i){$L(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===sh.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new bC(fC.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new bC(fC.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===sh.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=JM(r.width),c=JM(r.height);if(!a)throw new bC(fC.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===sh.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=u):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=u);var d,l,h=o.captureStream(5).getVideoTracks()[0];if(e===sh.STREAM_INDEX_MAIN)this._localImgVideoTrack=h,null!==(d=this._localVideoTrack)&&void 0!==d&&d.dummy&&this._localVideoTrack.setTrack(this._localImgVideoTrack,this._extensionManager);else this._localImgScreenTrack=h,null!==(l=this._localScreenVideoTrack)&&void 0!==l&&l.dummy&&this._localScreenVideoTrack.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=Ng(Pg().mark((function e(r,n){var i,o,a;return Pg().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(Lh.onLocalStreamTrackChangedByExtension,{streamIndex:sh.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:(_=Ng(Pg().mark((function e(t){var r,n;return Pg().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),null===(r=this._localAudioTrack)||void 0===r||r.generatePreProcessingTrack(this._extensionManager),null===(n=this._localVideoTrack)||void 0===n||n.generatePreProcessingTrack(this._extensionManager);case 18:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return _.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(Gg(OQ.getDefaultValue()))}},{key:"_updatePublish",value:(v=Ng(Pg().mark((function e(){var t,r,n,i=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},this.logger.info("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:OW.PUB},t=Ql(Ql({},r),t),this._visibility){e.next=6;break}throw new bC(fC.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===rX.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:e.next=24;break;case 17:if(e.prev=17,e.t0=e.catch(12),!(e.t0 instanceof bC)){e.next=23;break}throw e.t0;case 23:throw new bC(fC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 24:return e.prev=24,n(),e.finish(24);case 27:case"end":return e.stop()}}),e,this,[[12,17,24,27]])}))),function(){return v.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(p=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),$L(t,"filePath"),ZL(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 p.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this.logger.info("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(h=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),ZL(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 h.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){this.logger.info("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){this.logger.info("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;this.logger.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{sU(e),eU(t,"priority",[yh.HIGH,yh.MEDIUM,yh.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:(l=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("takeLocalSnapshot()","streamIndex: %o",t),eU(t,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),r=t===sh.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new bC(fC.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===sh.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",TQ(r.preprocessingTrack,(null==n?void 0:n.mirrorType)===lh.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(d=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),$L(t,"id"),eU(r,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),c=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=aI(i).call(i,(function(e){return e.isScreen===(r===sh.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 bC(fC.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",TQ(c.preprocessingTrack,!1,r===sh.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){this.logger.info("setSubscribeFallbackOption()","option: %o",e);try{eU(e,"option",[gh.DISABLE,gh.VIDEO_STREAM_LOW,gh.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=this;if(e===sh.STREAM_INDEX_MAIN?(r="video"===t?this.localVideoTrack:this.localAudioTrack,n=function(){var e;return null===(e=i._room)||void 0===e?void 0:e.localStream}):(r="video"===t?this.localScreenVideoTrack:this.localScreenAudioTrack,n=function(){var e;return null===(e=i._room)||void 0===e?void 0:e.localScreenStream}),r){var o=r instanceof AH&&r.mixedAudioTrack?r.mixedAudioTrack:r.preprocessingTrack;if(o){var a=n();return this._reportMsTrackEvent(o,(null==a?void 0:a.stream.id)||"local"),o}}}},{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===sh.STREAM_INDEX_MAIN)a=aI(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=aI(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.preprocessingTrack;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.preprocessingTrack;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:"setJoinRoomParams",value:function(e){e&&(this._ctx.joinRoomParams=e)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i,o,a,s=this;(eU(e,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),t=fU(t,"volume",0,400),e===sh.STREAM_INDEX_SCREEN)?(null===(r=this._localScreenAudioTrack)||void 0===r||r.once("needReplaceTrack",(function(){var e;null===(e=s._room)||void 0===e||e.updatePubScreenTrack()})),null===(n=this._localScreenAudioTrack)||void 0===n||n.setVolume(t),this._localScreenAudioVolume=t):(null===(i=this._localAudioTrack)||void 0===i||i.once("needReplaceTrack",(function(){var e;null===(e=s._room)||void 0===e||e.updatePubTrack()})),null===(o=this._localAudioTrack)||void 0===o||o.setVolume(t),null===(a=this._audioDeviceManager.audioTrack)||void 0===a||a.setVolume(t),this._localAudioVolume=t)}},{key:"setPlaybackVolume",value:function(e,t,r){var n,i,o,a;if(sU(e),eU(t,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),r=fU(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)qM("setPlaybackVolume is not supported in Conference mode");else{var s=t===sh.STREAM_INDEX_SCREEN;s?this._remoteScreenAudioVolume.set(e,r):this._remoteAudioVolume.set(e,r);var c=null===(i=this._room)||void 0===i||null===(o=i.remoteStreams.get(e))||void 0===o?void 0:aI(o).call(o,(function(e){return e.isScreen===s}));null==c||null===(a=c.audioTrack)||void 0===a||a.setVolume(r)}}},{key:"setPublicStreamVolume",value:function(e,t){var r,n,i;$L(e,"publicStreamId"),t=fU(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:(u=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){aU(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 u.apply(this,arguments)})},{key:"updateForwardStreamToRooms",value:(c=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){aU(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 c.apply(this,arguments)})},{key:"stopForwardStreamToRooms",value:(s=Ng(Pg().mark((function e(){var t;return Pg().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 s.apply(this,arguments)})},{key:"pauseForwardStreamToAllRooms",value:(a=Ng(Pg().mark((function e(){var t;return Pg().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 a.apply(this,arguments)})},{key:"resumeForwardStreamToAllRooms",value:(o=Ng(Pg().mark((function e(){var t;return Pg().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 o.apply(this,arguments)})},{key:"ambulance",value:(i=Ng(Pg().mark((function e(){var t,r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,sZ(this);case 2:return t=e.sent,r=Gg(t),this.monitor.reportLongString("ambulance",r),e.abrupt("return",t);case 6: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(){JN(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=Ng(Pg().mark((function e(){var t,r,n,i=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},this.logger.info("_updateScreenPublish()"),r={mediaType:void 0,pubState:OW.PUB},t=Ql(Ql({},r),t),this._visibility){e.next=6;break}throw new bC(fC.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===rX.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 15:e.next=24;break;case 17:if(e.prev=17,e.t0=e.catch(12),!(e.t0 instanceof bC)){e.next=23;break}throw e.t0;case 23:throw new bC(fC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 24:return e.prev=24,n(),e.finish(24);case 27:case"end":return e.stop()}}),e,this,[[12,17,24,27]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){this.logger.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;if(!o){var u;o=new NX(this.id,r,{muted:(null===(u=this._config)||void 0===u?void 0:u.autoPlayPolicy)===Th.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?sh.STREAM_INDEX_SCREEN:sh.STREAM_INDEX_MAIN),i.set(r,o);var d=this._audioDeviceManager.getSinkId();d&&o.setPlaybackDevice(d)}(null===(a=this._config)||void 0===a?void 0:a.autoPlayPolicy)!==Th.PLAY_MANUALLY&&o.playAudio(e.audioTrack),e.audioTrack.setPlayer(o);var l=n?null!==(s=this._remoteScreenAudioVolume.get(r))&&void 0!==s?s:100:null!==(c=this._remoteAudioVolume.get(r))&&void 0!==c?c:100;e.audioTrack.setVolume(l),rL&&dL&&(t=this._remoteAudioPlayer,xQ&&clearTimeout(xQ),xQ=setTimeout((function(){var e,r=my(t);try{for(r.s();!(e=r.n()).done;){var n=gy(e.value,2),i=n[0],o=n[1];null!=i&&_C(i).call(i,"mux")&&o.pause()}}catch(jZ){r.e(jZ)}finally{r.f()}var a,s=my(t);try{for(s.s();!(a=s.n()).done;){var c=gy(a.value,2),u=c[0],d=c[1];null!=u&&_C(u).call(u,"mux")&&d.manuallyPlay()}}catch(jZ){s.e(jZ)}finally{s.f()}}),2e3))}else{var h;null===(h=o)||void 0===h||h.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;this.logger.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)!==Th.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=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.stream,n=r.attributes,i=n.localaudio,o=n.audiostream,a=n.localvideo,s=n.videostream,c=CH.NONE,o&&(c|=ch.AUDIO),s&&(c|=ch.VIDEO),!c){e.next=11;break}return e.next=8,new jI((function(e){return setTimeout(e)}));case 8:r.isScreen?this.safeEmit(Lh.onUserPublishScreen,{userId:r.userId,mediaType:c}):(this.safeEmit(Lh.onUserPublishStream,{userId:r.userId,mediaType:c,videoStreamDescriptions:r.attributes.videoDescriptions}),this._handleAutoSubscribe(r,!0)),this.safeEmit("onAddStream",{userId:r.userId,mediaType:c,isScreen:!!r.isScreen}),r.isScreen||(i&&this.safeEmit(Lh.onUserStartAudioCapture,{userId:r.userId}),a&&this.safeEmit(Lh.onUserStartVideoCapture,{userId:r.userId}));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=CH.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=ch.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=ch.VIDEO),i){var o,a;if(t&&GM(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&zM(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=pZ[e.reason])&&void 0!==t?t:uh.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?Lh.onUserUnpublishScreen:Lh.onUserUnpublishStream,a=CH.NONE;n.attributes.audiostream&&(a|=ch.AUDIO),n.attributes.videostream&&(a|=ch.VIDEO),a!==CH.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(Lh.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(Lh.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(Lh.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,Fg(e=[Lh.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._ctx.useCloudProxy&&e.state===dh.CONNECTION_STATE_CONNECTED&&this.safeEmit(Lh.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(Lh.onConnectionStateChanged,e),e.state===dh.CONNECTION_STATE_RECONNECTING){var t,r=my(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=gy(t.value,2),i=n[0],o=n[1];_C(i).call(i,"mux")&&o.stop()}}catch(jZ){r.e(jZ)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ch.AUDIO_AND_VIDEO,n=(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),i=(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e),o=[];return r&ch.AUDIO&&o.push(n),r&ch.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&ch.AUDIO&&(r.isScreen?t._remoteScreenAudioPlayer.delete(r.userId):t._remoteAudioPlayer.delete(r.userId)),r.isScreen?e.mediaType&ch.VIDEO&&t._remoteScreenPlayer.delete(r.userId):e.mediaType&ch.VIDEO&&t._remoteVideoPlayer.delete(r.userId),null==n||n.destroy()}))}}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(Lh.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(Lh.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t=this,r=e.userId,n=e.isScreen,i=e.mediaType,o=e.pubState,a=e.remoteStream,s={userId:r,mediaType:i};i&ch.AUDIO&&setTimeout((function(){t._updateAudioPlayerState(a)})),n?o===OW.PUB?this.safeEmit(Lh.onUserPublishScreen,s):this.safeEmit(Lh.onUserUnpublishScreen,Ql(Ql({},s),{},{reason:uh.STREAM_REMOVE_REASON_UNPUBLISH})):o===OW.PUB?(s.videoStreamDescriptions=a.attributes.videoDescriptions,this.safeEmit(Lh.onUserPublishStream,s),this._handleAutoSubscribe(a,!0)):this.safeEmit(Lh.onUserUnpublishStream,Ql(Ql({},s),{},{reason:uh.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(Lh.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(Lh.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Lh.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Lh.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(Lh.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(Lh.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Lh.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(Lh.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Lh.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Lh.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(Lh.onError,{errorCode:fC.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(Lh.onError,{errorCode:fC.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(Lh.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"waitForNewToken",get:function(){return!!this._tempRoomInfo}},{key:"getSubLock",value:function(e,t){var r,n=e?this._subScreenLocks:this._subLocks,i=n.get(t);i||(i=new wW(Fg(r="sub_".concat(e?1:0,"_")).call(r,t)),n.set(t,i));return i}},{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=[];return null!==(e=this._room)&&void 0!==e&&e.remoteStreams&&this._room.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){t.push({userId:e.userId,isScreen:e.isScreen,hasVideo:e.hasVideo,hasAudio:e.hasAudio,videoStreamDescriptions:e.attributes.videoDescriptions})}))})),t}},{key:"iceState",get:function(){var e,t,r;return null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient.handler)||void 0===t||null===(r=t._peerConnection)||void 0===r?void 0:r.iceConnectionState}},{key:"remoteUsers",get:function(){var e,t=[];return null!==(e=this._room)&&void 0!==e&&e.remoteUsers&&this._room.remoteUsers.forEach((function(e){t.push({userId:e.userId})})),t}},{key:"multiChatMode",get:function(){var e;return!(null===(e=this._room)||void 0===e||!e._mediaServerClient.roomAttributes.multiChatMode)}},{key:"checkMediaType",get:function(){return this._checkMediaType}},{key:"assertNotInRoom",get:function(){return this._assertNotInRoom}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(Lh.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==rX.CONNECTED)throw new bC(fC.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){eU(e,"mediaType",[ch.AUDIO,ch.VIDEO,ch.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=Ng(Pg().mark((function e(t){var r,n,i;return Pg().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===Hj.INTERNAL;if(i){var o="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: ".concat(o)),JN(this.id,e,o)}return!i}},{key:"_getServerConfig",value:function(){var e=this,t=LL.getServerConfig(this.appId);t.rts_report&&MN.setConfig(t.rts_report),this._ctx.joinRoomConfig.setServerConfig(t.web_join_room),this._getServerConfigExecutor(t),vM({engineId:this.id,appId:this.appId,sdkVersion:KL("VERSION"),requestDomains:KL("CONFIG_REQUEST_DOMAINS"),keys:["rts_report","web_join_room","web_rtc_config"],deviceId:KL("DEVICE_ID")}).then((function(t){LL.setServerConfig(e.appId,t)}))}},{key:"_getServerConfigExecutor",value:function(e){var t,r,n,i;Nx.setParameter("UPLOAD_CONSOLE_ON",!(null==e||null===(t=e.web_rtc_config)||void 0===t||!t.upload_console_on)),Nx.setParameter("UPLOAD_CONSOLE_LENGTH_CUT",null==e||null===(r=e.web_rtc_config)||void 0===r?void 0:r.upload_console_length_cut),Nx.setParameter("UPLOAD_REPORT_LIMIT",null==e||null===(n=e.web_rtc_config)||void 0===n?void 0:n.upload_report_limit),Nx.setParameter("ENABLE_REPORT_IDB_BUFFER",!(null==e||null===(i=e.web_rtc_config)||void 0===i||!i.enable_report_idb_buffer))}}]),Re}(kU);lZ([XN()],hZ.prototype,"updateToken",1),lZ([XN(),fZ("video")],hZ.prototype,"setVideoCaptureDevice",1),lZ([XN(),fZ("audio")],hZ.prototype,"setAudioCaptureDevice",1),lZ([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=KN(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)}}},XN()],hZ.prototype,"connect",1),lZ([XN()],hZ.prototype,"joinRoom",1),lZ([XN()],hZ.prototype,"leaveRoom",1),lZ([XN()],hZ.prototype,"destroy",1),lZ([XN()],hZ.prototype,"publishStream",1),lZ([XN()],hZ.prototype,"unpublishStream",1),lZ([XN()],hZ.prototype,"publishScreen",1),lZ([XN()],hZ.prototype,"unpublishScreen",1),lZ([XN()],hZ.prototype,"subscribeStream",1),lZ([vZ],hZ.prototype,"_subscribe",1),lZ([XN()],hZ.prototype,"unsubscribeStream",1),lZ([XN()],hZ.prototype,"subscribeScreen",1),lZ([XN()],hZ.prototype,"unsubscribeScreen",1),lZ([vZ],hZ.prototype,"_unsubscribe",1),lZ([XN(),_Z],hZ.prototype,"setRemoteVideoConfig",1),lZ([XN(),fZ("video")],hZ.prototype,"startVideoCapture",1),lZ([XN(),fZ("video")],hZ.prototype,"stopVideoCapture",1),lZ([XN(),fZ("audio")],hZ.prototype,"startAudioCapture",1),lZ([XN(),fZ("audio")],hZ.prototype,"stopAudioCapture",1),lZ([XN(),fZ("all")],hZ.prototype,"startAudioAndVideoCapture",1),lZ([XN()],hZ.prototype,"startVideoAndAudioCapture",1),lZ([XN()],hZ.prototype,"getAudioMixingManager",1),lZ([XN(),mZ],hZ.prototype,"startScreenCapture",1),lZ([XN(),mZ],hZ.prototype,"stopScreenCapture",1),lZ([XN()],hZ.prototype,"setLocalVideoPlayer",1),lZ([XN()],hZ.prototype,"startLiveTranscoding",1),lZ([XN()],hZ.prototype,"updateLiveTranscoding",1),lZ([XN()],hZ.prototype,"stopLiveTranscoding",1),lZ([XN()],hZ.prototype,"startSubtitle",1),lZ([XN()],hZ.prototype,"stopSubtitle",1),lZ([XN()],hZ.prototype,"setBusinessId",1),lZ([XN()],hZ.prototype,"setUserVisibility",1),lZ([XN()],hZ.prototype,"setRemoteVideoPlayer",1),lZ([XN()],hZ.prototype,"setLocalVideoMirrorType",1),lZ([XN()],hZ.prototype,"setAudioPlaybackDevice",1),lZ([XN()],hZ.prototype,"play",1),lZ([XN()],hZ.prototype,"pauseAllSubscribedStream",1),lZ([XN()],hZ.prototype,"resumeAllSubscribedStream",1),lZ([XN()],hZ.prototype,"sendUserMessage",1),lZ([XN()],hZ.prototype,"sendUserBinaryMessage",1),lZ([XN()],hZ.prototype,"sendRoomMessage",1),lZ([XN()],hZ.prototype,"sendRoomBinaryMessage",1),lZ([XN()],hZ.prototype,"setAudioCaptureConfig",1),lZ([YM("4.51"),XN()],hZ.prototype,"setVideoCaptureConfig",1),lZ([XN()],hZ.prototype,"enableSimulcastMode",1),lZ([XN()],hZ.prototype,"setVideoEncoderConfig",1),lZ([XN()],hZ.prototype,"setScreenEncoderConfig",1),lZ([XN()],hZ.prototype,"sendSEIMessage",1),lZ([YM("4.42"),XN()],hZ.prototype,"setAudioVolumeIndicationInterval",1),lZ([XN()],hZ.prototype,"enableAudioPropertiesReport",1),lZ([XN()],hZ.prototype,"setVideoSourceType",1),lZ([XN()],hZ.prototype,"setExternalVideoTrack",1),lZ([XN()],hZ.prototype,"setAudioSourceType",1),lZ([XN()],hZ.prototype,"setExternalAudioTrack",1),lZ([XN()],hZ.prototype,"login",1),lZ([XN()],hZ.prototype,"logout",1),lZ([XN()],hZ.prototype,"updateLoginToken",1),lZ([XN()],hZ.prototype,"getPeerOnlineStatus",1),lZ([XN()],hZ.prototype,"sendUserMessageOutsideRoom",1),lZ([XN()],hZ.prototype,"sendUserBinaryMessageOutsideRoom",1),lZ([XN()],hZ.prototype,"setServerParams",1),lZ([XN()],hZ.prototype,"sendServerMessage",1),lZ([XN()],hZ.prototype,"sendServerBinaryMessage",1),lZ([XN()],hZ.prototype,"startCloudProxy",1),lZ([XN()],hZ.prototype,"stopCloudProxy",1),lZ([XN()],hZ.prototype,"startPushPublicStream",1),lZ([XN()],hZ.prototype,"updatePublicStreamParam",1),lZ([XN()],hZ.prototype,"stopPushPublicStream",1),lZ([XN("streamId")],hZ.prototype,"startPlayPublicStream",1),lZ([XN("streamId")],hZ.prototype,"stopPlayPublicStream",1),lZ([XN()],hZ.prototype,"setAudioProfile",1),lZ([XN()],hZ.prototype,"setAudioEncodeMaxBitrate",1),lZ([XN()],hZ.prototype,"setPublicStreamVideoPlayer",1),lZ([XN()],hZ.prototype,"setDummyCaptureImagePath",1),lZ([XN()],hZ.prototype,"registerExtension",1),lZ([XN()],hZ.prototype,"startAudioPlaybackDeviceTest",1),lZ([XN()],hZ.prototype,"stopAudioPlaybackDeviceTest",1),lZ([XN()],hZ.prototype,"startAudioDeviceRecordTest",1),lZ([XN()],hZ.prototype,"stopAudioDeviceRecordAndPlayTest",1),lZ([XN()],hZ.prototype,"stopAudioDevicePlayTest",1),lZ([XN(),_Z],hZ.prototype,"setRemoteUserPriority",1),lZ([XN()],hZ.prototype,"takeLocalSnapshot",1),lZ([XN()],hZ.prototype,"takeRemoteSnapshot",1),lZ([XN()],hZ.prototype,"setSubscribeFallbackOption",1),lZ([XN()],hZ.prototype,"getLocalStreamTrack",1),lZ([XN()],hZ.prototype,"getRemoteStreamTrack",1),lZ([XN()],hZ.prototype,"getPublicStreamTrack",1),lZ([XN()],hZ.prototype,"setRemoteStreamRenderSync",1),lZ([XN()],hZ.prototype,"setJoinRoomParams",1),lZ([XN()],hZ.prototype,"startForwardStreamToRooms",1),lZ([XN()],hZ.prototype,"updateForwardStreamToRooms",1),lZ([XN()],hZ.prototype,"stopForwardStreamToRooms",1),lZ([XN()],hZ.prototype,"pauseForwardStreamToAllRooms",1),lZ([XN()],hZ.prototype,"resumeForwardStreamToAllRooms",1);var pZ={"client unpublished":uh.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":uh.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":uh.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":uh.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":uh.STREAM_REMOVE_REASON_REPUBLISH};function vZ(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var t,r,i,o,a,s,c,u=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=u.length,r=new Array(t),i=0;i<t;i++)r[i]=u[i];return o=r[0],a=r[1],s=r[2],this.checkMediaType(s),this.assertNotInRoom(),e.next=6,this.getSubLock(o,a).lock();case 6:return c=e.sent,e.prev=7,e.next=10,n.apply(this,r);case 10:return e.abrupt("return",e.sent);case 11:return e.prev=11,c(),e.finish(11);case 14:case"end":return e.stop()}}),e,this,[[7,,11,14]])}))),r}function _Z(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var t,r,i,o,a,s=arguments;return Pg().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=r[0],e.next=4,this.getSubLock(!1,o).lock();case 4:return a=e.sent,e.prev=5,e.next=8,n.apply(this,r);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,a(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[5,,9,12]])}))),r}function fZ(e){return function(t,r,n){var i=n.value;return n.value=Ng(Pg().mark((function t(){var r,n,o,a,s,c=arguments;return Pg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],"video"!==e&&r.push(this._audioCaptureLock.lock()),"audio"!==e&&r.push(this._videoCaptureLock.lock()),t.next=5,jI.all(r);case 5:for(n=t.sent,t.prev=6,o=c.length,a=new Array(o),s=0;s<o;s++)a[s]=c[s];return t.next=10,i.apply(this,a);case 10:return t.abrupt("return",t.sent);case 11:return t.prev=11,n.forEach((function(e){return e()})),t.finish(11);case 14:case"end":return t.stop()}}),t,this,[[6,,11,14]])}))),n}}function mZ(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var t,r,i,o,a=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._screenCaptureLock.lock();case 2:for(t=e.sent,e.prev=3,r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=7,n.apply(this,i);case 7:return e.abrupt("return",e.sent);case 8:return e.prev=8,t(),e.finish(8);case 11:case"end":return e.stop()}}),e,this,[[3,,8,11]])}))),r}var gZ,yZ=uT,SZ=HI,bZ=function(e,t,r,n){for(var i,o=n>1?void 0:n?SZ(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&&yZ(t,r,o),o},kZ=function(e){UA(i,e);var t,r,n=ew(i);function i(e,t,r){var o;return Fh(this,i),ql(aA(o=n.call(this,e,t,r)),"singleStreamRenderMode",!1),o.id=t,o.logger=new pM("BLWEngine",0,t),YL([{width:192,height:108,frameRate:15,maxKbps:100},{width:320,height:180,frameRate:15,maxKbps:140},{width:640,height:360,frameRate:15,maxKbps:400},{width:1280,height:720,frameRate:15,maxKbps:1e3},{width:1920,height:1080,frameRate:15,maxKbps:2e3}]),o._handleEngineEvents(),o}return Vh(i,[{key:"subscribeStream",value:(r=Ng(Pg().mark((function e(t,r){var n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("subscribeStream()","userId: %o, mediaType: %o",t,r),this.singleStreamRenderMode&&zM(r)&&MA(NA(i.prototype),"subscribeScreen",this).call(this,t,ch.VIDEO).catch((function(e){n.logger.error("singleStreamRenderMode subscribeScreen()",e)})),e.abrupt("return",MA(NA(i.prototype),"subscribeStream",this).call(this,t,r));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"unsubscribeStream",value:(t=Ng(Pg().mark((function e(t,r){var n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this.singleStreamRenderMode&&zM(r)&&MA(NA(i.prototype),"unsubscribeScreen",this).call(this,t,ch.VIDEO).catch((function(e){n.logger.error("singleStreamRenderMode unsubscribeScreen()",e)})),e.abrupt("return",MA(NA(i.prototype),"unsubscribeStream",this).call(this,t,r));case 3:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"setRemoteScreenVideoStreamIndex",value:function(e){var t;return this.logger.print("setRemoteScreenVideoStreamIndex()","streamIndex: %o",e),(null===(t=this._room)||void 0===t?void 0:t.connectionState)!==rX.CONNECTED&&(this.singleStreamRenderMode=e===sh.STREAM_INDEX_MAIN,!0)}},{key:"setRemoteVideoPlayer",value:function(e,t){if(this.logger.print("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),!this.singleStreamRenderMode||e!==sh.STREAM_INDEX_SCREEN)return MA(NA(i.prototype),"setRemoteVideoPlayer",this).call(this,e,t)}},{key:"destroy",value:function(){this.singleStreamRenderMode=!1,MA(NA(i.prototype),"destroy",this).call(this)}},{key:"_updateVideoPlayerState",value:function(e){var t,r;if(!this.singleStreamRenderMode)return MA(NA(i.prototype),"_updateVideoPlayerState",this).call(this,e);var n,o=e.userId,a=null===(t=this._room)||void 0===t?void 0:t.remoteStreams.get(o);Array.isArray(a)&&a.forEach((function(e){e.isScreen&&(n=e)}));var s=this._remoteVideoPlayer.get(o);if(s){if(!e.isScreen&&null!==(r=n)&&void 0!==r&&r.videoTrack)return this.logger.print("_updateVideoPlayerState","prevent play main stream"),void s.playVideo(n.videoTrack,n);var c;if(e.videoTrack)(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)!==Th.PLAY_MANUALLY&&s.playVideo(e.videoTrack,e);else s.played&&s.stop()}}},{key:"_handleEngineEvents",value:function(){var e=this;this.on(Lh.onUserPublishScreen,(function(t){if(e.singleStreamRenderMode&&zM(t.mediaType)){var r,n,i=null===(r=e._room)||void 0===r?void 0:r.remoteStreams.get(t.userId),o=null==i?void 0:aI(i).call(i,(function(e){return!e.isScreen})),a=null==i?void 0:aI(i).call(i,(function(e){return e.isScreen}));null!=a&&a.hasSubscribed?(e.logger.info("onUserPublishScreen","singleStreamRenderMode screen hasSubscribed"),e._updateVideoPlayerState(a)):(null!==(n=e._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo||null!=o&&o.hasSubscribed&&zM(o.subMediaType))&&(e.logger.info("onUserPublishScreen","singleStreamRenderMode subscribeScreen"),e.subscribeScreen(t.userId,ch.VIDEO))}})),this.on(Lh.onUserUnpublishScreen,(function(t){if(e.singleStreamRenderMode&&zM(t.mediaType)){var r,n=e._remoteVideoPlayer.get(t.userId),i=null===(r=e._room)||void 0===r?void 0:r.remoteStreams.get(t.userId),o=null==i?void 0:aI(i).call(i,(function(e){return!e.isScreen}));if(null==o||!o.videoTrack||!n)return;n.playVideo(o.videoTrack)}}))}}]),i}(hZ);bZ([XN()],kZ.prototype,"subscribeStream",1),bZ([XN()],kZ.prototype,"unsubscribeStream",1),bZ([XN()],kZ.prototype,"setRemoteScreenVideoStreamIndex",1),bZ([XN()],kZ.prototype,"setRemoteVideoPlayer",1),bZ([XN()],kZ.prototype,"destroy",1);var EZ=new pM("VERTC",0);Tx.storeKey=Fg(gZ="".concat(Date.now(),"-")).call(gZ,LL.getDeviceId()),UN({rtc_sdk_version:GL.VERSION,device_id:LL.getDeviceId(),log_cache_key:Tx.storeKey}),VN(GL.LOG_SERVER_URL);var TZ=1,IZ=function(e,t){EZ.info("createEngine","Invoke VERTC.createEngine"),$L(e,"appId");var r=(TZ++).toString();return WN(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new hZ(e,r,t)},RZ=function(e,t){EZ.print("createBLWEngine","Invoke VERTC.createBLWEngine"),$L(e,"appId");var r=(TZ++).toString();return WN(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new kZ(e,r,t)},AZ=function(e){if(EZ.info("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof hZ))throw new bC(fC.INVALID_ENGINE,"Invalid engine object");var t;e.destroy(),(t=e.monitor).report("sdk_init_engine",{start:Date.now(),type:"end"}),zN.delete(t.id)},wZ=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Oj.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),CZ=function(){var e=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=(t=s.length>0&&void 0!==s[0]?s[0]:{video:!0,audio:!0}).video,n=t.audio,i={video:!1,audio:!1},!r){e.next=14;break}return e.prev=4,e.next=7,Oj.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,Oj.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)}}(),xZ=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Oj.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),OZ=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Oj.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),PZ=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Oj.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),DZ=function(){return GL.VERSION},NZ=function(){return wB()},MZ=function(){return xB()},LZ=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(Tx.logLevel=t),r&&(Tx.LogfileSize=r)},UZ=function(e){Tx.download(e)};function VZ(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Gg(qg(t).call(t,(function(e){return e instanceof hZ?"[ENGINE]":e})))}function FZ(e,t){return function(){BN(t,0,VZ.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 jN(t,0,VZ(e)),e})).catch((function(e){throw jN(t,e.code,e.message),e})):(jN(t,0,VZ(r)),r)}}return Ql(Ql(Ql(Ql({},new(Vh((function e(){Fh(this,e),ql(this,"getSdkVersion",FZ(DZ,"getSdkVersion")),ql(this,"createEngine",FZ(IZ,"createEngine")),ql(this,"createBLWEngine",FZ(RZ,"createBLWEngine")),ql(this,"destroyEngine",FZ(AZ,"destroyEngine")),ql(this,"enumerateDevices",FZ(wZ,"enumerateDevices")),ql(this,"enableDevices",FZ(CZ,"enableDevices")),ql(this,"enumerateAudioCaptureDevices",FZ(xZ,"enumerateAudioCaptureDevices")),ql(this,"enumerateVideoCaptureDevices",FZ(OZ,"enumerateVideoCaptureDevices")),ql(this,"enumerateAudioPlaybackDevices",FZ(PZ,"enumerateAudioPlaybackDevices")),ql(this,"getParameter",KL),ql(this,"setParameter",zL),ql(this,"isSupported",FZ(NZ,"isSupported")),ql(this,"getSupportedCodecs",FZ(MZ,"getSupportedCodecs")),ql(this,"events",Lh),ql(this,"ErrorCode",fC),ql(this,"platform","BytePlus"),ql(this,"commitInfo","HEAD<e244644*>"),ql(this,"downloadLog",FZ(UZ,"downloadLog")),ql(this,"setLogConfig",FZ(LZ,"setLogConfig"))})))),Oh),Mh),{},{events:Lh})}));
|
|
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(e)}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n=function(e){return e&&e.Math===Math&&e},i=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof t&&t)||function(){return this}()||t||Function("return this")(),o=function(e){try{return!!e()}catch(t){return!0}},a=!o((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),s=a,c=Function.prototype,u=c.apply,d=c.call,l="object"==typeof Reflect&&Reflect.apply||(s?d.bind(u):function(){return d.apply(u,arguments)}),h=a,p=Function.prototype,v=p.call,_=h&&p.bind.bind(v,v),f=h?_:function(e){return function(){return v.apply(e,arguments)}},m=f,g=m({}.toString),y=m("".slice),S=function(e){return y(g(e),8,-1)},b=S,k=f,E=function(e){if("Function"===b(e))return k(e)},T="object"==typeof document&&document.all,I={all:T,IS_HTMLDDA:void 0===T&&void 0!==T},R=I.all,A=I.IS_HTMLDDA?function(e){return"function"==typeof e||e===R}:function(e){return"function"==typeof e},w={},C=!o((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),x=a,O=Function.prototype.call,P=x?O.bind(O):function(){return O.apply(O,arguments)},D={},N={}.propertyIsEnumerable,M=Object.getOwnPropertyDescriptor,L=M&&!N.call({1:2},1);D.f=L?function(e){var t=M(this,e);return!!t&&t.enumerable}:N;var U,V,F=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},B=o,j=S,H=Object,G=f("".split),z=B((function(){return!H("z").propertyIsEnumerable(0)}))?function(e){return"String"===j(e)?G(e,""):H(e)}:H,K=function(e){return null==e},W=K,X=TypeError,Y=function(e){if(W(e))throw X("Can't call method on "+e);return e},q=z,J=Y,Q=function(e){return q(J(e))},Z=A,$=I.all,ee=I.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:Z(e)||e===$}:function(e){return"object"==typeof e?null!==e:Z(e)},te={},re=te,ne=i,ie=A,oe=function(e){return ie(e)?e:void 0},ae=function(e,t){return arguments.length<2?oe(re[e])||oe(ne[e]):re[e]&&re[e][t]||ne[e]&&ne[e][t]},se=f({}.isPrototypeOf),ce="undefined"!=typeof navigator&&String(navigator.userAgent)||"",ue=i,de=ce,le=ue.process,he=ue.Deno,pe=le&&le.versions||he&&he.version,ve=pe&&pe.v8;ve&&(V=(U=ve.split("."))[0]>0&&U[0]<4?1:+(U[0]+U[1])),!V&&de&&(!(U=de.match(/Edge\/(\d+)/))||U[1]>=74)&&(U=de.match(/Chrome\/(\d+)/))&&(V=+U[1]);var _e=V,fe=_e,me=o,ge=i.String,ye=!!Object.getOwnPropertySymbols&&!me((function(){var e=Symbol("symbol detection");return!ge(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&fe&&fe<41})),Se=ye&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,be=ae,ke=A,Ee=se,Te=Object,Ie=Se?function(e){return"symbol"==typeof e}:function(e){var t=be("Symbol");return ke(t)&&Ee(t.prototype,Te(e))},Re=String,Ae=function(e){try{return Re(e)}catch(t){return"Object"}},we=A,Ce=Ae,xe=TypeError,Oe=function(e){if(we(e))return e;throw xe(Ce(e)+" is not a function")},Pe=Oe,De=K,Ne=function(e,t){var r=e[t];return De(r)?void 0:Pe(r)},Me=P,Le=A,Ue=ee,Ve=TypeError,Fe={exports:{}},Be=i,je=Object.defineProperty,He=function(e,t){try{je(Be,e,{value:t,configurable:!0,writable:!0})}catch(r){Be[e]=t}return t},Ge="__core-js_shared__",ze=i[Ge]||He(Ge,{}),Ke=ze;(Fe.exports=function(e,t){return Ke[e]||(Ke[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.32.1",mode:"pure",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.32.1/LICENSE",source:"https://github.com/zloirock/core-js"});var We=Fe.exports,Xe=Y,Ye=Object,qe=function(e){return Ye(Xe(e))},Je=qe,Qe=f({}.hasOwnProperty),Ze=Object.hasOwn||function(e,t){return Qe(Je(e),t)},$e=f,et=0,tt=Math.random(),rt=$e(1..toString),nt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+rt(++et+tt,36)},it=We,ot=Ze,at=nt,st=ye,ct=Se,ut=i.Symbol,dt=it("wks"),lt=ct?ut.for||ut:ut&&ut.withoutSetter||at,ht=function(e){return ot(dt,e)||(dt[e]=st&&ot(ut,e)?ut[e]:lt("Symbol."+e)),dt[e]},pt=P,vt=ee,_t=Ie,ft=Ne,mt=function(e,t){var r,n;if("string"===t&&Le(r=e.toString)&&!Ue(n=Me(r,e)))return n;if(Le(r=e.valueOf)&&!Ue(n=Me(r,e)))return n;if("string"!==t&&Le(r=e.toString)&&!Ue(n=Me(r,e)))return n;throw Ve("Can't convert object to primitive value")},gt=TypeError,yt=ht("toPrimitive"),St=function(e,t){if(!vt(e)||_t(e))return e;var r,n=ft(e,yt);if(n){if(void 0===t&&(t="default"),r=pt(n,e,t),!vt(r)||_t(r))return r;throw gt("Can't convert object to primitive value")}return void 0===t&&(t="number"),mt(e,t)},bt=Ie,kt=function(e){var t=St(e,"string");return bt(t)?t:t+""},Et=ee,Tt=i.document,It=Et(Tt)&&Et(Tt.createElement),Rt=function(e){return It?Tt.createElement(e):{}},At=Rt,wt=!C&&!o((function(){return 7!==Object.defineProperty(At("div"),"a",{get:function(){return 7}}).a})),Ct=C,xt=P,Ot=D,Pt=F,Dt=Q,Nt=kt,Mt=Ze,Lt=wt,Ut=Object.getOwnPropertyDescriptor;w.f=Ct?Ut:function(e,t){if(e=Dt(e),t=Nt(t),Lt)try{return Ut(e,t)}catch(r){}if(Mt(e,t))return Pt(!xt(Ot.f,e,t),e[t])};var Vt=o,Ft=A,Bt=/#|\.prototype\./,jt=function(e,t){var r=Gt[Ht(e)];return r===Kt||r!==zt&&(Ft(t)?Vt(t):!!t)},Ht=jt.normalize=function(e){return String(e).replace(Bt,".").toLowerCase()},Gt=jt.data={},zt=jt.NATIVE="N",Kt=jt.POLYFILL="P",Wt=jt,Xt=Oe,Yt=a,qt=E(E.bind),Jt=function(e,t){return Xt(e),void 0===t?e:Yt?qt(e,t):function(){return e.apply(t,arguments)}},Qt={},Zt=C&&o((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),$t=ee,er=String,tr=TypeError,rr=function(e){if($t(e))return e;throw tr(er(e)+" is not an object")},nr=C,ir=wt,or=Zt,ar=rr,sr=kt,cr=TypeError,ur=Object.defineProperty,dr=Object.getOwnPropertyDescriptor,lr="enumerable",hr="configurable",pr="writable";Qt.f=nr?or?function(e,t,r){if(ar(e),t=sr(t),ar(r),"function"==typeof e&&"prototype"===t&&"value"in r&&pr in r&&!r[pr]){var n=dr(e,t);n&&n[pr]&&(e[t]=r.value,r={configurable:hr in r?r[hr]:n[hr],enumerable:lr in r?r[lr]:n[lr],writable:!1})}return ur(e,t,r)}:ur:function(e,t,r){if(ar(e),t=sr(t),ar(r),ir)try{return ur(e,t,r)}catch(n){}if("get"in r||"set"in r)throw cr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var vr=Qt,_r=F,fr=C?function(e,t,r){return vr.f(e,t,_r(1,r))}:function(e,t,r){return e[t]=r,e},mr=i,gr=l,yr=E,Sr=A,br=w.f,kr=Wt,Er=te,Tr=Jt,Ir=fr,Rr=Ze,Ar=function(e){var t=function(r,n,i){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,i)}return gr(e,this,arguments)};return t.prototype=e.prototype,t},wr=function(e,t){var r,n,i,o,a,s,c,u,d,l=e.target,h=e.global,p=e.stat,v=e.proto,_=h?mr:p?mr[l]:(mr[l]||{}).prototype,f=h?Er:Er[l]||Ir(Er,l,{})[l],m=f.prototype;for(o in t)n=!(r=kr(h?o:l+(p?".":"#")+o,e.forced))&&_&&Rr(_,o),s=f[o],n&&(c=e.dontCallGetSet?(d=br(_,o))&&d.value:_[o]),a=n&&c?c:t[o],n&&typeof s==typeof a||(u=e.bind&&n?Tr(a,mr):e.wrap&&n?Ar(a):v&&Sr(a)?yr(a):a,(e.sham||a&&a.sham||s&&s.sham)&&Ir(u,"sham",!0),Ir(f,o,u),v&&(Rr(Er,i=l+"Prototype")||Ir(Er,i,{}),Ir(Er[i],o,a),e.real&&m&&(r||!m[o])&&Ir(m,o,a)))},Cr=Math.ceil,xr=Math.floor,Or=Math.trunc||function(e){var t=+e;return(t>0?xr:Cr)(t)},Pr=function(e){var t=+e;return t!=t||0===t?0:Or(t)},Dr=Pr,Nr=Math.max,Mr=Math.min,Lr=function(e,t){var r=Dr(e);return r<0?Nr(r+t,0):Mr(r,t)},Ur=Pr,Vr=Math.min,Fr=function(e){return e>0?Vr(Ur(e),9007199254740991):0},Br=Fr,jr=function(e){return Br(e.length)},Hr=Q,Gr=Lr,zr=jr,Kr=function(e){return function(t,r,n){var i,o=Hr(t),a=zr(o),s=Gr(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},Wr={includes:Kr(!0),indexOf:Kr(!1)},Xr={},Yr=Ze,qr=Q,Jr=Wr.indexOf,Qr=Xr,Zr=f([].push),$r=function(e,t){var r,n=qr(e),i=0,o=[];for(r in n)!Yr(Qr,r)&&Yr(n,r)&&Zr(o,r);for(;t.length>i;)Yr(n,r=t[i++])&&(~Jr(o,r)||Zr(o,r));return o},en=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],tn=$r,rn=en,nn=Object.keys||function(e){return tn(e,rn)},on=qe,an=nn;wr({target:"Object",stat:!0,forced:o((function(){an(1)}))},{keys:function(e){return an(on(e))}});var sn=te.Object.keys,cn=r(sn),un={};un[ht("toStringTag")]="z";var dn="[object z]"===String(un),ln=dn,hn=A,pn=S,vn=ht("toStringTag"),_n=Object,fn="Arguments"===pn(function(){return arguments}()),mn=ln?pn: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=_n(e),vn))?r:fn?pn(t):"Object"===(n=pn(t))&&hn(t.callee)?"Arguments":n},gn=mn,yn=String,Sn=function(e){if("Symbol"===gn(e))throw TypeError("Cannot convert a Symbol value to a string");return yn(e)},bn={},kn=C,En=Zt,Tn=Qt,In=rr,Rn=Q,An=nn;bn.f=kn&&!En?Object.defineProperties:function(e,t){In(e);for(var r,n=Rn(t),i=An(t),o=i.length,a=0;o>a;)Tn.f(e,r=i[a++],n[r]);return e};var wn,Cn=ae("document","documentElement"),xn=nt,On=We("keys"),Pn=function(e){return On[e]||(On[e]=xn(e))},Dn=rr,Nn=bn,Mn=en,Ln=Xr,Un=Cn,Vn=Rt,Fn="prototype",Bn="script",jn=Pn("IE_PROTO"),Hn=function(){},Gn=function(e){return"<"+Bn+">"+e+"</"+Bn+">"},zn=function(e){e.write(Gn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Kn=function(){try{wn=new ActiveXObject("htmlfile")}catch(i){}var e,t,r;Kn="undefined"!=typeof document?document.domain&&wn?zn(wn):(t=Vn("iframe"),r="java"+Bn+":",t.style.display="none",Un.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(Gn("document.F=Object")),e.close(),e.F):zn(wn);for(var n=Mn.length;n--;)delete Kn[Fn][Mn[n]];return Kn()};Ln[jn]=!0;var Wn=Object.create||function(e,t){var r;return null!==e?(Hn[Fn]=Dn(e),r=new Hn,Hn[Fn]=null,r[jn]=e):r=Kn(),void 0===t?r:Nn.f(r,t)},Xn={},Yn=$r,qn=en.concat("length","prototype");Xn.f=Object.getOwnPropertyNames||function(e){return Yn(e,qn)};var Jn={},Qn=kt,Zn=Qt,$n=F,ei=function(e,t,r){var n=Qn(t);n in e?Zn.f(e,n,$n(0,r)):e[n]=r},ti=Lr,ri=jr,ni=ei,ii=Array,oi=Math.max,ai=function(e,t,r){for(var n=ri(e),i=ti(t,n),o=ti(void 0===r?n:r,n),a=ii(oi(o-i,0)),s=0;i<o;i++,s++)ni(a,s,e[i]);return a.length=s,a},si=S,ci=Q,ui=Xn.f,di=ai,li="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Jn.f=function(e){return li&&"Window"===si(e)?function(e){try{return ui(e)}catch(t){return di(li)}}(e):ui(ci(e))};var hi={};hi.f=Object.getOwnPropertySymbols;var pi=fr,vi=function(e,t,r,n){return n&&n.enumerable?e[t]=r:pi(e,t,r),e},_i=Qt,fi=function(e,t,r){return _i.f(e,t,r)},mi={},gi=ht;mi.f=gi;var yi,Si,bi,ki=te,Ei=Ze,Ti=mi,Ii=Qt.f,Ri=function(e){var t=ki.Symbol||(ki.Symbol={});Ei(t,e)||Ii(t,e,{value:Ti.f(e)})},Ai=P,wi=ae,Ci=ht,xi=vi,Oi=function(){var e=wi("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=Ci("toPrimitive");t&&!t[n]&&xi(t,n,(function(e){return Ai(r,this)}),{arity:1})},Pi=mn,Di=dn?{}.toString:function(){return"[object "+Pi(this)+"]"},Ni=dn,Mi=Qt.f,Li=fr,Ui=Ze,Vi=Di,Fi=ht("toStringTag"),Bi=function(e,t,r,n){if(e){var i=r?e:e.prototype;Ui(i,Fi)||Mi(i,Fi,{configurable:!0,value:t}),n&&!Ni&&Li(i,"toString",Vi)}},ji=A,Hi=i.WeakMap,Gi=ji(Hi)&&/native code/.test(String(Hi)),zi=i,Ki=ee,Wi=fr,Xi=Ze,Yi=ze,qi=Pn,Ji=Xr,Qi="Object already initialized",Zi=zi.TypeError,$i=zi.WeakMap;if(Gi||Yi.state){var eo=Yi.state||(Yi.state=new $i);eo.get=eo.get,eo.has=eo.has,eo.set=eo.set,yi=function(e,t){if(eo.has(e))throw Zi(Qi);return t.facade=e,eo.set(e,t),t},Si=function(e){return eo.get(e)||{}},bi=function(e){return eo.has(e)}}else{var to=qi("state");Ji[to]=!0,yi=function(e,t){if(Xi(e,to))throw Zi(Qi);return t.facade=e,Wi(e,to,t),t},Si=function(e){return Xi(e,to)?e[to]:{}},bi=function(e){return Xi(e,to)}}var ro={set:yi,get:Si,has:bi,enforce:function(e){return bi(e)?Si(e):yi(e,{})},getterFor:function(e){return function(t){var r;if(!Ki(t)||(r=Si(t)).type!==e)throw Zi("Incompatible receiver, "+e+" required");return r}}},no=S,io=Array.isArray||function(e){return"Array"===no(e)},oo=A,ao=ze,so=f(Function.toString);oo(ao.inspectSource)||(ao.inspectSource=function(e){return so(e)});var co=ao.inspectSource,uo=f,lo=o,ho=A,po=mn,vo=co,_o=function(){},fo=[],mo=ae("Reflect","construct"),go=/^\s*(?:class|function)\b/,yo=uo(go.exec),So=!go.exec(_o),bo=function(e){if(!ho(e))return!1;try{return mo(_o,fo,e),!0}catch(t){return!1}},ko=function(e){if(!ho(e))return!1;switch(po(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return So||!!yo(go,vo(e))}catch(t){return!0}};ko.sham=!0;var Eo=!mo||lo((function(){var e;return bo(bo.call)||!bo(Object)||!bo((function(){e=!0}))||e}))?ko:bo,To=io,Io=Eo,Ro=ee,Ao=ht("species"),wo=Array,Co=function(e){var t;return To(e)&&(t=e.constructor,(Io(t)&&(t===wo||To(t.prototype))||Ro(t)&&null===(t=t[Ao]))&&(t=void 0)),void 0===t?wo:t},xo=function(e,t){return new(Co(e))(0===t?0:t)},Oo=Jt,Po=z,Do=qe,No=jr,Mo=xo,Lo=f([].push),Uo=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=Do(c),_=Po(v),f=Oo(u,d),m=No(_),g=0,y=l||Mo,S=t?y(c,m):r||a?y(c,0):void 0;m>g;g++)if((s||g in _)&&(p=f(h=_[g],g,v),e))if(t)S[g]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return g;case 2:Lo(S,h)}else switch(e){case 4:return!1;case 7:Lo(S,h)}return o?-1:n||i?i:S}},Vo={forEach:Uo(0),map:Uo(1),filter:Uo(2),some:Uo(3),every:Uo(4),find:Uo(5),findIndex:Uo(6),filterReject:Uo(7)},Fo=wr,Bo=i,jo=P,Ho=f,Go=C,zo=ye,Ko=o,Wo=Ze,Xo=se,Yo=rr,qo=Q,Jo=kt,Qo=Sn,Zo=F,$o=Wn,ea=nn,ta=Xn,ra=Jn,na=hi,ia=w,oa=Qt,aa=bn,sa=D,ca=vi,ua=fi,da=We,la=Xr,ha=nt,pa=ht,va=mi,_a=Ri,fa=Oi,ma=Bi,ga=ro,ya=Vo.forEach,Sa=Pn("hidden"),ba="Symbol",ka="prototype",Ea=ga.set,Ta=ga.getterFor(ba),Ia=Object[ka],Ra=Bo.Symbol,Aa=Ra&&Ra[ka],wa=Bo.TypeError,Ca=Bo.QObject,xa=ia.f,Oa=oa.f,Pa=ra.f,Da=sa.f,Na=Ho([].push),Ma=da("symbols"),La=da("op-symbols"),Ua=da("wks"),Va=!Ca||!Ca[ka]||!Ca[ka].findChild,Fa=Go&&Ko((function(){return 7!==$o(Oa({},"a",{get:function(){return Oa(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=xa(Ia,t);n&&delete Ia[t],Oa(e,t,r),n&&e!==Ia&&Oa(Ia,t,n)}:Oa,Ba=function(e,t){var r=Ma[e]=$o(Aa);return Ea(r,{type:ba,tag:e,description:t}),Go||(r.description=t),r},ja=function(e,t,r){e===Ia&&ja(La,t,r),Yo(e);var n=Jo(t);return Yo(r),Wo(Ma,n)?(r.enumerable?(Wo(e,Sa)&&e[Sa][n]&&(e[Sa][n]=!1),r=$o(r,{enumerable:Zo(0,!1)})):(Wo(e,Sa)||Oa(e,Sa,Zo(1,{})),e[Sa][n]=!0),Fa(e,n,r)):Oa(e,n,r)},Ha=function(e,t){Yo(e);var r=qo(t),n=ea(r).concat(Wa(r));return ya(n,(function(t){Go&&!jo(Ga,r,t)||ja(e,t,r[t])})),e},Ga=function(e){var t=Jo(e),r=jo(Da,this,t);return!(this===Ia&&Wo(Ma,t)&&!Wo(La,t))&&(!(r||!Wo(this,t)||!Wo(Ma,t)||Wo(this,Sa)&&this[Sa][t])||r)},za=function(e,t){var r=qo(e),n=Jo(t);if(r!==Ia||!Wo(Ma,n)||Wo(La,n)){var i=xa(r,n);return!i||!Wo(Ma,n)||Wo(r,Sa)&&r[Sa][n]||(i.enumerable=!0),i}},Ka=function(e){var t=Pa(qo(e)),r=[];return ya(t,(function(e){Wo(Ma,e)||Wo(la,e)||Na(r,e)})),r},Wa=function(e){var t=e===Ia,r=Pa(t?La:qo(e)),n=[];return ya(r,(function(e){!Wo(Ma,e)||t&&!Wo(Ia,e)||Na(n,Ma[e])})),n};zo||(Ra=function(){if(Xo(Aa,this))throw wa("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Qo(arguments[0]):void 0,t=ha(e),r=function(e){this===Ia&&jo(r,La,e),Wo(this,Sa)&&Wo(this[Sa],t)&&(this[Sa][t]=!1),Fa(this,t,Zo(1,e))};return Go&&Va&&Fa(Ia,t,{configurable:!0,set:r}),Ba(t,e)},ca(Aa=Ra[ka],"toString",(function(){return Ta(this).tag})),ca(Ra,"withoutSetter",(function(e){return Ba(ha(e),e)})),sa.f=Ga,oa.f=ja,aa.f=Ha,ia.f=za,ta.f=ra.f=Ka,na.f=Wa,va.f=function(e){return Ba(pa(e),e)},Go&&ua(Aa,"description",{configurable:!0,get:function(){return Ta(this).description}})),Fo({global:!0,constructor:!0,wrap:!0,forced:!zo,sham:!zo},{Symbol:Ra}),ya(ea(Ua),(function(e){_a(e)})),Fo({target:ba,stat:!0,forced:!zo},{useSetter:function(){Va=!0},useSimple:function(){Va=!1}}),Fo({target:"Object",stat:!0,forced:!zo,sham:!Go},{create:function(e,t){return void 0===t?$o(e):Ha($o(e),t)},defineProperty:ja,defineProperties:Ha,getOwnPropertyDescriptor:za}),Fo({target:"Object",stat:!0,forced:!zo},{getOwnPropertyNames:Ka}),fa(),ma(Ra,ba),la[Sa]=!0;var Xa=ye&&!!Symbol.for&&!!Symbol.keyFor,Ya=wr,qa=ae,Ja=Ze,Qa=Sn,Za=We,$a=Xa,es=Za("string-to-symbol-registry"),ts=Za("symbol-to-string-registry");Ya({target:"Symbol",stat:!0,forced:!$a},{for:function(e){var t=Qa(e);if(Ja(es,t))return es[t];var r=qa("Symbol")(t);return es[t]=r,ts[r]=t,r}});var rs=wr,ns=Ze,is=Ie,os=Ae,as=Xa,ss=We("symbol-to-string-registry");rs({target:"Symbol",stat:!0,forced:!as},{keyFor:function(e){if(!is(e))throw TypeError(os(e)+" is not a symbol");if(ns(ss,e))return ss[e]}});var cs=f([].slice),us=io,ds=A,ls=S,hs=Sn,ps=f([].push),vs=wr,_s=ae,fs=l,ms=P,gs=f,ys=o,Ss=A,bs=Ie,ks=cs,Es=function(e){if(ds(e))return e;if(us(e)){for(var t=e.length,r=[],n=0;n<t;n++){var i=e[n];"string"==typeof i?ps(r,i):"number"!=typeof i&&"Number"!==ls(i)&&"String"!==ls(i)||ps(r,hs(i))}var o=r.length,a=!0;return function(e,t){if(a)return a=!1,t;if(us(this))return t;for(var n=0;n<o;n++)if(r[n]===e)return t}}},Ts=ye,Is=String,Rs=_s("JSON","stringify"),As=gs(/./.exec),ws=gs("".charAt),Cs=gs("".charCodeAt),xs=gs("".replace),Os=gs(1..toString),Ps=/[\uD800-\uDFFF]/g,Ds=/^[\uD800-\uDBFF]$/,Ns=/^[\uDC00-\uDFFF]$/,Ms=!Ts||ys((function(){var e=_s("Symbol")("stringify detection");return"[null]"!==Rs([e])||"{}"!==Rs({a:e})||"{}"!==Rs(Object(e))})),Ls=ys((function(){return'"\\udf06\\ud834"'!==Rs("\udf06\ud834")||'"\\udead"'!==Rs("\udead")})),Us=function(e,t){var r=ks(arguments),n=Es(t);if(Ss(n)||void 0!==e&&!bs(e))return r[1]=function(e,t){if(Ss(n)&&(t=ms(n,this,Is(e),t)),!bs(t))return t},fs(Rs,null,r)},Vs=function(e,t,r){var n=ws(r,t-1),i=ws(r,t+1);return As(Ds,e)&&!As(Ns,i)||As(Ns,e)&&!As(Ds,n)?"\\u"+Os(Cs(e,0),16):e};Rs&&vs({target:"JSON",stat:!0,arity:3,forced:Ms||Ls},{stringify:function(e,t,r){var n=ks(arguments),i=fs(Ms?Us:Rs,null,n);return Ls&&"string"==typeof i?xs(i,Ps,Vs):i}});var Fs=hi,Bs=qe;wr({target:"Object",stat:!0,forced:!ye||o((function(){Fs.f(1)}))},{getOwnPropertySymbols:function(e){var t=Fs.f;return t?t(Bs(e)):[]}});var js=te.Object.getOwnPropertySymbols,Hs=r(js),Gs=o,zs=_e,Ks=ht("species"),Ws=function(e){return zs>=51||!Gs((function(){var t=[];return(t.constructor={})[Ks]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Xs=Vo.filter;wr({target:"Array",proto:!0,forced:!Ws("filter")},{filter:function(e){return Xs(this,e,arguments.length>1?arguments[1]:void 0)}});var Ys=te,qs=function(e){return Ys[e+"Prototype"]},Js=qs("Array").filter,Qs=se,Zs=Js,$s=Array.prototype,ec=function(e){var t=e.filter;return e===$s||Qs($s,e)&&t===$s.filter?Zs:t},tc=r(ec),rc={exports:{}},nc=wr,ic=o,oc=Q,ac=w.f,sc=C;nc({target:"Object",stat:!0,forced:!sc||ic((function(){ac(1)})),sham:!sc},{getOwnPropertyDescriptor:function(e,t){return ac(oc(e),t)}});var cc=te.Object,uc=rc.exports=function(e,t){return cc.getOwnPropertyDescriptor(e,t)};cc.getOwnPropertyDescriptor.sham&&(uc.sham=!0);var dc=rc.exports,lc=r(dc),hc=C,pc=io,vc=TypeError,_c=Object.getOwnPropertyDescriptor,fc=hc&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}()?function(e,t){if(pc(e)&&!_c(e,"length").writable)throw vc("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},mc=TypeError,gc=function(e){if(e>9007199254740991)throw mc("Maximum allowed index exceeded");return e},yc=qe,Sc=jr,bc=fc,kc=gc;wr({target:"Array",proto:!0,arity:1,forced:o((function(){return 4294967297!==[].push.call({length:4294967296},1)}))||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}}()},{push:function(e){var t=yc(this),r=Sc(t),n=arguments.length;kc(r+n);for(var i=0;i<n;i++)t[r]=arguments[i],r++;return bc(t,r),r}});var Ec,Tc,Ic,Rc=qs("Array").push,Ac=se,wc=Rc,Cc=Array.prototype,xc=r((function(e){var t=e.push;return e===Cc||Ac(Cc,e)&&t===Cc.push?wc:t})),Oc={},Pc=C,Dc=Ze,Nc=Function.prototype,Mc=Pc&&Object.getOwnPropertyDescriptor,Lc=Dc(Nc,"name"),Uc={EXISTS:Lc,PROPER:Lc&&"something"===function(){}.name,CONFIGURABLE:Lc&&(!Pc||Pc&&Mc(Nc,"name").configurable)},Vc=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Fc=Ze,Bc=A,jc=qe,Hc=Vc,Gc=Pn("IE_PROTO"),zc=Object,Kc=zc.prototype,Wc=Hc?zc.getPrototypeOf:function(e){var t=jc(e);if(Fc(t,Gc))return t[Gc];var r=t.constructor;return Bc(r)&&t instanceof r?r.prototype:t instanceof zc?Kc:null},Xc=o,Yc=A,qc=ee,Jc=Wn,Qc=Wc,Zc=vi,$c=ht("iterator"),eu=!1;[].keys&&("next"in(Ic=[].keys())?(Tc=Qc(Qc(Ic)))!==Object.prototype&&(Ec=Tc):eu=!0);var tu=!qc(Ec)||Xc((function(){var e={};return Ec[$c].call(e)!==e}));Yc((Ec=tu?{}:Jc(Ec))[$c])||Zc(Ec,$c,(function(){return this}));var ru={IteratorPrototype:Ec,BUGGY_SAFARI_ITERATORS:eu},nu=ru.IteratorPrototype,iu=Wn,ou=F,au=Bi,su=Oc,cu=function(){return this},uu=function(e,t,r,n){var i=t+" Iterator";return e.prototype=iu(nu,{next:ou(+!n,r)}),au(e,i,!1,!0),su[i]=cu,e},du=f,lu=Oe,hu=A,pu=String,vu=TypeError,_u=function(e,t,r){try{return du(lu(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(n){}},fu=rr,mu=function(e){if("object"==typeof e||hu(e))return e;throw vu("Can't set "+pu(e)+" as a prototype")},gu=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=_u(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return fu(r),mu(n),t?e(r,n):r.__proto__=n,r}}():void 0),yu=wr,Su=P,bu=Uc,ku=uu,Eu=Wc,Tu=Bi,Iu=vi,Ru=Oc,Au=ru,wu=bu.PROPER,Cu=Au.BUGGY_SAFARI_ITERATORS,xu=ht("iterator"),Ou="keys",Pu="values",Du="entries",Nu=function(){return this},Mu=function(e,t,r,n,i,o,a){ku(r,t,n);var s,c,u,d=function(e){if(e===i&&_)return _;if(!Cu&&e in p)return p[e];switch(e){case Ou:case Pu:case Du:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,p=e.prototype,v=p[xu]||p["@@iterator"]||i&&p[i],_=!Cu&&v||d(i),f="Array"===t&&p.entries||v;if(f&&(s=Eu(f.call(new e)))!==Object.prototype&&s.next&&(Tu(s,l,!0,!0),Ru[l]=Nu),wu&&i===Pu&&v&&v.name!==Pu&&(h=!0,_=function(){return Su(v,this)}),i)if(c={values:d(Pu),keys:o?_:d(Ou),entries:d(Du)},a)for(u in c)(Cu||h||!(u in p))&&Iu(p,u,c[u]);else yu({target:t,proto:!0,forced:Cu||h},c);return a&&p[xu]!==_&&Iu(p,xu,_,{name:i}),Ru[t]=_,c},Lu=function(e,t){return{value:e,done:t}},Uu=Q,Vu=Oc,Fu=ro;Qt.f;var Bu=Mu,ju=Lu,Hu="Array Iterator",Gu=Fu.set,zu=Fu.getterFor(Hu);Bu(Array,"Array",(function(e,t){Gu(this,{type:Hu,target:Uu(e),index:0,kind:t})}),(function(){var e=zu(this),t=e.target,r=e.kind,n=e.index++;if(!t||n>=t.length)return e.target=void 0,ju(void 0,!0);switch(r){case"keys":return ju(n,!1);case"values":return ju(t[n],!1)}return ju([n,t[n]],!1)}),"values"),Vu.Arguments=Vu.Array;var Ku={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},Wu=i,Xu=mn,Yu=fr,qu=Oc,Ju=ht("toStringTag");for(var Qu in Ku){var Zu=Wu[Qu],$u=Zu&&Zu.prototype;$u&&Xu($u)!==Ju&&Yu($u,Ju,Qu),qu[Qu]=qu.Array}var ed=o,td=function(e,t){var r=[][e];return!!r&&ed((function(){r.call(null,t||function(){return 1},1)}))},rd=Vo.forEach,nd=td("forEach")?[].forEach:function(e){return rd(this,e,arguments.length>1?arguments[1]:void 0)};wr({target:"Array",proto:!0,forced:[].forEach!==nd},{forEach:nd});var id=qs("Array").forEach,od=mn,ad=Ze,sd=se,cd=id,ud=Array.prototype,dd={DOMTokenList:!0,NodeList:!0},ld=r((function(e){var t=e.forEach;return e===ud||sd(ud,e)&&t===ud.forEach||ad(dd,od(e))?cd:t})),hd=ae,pd=Xn,vd=hi,_d=rr,fd=f([].concat),md=hd("Reflect","ownKeys")||function(e){var t=pd.f(_d(e)),r=vd.f;return r?fd(t,r(e)):t},gd=md,yd=Q,Sd=w,bd=ei;wr({target:"Object",stat:!0,sham:!C},{getOwnPropertyDescriptors:function(e){for(var t,r,n=yd(e),i=Sd.f,o=gd(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&bd(a,t,r);return a}});var kd=r(te.Object.getOwnPropertyDescriptors),Ed={exports:{}},Td=wr,Id=C,Rd=bn.f;Td({target:"Object",stat:!0,forced:Object.defineProperties!==Rd,sham:!Id},{defineProperties:Rd});var Ad=te.Object,wd=Ed.exports=function(e,t){return Ad.defineProperties(e,t)};Ad.defineProperties.sham&&(wd.sham=!0);var Cd=r(Ed.exports),xd={exports:{}},Od=wr,Pd=C,Dd=Qt.f;Od({target:"Object",stat:!0,forced:Object.defineProperty!==Dd,sham:!Pd},{defineProperty:Dd});var Nd=te.Object,Md=xd.exports=function(e,t,r){return Nd.defineProperty(e,t,r)};Nd.defineProperty.sham&&(Md.sham=!0);var Ld=xd.exports,Ud=r(Ld),Vd=wr,Fd=o,Bd=io,jd=ee,Hd=qe,Gd=jr,zd=gc,Kd=ei,Wd=xo,Xd=Ws,Yd=_e,qd=ht("isConcatSpreadable"),Jd=Yd>=51||!Fd((function(){var e=[];return e[qd]=!1,e.concat()[0]!==e})),Qd=function(e){if(!jd(e))return!1;var t=e[qd];return void 0!==t?!!t:Bd(e)};Vd({target:"Array",proto:!0,arity:1,forced:!Jd||!Xd("concat")},{concat:function(e){var t,r,n,i,o,a=Hd(this),s=Wd(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(Qd(o=-1===t?a:arguments[t]))for(i=Gd(o),zd(c+i),r=0;r<i;r++,c++)r in o&&Kd(s,c,o[r]);else zd(c+1),Kd(s,c++,o);return s.length=c,s}}),Ri("asyncIterator"),Ri("hasInstance"),Ri("isConcatSpreadable"),Ri("iterator"),Ri("match"),Ri("matchAll"),Ri("replace"),Ri("search"),Ri("species"),Ri("split");var Zd=Oi;Ri("toPrimitive"),Zd();var $d=ae,el=Bi;Ri("toStringTag"),el($d("Symbol"),"Symbol"),Ri("unscopables"),Bi(i.JSON,"JSON",!0);var tl=te.Symbol,rl=ht,nl=Qt.f,il=rl("metadata"),ol=Function.prototype;void 0===ol[il]&&nl(ol,il,{value:null}),Ri("asyncDispose"),Ri("dispose"),Ri("metadata");var al=tl,sl=f,cl=ae("Symbol"),ul=cl.keyFor,dl=sl(cl.prototype.valueOf),ll=cl.isRegisteredSymbol||function(e){try{return void 0!==ul(dl(e))}catch(t){return!1}};wr({target:"Symbol",stat:!0},{isRegisteredSymbol:ll});for(var hl=We,pl=ae,vl=f,_l=Ie,fl=ht,ml=pl("Symbol"),gl=ml.isWellKnownSymbol,yl=pl("Object","getOwnPropertyNames"),Sl=vl(ml.prototype.valueOf),bl=hl("wks"),kl=0,El=yl(ml),Tl=El.length;kl<Tl;kl++)try{var Il=El[kl];_l(ml[Il])&&fl(Il)}catch(jZ){}var Rl=function(e){if(gl&&gl(e))return!0;try{for(var t=Sl(e),r=0,n=yl(bl),i=n.length;r<i;r++)if(bl[n[r]]==t)return!0}catch(jZ){}return!1};wr({target:"Symbol",stat:!0,forced:!0},{isWellKnownSymbol:Rl}),Ri("matcher"),Ri("observable"),wr({target:"Symbol",stat:!0,name:"isRegisteredSymbol"},{isRegistered:ll}),wr({target:"Symbol",stat:!0,name:"isWellKnownSymbol",forced:!0},{isWellKnown:Rl}),Ri("metadataKey"),Ri("patternMatch"),Ri("replaceAll");var Al=r(al),wl=f,Cl=Pr,xl=Sn,Ol=Y,Pl=wl("".charAt),Dl=wl("".charCodeAt),Nl=wl("".slice),Ml=function(e){return function(t,r){var n,i,o=xl(Ol(t)),a=Cl(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Dl(o,a))<55296||n>56319||a+1===s||(i=Dl(o,a+1))<56320||i>57343?e?Pl(o,a):n:e?Nl(o,a,a+2):i-56320+(n-55296<<10)+65536}},Ll={codeAt:Ml(!1),charAt:Ml(!0)},Ul=Ll.charAt,Vl=Sn,Fl=ro,Bl=Mu,jl=Lu,Hl="String Iterator",Gl=Fl.set,zl=Fl.getterFor(Hl);Bl(String,"String",(function(e){Gl(this,{type:Hl,string:Vl(e),index:0})}),(function(){var e,t=zl(this),r=t.string,n=t.index;return n>=r.length?jl(void 0,!0):(e=Ul(r,n),t.index+=e.length,jl(e,!1))}));var Kl=r(mi.f("iterator"));function Wl(e){return(Wl="function"==typeof Al&&"symbol"==typeof Kl?function(e){return typeof e}:function(e){return e&&"function"==typeof Al&&e.constructor===Al&&e!==Al.prototype?"symbol":typeof e})(e)}var Xl=r(mi.f("toPrimitive"));function Yl(e){var t=function(e,t){if("object"!==Wl(e)||null===e)return e;var r=e[Xl];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==Wl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Wl(t)?t:String(t)}function ql(e,t,r){return(t=Yl(t))in e?Ud(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Jl(e,t){var r=cn(e);if(Hs){var n=Hs(e);t&&(n=tc(n).call(n,(function(t){return lc(e,t).enumerable}))),xc(r).apply(r,n)}return r}function Ql(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?ld(r=Jl(Object(i),!0)).call(r,(function(t){ql(e,t,i[t])})):kd?Cd(e,kd(i)):ld(n=Jl(Object(i))).call(n,(function(t){Ud(e,t,lc(i,t))}))}return e}var Zl=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}(Zl||{}),$l=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}($l||{}),eh=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}(eh||{}),th=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(th||{}),rh=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(rh||{}),nh=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(nh||{}),ih=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(ih||{}),oh=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(oh||{}),ah=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}(ah||{}),sh=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(sh||{}),ch=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(ch||{}),uh=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}(uh||{}),dh=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}(dh||{}),lh=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(lh||{}),hh=function(e){return e[e.NORMAL=0]="NORMAL",e[e.DISCONNECT=1]="DISCONNECT",e[e.RESET=2]="RESET",e}(hh||{}),ph=function(e){return e[e.MICROPHONE=0]="MICROPHONE",e[e.AUDIOMIXING=1]="AUDIOMIXING",e}(ph||{}),vh=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(vh||{}),_h=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(_h||{}),fh=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}(fh||{}),mh=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(mh||{}),gh=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}(gh||{}),yh=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(yh||{}),Sh=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}(Sh||{}),bh=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(bh||{}),kh=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}(kh||{}),Eh=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}(Eh||{}),Th=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}(Th||{}),Ih=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(Ih||{}),Rh=function(e){return e.H264="H264",e.H265="H265",e}(Rh||{}),Ah=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(Ah||{}),wh=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(wh||{}),Ch=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}(Ch||{}),xh=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}(xh||{}),Oh=Object.freeze({__proto__:null,AAC_PROFILE:Ih,AudioProfileType:Eh,AudioReportMode:ph,AudioSourceType:$l,ChannelProfile:th,ConnectionState:dh,FallbackOrRecoverReason:bh,ForwardStreamError:xh,ForwardStreamState:Ch,LocalMainReportMode:hh,LogChannel:vh,MediaType:ch,MirrorMode:oh,MirrorType:lh,NetworkQuality:Sh,PublicInterpolationMode:mh,PublicStreamType:fh,PublishState:ih,RTCAutoPlayPolicy:Th,RemoteUserPriority:yh,RoomProfileType:kh,SUBTITLE_MODE:Ah,StreamIndex:sh,StreamRemoveReason:uh,SubscribeFallbackOption:gh,SubscribeMode:rh,SubscribeState:nh,SubtitleEventType:wh,TRANSCODING_VIDEO_CODEC:Rh,USER_ONLINE_STATUS:_h,UserOfflineReason:eh,VideoRenderMode:ah,VideoSourceType:Zl}),Ph=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}(Ph||{}),Dh=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(Dh||{}),Nh=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}(Nh||{}),Mh=Object.freeze({__proto__:null,AudioMixingDualMonoMode:Ph,AudioMixingState:Nh,AudioMixingType:Dh}),Lh=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.onPublishRetry="onPublishRetry",e.onSubscribeRetry="onSubscribeRetry",e.onPublishResult="onPublishResult",e.onSubscribeResult="onSubscribeResult",e}(Lh||{});function Uh(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),Ud(e,Yl(n.key),n)}}function Vh(e,t,r){return t&&Uh(e.prototype,t),r&&Uh(e,r),Ud(e,"prototype",{writable:!1}),e}function Fh(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}wr({target:"Object",stat:!0,sham:!C},{create:Wn});var Bh=te.Object,jh=r((function(e,t){return Bh.create(e,t)})),Hh=qe,Gh=Wc,zh=Vc;wr({target:"Object",stat:!0,forced:o((function(){Gh(1)})),sham:!zh},{getPrototypeOf:function(e){return Gh(Hh(e))}});var Kh=r(te.Object.getPrototypeOf);wr({target:"Object",stat:!0},{setPrototypeOf:gu});var Wh=te.Object.setPrototypeOf,Xh=r(Wh),Yh=Ze,qh=md,Jh=w,Qh=Qt,Zh=ee,$h=fr,ep=Error,tp=f("".replace),rp=String(ep("zxcasd").stack),np=/\n\s*at [^:]*:[^\n]*/,ip=np.test(rp),op=F,ap=!o((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",op(1,7)),7!==e.stack)})),sp=fr,cp=function(e,t){if(ip&&"string"==typeof e&&!ep.prepareStackTrace)for(;t--;)e=tp(e,np,"");return e},up=ap,dp=Error.captureStackTrace,lp=Oc,hp=ht("iterator"),pp=Array.prototype,vp=function(e){return void 0!==e&&(lp.Array===e||pp[hp]===e)},_p=mn,fp=Ne,mp=K,gp=Oc,yp=ht("iterator"),Sp=function(e){if(!mp(e))return fp(e,yp)||fp(e,"@@iterator")||gp[_p(e)]},bp=P,kp=Oe,Ep=rr,Tp=Ae,Ip=Sp,Rp=TypeError,Ap=function(e,t){var r=arguments.length<2?Ip(e):t;if(kp(r))return Ep(bp(r,e));throw Rp(Tp(e)+" is not iterable")},wp=P,Cp=rr,xp=Ne,Op=function(e,t,r){var n,i;Cp(e);try{if(!(n=xp(e,"return"))){if("throw"===t)throw r;return r}n=wp(n,e)}catch(jZ){i=!0,n=jZ}if("throw"===t)throw r;if(i)throw n;return Cp(n),r},Pp=Jt,Dp=P,Np=rr,Mp=Ae,Lp=vp,Up=jr,Vp=se,Fp=Ap,Bp=Sp,jp=Op,Hp=TypeError,Gp=function(e,t){this.stopped=e,this.result=t},zp=Gp.prototype,Kp=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),_=Pp(t,d),f=function(e){return n&&jp(n,"normal",e),new Gp(!0,e)},m=function(e){return l?(Np(e),v?_(e[0],e[1],f):_(e[0],e[1])):v?_(e,f):_(e)};if(h)n=e.iterator;else if(p)n=e;else{if(!(i=Bp(e)))throw Hp(Mp(e)+" is not iterable");if(Lp(i)){for(o=0,a=Up(e);a>o;o++)if((s=m(e[o]))&&Vp(zp,s))return s;return new Gp(!1)}n=Fp(e,i)}for(c=h?e.next:n.next;!(u=Dp(c,n)).done;){try{s=m(u.value)}catch(jZ){jp(n,"throw",jZ)}if("object"==typeof s&&s&&Vp(zp,s))return s}return new Gp(!1)},Wp=Sn,Xp=wr,Yp=se,qp=Wc,Jp=gu,Qp=function(e,t,r){for(var n=qh(t),i=Qh.f,o=Jh.f,a=0;a<n.length;a++){var s=n[a];Yh(e,s)||r&&Yh(r,s)||i(e,s,o(t,s))}},Zp=Wn,$p=fr,ev=F,tv=function(e,t){Zh(t)&&"cause"in t&&$h(e,"cause",t.cause)},rv=function(e,t,r,n){up&&(dp?dp(e,t):sp(e,"stack",cp(r,n)))},nv=Kp,iv=function(e,t){return void 0===e?arguments.length<2?"":t:Wp(e)},ov=ht("toStringTag"),av=Error,sv=[].push,cv=function(e,t){var r,n=Yp(uv,this);Jp?r=Jp(av(),n?qp(this):uv):(r=n?this:Zp(uv),$p(r,ov,"Error")),void 0!==t&&$p(r,"message",iv(t)),rv(r,cv,r.stack,1),arguments.length>2&&tv(r,arguments[2]);var i=[];return nv(e,sv,{that:i}),$p(r,"errors",i),r};Jp?Jp(cv,av):Qp(cv,av,{name:!0});var uv=cv.prototype=Zp(av.prototype,{constructor:ev(1,cv),message:ev(1,""),name:ev(1,"AggregateError")});Xp({global:!0,constructor:!0,arity:2},{AggregateError:cv});var dv,lv,hv,pv,vv="process"===S(i.process),_v=ae,fv=fi,mv=C,gv=ht("species"),yv=function(e){var t=_v(e);mv&&t&&!t[gv]&&fv(t,gv,{configurable:!0,get:function(){return this}})},Sv=se,bv=TypeError,kv=function(e,t){if(Sv(t,e))return e;throw bv("Incorrect invocation")},Ev=Eo,Tv=Ae,Iv=TypeError,Rv=function(e){if(Ev(e))return e;throw Iv(Tv(e)+" is not a constructor")},Av=rr,wv=Rv,Cv=K,xv=ht("species"),Ov=function(e,t){var r,n=Av(e).constructor;return void 0===n||Cv(r=Av(n)[xv])?t:wv(r)},Pv=TypeError,Dv=function(e,t){if(e<t)throw Pv("Not enough arguments");return e},Nv=/(?:ipad|iphone|ipod).*applewebkit/i.test(ce),Mv=i,Lv=l,Uv=Jt,Vv=A,Fv=Ze,Bv=o,jv=Cn,Hv=cs,Gv=Rt,zv=Dv,Kv=Nv,Wv=vv,Xv=Mv.setImmediate,Yv=Mv.clearImmediate,qv=Mv.process,Jv=Mv.Dispatch,Qv=Mv.Function,Zv=Mv.MessageChannel,$v=Mv.String,e_=0,t_={},r_="onreadystatechange";Bv((function(){dv=Mv.location}));var n_=function(e){if(Fv(t_,e)){var t=t_[e];delete t_[e],t()}},i_=function(e){return function(){n_(e)}},o_=function(e){n_(e.data)},a_=function(e){Mv.postMessage($v(e),dv.protocol+"//"+dv.host)};Xv&&Yv||(Xv=function(e){zv(arguments.length,1);var t=Vv(e)?e:Qv(e),r=Hv(arguments,1);return t_[++e_]=function(){Lv(t,void 0,r)},lv(e_),e_},Yv=function(e){delete t_[e]},Wv?lv=function(e){qv.nextTick(i_(e))}:Jv&&Jv.now?lv=function(e){Jv.now(i_(e))}:Zv&&!Kv?(pv=(hv=new Zv).port2,hv.port1.onmessage=o_,lv=Uv(pv.postMessage,pv)):Mv.addEventListener&&Vv(Mv.postMessage)&&!Mv.importScripts&&dv&&"file:"!==dv.protocol&&!Bv(a_)?(lv=a_,Mv.addEventListener("message",o_,!1)):lv=r_ in Gv("script")?function(e){jv.appendChild(Gv("script"))[r_]=function(){jv.removeChild(this),n_(e)}}:function(e){setTimeout(i_(e),0)});var s_={set:Xv,clear:Yv},c_=function(){this.head=null,this.tail=null};c_.prototype={add:function(e){var t={item:e,next:null},r=this.tail;r?r.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var u_,d_,l_,h_,p_,v_=c_,__=/ipad|iphone|ipod/i.test(ce)&&"undefined"!=typeof Pebble,f_=/web0s(?!.*chrome)/i.test(ce),m_=i,g_=Jt,y_=w.f,S_=s_.set,b_=v_,k_=Nv,E_=__,T_=f_,I_=vv,R_=m_.MutationObserver||m_.WebKitMutationObserver,A_=m_.document,w_=m_.process,C_=m_.Promise,x_=y_(m_,"queueMicrotask"),O_=x_&&x_.value;if(!O_){var P_=new b_,D_=function(){var e,t;for(I_&&(e=w_.domain)&&e.exit();t=P_.get();)try{t()}catch(jZ){throw P_.head&&u_(),jZ}e&&e.enter()};k_||I_||T_||!R_||!A_?!E_&&C_&&C_.resolve?((h_=C_.resolve(void 0)).constructor=C_,p_=g_(h_.then,h_),u_=function(){p_(D_)}):I_?u_=function(){w_.nextTick(D_)}:(S_=g_(S_,m_),u_=function(){S_(D_)}):(d_=!0,l_=A_.createTextNode(""),new R_(D_).observe(l_,{characterData:!0}),u_=function(){l_.data=d_=!d_}),O_=function(e){P_.head||u_(),P_.add(e)}}var N_=O_,M_=function(e){try{return{error:!1,value:e()}}catch(jZ){return{error:!0,value:jZ}}},L_=i.Promise,U_="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,V_=!U_&&!vv&&"object"==typeof window&&"object"==typeof document,F_=i,B_=L_,j_=A,H_=Wt,G_=co,z_=ht,K_=V_,W_=U_,X_=_e,Y_=B_&&B_.prototype,q_=z_("species"),J_=!1,Q_=j_(F_.PromiseRejectionEvent),Z_={CONSTRUCTOR:H_("Promise",(function(){var e=G_(B_),t=e!==String(B_);if(!t&&66===X_)return!0;if(!Y_.catch||!Y_.finally)return!0;if(!X_||X_<51||!/native code/.test(e)){var r=new B_((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[q_]=n,!(J_=r.then((function(){}))instanceof n))return!0}return!t&&(K_||W_)&&!Q_})),REJECTION_EVENT:Q_,SUBCLASSING:J_},$_={},ef=Oe,tf=TypeError,rf=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw tf("Bad Promise constructor");t=e,r=n})),this.resolve=ef(t),this.reject=ef(r)};$_.f=function(e){return new rf(e)};var nf,of,af=wr,sf=vv,cf=i,uf=P,df=vi,lf=Bi,hf=yv,pf=Oe,vf=A,_f=ee,ff=kv,mf=Ov,gf=s_.set,yf=N_,Sf=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(jZ){}},bf=M_,kf=v_,Ef=ro,Tf=L_,If=Z_,Rf=$_,Af="Promise",wf=If.CONSTRUCTOR,Cf=If.REJECTION_EVENT,xf=Ef.getterFor(Af),Of=Ef.set,Pf=Tf&&Tf.prototype,Df=Tf,Nf=Pf,Mf=cf.TypeError,Lf=cf.document,Uf=cf.process,Vf=Rf.f,Ff=Vf,Bf=!!(Lf&&Lf.createEvent&&cf.dispatchEvent),jf="unhandledrejection",Hf=function(e){var t;return!(!_f(e)||!vf(t=e.then))&&t},Gf=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&&Yf(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=Hf(r))?uf(n,r,c,u):c(r)):u(o)}catch(jZ){d&&!i&&d.exit(),u(jZ)}},zf=function(e,t){e.notified||(e.notified=!0,yf((function(){for(var r,n=e.reactions;r=n.get();)Gf(r,e);e.notified=!1,t&&!e.rejection&&Wf(e)})))},Kf=function(e,t,r){var n,i;Bf?((n=Lf.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),cf.dispatchEvent(n)):n={promise:t,reason:r},!Cf&&(i=cf["on"+e])?i(n):e===jf&&Sf("Unhandled promise rejection",r)},Wf=function(e){uf(gf,cf,(function(){var t,r=e.facade,n=e.value;if(Xf(e)&&(t=bf((function(){sf?Uf.emit("unhandledRejection",n,r):Kf(jf,r,n)})),e.rejection=sf||Xf(e)?2:1,t.error))throw t.value}))},Xf=function(e){return 1!==e.rejection&&!e.parent},Yf=function(e){uf(gf,cf,(function(){var t=e.facade;sf?Uf.emit("rejectionHandled",t):Kf("rejectionhandled",t,e.value)}))},qf=function(e,t,r){return function(n){e(t,n,r)}},Jf=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,zf(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=Hf(t);n?yf((function(){var r={done:!1};try{uf(n,t,qf(Qf,r,e),qf(Jf,r,e))}catch(jZ){Jf(r,jZ,e)}})):(e.value=t,e.state=1,zf(e,!1))}catch(jZ){Jf({done:!1},jZ,e)}}};wf&&(Nf=(Df=function(e){ff(this,Nf),pf(e),uf(nf,this);var t=xf(this);try{e(qf(Qf,t),qf(Jf,t))}catch(jZ){Jf(t,jZ)}}).prototype,(nf=function(e){Of(this,{type:Af,done:!1,notified:!1,parent:!1,reactions:new kf,rejection:!1,state:0,value:void 0})}).prototype=df(Nf,"then",(function(e,t){var r=xf(this),n=Vf(mf(this,Df));return r.parent=!0,n.ok=!vf(e)||e,n.fail=vf(t)&&t,n.domain=sf?Uf.domain:void 0,0===r.state?r.reactions.add(n):yf((function(){Gf(n,r)})),n.promise})),of=function(){var e=new nf,t=xf(e);this.promise=e,this.resolve=qf(Qf,t),this.reject=qf(Jf,t)},Rf.f=Vf=function(e){return e===Df||undefined===e?new of(e):Ff(e)}),af({global:!0,constructor:!0,wrap:!0,forced:wf},{Promise:Df}),lf(Df,Af,!1,!0),hf(Af);var Zf=ht("iterator"),$f=!1;try{var em=0,tm={next:function(){return{done:!!em++}},return:function(){$f=!0}};tm[Zf]=function(){return this},Array.from(tm,(function(){throw 2}))}catch(jZ){}var rm=function(e,t){if(!t&&!$f)return!1;var r=!1;try{var n={};n[Zf]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(jZ){}return r},nm=L_,im=Z_.CONSTRUCTOR||!rm((function(e){nm.all(e).then(void 0,(function(){}))})),om=P,am=Oe,sm=$_,cm=M_,um=Kp;wr({target:"Promise",stat:!0,forced:im},{all:function(e){var t=this,r=sm.f(t),n=r.resolve,i=r.reject,o=cm((function(){var r=am(t.resolve),o=[],a=0,s=1;um(e,(function(e){var c=a++,u=!1;s++,om(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 dm=wr,lm=Z_.CONSTRUCTOR;L_&&L_.prototype,dm({target:"Promise",proto:!0,forced:lm,real:!0},{catch:function(e){return this.then(void 0,e)}});var hm=P,pm=Oe,vm=$_,_m=M_,fm=Kp;wr({target:"Promise",stat:!0,forced:im},{race:function(e){var t=this,r=vm.f(t),n=r.reject,i=_m((function(){var i=pm(t.resolve);fm(e,(function(e){hm(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var mm=P,gm=$_;wr({target:"Promise",stat:!0,forced:Z_.CONSTRUCTOR},{reject:function(e){var t=gm.f(this);return mm(t.reject,void 0,e),t.promise}});var ym=rr,Sm=ee,bm=$_,km=function(e,t){if(ym(e),Sm(t)&&t.constructor===e)return t;var r=bm.f(e);return(0,r.resolve)(t),r.promise},Em=wr,Tm=L_,Im=Z_.CONSTRUCTOR,Rm=km,Am=ae("Promise"),wm=!Im;Em({target:"Promise",stat:!0,forced:true},{resolve:function(e){return Rm(wm&&this===Am?Tm:this,e)}});var Cm=P,xm=Oe,Om=$_,Pm=M_,Dm=Kp;wr({target:"Promise",stat:!0,forced:im},{allSettled:function(e){var t=this,r=Om.f(t),n=r.resolve,i=r.reject,o=Pm((function(){var r=xm(t.resolve),i=[],o=0,a=1;Dm(e,(function(e){var s=o++,c=!1;a++,Cm(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 Nm=P,Mm=Oe,Lm=ae,Um=$_,Vm=M_,Fm=Kp,Bm="No one promise resolved";wr({target:"Promise",stat:!0,forced:im},{any:function(e){var t=this,r=Lm("AggregateError"),n=Um.f(t),i=n.resolve,o=n.reject,a=Vm((function(){var n=Mm(t.resolve),a=[],s=0,c=1,u=!1;Fm(e,(function(e){var d=s++,l=!1;c++,Nm(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,Bm)))}))})),--c||o(new r(a,Bm))}));return a.error&&o(a.value),n.promise}});var jm=wr,Hm=L_,Gm=o,zm=ae,Km=A,Wm=Ov,Xm=km,Ym=Hm&&Hm.prototype;jm({target:"Promise",proto:!0,real:!0,forced:!!Hm&&Gm((function(){Ym.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Wm(this,zm("Promise")),r=Km(e);return this.then(r?function(r){return Xm(t,e()).then((function(){return r}))}:e,r?function(r){return Xm(t,e()).then((function(){throw r}))}:e)}});var qm=te.Promise,Jm=$_;wr({target:"Promise",stat:!0},{withResolvers:function(){var e=Jm.f(this);return{promise:e.promise,resolve:e.resolve,reject:e.reject}}});var Qm=qm,Zm=$_,$m=M_;wr({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=Zm.f(this),r=$m(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var eg=Qm,tg=r(eg),rg=wr,ng=io,ig=f([].reverse),og=[1,2];rg({target:"Array",proto:!0,forced:String(og)===String(og.reverse())},{reverse:function(){return ng(this)&&(this.length=this.length),ig(this)}});var ag=qs("Array").reverse,sg=se,cg=ag,ug=Array.prototype,dg=function(e){var t=e.reverse;return e===ug||sg(ug,e)&&t===ug.reverse?cg:t},lg=r(dg),hg=wr,pg=io,vg=Eo,_g=ee,fg=Lr,mg=jr,gg=Q,yg=ei,Sg=ht,bg=cs,kg=Ws("slice"),Eg=Sg("species"),Tg=Array,Ig=Math.max;hg({target:"Array",proto:!0,forced:!kg},{slice:function(e,t){var r,n,i,o=gg(this),a=mg(o),s=fg(e,a),c=fg(void 0===t?a:t,a);if(pg(o)&&(r=o.constructor,(vg(r)&&(r===Tg||pg(r.prototype))||_g(r)&&null===(r=r[Eg]))&&(r=void 0),r===Tg||void 0===r))return bg(o,s,c);for(n=new(void 0===r?Tg:r)(Ig(c-s,0)),i=0;s<c;s++,i++)s in o&&yg(n,i,o[s]);return n.length=i,n}});var Rg=qs("Array").slice,Ag=se,wg=Rg,Cg=Array.prototype,xg=function(e){var t=e.slice;return e===Cg||Ag(Cg,e)&&t===Cg.slice?wg:t},Og=r(xg);function Pg(){Pg=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Ud||function(e,t,r){e[t]=r.value},o="function"==typeof Al?Al:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,r){return Ud(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(O){u=function(e,t,r){return e[t]=r}}function d(e,t,r,n){var o=t&&t.prototype instanceof m?t:m,a=jh(o.prototype),s=new C(n||[]);return i(a,"_invoke",{value:I(e,r,s)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(n){return{type:"throw",arg:n}}}t.wrap=d;var h="suspendedStart",p="suspendedYield",v="executing",_="completed",f={};function m(){}function g(){}function y(){}var S={};u(S,a,(function(){return this}));var b=Kh&&Kh(Kh(x([])));b&&b!==r&&n.call(b,a)&&(S=b);var k=y.prototype=m.prototype=jh(S);function E(e){var t;ld(t=["next","throw","return"]).call(t,(function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function r(i,o,a,s){var c=l(e[i],e,o);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==Wl(d)&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(d).then((function(e){u.value=e,a(u)}),(function(e){return r("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return o=o?o.then(i,i):i()}})}function I(t,r,n){var i=h;return function(o,a){if(i===v)throw new Error("Generator is already running");if(i===_){if("throw"===o)throw a;return{value:e,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var c=R(s,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=_,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?_:p,u.arg===f)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=_,n.method="throw",n.arg=u.arg)}}}function R(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,R(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var o=l(i,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,f;var a=o.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,f):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}function A(e){var t,r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),xc(t=this.tryEntries).call(t,r)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],ld(e).call(e,A,this),this.reset(!0)}function x(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(Wl(t)+" is not iterable")}return g.prototype=y,i(k,"constructor",{value:y,configurable:!0}),i(y,"constructor",{value:g,configurable:!0}),g.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Xh?Xh(e,y):(e.__proto__=y,u(e,c,"GeneratorFunction")),e.prototype=jh(k),e},t.awrap=function(e){return{__await:e}},E(T.prototype),u(T.prototype,s,(function(){return this})),t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=tg);var a=new T(d(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},E(k),u(k,c,"Generator"),u(k,a,(function(){return this})),u(k,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)xc(r).call(r,n);return lg(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}},t.values=x,C.prototype={constructor:C,reset:function(t){var r;if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,ld(r=this.tryEntries).call(r,w),!t)for(var i in this)"t"===i.charAt(0)&&n.call(this,i)&&!isNaN(+Og(i).call(i,1))&&(this[i]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.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,f):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),f},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),w(r),f}},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;w(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:x(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),f}},t}function Dg(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(jZ){return void r(jZ)}s.done?t(c):tg.resolve(c).then(n,i)}function Ng(e){return function(){var t=this,r=arguments;return new tg((function(n,i){var o=e.apply(t,r);function a(e){Dg(o,n,i,a,s,"next",e)}function s(e){Dg(o,n,i,a,s,"throw",e)}a(void 0)}))}}var Mg=qs("Array").concat,Lg=se,Ug=Mg,Vg=Array.prototype,Fg=r((function(e){var t=e.concat;return e===Vg||Lg(Vg,e)&&t===Vg.concat?Ug:t})),Bg=te,jg=l;Bg.JSON||(Bg.JSON={stringify:JSON.stringify});var Hg=function(e,t,r){return jg(Bg.JSON.stringify,null,arguments)},Gg=r(Hg),zg=Vo.map;wr({target:"Array",proto:!0,forced:!Ws("map")},{map:function(e){return zg(this,e,arguments.length>1?arguments[1]:void 0)}});var Kg=qs("Array").map,Wg=se,Xg=Kg,Yg=Array.prototype,qg=r((function(e){var t=e.map;return e===Yg||Wg(Yg,e)&&t===Yg.map?Xg:t})),Jg=r(Sp);wr({target:"Array",stat:!0},{isArray:io});var Qg=r(te.Array.isArray),Zg=rr,$g=Op,ey=Jt,ty=P,ry=qe,ny=function(e,t,r,n){try{return n?t(Zg(r)[0],r[1]):t(r)}catch(jZ){$g(e,"throw",jZ)}},iy=vp,oy=Eo,ay=jr,sy=ei,cy=Ap,uy=Sp,dy=Array,ly=function(e){var t=ry(e),r=oy(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=ey(i,n>2?arguments[2]:void 0));var a,s,c,u,d,l,h=uy(t),p=0;if(!h||this===dy&&iy(h))for(a=ay(t),s=r?new this(a):dy(a);a>p;p++)l=o?i(t[p],p):t[p],sy(s,p,l);else for(d=(u=cy(t,h)).next,s=r?new this:[];!(c=ty(d,u)).done;p++)l=o?ny(u,i,[c.value,p],!0):c.value,sy(s,p,l);return s.length=p,s},hy=ly;wr({target:"Array",stat:!0,forced:!rm((function(e){Array.from(e)}))},{from:hy});var py=te.Array.from,vy=r(py);function _y(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}function fy(e,t){var r;if(e){if("string"==typeof e)return _y(e,t);var n=Og(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?vy(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_y(e,t):void 0}}function my(e,t){var r=void 0!==Al&&Jg(e)||e["@@iterator"];if(!r){if(Qg(e)||(r=fy(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 gy(e,t){return function(e){if(Qg(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==Al&&Jg(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)&&(xc(s).call(s,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)||fy(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.")}()}var yy=wr,Sy=o,by=Jn.f;yy({target:"Object",stat:!0,forced:Sy((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:by});var ky=te.Object,Ey=r((function(e){return ky.getOwnPropertyNames(e)})),Ty=r(ec),Iy=Wr.includes;wr({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return Iy(this,e,arguments.length>1?arguments[1]:void 0)}});var Ry=qs("Array").includes,Ay=ee,wy=S,Cy=ht("match"),xy=function(e){var t;return Ay(e)&&(void 0!==(t=e[Cy])?!!t:"RegExp"===wy(e))},Oy=TypeError,Py=function(e){if(xy(e))throw Oy("The method doesn't accept regular expressions");return e},Dy=ht("match"),Ny=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Dy]=!1,"/./"[e](t)}catch(n){}}return!1},My=wr,Ly=Py,Uy=Y,Vy=Sn,Fy=Ny,By=f("".indexOf);My({target:"String",proto:!0,forced:!Fy("includes")},{includes:function(e){return!!~By(Vy(Uy(this)),Vy(Ly(e)),arguments.length>1?arguments[1]:void 0)}});var jy=qs("String").includes,Hy=se,Gy=Ry,zy=jy,Ky=Array.prototype,Wy=String.prototype,Xy=r((function(e){var t=e.includes;return e===Ky||Hy(Ky,e)&&t===Ky.includes?Gy:"string"==typeof e||e===Wy||Hy(Wy,e)&&t===Wy.includes?zy:t})),Yy=Oe,qy=qe,Jy=z,Qy=jr,Zy=TypeError,$y=function(e){return function(t,r,n,i){Yy(r);var o=qy(t),a=Jy(o),s=Qy(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 Zy("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}},eS={left:$y(!1),right:$y(!0)}.left;wr({target:"Array",proto:!0,forced:!vv&&_e>79&&_e<83||!td("reduce")},{reduce:function(e){var t=arguments.length;return eS(this,e,t,t>1?arguments[1]:void 0)}});var tS=qs("Array").reduce,rS=se,nS=tS,iS=Array.prototype,oS=r((function(e){var t=e.reduce;return e===iS||rS(iS,e)&&t===iS.reduce?nS:t})),aS=C,sS=o,cS=f,uS=Wc,dS=nn,lS=Q,hS=cS(D.f),pS=cS([].push),vS=aS&&sS((function(){var e=Object.create(null);return e[2]=2,!hS(e,2)})),_S=function(e){return function(t){for(var r,n=lS(t),i=dS(n),o=vS&&null===uS(n),a=i.length,s=0,c=[];a>s;)r=i[s++],aS&&!(o?r in n:hS(n,r))||pS(c,e?[r,n[r]]:n[r]);return c}},fS={entries:_S(!0),values:_S(!1)}.entries;wr({target:"Object",stat:!0},{entries:function(e){return fS(e)}});var mS,gS,yS,SS,bS,kS,ES,TS,IS,RS,AS,wS,CS,xS,OS,PS,DS,NS=r(te.Object.entries),MS=r(sn),LS={};function US(e,t){try{var r;return Xy(r=e[t].toString()).call(r,"[native code]")?"native":"non-native"}catch(n){return"untouchable"}}var VS=oS(mS="undefined"!=typeof window?[[null===(gS=window.RTCPeerConnection)||void 0===gS?void 0:gS.prototype,"RTCPeerConnection.prototype"],[window.RTCPeerConnection,"RTCPeerConnection"],[null===(yS=window.RTCDataChannel)||void 0===yS?void 0:yS.prototype,"RTCDataChannel.prototype"],[window.RTCDataChannel,"RTCDataChannel"],[null===(SS=window.MediaStreamTrack)||void 0===SS?void 0:SS.prototype,"MediaStreamTrack.prototype"],[window.MediaStreamTrack,"MediaStreamTrack"],[null===(bS=window.MediaStream)||void 0===bS?void 0:bS.prototype,"MediaStream.prototype"],[window.MediaStream,"MediaStream"],[null===(kS=window.HTMLAudioElement)||void 0===kS?void 0:kS.prototype,"HTMLAudioElement.prototype"],[null===(ES=window.HTMLVideoElement)||void 0===ES?void 0:ES.prototype,"HTMLVideoElement.prototype"],[null===(TS=window.HTMLMediaElement)||void 0===TS?void 0:TS.prototype,"HTMLMediaElement.prototype"],[null!==(IS=null===(RS=window.AudioContext)||void 0===RS?void 0:RS.prototype)&&void 0!==IS?IS:null===(AS=window.webkitAudioContext)||void 0===AS?void 0:AS.prototype,"AudioContext.prototype"],[null===(wS=window.BaseAudioContext)||void 0===wS?void 0:wS.prototype,"BaseAudioContext.prototype"],[null===(CS=window.AudioNode)||void 0===CS?void 0:CS.prototype,"AudioNode.prototype"],[window.navigator.mediaDevices,"navigator.mediaDevices"],[window.console,"console"]]:[]).call(mS,(function(e,t){var r=gy(t,2),n=r[0],i=r[1];return Fg(e).call(e,function(e,t){var r;if(!e)return[];var n=Ey(e);return qg(r=Ty(n).call(n,(function(t){if("peerIdentity"===t)return!1;try{return"function"==typeof e[t]||void 0===e[t]}catch(r){return!1}}))).call(r,(function(r){return{obj:e,prefix:t,attr:r}}))}(n,i))}),[]);"undefined"!=typeof window&&VS.push({obj:window.navigator.mediaDevices,prefix:"navigator.mediaDevices",attr:"getUserMedia"},{obj:window.navigator.mediaDevices,prefix:"navigator.mediaDevices",attr:"getDisplayMedia"},{obj:window.navigator.mediaDevices,prefix:"navigator.mediaDevices",attr:"enumerateDevices"},{obj:window.navigator.mediaDevices,prefix:"navigator.mediaDevices",attr:"getSupportedConstraints"});var FS,BS=my(VS);try{for(BS.s();!(FS=BS.n()).done;){var jS,HS=FS.value,GS=HS.obj,zS=HS.prefix,KS=HS.attr,WS=Fg(jS="".concat(zS,".")).call(jS,KS);LS[WS]=US(GS,KS)}}catch(HZ){BS.e(HZ)}finally{BS.f()}"undefined"!=typeof window&&(Xy(xS=window.location.search).call(xS,"_rtc_debug_")||(null===(OS=window.localStorage)||void 0===OS?void 0:OS.getItem("_rtc_debug_")))&&console.log("RTC_AMBULANCE",LS);var XS=qg(PS=Ty(DS=NS(LS)).call(DS,(function(e){var t=gy(e,2);return t[0],"non-native"===t[1]}))).call(PS,(function(e){var t=gy(e,2),r=t[0];return t[1],r}));MS(XS).length&&console.warn("RTC_AMBULANCE","have non-native code:\n",XS.join("\n"));var YS="\t\n\v\f\r \u2028\u2029\ufeff",qS=Y,JS=Sn,QS=YS,ZS=f("".replace),$S=RegExp("^["+QS+"]+"),eb=RegExp("(^|[^"+QS+"])["+QS+"]+$"),tb=function(e){return function(t){var r=JS(qS(t));return 1&e&&(r=ZS(r,$S,"")),2&e&&(r=ZS(r,eb,"$1")),r}},rb={start:tb(1),end:tb(2),trim:tb(3)},nb=i,ib=o,ob=f,ab=Sn,sb=rb.trim,cb=YS,ub=nb.parseInt,db=nb.Symbol,lb=db&&db.iterator,hb=/^[+-]?0x/i,pb=ob(hb.exec),vb=8!==ub(cb+"08")||22!==ub(cb+"0x16")||lb&&!ib((function(){ub(Object(lb))}))?function(e,t){var r=sb(ab(e));return ub(r,t>>>0||(pb(hb,r)?16:10))}:ub;wr({global:!0,forced:parseInt!==vb},{parseInt:vb});var _b=r(te.parseInt),fb={exports:{}},mb=o((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),gb=o,yb=ee,Sb=S,bb=mb,kb=Object.isExtensible,Eb=gb((function(){kb(1)}))||bb?function(e){return!!yb(e)&&((!bb||"ArrayBuffer"!==Sb(e))&&(!kb||kb(e)))}:kb,Tb=!o((function(){return Object.isExtensible(Object.preventExtensions({}))})),Ib=wr,Rb=f,Ab=Xr,wb=ee,Cb=Ze,xb=Qt.f,Ob=Xn,Pb=Jn,Db=Eb,Nb=Tb,Mb=!1,Lb=nt("meta"),Ub=0,Vb=function(e){xb(e,Lb,{value:{objectID:"O"+Ub++,weakData:{}}})},Fb=fb.exports={enable:function(){Fb.enable=function(){},Mb=!0;var e=Ob.f,t=Rb([].splice),r={};r[Lb]=1,e(r).length&&(Ob.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===Lb){t(n,i,1);break}return n},Ib({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Pb.f}))},fastKey:function(e,t){if(!wb(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!Cb(e,Lb)){if(!Db(e))return"F";if(!t)return"E";Vb(e)}return e[Lb].objectID},getWeakData:function(e,t){if(!Cb(e,Lb)){if(!Db(e))return!0;if(!t)return!1;Vb(e)}return e[Lb].weakData},onFreeze:function(e){return Nb&&Mb&&Db(e)&&!Cb(e,Lb)&&Vb(e),e}};Ab[Lb]=!0;var Bb=fb.exports,jb=wr,Hb=i,Gb=Bb,zb=o,Kb=fr,Wb=Kp,Xb=kv,Yb=A,qb=ee,Jb=K,Qb=Bi,Zb=Qt.f,$b=Vo.forEach,ek=C,tk=ro.set,rk=ro.getterFor,nk=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=Hb[e],c=s&&s.prototype,u={};if(ek&&Yb(s)&&(o||c.forEach&&!zb((function(){(new s).entries().next()})))){var d=(n=t((function(t,r){tk(Xb(t,d),{type:e,collection:new s}),Jb(r)||Wb(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,l=rk(e);$b(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"===e||"set"===e;!(e in c)||o&&"clear"===e||Kb(d,e,(function(r,n){var i=l(this).collection;if(!t&&o&&!qb(r))return"get"===e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||Zb(d,"size",{configurable:!0,get:function(){return l(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Gb.enable();return Qb(n,e,!1,!0),u[e]=n,jb({global:!0,forced:!0},u),o||r.setStrong(n,e,i),n},ik=vi,ok=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:ik(e,n,t[n],r);return e},ak=Wn,sk=fi,ck=ok,uk=Jt,dk=kv,lk=K,hk=Kp,pk=Mu,vk=Lu,_k=yv,fk=C,mk=Bb.fastKey,gk=ro.set,yk=ro.getterFor,Sk={getConstructor:function(e,t,r,n){var i=e((function(e,i){dk(e,o),gk(e,{type:t,index:ak(null),first:void 0,last:void 0,size:0}),fk||(e.size=0),lk(i)||hk(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=yk(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=mk(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),fk?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=mk(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key===t)return r};return ck(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,fk?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),fk?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=uk(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)}}),ck(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)}}),fk&&sk(o,"size",{configurable:!0,get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=yk(t),o=yk(n);pk(e,t,(function(e,t){gk(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)?vk("keys"===t?r.key:"values"===t?r.value:[r.key,r.value],!1):(e.target=void 0,vk(void 0,!0))}),r?"entries":"values",!r,!0),_k(t)}};nk("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Sk);var bk=te.Map,kk=function(e,t){return 1===t?function(t,r){return t[e](r)}:function(t,r,n){return t[e](r,n)}},Ek=kk,Tk=ae("Map"),Ik={Map:Tk,set:Ek("set",2),get:Ek("get",1),has:Ek("has",1),remove:Ek("delete",1),proto:Tk.prototype},Rk=wr,Ak=Oe,wk=Y,Ck=Kp,xk=Ik.Map,Ok=Ik.has,Pk=Ik.get,Dk=Ik.set,Nk=f([].push);Rk({target:"Map",stat:!0,forced:true},{groupBy:function(e,t){wk(e),Ak(t);var r=new xk,n=0;return Ck(e,(function(e){var i=t(e,n++);Ok(r,i)?Nk(Pk(r,i),e):Dk(r,i,[e])})),r}});var Mk=bk,Lk=Jt,Uk=P,Vk=Oe,Fk=Rv,Bk=K,jk=Kp,Hk=[].push,Gk=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return Fk(this),(t=void 0!==a)&&Vk(a),Bk(e)?new this:(r=[],t?(n=0,i=Lk(a,o>2?arguments[2]:void 0),jk(e,(function(e){Uk(Hk,r,i(e,n++))}))):jk(e,Hk,{that:r}),new this(r))};wr({target:"Map",stat:!0,forced:!0},{from:Gk});var zk=cs,Kk=function(){return new this(zk(arguments))};wr({target:"Map",stat:!0,forced:!0},{of:Kk});var Wk=Ae,Xk=function(e){if("object"==typeof e&&"size"in e&&"has"in e&&"get"in e&&"set"in e&&"delete"in e&&"entries"in e)return e;throw TypeError(Wk(e)+" is not a map")},Yk=Xk,qk=Ik.remove;wr({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=Yk(this),r=!0,n=0,i=arguments.length;n<i;n++)e=qk(t,arguments[n]),r=r&&e;return!!r}});var Jk=Xk,Qk=Ik.get,Zk=Ik.has,$k=Ik.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,t){var r,n,i=Jk(this);return Zk(i,e)?(r=Qk(i,e),"update"in t&&(r=t.update(r,e,i),$k(i,e,r)),r):(n=t.insert(e,i),$k(i,e,n),n)}});var eE=P,tE=function(e,t,r){for(var n,i,o=r?e:e.iterator,a=e.next;!(n=eE(a,o)).done;)if(void 0!==(i=t(n.value)))return i},rE=tE,nE=function(e,t,r){return r?rE(e.entries(),(function(e){return t(e[1],e[0])}),!0):e.forEach(t)},iE=Jt,oE=Xk,aE=nE;wr({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=oE(this),r=iE(e,arguments.length>1?arguments[1]:void 0);return!1!==aE(t,(function(e,n){if(!r(e,n,t))return!1}),!0)}});var sE=Jt,cE=Xk,uE=nE,dE=Ik.Map,lE=Ik.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=cE(this),r=sE(e,arguments.length>1?arguments[1]:void 0),n=new dE;return uE(t,(function(e,i){r(e,i,t)&&lE(n,i,e)})),n}});var hE=Jt,pE=Xk,vE=nE;wr({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=pE(this),r=hE(e,arguments.length>1?arguments[1]:void 0),n=vE(t,(function(e,n){if(r(e,n,t))return{value:e}}),!0);return n&&n.value}});var _E=Jt,fE=Xk,mE=nE;wr({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=fE(this),r=_E(e,arguments.length>1?arguments[1]:void 0),n=mE(t,(function(e,n){if(r(e,n,t))return{key:n}}),!0);return n&&n.key}});var gE=function(e,t){return e===t||e!=e&&t!=t},yE=Xk,SE=nE;wr({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return!0===SE(yE(this),(function(t){if(gE(t,e))return!0}),!0)}});var bE=P,kE=Kp,EE=A,TE=Oe,IE=Ik.Map;wr({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new(EE(this)?this:IE);TE(t);var n=TE(r.set);return kE(e,(function(e){bE(n,r,t(e),e)})),r}});var RE=Xk,AE=nE;wr({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){var t=AE(RE(this),(function(t,r){if(t===e)return{key:r}}),!0);return t&&t.key}});var wE=Jt,CE=Xk,xE=nE,OE=Ik.Map,PE=Ik.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=CE(this),r=wE(e,arguments.length>1?arguments[1]:void 0),n=new OE;return xE(t,(function(e,i){PE(n,r(e,i,t),e)})),n}});var DE=Jt,NE=Xk,ME=nE,LE=Ik.Map,UE=Ik.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=NE(this),r=DE(e,arguments.length>1?arguments[1]:void 0),n=new LE;return ME(t,(function(e,i){UE(n,i,r(e,i,t))})),n}});var VE=Xk,FE=Kp,BE=Ik.set;wr({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=VE(this),r=arguments.length,n=0;n<r;)FE(arguments[n++],(function(e,r){BE(t,e,r)}),{AS_ENTRIES:!0});return t}});var jE=Oe,HE=Xk,GE=nE,zE=TypeError;wr({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=HE(this),r=arguments.length<2,n=r?void 0:arguments[1];if(jE(e),GE(t,(function(i,o){r?(r=!1,n=i):n=e(n,i,o,t)})),r)throw zE("Reduce of empty map with no initial value");return n}});var KE=Jt,WE=Xk,XE=nE;wr({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=WE(this),r=KE(e,arguments.length>1?arguments[1]:void 0);return!0===XE(t,(function(e,n){if(r(e,n,t))return!0}),!0)}});var YE=Oe,qE=Xk,JE=TypeError,QE=Ik.get,ZE=Ik.has,$E=Ik.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=qE(this),n=arguments.length;YE(t);var i=ZE(r,e);if(!i&&n<3)throw JE("Updating absent value");var o=i?QE(r,e):YE(n>2?arguments[2]:void 0)(e,r);return $E(r,e,t(o,e,r)),r}});var eT=P,tT=Oe,rT=A,nT=rr,iT=TypeError,oT=function(e,t){var r,n=nT(this),i=tT(n.get),o=tT(n.has),a=tT(n.set),s=arguments.length>2?arguments[2]:void 0;if(!rT(t)&&!rT(s))throw iT("At least one callback required");return eT(o,n,e)?(r=eT(i,n,e),rT(t)&&(r=t(r),eT(a,n,e,r))):rT(s)&&(r=s(),eT(a,n,e,r)),r};wr({target:"Map",proto:!0,real:!0,forced:!0},{upsert:oT}),wr({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:oT});var aT=Mk,sT=r(aT),cT=r(aT),uT=r(Ld),dT=C,lT=f,hT=P,pT=o,vT=nn,_T=hi,fT=D,mT=qe,gT=z,yT=Object.assign,ST=Object.defineProperty,bT=lT([].concat),kT=!yT||pT((function(){if(dT&&1!==yT({b:1},yT(ST({},"a",{enumerable:!0,get:function(){ST(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!==yT({},e)[r]||vT(yT({},t)).join("")!==n}))?function(e,t){for(var r=mT(e),n=arguments.length,i=1,o=_T.f,a=fT.f;n>i;)for(var s,c=gT(arguments[i++]),u=o?bT(vT(c),o(c)):vT(c),d=u.length,l=0;d>l;)s=u[l++],dT&&!hT(a,c,s)||(r[s]=c[s]);return r}:yT,ET=kT;wr({target:"Object",stat:!0,arity:2,forced:Object.assign!==ET},{assign:ET});var TT=r(te.Object.assign),IT=wr,RT=E;w.f;var AT=Fr,wT=Sn,CT=Py,xT=Y,OT=Ny,PT=RT("".endsWith),DT=RT("".slice),NT=Math.min;IT({target:"String",proto:!0,forced:!OT("endsWith")},{endsWith:function(e){var t=wT(xT(this));CT(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:NT(AT(r),n),o=wT(e);return PT?PT(t,o,i):DT(t,i-o.length,i)===o}});var MT=qs("String").endsWith,LT=se,UT=MT,VT=String.prototype,FT=r((function(e){var t=e.endsWith;return"string"==typeof e||e===VT||LT(VT,e)&&t===VT.endsWith?UT:t})),BT=!0,jT=!0;function HT(e,t,r){var n=e.match(t);return n&&n.length>=r&&_b(n[r],10)}function GT(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 cT),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===MS(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},uT(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 zT(e){return"boolean"!=typeof e?new Error("Argument type: "+Wl(e)+". Please use a boolean."):(BT=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function KT(e){return"boolean"!=typeof e?new Error("Argument type: "+Wl(e)+". Please use a boolean."):(jT=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function WT(){if("object"===("undefined"==typeof window?"undefined":Wl(window))){if(BT)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function XT(e,t){jT&&console.warn(e+" is deprecated, please use "+t+" instead.")}function YT(e){return"[object Object]"===Object.prototype.toString.call(e)}function qT(e){var t;return YT(e)?oS(t=MS(e)).call(t,(function(t,r){var n=YT(e[r]),i=n?qT(e[r]):e[r],o=n&&!MS(i).length;return void 0===i||o?t:TT(t,ql({},r,i))}),{}):e}function JT(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),MS(t).forEach((function(n){FT(n).call(n,"Id")?JT(e,e.get(t[n]),r):FT(n).call(n,"Ids")&&t[n].forEach((function(t){JT(e,e.get(t),r)}))})))}function QT(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new cT;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&&JT(e,r,i)}))})),i}var ZT=wr,$T=Vo.find,eI="find",tI=!0;eI in[]&&Array(1)[eI]((function(){tI=!1})),ZT({target:"Array",proto:!0,forced:tI},{find:function(e){return $T(this,e,arguments.length>1?arguments[1]:void 0)}});var rI=qs("Array").find,nI=se,iI=rI,oI=Array.prototype,aI=r((function(e){var t=e.find;return e===oI||nI(oI,e)&&t===oI.find?iI:t})),sI=r(xg),cI=wr,uI=Wr.indexOf,dI=td,lI=E([].indexOf),hI=!!lI&&1/lI([1],1,-0)<0;cI({target:"Array",proto:!0,forced:hI||!dI("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return hI?lI(this,e,t)||0:uI(this,e,t)}});var pI=qs("Array").indexOf,vI=se,_I=pI,fI=Array.prototype,mI=function(e){var t=e.indexOf;return e===fI||vI(fI,e)&&t===fI.indexOf?_I:t},gI=r(mI),yI=r(mI),SI=Ae,bI=TypeError,kI=function(e,t){if(!delete e[t])throw bI("Cannot delete property "+SI(t)+" of "+SI(e))},EI=wr,TI=qe,II=Lr,RI=Pr,AI=jr,wI=fc,CI=gc,xI=xo,OI=ei,PI=kI,DI=Ws("splice"),NI=Math.max,MI=Math.min;EI({target:"Array",proto:!0,forced:!DI},{splice:function(e,t){var r,n,i,o,a,s,c=TI(this),u=AI(c),d=II(e,u),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=u-d):(r=l-2,n=MI(NI(RI(t),0),u-d)),CI(u+r-n),i=xI(c,n),o=0;o<n;o++)(a=d+o)in c&&OI(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]:PI(c,s);for(o=u;o>u-n+r;o--)PI(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]:PI(c,s);for(o=0;o<r;o++)c[o+d]=arguments[o+2];return wI(c,u-n+r),i}});var LI=qs("Array").splice,UI=se,VI=LI,FI=Array.prototype,BI=r((function(e){var t=e.splice;return e===FI||UI(FI,e)&&t===FI.splice?VI:t})),jI=r(eg),HI=r(dc),GI=WT;function zI(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==Wl(e)||e.mandatory||e.optional)return e;var t,r={};(MS(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===Wl(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()+sI(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=Fg(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(Gg(e)))&&"object"===Wl(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(Gg(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===Wl(e.video)){var a=e.video.facingMode;a=a&&("object"===Wl(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=Ty(t).call(t,(function(e){return"videoinput"===e.kind}));var r=aI(t).call(t,(function(e){return s.some((function(t){var r;return Xy(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&Xy(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),GI("chrome: "+Gg(e)),i(e)}));e.video=n(e.video)}return GI("chrome: "+Gg(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 jI.reject(o(e))}))}))}}}}function KI(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function WI(e){if("object"===Wl(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){uT(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=aI(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=aI(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 GT(e,"track",(function(e){return e.transceiver||uT(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function XI(e){if("object"===Wl(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||[],sI(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=yI(t=this._senders).call(t,e);-1!==i&&BI(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=aI(r=t._senders).call(r,(function(t){return t.track===e}));o&&BI(n=t._senders).call(n,yI(i=t._senders).call(i,o),1)}))}}else if("object"===Wl(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},uT(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 YI(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=sI(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 cT(qg(t=MS(e)).call(t,(function(t){return[t,e[t]]})))};if(arguments.length>=2){return t.apply(this,[function(e){i(s(a(e)))},n])}return new jI((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function qI(e){if("object"===Wl(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 QT(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}),GT(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 QT(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?jI.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():jI.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function JI(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},qg(e=MS(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===yI(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(aI(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=Ty(t=this.getSenders()).call(t,(function(e){return-1===yI(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Fg(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&&MS(this._shimmedLocalStreams).forEach((function(r){var n,i,o=yI(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&BI(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function QI(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return JI(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},qg(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(aI(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=sI([]).call(arguments,1);if(1!==s.length||!aI(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");if(aI(i=this.getSenders()).call(i,(function(e){return e.track===t})))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var c=this._streams[r.id];if(c)c.addTrack(t),jI.resolve().then((function(){a.dispatchEvent(new Event("negotiationneeded"))}));else{var u=new e.MediaStream([t]);this._streams[r.id]=u,this._reverseStreams[u.id]=r,this.addStream(u)}return aI(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=ql({},t,(function(){var e=this,t=arguments;return arguments.length&&"function"==typeof arguments[0]?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]=(e=this,r=(t=arguments[0]).sdp,MS(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})),o.apply(this,arguments)):o.apply(this,arguments);var e,t,r};var a=HI(e.RTCPeerConnection.prototype,"localDescription");uT(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||{},MS(this._streams).forEach((function(n){var i;aI(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 MS(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 ZI(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=ql({},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 $I(e,t){GT(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 eR=Object.freeze({__proto__:null,fixNegotiationNeeded:$I,shimAddTrackRemoveTrack:QI,shimAddTrackRemoveTrackWithNative:JI,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"))},shimGetSendersWithDtmf:XI,shimGetStats:YI,shimGetUserMedia:zI,shimMediaStream:KI,shimOnTrack:WI,shimPeerConnection:ZI,shimSenderReceiverGetStats:qI});function tR(e){return function(e){if(Qg(e))return _y(e)}(e)||function(e){if(void 0!==Al&&null!=Jg(e)||null!=e["@@iterator"])return vy(e)}(e)||fy(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 rR=i,nR=o,iR=Sn,oR=rb.trim,aR=YS,sR=f("".charAt),cR=rR.parseFloat,uR=rR.Symbol,dR=uR&&uR.iterator,lR=1/cR(aR+"-0")!=-1/0||dR&&!nR((function(){cR(Object(dR))}))?function(e){var t=oR(iR(e)),r=cR(t);return 0===r&&"-"===sR(t,0)?-0:r}:cR;wr({global:!0,forced:parseFloat!==lR},{parseFloat:lR});var hR=r(te.parseFloat);function pR(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){XT("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"===Wl(e)&&"object"===Wl(e.audio)&&(e=JSON.parse(Gg(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"===Wl(e)&&(e=JSON.parse(Gg(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function vR(e){"object"===Wl(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&uT(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function _R(e,t){if("object"===Wl(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=ql({},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=sI(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,TT({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function fR(e){if("object"===Wl(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):jI.resolve(new cT)}}}function mR(e){if("object"===Wl(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}),GT(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function gR(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;XT("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&Xy(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function yR(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function SR(e){if("object"===Wl(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=tR(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&&!(hR(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(hR(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===MS(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 bR(e){if("object"===Wl(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=Fg(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function kR(e){if("object"===Wl(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?jI.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function ER(e){if("object"===Wl(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?jI.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var TR=Object.freeze({__proto__:null,shimAddTransceiver:SR,shimCreateAnswer:ER,shimCreateOffer:kR,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,jI.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})},shimGetParameters:bR,shimGetUserMedia:pR,shimOnTrack:vR,shimPeerConnection:_R,shimRTCDataChannel:yR,shimReceiverGetStats:mR,shimRemoveStream:gR,shimSenderGetStats:fR});function IR(e){if("object"===Wl(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=[]),Xy(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?Xy(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=yI(t=this._localStreams).call(t,e);if(-1!==i){BI(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){Xy(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function RR(e){if("object"===Wl(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){uT(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=[]),!Xy(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=[]),!(yI(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 AR(e){if("object"===Wl(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),jI.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),jI.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),jI.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),jI.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),jI.resolve()):n},t.addIceCandidate=s}}function wR(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(CR(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function CR(e){return e&&void 0!==e.video?TT({},e,{video:qT(e.video)}):e}function xR(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")?(XT("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(Gg(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&&uT(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function OR(e){"object"===Wl(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&uT(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function PR(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=aI(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=aI(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 DR(e){"object"!==Wl(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var NR=Object.freeze({__proto__:null,shimAudioContext:DR,shimCallbacksAPI:AR,shimConstraints:CR,shimCreateOfferLegacy:PR,shimGetUserMedia:wR,shimLocalStreamsAPI:IR,shimRTCIceServerUrls:xR,shimRemoteStreamsAPI:RR,shimTrackEventTransceiver:OR}),MR=Uc.PROPER,LR=o,UR=YS,VR=rb.trim;wr({target:"String",proto:!0,forced:function(e){return LR((function(){return!!UR[e]()||"
"!=="
"[e]()||MR&&UR[e].name!==e}))}("trim")},{trim:function(){return VR(this)}});var FR,BR,jR=qs("String").trim,HR=se,GR=jR,zR=String.prototype,KR=r((function(e){var t=e.trim;return"string"==typeof e||e===zR||HR(zR,e)&&t===zR.trim?GR:t})),WR={exports:{}};FR=WR,(BR={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=BR.generateIdentifier(),BR.splitLines=function(e){var t;return qg(t=KR(e).call(e).split("\n")).call(t,(function(e){return KR(e).call(e)}))},BR.splitSections=function(e){var t=e.split("\nm=");return qg(t).call(t,(function(e,t){var r;return KR(r=t>0?"m="+e:e).call(r)+"\r\n"}))},BR.getDescription=function(e){var t=BR.splitSections(e);return t&&t[0]},BR.getMediaSections=function(e){var t=BR.splitSections(e);return t.shift(),t},BR.matchPrefix=function(e,t){var r;return Ty(r=BR.splitLines(e)).call(r,(function(e){return 0===yI(e).call(e,t)}))},BR.parseCandidate=function(e){for(var t,r={foundation:(t=0===yI(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:_b(t[3],10),ip:t[4],address:t[4],port:_b(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=_b(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},BR.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(" ")},BR.parseIceOptions=function(e){return e.substr(14).split(" ")},BR.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:_b(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=_b(t[1],10),r.channels=3===t.length?_b(t[2],10):1,r.numChannels=r.channels,r},BR.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"},BR.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:_b(r[0],10),direction:yI(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},BR.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},BR.parseFmtp=function(e){for(var t,r={},n=e.substr(yI(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=KR(o=n[i]).call(o).split("="),r[KR(a=t[0]).call(a)]=t[1]}return r},BR.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&MS(e.parameters).length){var n=[];MS(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},BR.parseRtcpFb=function(e){var t=e.substr(yI(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},BR.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},BR.parseSsrcMedia=function(e){var t=yI(e).call(e," "),r={ssrc:_b(e.substr(7,t-7),10)},n=yI(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},BR.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:qg(t).call(t,(function(e){return _b(e,10)}))}},BR.getMid=function(e){var t=BR.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},BR.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},BR.getDtlsParameters=function(e,t){var r=BR.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:qg(r).call(r,BR.parseFingerprint)}},BR.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},BR.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:_b(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:sI(t).call(t,3)}},BR.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===Wl(e.keyParams)?BR.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},BR.parseCryptoKeyParams=function(e){if(0!==yI(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}},BR.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},BR.getCryptoParameters=function(e,t){var r=BR.matchPrefix(e+t,"a=crypto:");return qg(r).call(r,BR.parseCryptoLine)},BR.getIceParameters=function(e,t){var r=BR.matchPrefix(e+t,"a=ice-ufrag:")[0],n=BR.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},BR.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},BR.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=BR.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=BR.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=BR.parseRtpMap(o),c=BR.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=c.length?BR.parseFmtp(c[0]):{},s.rtcpFeedback=qg(a=BR.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,BR.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return BR.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(BR.parseExtmap(e))})),t},BR.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=qg(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+=BR.writeRtpMap(e),n+=BR.writeFmtp(e),n+=BR.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+=BR.writeExtmap(e)})),n},BR.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],c=BR.parseRtpParameters(e),u=-1!==yI(t=c.fecMechanisms).call(t,"RED"),d=-1!==yI(r=c.fecMechanisms).call(r,"ULPFEC"),l=Ty(n=qg(i=BR.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return BR.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=l.length>0&&l[0].ssrc,p=qg(o=BR.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return qg(t).call(t,(function(e){return _b(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:_b(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),u&&((t=JSON.parse(Gg(t))).fec={ssrc:h,mechanism:d?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var v,_,f=BR.matchPrefix(e,"b=");return f.length&&(f=0===yI(v=f[0]).call(v,"b=TIAS:")?_b(f[0].substr(7),10):0===yI(_=f[0]).call(_,"b=AS:")?1e3*_b(f[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=f}))),s},BR.parseRtcpParameters=function(e){var t,r,n={},i=Ty(t=qg(r=BR.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return BR.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=BR.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=BR.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},BR.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},BR.parseMsid=function(e){var t,r,n,i=BR.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=Ty(t=qg(r=BR.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return BR.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},BR.parseSctpDescription=function(e){var t,r=BR.parseMLine(e),n=BR.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=_b(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=BR.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:_b(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=BR.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:_b(a[0],10),protocol:a[1],maxMessageSize:t}}},BR.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("")},BR.generateSessionId=function(){return Math.random().toString().substr(2,21)},BR.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||BR.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},BR.getDirection=function(e,t){for(var r=BR.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?BR.getDirection(t):"sendrecv"},BR.getKind=function(e){return BR.splitLines(e)[0].split(" ")[0].substr(2)},BR.isRejected=function(e){return"0"===e.split(" ",2)[1]},BR.parseMLine=function(e){var t=BR.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:_b(t[1],10),protocol:t[2],fmt:sI(t).call(t,3).join(" ")}},BR.parseOLine=function(e){var t=BR.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:_b(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},BR.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=BR.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},FR.exports=BR;var XR=WR.exports,YR=r(XR),qR=e({__proto__:null,default:YR},[XR]);function JR(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===Wl(e)&&e.candidate&&0===yI(r=e.candidate).call(r,"a=")&&((e=JSON.parse(Gg(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=YR.parseCandidate(e.candidate),o=TT(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,GT(e,"icecandidate",(function(t){return t.candidate&&uT(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function QR(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||GT(e,"icecandidate",(function(e){if(e.candidate){var t=YR.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function ZR(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||uT(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e,n;(this._sctp=null,"chrome"===t.browser&&t.version>=76)&&("plan-b"===this.getConfiguration().sdpSemantics&&uT(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0}));if(function(e){if(!e||!e.sdp)return!1;var t=YR.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=YR.parseMLine(e);return r&&"application"===r.kind&&-1!==yI(t=r.protocol).call(t,"SCTP")}))}(arguments[0])){var i,o=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=_b(t[1],10);return r!=r?-1:r}(arguments[0]),a=(e=o,n=65536,"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),n),s=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=YR.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=_b(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n}(arguments[0],o);i=0===a&&0===s?Number.POSITIVE_INFINITY:0===a||0===s?Math.max(a,s):Math.min(a,s);var c={};uT(c,"maxMessageSize",{get:function(){return i}}),this._sctp=c}return r.apply(this,arguments)}}}function $R(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},GT(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 eA(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;uT(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),uT(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 tA(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!==yI(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=Ty(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==KR(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 rA(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?jI.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),jI.resolve())})}}function nA(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"!==Wl(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"}return t.sdp||"offer"!==t.type&&"answer"!==t.type?r.apply(this,[t]):("offer"===t.type?this.createOffer:this.createAnswer).apply(this).then((function(t){return r.apply(e,[t])}))})}}var iA=Object.freeze({__proto__:null,removeExtmapAllowMixed:tA,shimAddIceCandidateNullOrEmpty:rA,shimConnectionState:eA,shimMaxMessageSize:ZR,shimParameterlessSetLocalDescription:nA,shimRTCIceCandidate:JR,shimRTCIceCandidateRelayProtocol:QR,shimSendThrowTypeError:$R});if(function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).window,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},r=WT,n=function(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=HT(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=HT(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=HT(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),i={browserDetails:n,commonShim:iA,extractVersion:HT,disableLog:zT,disableWarnings:KT,sdp:qR};switch(n.browser){case"chrome":if(!eR||!ZI||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),i;if(null===n.version)return r("Chrome shim can not determine version, not shimming."),i;r("adapter.js shimming chrome."),i.browserShim=eR,rA(e,n),nA(e),zI(e,n),KI(e),ZI(e,n),WI(e),QI(e,n),XI(e),YI(e),qI(e),$I(e,n),JR(e),QR(e),eA(e),ZR(e,n),$R(e),tA(e,n);break;case"firefox":if(!TR||!_R||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),i;r("adapter.js shimming firefox."),i.browserShim=TR,rA(e,n),nA(e),pR(e,n),_R(e,n),vR(e),gR(e),fR(e),mR(e),yR(e),SR(e),bR(e),kR(e),ER(e),JR(e),eA(e),ZR(e,n),$R(e);break;case"safari":if(!NR||!t.shimSafari)return r("Safari shim is not included in this adapter release."),i;r("adapter.js shimming safari."),i.browserShim=NR,rA(e,n),nA(e),xR(e),PR(e),AR(e),IR(e),RR(e),OR(e),wR(e),DR(e),JR(e),QR(e),ZR(e,n),$R(e),tA(e,n);break;default:r("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var oA=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=oA.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 aA(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var sA=Ze,cA=function(e){return void 0!==e&&(sA(e,"value")||sA(e,"writable"))},uA=P,dA=ee,lA=rr,hA=cA,pA=w,vA=Wc;wr({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return lA(t)===o?t[r]:(n=pA.f(t,r))?hA(n)?n.value:void 0===n.get?void 0:uA(n.get,o):dA(i=vA(t))?e(i,r,o):void 0}});var _A=te.Reflect.get,fA=r(_A),mA=f,gA=Oe,yA=ee,SA=Ze,bA=cs,kA=a,EA=Function,TA=mA([].concat),IA=mA([].join),RA={},AA=kA?EA.bind:function(e){var t=gA(this),r=t.prototype,n=bA(arguments,1),i=function(){var r=TA(n,bA(arguments));return this instanceof i?function(e,t,r){if(!SA(RA,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";RA[t]=EA("C,a","return new C("+IA(n,",")+")")}return RA[t](e,r)}(t,r.length,r):t.apply(e,r)};return yA(r)&&(i.prototype=r),i},wA=AA;wr({target:"Function",proto:!0,forced:Function.bind!==wA},{bind:wA});var CA=qs("Function").bind,xA=se,OA=CA,PA=Function.prototype,DA=r((function(e){var t=e.bind;return e===PA||xA(PA,e)&&t===PA.bind?OA:t}));function NA(e){var t;return(NA=Xh?DA(t=Kh).call(t):function(e){return e.__proto__||Kh(e)})(e)}function MA(){var e;"undefined"!=typeof Reflect&&fA?MA=DA(e=fA).call(e):MA=function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=NA(e)););return e}(e,t);if(n){var i=lc(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return MA.apply(this,arguments)}function LA(e,t){var r;return(LA=Xh?DA(r=Xh).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function UA(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=jh(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Ud(e,"prototype",{writable:!1}),t&&LA(e,t)}var VA=wr,FA=l,BA=AA,jA=Rv,HA=rr,GA=ee,zA=Wn,KA=o,WA=ae("Reflect","construct"),XA=Object.prototype,YA=[].push,qA=KA((function(){function e(){}return!(WA((function(){}),[],e)instanceof e)})),JA=!KA((function(){WA((function(){}))})),QA=qA||JA;VA({target:"Reflect",stat:!0,forced:QA,sham:QA},{construct:function(e,t){jA(e),HA(t);var r=arguments.length<3?e:jA(arguments[2]);if(JA&&!qA)return WA(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 FA(YA,n,t),new(FA(BA,e,n))}var i=r.prototype,o=zA(GA(i)?i:XA),a=FA(e,o,t);return GA(a)?a:o}});var ZA=r(te.Reflect.construct);function $A(){if("undefined"==typeof Reflect||!ZA)return!1;if(ZA.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(ZA(Boolean,[],(function(){}))),!0}catch(e){return!1}}function ew(e){var t=$A();return function(){var r,n=NA(e);if(t){var i=NA(this).constructor;r=ZA(n,arguments,i)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===Wl(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return aA(e)}(this,r)}}var tw=qs("Array").values,rw=mn,nw=Ze,iw=se,ow=tw,aw=Array.prototype,sw={DOMTokenList:!0,NodeList:!0},cw=r((function(e){var t=e.values;return e===aw||iw(aw,e)&&t===aw.values||nw(sw,rw(e))?ow:t})),uw=ai,dw=Math.floor,lw=function(e,t){var r=e.length,n=dw(r/2);return r<8?hw(e,t):pw(e,lw(uw(e,0,n),t),lw(uw(e,n),t),t)},hw=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},pw=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},vw=lw,_w=ce.match(/firefox\/(\d+)/i),fw=!!_w&&+_w[1],mw=/MSIE|Trident/.test(ce),gw=ce.match(/AppleWebKit\/(\d+)\./),yw=!!gw&&+gw[1],Sw=wr,bw=f,kw=Oe,Ew=qe,Tw=jr,Iw=kI,Rw=Sn,Aw=o,ww=vw,Cw=td,xw=fw,Ow=mw,Pw=_e,Dw=yw,Nw=[],Mw=bw(Nw.sort),Lw=bw(Nw.push),Uw=Aw((function(){Nw.sort(void 0)})),Vw=Aw((function(){Nw.sort(null)})),Fw=Cw("sort"),Bw=!Aw((function(){if(Pw)return Pw<70;if(!(xw&&xw>3)){if(Ow)return!0;if(Dw)return Dw<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++)Nw.push({k:t+n,v:r})}for(Nw.sort((function(e,t){return t.v-e.v})),n=0;n<Nw.length;n++)t=Nw[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));Sw({target:"Array",proto:!0,forced:Uw||!Vw||!Fw||!Bw},{sort:function(e){void 0!==e&&kw(e);var t=Ew(this);if(Bw)return void 0===e?Mw(t):Mw(t,e);var r,n,i=[],o=Tw(t);for(n=0;n<o;n++)n in t&&Lw(i,t[n]);for(ww(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:Rw(t)>Rw(r)?1:-1}}(e)),r=Tw(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)Iw(t,n++);return t}});var jw=qs("Array").sort,Hw=se,Gw=jw,zw=Array.prototype,Kw=r((function(e){var t=e.sort;return e===zw||Hw(zw,e)&&t===zw.sort?Gw:t})),Ww=wr,Xw=Vo.findIndex,Yw="findIndex",qw=!0;Yw in[]&&Array(1)[Yw]((function(){qw=!1})),Ww({target:"Array",proto:!0,forced:qw},{findIndex:function(e){return Xw(this,e,arguments.length>1?arguments[1]:void 0)}});var Jw=qs("Array").findIndex,Qw=se,Zw=Jw,$w=Array.prototype,eC=r((function(e){var t=e.findIndex;return e===$w||Qw($w,e)&&t===$w.findIndex?Zw:t})),tC=wr,rC=E;w.f;var nC=Fr,iC=Sn,oC=Py,aC=Y,sC=Ny,cC=rC("".startsWith),uC=rC("".slice),dC=Math.min;tC({target:"String",proto:!0,forced:!sC("startsWith")},{startsWith:function(e){var t=iC(aC(this));oC(e);var r=nC(dC(arguments.length>1?arguments[1]:void 0,t.length)),n=iC(e);return cC?cC(t,n,r):uC(t,r,r+n.length)===n}});var lC=qs("String").startsWith,hC=se,pC=lC,vC=String.prototype,_C=r((function(e){var t=e.startsWith;return"string"==typeof e||e===vC||hC(vC,e)&&t===vC.startsWith?pC:t})),fC=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_EXCEED_QPS="USER_MESSAGE_EXCEED_QPS",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e.SUBTITLE_ALREADY_ON="SUBTITLE_ALREADY_ON",e.SUBTITLE_NOT_TURNED_ON="SUBTITLE_NOT_TURNED_ON",e.SUBTITLE_ERR_POSTPROCESS="SUBTITLE_ERR_POSTPROCESS",e.SUBTITLE_ERR_CONNECTION_ERROR="SUBTITLE_ERR_CONNECTION_ERROR",e.SUBTITLE_ERR_PROCESS_ERROR="SUBTITLE_ERR_PROCESS_ERROR",e.SUBTITLE_ERR_UNKNOWN="SUBTITLE_ERR_UNKNOWN",e.UNEXPECTED_INVOKE_FORWARD_STREAM="UNEXPECTED_INVOKE_FORWARD_STREAM",e.ROOM_FORBIDDEN="ROOM_FORBIDDEN",e.USER_FORBIDDEN="USER_FORBIDDEN",e}(fC||{}),mC=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}(mC||{});function gC(e,t,r){var n;$A()?gC=DA(n=ZA).call(n):gC=function(e,t,r){var n=[null];xc(n).apply(n,t);var i=new(DA(Function).apply(e,n));return r&&LA(i,r.prototype),i};return gC.apply(null,arguments)}function yC(e){var t="function"==typeof sT?new sT:void 0;return yC=function(e){if(null===e||(r=e,-1===gI(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 gC(e,arguments,NA(this).constructor)}return i.prototype=jh(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),LA(i,e)},yC(e)}var SC=r(Wh),bC=function(e){UA(r,e);var t=ew(r);function r(e,n,i){var o;return Fh(this,r),ql(aA(o=t.call(this,n)),"code",void 0),ql(aA(o),"message",void 0),ql(aA(o),"error",void 0),o.code=e,o.message=n,o.error=i,SC(aA(o),r.prototype),o}return Vh(r,[{key:"toString",value:function(){var e;return Fg(e="SDKError: ".concat(this.code," ")).call(e,this.message)}}]),r}(yC(Error)),kC=Pr,EC=Sn,TC=Y,IC=RangeError,RC=f,AC=Fr,wC=Sn,CC=function(e){var t=EC(TC(this)),r="",n=kC(e);if(n<0||n===1/0)throw IC("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},xC=Y,OC=RC(CC),PC=RC("".slice),DC=Math.ceil,NC=function(e){return function(t,r,n){var i,o,a=wC(xC(t)),s=AC(r),c=a.length,u=void 0===n?" ":wC(n);return s<=c||""===u?a:((o=OC(u,DC((i=s-c)/u.length))).length>i&&(o=PC(o,0,i)),e?a+o:o+a)}},MC={start:NC(!1),end:NC(!0)},LC=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(ce),UC=MC.end;wr({target:"String",proto:!0,forced:LC},{padEnd:function(e){return UC(this,e,arguments.length>1?arguments[1]:void 0)}});var VC=qs("String").padEnd,FC=se,BC=VC,jC=String.prototype,HC=r((function(e){var t=e.padEnd;return"string"==typeof e||e===jC||FC(jC,e)&&t===jC.padEnd?BC:t})),GC=vb;wr({target:"Number",stat:!0,forced:Number.parseInt!==GC},{parseInt:GC});var zC=r(te.Number.parseInt),KC=r(py),WC=r(dg),XC=Math.log,YC=Math.LOG10E;wr({target:"Math",stat:!0},{log10:Math.log10||function(e){return XC(e)*YC}});var qC,JC=r(te.Math.log10),QC=qs("Array").keys,ZC=mn,$C=Ze,ex=se,tx=QC,rx=Array.prototype,nx={DOMTokenList:!0,NodeList:!0},ix=r((function(e){var t=e.keys;return e===rx||ex(rx,e)&&t===rx.keys||$C(nx,ZC(e))?tx:t})),ox=new Uint8Array(16);function ax(){if(!qC&&!(qC="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 qC(ox)}var sx=/^(?:[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;for(var cx=[],ux=0;ux<256;++ux)cx.push((ux+256).toString(16).substr(1));function dx(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(cx[e[t+0]]+cx[e[t+1]]+cx[e[t+2]]+cx[e[t+3]]+"-"+cx[e[t+4]]+cx[e[t+5]]+"-"+cx[e[t+6]]+cx[e[t+7]]+"-"+cx[e[t+8]]+cx[e[t+9]]+"-"+cx[e[t+10]]+cx[e[t+11]]+cx[e[t+12]]+cx[e[t+13]]+cx[e[t+14]]+cx[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&sx.test(e)}(r))throw TypeError("Stringified UUID is invalid");return r}function lx(e,t,r){var n=(e=e||{}).random||(e.rng||ax)();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 dx(n)}var hx=function(){return"undefined"==typeof window},px=function(){return lx()},vx=function(e){return"number"==typeof e},_x=function(e){var t;return Xy(t=Function.prototype.toString.call(e)).call(t,"[native code]")};function fx(e){return null==e?"undefined | null":"string"==typeof e?e:Gg({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function mx(e){return null==e?"undefined | null":"string"==typeof e?e:Gg({id:e.id,active:e.active})}function gx(e){return null==e?"undefined | null":"string"==typeof e?e:Gg({track:fx(e.track)})}function yx(e){return null==e?"undefined | null":"string"==typeof e?e:Gg({track:fx(e.track)})}function Sx(e){return null==e?"undefined | null":"string"==typeof e?e:Gg({currentDirection:e.currentDirection,direction:e.direction,mid:e.mid,stopped:e.stopped,receiver:yx(e.receiver),sender:gx(e.sender)})}var bx="@byted/ve-rtc",kx="@byted/ve-rtc-cache-size",Ex=function(){function e(){Fh(this,e),ql(this,"storeKey",void 0),ql(this,"logLevel",void 0),ql(this,"LogfileSize",void 0),ql(this,"db",void 0),ql(this,"logId",void 0),ql(this,"cacheLog",void 0),ql(this,"cachedSize",void 0),ql(this,"preCacheTime",void 0),ql(this,"timer",void 0),ql(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 Vh(e,[{key:"_createStore",value:function(){var e=this;if(!hx()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(bx);try{localStorage.removeItem(kx)}catch(jZ){}},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(kx);if(t)this.cachedSize=Number(t);else cw(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(jZ){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(kx,"".concat(this.cachedSize))}catch(jZ){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(bx,e).objectStore(bx)}},{key:"set",value:function(e){var t=this;return new jI((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Fg(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=Fg(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Fg(s=Fg(c="".concat(l?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(Fg(u="".concat(l)).call(u,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Fg(d="".concat(t.cacheLog)).call(d,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(HZ){var p;if(!e)return n(HZ);t.cacheLog+=Fg(p="\n\n".concat(t.logId,": ")).call(p,e),t.logId++,n(HZ)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Fg(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new jI((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 jI((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 ix(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 jI((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 jI((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}(),Tx=new Ex,Ix=MC.start;wr({target:"String",proto:!0,forced:LC},{padStart:function(e){return Ix(this,e,arguments.length>1?arguments[1]:void 0)}});var Rx=qs("String").padStart,Ax=se,wx=Rx,Cx=String.prototype,xx=r((function(e){var t=e.padStart;return"string"==typeof e||e===Cx||Ax(Cx,e)&&t===Cx.padStart?wx:t})),Ox=function(){function e(){Fh(this,e),ql(this,"_all",{})}return Vh(e,[{key:"on",value:function(e,t){var r=this._all[e];r?r.push(t):this._all[e]=[t]}},{key:"once",value:function(e,t){var r=this;this.on(e,(function n(){t.apply(void 0,arguments),r.off(e,n)}))}},{key:"off",value:function(e,t){var r=this._all[e];null==r||BI(r).call(r,yI(r).call(r,t)>>>0,1)}},{key:"emit",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i=this._all[e];null==i||sI(i).call(i).forEach((function(e){return e.apply(void 0,r)}))}},{key:"safeEmit",value:function(e){try{for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return this.emit.apply(this,Fg(t=[e]).call(t,n))}catch(jZ){console.error(jZ)}}},{key:"destroy",value:function(){this._all={}}}]),e}(),Px=["UPLOAD_CONSOLE_LENGTH_CUT","UPLOAD_REPORT_LIMIT"];var Dx=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"config",{UPLOAD_CONSOLE_ON:!1,UPLOAD_CONSOLE_LENGTH_CUT:200,UPLOAD_REPORT_LIMIT:45e4,ENABLE_REPORT_IDB_BUFFER:!1}),n}return Vh(r,[{key:"setParameter",value:function(e,t){if(function(e){return Xy(Px).call(Px,e)}(e))try{var r=Number(t);if(Number.isNaN(r))return;this.config[e]=r}catch(i){var n;return void console.warn(Fg(n="Cannot convert core lib parameter ".concat(e,":")).call(n,t," into number"))}else this.config[e]=t;this.emit(e,this.config[e])}},{key:"getParameter",value:function(e){return this.config[e]}},{key:"getKeys",value:function(){return MS(this.config)}}]),r}(Ox),Nx=new Dx,Mx=io,Lx=jr,Ux=gc,Vx=Jt,Fx=function(e,t,r,n,i,o,a,s){for(var c,u,d=i,l=0,h=!!a&&Vx(a,s);l<n;)l in r&&(c=h?h(r[l],l,t):r[l],o>0&&Mx(c)?(u=Lx(c),d=Fx(e,t,c,u,d,o-1)-1):(Ux(d+1),e[d]=c),d++),l++;return d},Bx=Fx,jx=qe,Hx=jr,Gx=Pr,zx=xo;wr({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=jx(this),r=Hx(t),n=zx(t,0);return n.length=Bx(n,t,t,r,0,void 0===e?1:Gx(e)),n}});var Kx=qs("Array").flat,Wx=se,Xx=Kx,Yx=Array.prototype,qx=r((function(e){var t=e.flat;return e===Yx||Wx(Yx,e)&&t===Yx.flat?Xx:t})),Jx={};!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=sI(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==Wl(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 Fg([]).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)}(Jx);var Qx={},Zx={},$x={},eO=Jx,tO=0,rO=1;function nO(e){for(var t=e.length;--t>=0;)e[t]=0}var iO=0,oO=29,aO=256,sO=aO+1+oO,cO=30,uO=19,dO=2*sO+1,lO=15,hO=16,pO=7,vO=256,_O=16,fO=17,mO=18,gO=[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],yO=[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],SO=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],bO=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],kO=new Array(2*(sO+2));nO(kO);var EO=new Array(2*cO);nO(EO);var TO=new Array(512);nO(TO);var IO=new Array(256);nO(IO);var RO=new Array(oO);nO(RO);var AO,wO,CO,xO=new Array(cO);function OO(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 PO(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function DO(e){return e<256?TO[e]:TO[256+(e>>>7)]}function NO(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function MO(e,t,r){e.bi_valid>hO-r?(e.bi_buf|=t<<e.bi_valid&65535,NO(e,e.bi_buf),e.bi_buf=t>>hO-e.bi_valid,e.bi_valid+=r-hO):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function LO(e,t,r){MO(e,r[2*t],r[2*t+1])}function UO(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function VO(e,t,r){var n,i,o=new Array(lO+1),a=0;for(n=1;n<=lO;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]=UO(o[s]++,s))}}function FO(e){var t;for(t=0;t<sO;t++)e.dyn_ltree[2*t]=0;for(t=0;t<cO;t++)e.dyn_dtree[2*t]=0;for(t=0;t<uO;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*vO]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function BO(e){e.bi_valid>8?NO(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 jO(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 HO(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&jO(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!jO(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function GO(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?LO(e,i,t):(LO(e,(o=IO[i])+aO+1,t),0!==(a=gO[o])&&MO(e,i-=RO[o],a),LO(e,o=DO(--n),r),0!==(a=yO[o])&&MO(e,n-=xO[o],a))}while(s<e.last_lit);LO(e,vO,t)}function zO(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=dO,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--)HO(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],HO(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++,HO(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,_=0;for(o=0;o<=lO;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<dO;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>v&&(o=v,_++),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!==_){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]--,_-=2}while(_>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),VO(o,u,e.bl_count)}function KO(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[2*_O]++):s<=10?e.bl_tree[2*fO]++:e.bl_tree[2*mO]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function WO(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{LO(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(LO(e,i,e.bl_tree),s--),LO(e,_O,e.bl_tree),MO(e,s-3,2)):s<=10?(LO(e,fO,e.bl_tree),MO(e,s-3,3)):(LO(e,mO,e.bl_tree),MO(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}nO(xO);var XO=!1;function YO(e,t,r,n){MO(e,(iO<<1)+(n?1:0),3),function(e,t,r,n){BO(e),n&&(NO(e,r),NO(e,~r)),eO.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}$x._tr_init=function(e){XO||(!function(){var e,t,r,n,i,o=new Array(lO+1);for(r=0,n=0;n<oO-1;n++)for(RO[n]=r,e=0;e<1<<gO[n];e++)IO[r++]=n;for(IO[r-1]=n,i=0,n=0;n<16;n++)for(xO[n]=i,e=0;e<1<<yO[n];e++)TO[i++]=n;for(i>>=7;n<cO;n++)for(xO[n]=i<<7,e=0;e<1<<yO[n]-7;e++)TO[256+i++]=n;for(t=0;t<=lO;t++)o[t]=0;for(e=0;e<=143;)kO[2*e+1]=8,e++,o[8]++;for(;e<=255;)kO[2*e+1]=9,e++,o[9]++;for(;e<=279;)kO[2*e+1]=7,e++,o[7]++;for(;e<=287;)kO[2*e+1]=8,e++,o[8]++;for(VO(kO,sO+1,o),e=0;e<cO;e++)EO[2*e+1]=5,EO[2*e]=UO(e,5);AO=new OO(kO,gO,aO+1,sO,lO),wO=new OO(EO,yO,0,cO,lO),CO=new OO(new Array(0),SO,0,uO,pO)}(),XO=!0),e.l_desc=new PO(e.dyn_ltree,AO),e.d_desc=new PO(e.dyn_dtree,wO),e.bl_desc=new PO(e.bl_tree,CO),e.bi_buf=0,e.bi_valid=0,FO(e)},$x._tr_stored_block=YO,$x._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 tO;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return rO;for(t=32;t<aO;t++)if(0!==e.dyn_ltree[2*t])return rO;return tO}(e)),zO(e,e.l_desc),zO(e,e.d_desc),a=function(e){var t;for(KO(e,e.dyn_ltree,e.l_desc.max_code),KO(e,e.dyn_dtree,e.d_desc.max_code),zO(e,e.bl_desc),t=uO-1;t>=3&&0===e.bl_tree[2*bO[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?YO(e,t,r,n):4===e.strategy||o===i?(MO(e,2+(n?1:0),3),GO(e,kO,EO)):(MO(e,4+(n?1:0),3),function(e,t,r,n){var i;for(MO(e,t-257,5),MO(e,r-1,5),MO(e,n-4,4),i=0;i<n;i++)MO(e,e.bl_tree[2*bO[i]+1],3);WO(e,e.dyn_ltree,t-1),WO(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),GO(e,e.dyn_ltree,e.dyn_dtree)),FO(e),n&&BO(e)},$x._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*(IO[r]+aO+1)]++,e.dyn_dtree[2*DO(t)]++),e.last_lit===e.lit_bufsize-1},$x._tr_align=function(e){MO(e,2,3),LO(e,vO,kO),function(e){16===e.bi_valid?(NO(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 qO=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 JO=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 QO,ZO=function(e,t,r,n){var i=JO,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},$O={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"},eP=Jx,tP=$x,rP=qO,nP=ZO,iP=$O,oP=0,aP=4,sP=0,cP=-2,uP=-1,dP=4,lP=2,hP=8,pP=9,vP=286,_P=30,fP=19,mP=2*vP+1,gP=15,yP=3,SP=258,bP=SP+yP+1,kP=42,EP=103,TP=113,IP=666,RP=1,AP=2,wP=3,CP=4;function xP(e,t){return e.msg=iP[t],t}function OP(e){return(e<<1)-(e>4?9:0)}function PP(e){for(var t=e.length;--t>=0;)e[t]=0}function DP(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(eP.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 NP(e,t){tP._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,DP(e.strm)}function MP(e,t){e.pending_buf[e.pending++]=t}function LP(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function UP(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-bP?e.strstart-(e.w_size-bP):0,u=e.window,d=e.w_mask,l=e.prev,h=e.strstart+SP,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=SP-(h-o),o=h-SP,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 VP(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-bP)){eP.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,eP.arraySet(s,a.input,a.next_in,d,c),1===a.state.wrap?a.adler=rP(a.adler,s,d,c):2===a.state.wrap&&(a.adler=nP(a.adler,s,d,c)),a.next_in+=d,a.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=yP)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+yP-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<yP)););}while(e.lookahead<bP&&0!==e.strm.avail_in)}function FP(e,t){for(var r,n;;){if(e.lookahead<bP){if(VP(e),e.lookahead<bP&&t===oP)return RP;if(0===e.lookahead)break}if(r=0,e.lookahead>=yP&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+yP-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-bP&&(e.match_length=UP(e,r)),e.match_length>=yP)if(n=tP._tr_tally(e,e.strstart-e.match_start,e.match_length-yP),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=yP){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+yP-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=tP._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(NP(e,!1),0===e.strm.avail_out))return RP}return e.insert=e.strstart<yP-1?e.strstart:yP-1,t===aP?(NP(e,!0),0===e.strm.avail_out?wP:CP):e.last_lit&&(NP(e,!1),0===e.strm.avail_out)?RP:AP}function BP(e,t){for(var r,n,i;;){if(e.lookahead<bP){if(VP(e),e.lookahead<bP&&t===oP)return RP;if(0===e.lookahead)break}if(r=0,e.lookahead>=yP&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+yP-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=yP-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-bP&&(e.match_length=UP(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===yP&&e.strstart-e.match_start>4096)&&(e.match_length=yP-1)),e.prev_length>=yP&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-yP,n=tP._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-yP),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+yP-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=yP-1,e.strstart++,n&&(NP(e,!1),0===e.strm.avail_out))return RP}else if(e.match_available){if((n=tP._tr_tally(e,0,e.window[e.strstart-1]))&&NP(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return RP}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=tP._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<yP-1?e.strstart:yP-1,t===aP?(NP(e,!0),0===e.strm.avail_out?wP:CP):e.last_lit&&(NP(e,!1),0===e.strm.avail_out)?RP:AP}function jP(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 HP(){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=hP,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 eP.Buf16(2*mP),this.dyn_dtree=new eP.Buf16(2*(2*_P+1)),this.bl_tree=new eP.Buf16(2*(2*fP+1)),PP(this.dyn_ltree),PP(this.dyn_dtree),PP(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new eP.Buf16(gP+1),this.heap=new eP.Buf16(2*vP+1),PP(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new eP.Buf16(2*vP+1),PP(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 GP(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=lP,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?kP:TP,e.adler=2===t.wrap?0:1,t.last_flush=oP,tP._tr_init(t),sP):xP(e,cP)}function zP(e){var t,r=GP(e);return r===sP&&((t=e.state).window_size=2*t.w_size,PP(t.head),t.max_lazy_match=QO[t.level].max_lazy,t.good_match=QO[t.level].good_length,t.nice_match=QO[t.level].nice_length,t.max_chain_length=QO[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=yP-1,t.match_available=0,t.ins_h=0),r}function KP(e,t,r,n,i,o){if(!e)return cP;var a=1;if(t===uP&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>pP||r!==hP||n<8||n>15||t<0||t>9||o<0||o>dP)return xP(e,cP);8===n&&(n=9);var s=new HP;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+yP-1)/yP),s.window=new eP.Buf8(2*s.w_size),s.head=new eP.Buf16(s.hash_size),s.prev=new eP.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new eP.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,zP(e)}QO=[new jP(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(VP(e),0===e.lookahead&&t===oP)return RP;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,NP(e,!1),0===e.strm.avail_out))return RP;if(e.strstart-e.block_start>=e.w_size-bP&&(NP(e,!1),0===e.strm.avail_out))return RP}return e.insert=0,t===aP?(NP(e,!0),0===e.strm.avail_out?wP:CP):(e.strstart>e.block_start&&(NP(e,!1),e.strm.avail_out),RP)})),new jP(4,4,8,4,FP),new jP(4,5,16,8,FP),new jP(4,6,32,32,FP),new jP(4,4,16,16,BP),new jP(8,16,32,32,BP),new jP(8,16,128,128,BP),new jP(8,32,128,256,BP),new jP(32,128,258,1024,BP),new jP(32,258,258,4096,BP)],Zx.deflateInit=function(e,t){return KP(e,t,hP,15,8,0)},Zx.deflateInit2=KP,Zx.deflateReset=zP,Zx.deflateResetKeep=GP,Zx.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?cP:(e.state.gzhead=t,sP):cP},Zx.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?xP(e,cP):cP;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===IP&&t!==aP)return xP(e,0===e.avail_out?-5:cP);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===kP)if(2===n.wrap)e.adler=0,MP(n,31),MP(n,139),MP(n,8),n.gzhead?(MP(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)),MP(n,255&n.gzhead.time),MP(n,n.gzhead.time>>8&255),MP(n,n.gzhead.time>>16&255),MP(n,n.gzhead.time>>24&255),MP(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),MP(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(MP(n,255&n.gzhead.extra.length),MP(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=nP(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(MP(n,0),MP(n,0),MP(n,0),MP(n,0),MP(n,0),MP(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),MP(n,3),n.status=TP);else{var a=hP+(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=TP,LP(n,a),0!==n.strstart&&(LP(n,e.adler>>>16),LP(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=nP(e.adler,n.pending_buf,n.pending-i,i)),DP(e),i=n.pending,n.pending!==n.pending_buf_size));)MP(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=nP(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=nP(e.adler,n.pending_buf,n.pending-i,i)),DP(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,MP(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=nP(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=nP(e.adler,n.pending_buf,n.pending-i,i)),DP(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,MP(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=nP(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=EP)}else n.status=EP;if(n.status===EP&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&DP(e),n.pending+2<=n.pending_buf_size&&(MP(n,255&e.adler),MP(n,e.adler>>8&255),e.adler=0,n.status=TP)):n.status=TP),0!==n.pending){if(DP(e),0===e.avail_out)return n.last_flush=-1,sP}else if(0===e.avail_in&&OP(t)<=OP(r)&&t!==aP)return xP(e,-5);if(n.status===IP&&0!==e.avail_in)return xP(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==oP&&n.status!==IP){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(VP(e),0===e.lookahead)){if(t===oP)return RP;break}if(e.match_length=0,r=tP._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(NP(e,!1),0===e.strm.avail_out))return RP}return e.insert=0,t===aP?(NP(e,!0),0===e.strm.avail_out?wP:CP):e.last_lit&&(NP(e,!1),0===e.strm.avail_out)?RP:AP}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=SP){if(VP(e),e.lookahead<=SP&&t===oP)return RP;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=yP&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+SP;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=SP-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=yP?(r=tP._tr_tally(e,1,e.match_length-yP),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=tP._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(NP(e,!1),0===e.strm.avail_out))return RP}return e.insert=0,t===aP?(NP(e,!0),0===e.strm.avail_out?wP:CP):e.last_lit&&(NP(e,!1),0===e.strm.avail_out)?RP:AP}(n,t):QO[n.level].func(n,t);if(s!==wP&&s!==CP||(n.status=IP),s===RP||s===wP)return 0===e.avail_out&&(n.last_flush=-1),sP;if(s===AP&&(1===t?tP._tr_align(n):5!==t&&(tP._tr_stored_block(n,0,0,!1),3===t&&(PP(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),DP(e),0===e.avail_out))return n.last_flush=-1,sP}return t!==aP?sP:n.wrap<=0?1:(2===n.wrap?(MP(n,255&e.adler),MP(n,e.adler>>8&255),MP(n,e.adler>>16&255),MP(n,e.adler>>24&255),MP(n,255&e.total_in),MP(n,e.total_in>>8&255),MP(n,e.total_in>>16&255),MP(n,e.total_in>>24&255)):(LP(n,e.adler>>>16),LP(n,65535&e.adler)),DP(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?sP:1)},Zx.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==kP&&69!==t&&73!==t&&91!==t&&t!==EP&&t!==TP&&t!==IP?xP(e,cP):(e.state=null,t===TP?xP(e,-3):sP):cP},Zx.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,d=t.length;if(!e||!e.state)return cP;if(2===(o=(r=e.state).wrap)||1===o&&r.status!==kP||r.lookahead)return cP;for(1===o&&(e.adler=rP(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(PP(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new eP.Buf8(r.w_size),eP.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,VP(r);r.lookahead>=yP;){n=r.strstart,i=r.lookahead-(yP-1);do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+yP-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=yP-1,VP(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=yP-1,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,sP},Zx.deflateInfo="pako deflate (from Nodeca project)";var WP={},XP=Jx,YP=!0,qP=!0;try{String.fromCharCode.apply(null,[0])}catch(GZ){YP=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(GZ){qP=!1}for(var JP=new XP.Buf8(256),QP=0;QP<256;QP++)JP[QP]=QP>=252?6:QP>=248?5:QP>=240?4:QP>=224?3:QP>=192?2:1;function ZP(e,t){if(t<65534&&(e.subarray&&qP||!e.subarray&&YP))return String.fromCharCode.apply(null,XP.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}JP[254]=JP[254]=1,WP.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 XP.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},WP.buf2binstring=function(e){return ZP(e,e.length)},WP.binstring2buf=function(e){for(var t=new XP.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},WP.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=JP[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 ZP(s,n)},WP.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+JP[e[r]]>t?r:t};var $P=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},eD=Zx,tD=Jx,rD=WP,nD=$O,iD=$P,oD=Object.prototype.toString,aD=0,sD=-1,cD=0,uD=8;function dD(e){if(!(this instanceof dD))return new dD(e);this.options=tD.assign({level:sD,method:uD,chunkSize:16384,windowBits:15,memLevel:8,strategy:cD,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 iD,this.strm.avail_out=0;var r=eD.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==aD)throw new Error(nD[r]);if(t.header&&eD.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?rD.string2buf(t.dictionary):"[object ArrayBuffer]"===oD.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=eD.deflateSetDictionary(this.strm,n))!==aD)throw new Error(nD[r]);this._dict_set=!0}}function lD(e,t){var r=new dD(t);if(r.push(e,!0),r.err)throw r.msg||nD[r.err];return r.result}dD.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=rD.string2buf(e):"[object ArrayBuffer]"===oD.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 tD.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=eD.deflate(i,n))&&r!==aD)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(rD.buf2binstring(tD.shrinkBuf(i.output,i.next_out))):this.onData(tD.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=eD.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===aD):2!==n||(this.onEnd(aD),i.avail_out=0,!0)},dD.prototype.onData=function(e){this.chunks.push(e)},dD.prototype.onEnd=function(e){e===aD&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=tD.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},Qx.Deflate=dD,Qx.deflate=lD,Qx.deflateRaw=function(e,t){return(t=t||{}).raw=!0,lD(e,t)},Qx.gzip=function(e,t){return(t=t||{}).gzip=!0,lD(e,t)};var hD={},pD=rr,vD=P,_D=Ze,fD=se,mD=function(){var e=pD(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},gD=RegExp.prototype,yD=se,SD=function(e){var t=e.flags;return void 0!==t||"flags"in gD||_D(e,"flags")||!fD(gD,e)?t:vD(mD,e)},bD=RegExp.prototype,kD=r((function(e){return e===bD||yD(bD,e)?SD(e):e.flags})),ED={},TD=Jx,ID=15,RD=[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],AD=[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],wD=[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],CD=[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],xD=Jx,OD=qO,PD=ZO,DD=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,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,_=r.lencode,f=r.distcode,m=(1<<r.lenbits)-1,g=(1<<r.distbits)-1;e:do{v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),y=_[p&m];t:for(;;){if(p>>>=S=y>>>24,v-=S,0===(S=y>>>16&255))R[o++]=65535&y;else{if(!(16&S)){if(0==(64&S)){y=_[(65535&y)+(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&y,(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),y=f[p&g];r:for(;;){if(p>>>=S=y>>>24,v-=S,!(16&(S=y>>>16&255))){if(0==(64&S)){y=f[(65535&y)+(p&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(k=65535&y,v<(S&=15)&&(p+=I[n++]<<v,(v+=8)<S&&(p+=I[n++]<<v,v+=8)),(k+=p&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(p>>>=S,v-=S,k>(S=o-a)){if((S=k-S)>d&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(E=0,T=h,0===l){if(E+=u-S,S<b){b-=S;do{R[o++]=h[E++]}while(--S);E=o-k,T=R}}else if(l<S){if(E+=u+l-S,(S-=l)<b){b-=S;do{R[o++]=h[E++]}while(--S);if(E=0,l<b){b-=S=l;do{R[o++]=h[E++]}while(--S);E=o-k,T=R}}}else if(E+=l-S,S<b){b-=S;do{R[o++]=h[E++]}while(--S);E=o-k,T=R}for(;b>2;)R[o++]=T[E++],R[o++]=T[E++],R[o++]=T[E++],b-=3;b&&(R[o++]=T[E++],b>1&&(R[o++]=T[E++]))}else{E=o-k;do{R[o++]=R[E++],R[o++]=R[E++],R[o++]=R[E++],b-=3}while(b>2);b&&(R[o++]=R[E++],b>1&&(R[o++]=R[E++]))}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},ND=function(e,t,r,n,i,o,a,s){var c,u,d,l,h,p,v,_,f,m=s.bits,g=0,y=0,S=0,b=0,k=0,E=0,T=0,I=0,R=0,A=0,w=null,C=0,x=new TD.Buf16(16),O=new TD.Buf16(16),P=null,D=0;for(g=0;g<=ID;g++)x[g]=0;for(y=0;y<n;y++)x[t[r+y]]++;for(k=m,b=ID;b>=1&&0===x[b];b--);if(k>b&&(k=b),0===b)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<b&&0===x[S];S++);for(k<S&&(k=S),I=1,g=1;g<=ID;g++)if(I<<=1,(I-=x[g])<0)return-1;if(I>0&&(0===e||1!==b))return-1;for(O[1]=0,g=1;g<ID;g++)O[g+1]=O[g]+x[g];for(y=0;y<n;y++)0!==t[r+y]&&(a[O[t[r+y]]++]=y);if(0===e?(w=P=a,p=19):1===e?(w=RD,C-=257,P=AD,D-=257,p=256):(w=wD,P=CD,p=-1),A=0,y=0,g=S,h=o,E=k,T=0,d=-1,l=(R=1<<k)-1,1===e&&R>852||2===e&&R>592)return 1;for(;;){v=g-T,a[y]<p?(_=0,f=a[y]):a[y]>p?(_=P[D+a[y]],f=w[C+a[y]]):(_=96,f=0),c=1<<g-T,S=u=1<<E;do{i[h+(A>>T)+(u-=c)]=v<<24|_<<16|f|0}while(0!==u);for(c=1<<g-1;A&c;)c>>=1;if(0!==c?(A&=c-1,A+=c):A=0,y++,0==--x[g]){if(g===b)break;g=t[r+a[y]]}if(g>k&&(A&l)!==d){for(0===T&&(T=k),h+=S,I=1<<(E=g-T);E+T<b&&!((I-=x[E+T])<=0);)E++,I<<=1;if(R+=1<<E,1===e&&R>852||2===e&&R>592)return 1;i[d=A&l]=k<<24|E<<16|h-o|0}}return 0!==A&&(i[h+A]=g-T<<24|64<<16|0),s.bits=k,0},MD=1,LD=2,UD=0,VD=-2,FD=1,BD=12,jD=30,HD=852,GD=592;function zD(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function KD(){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 xD.Buf16(320),this.work=new xD.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function WD(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=FD,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new xD.Buf32(HD),t.distcode=t.distdyn=new xD.Buf32(GD),t.sane=1,t.back=-1,UD):VD}function XD(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,WD(e)):VD}function YD(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)?VD:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,XD(e))):VD}function qD(e,t){var r,n;return e?(n=new KD,e.state=n,n.window=null,(r=YD(e,t))!==UD&&(e.state=null),r):VD}var JD,QD,ZD=!0;function $D(e){if(ZD){var t;for(JD=new xD.Buf32(512),QD=new xD.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(ND(MD,e.lens,0,288,JD,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ND(LD,e.lens,0,32,QD,0,e.work,{bits:5}),ZD=!1}e.lencode=JD,e.lenbits=9,e.distcode=QD,e.distbits=5}function eN(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 xD.Buf8(o.wsize)),n>=o.wsize?(xD.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),xD.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(xD.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}ED.inflateReset=XD,ED.inflateReset2=YD,ED.inflateResetKeep=WD,ED.inflateInit=function(e){return qD(e,15)},ED.inflateInit2=qD,ED.inflate=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R=0,A=new xD.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 VD;(r=e.state).mode===BD&&(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,E=UD;e:for(;;)switch(r.mode){case FD: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=PD(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=jD;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=jD;break}if(d-=4,k=8+(15&(u>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg="invalid window size",r.mode=jD;break}r.dmax=1<<k,e.adler=r.check=1,r.mode=512&u?10:BD,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&kD(r))){e.msg="unknown compression method",r.mode=jD;break}if(57344&kD(r)){e.msg="unknown header flags set",r.mode=jD;break}r.head&&(r.head.text=u>>8&1),512&kD(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=PD(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&kD(r)&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=PD(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&kD(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=PD(r.check,A,2,0)),u=0,d=0,r.mode=5;case 5:if(1024&kD(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&kD(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=PD(r.check,A,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&kD(r)&&((p=r.length)>s&&(p=s),p&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),xD.arraySet(r.head.extra,n,o,p,k)),512&kD(r)&&(r.check=PD(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&kD(r)){if(0===s)break e;p=0;do{k=n[o+p++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k))}while(k&&p<s);if(512&kD(r)&&(r.check=PD(r.check,n,p,o)),s-=p,o+=p,k)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&kD(r)){if(0===s)break e;p=0;do{k=n[o+p++],r.head&&k&&r.length<65536&&(r.head.comment+=String.fromCharCode(k))}while(k&&p<s);if(512&kD(r)&&(r.check=PD(r.check,n,p,o)),s-=p,o+=p,k)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&kD(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=jD;break}u=0,d=0}r.head&&(r.head.hcrc=kD(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=BD;break;case 10:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}e.adler=r.check=zD(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=BD;case BD: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($D(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=jD}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=jD;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;xD.arraySet(i,n,o,p,a),s-=p,o+=p,c-=p,a+=p,r.length-=p;break}r.mode=BD;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=jD;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},E=ND(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,E){e.msg="invalid code lengths set",r.mode=jD;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(g<16)u>>>=f,d-=f,r.lens[r.have++]=g;else{if(16===g){for(I=f+2;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u>>>=f,d-=f,0===r.have){e.msg="invalid bit length repeat",r.mode=jD;break}k=r.lens[r.have-1],p=3+(3&u),u>>>=2,d-=2}else if(17===g){for(I=f+3;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=f,k=0,p=3+(7&(u>>>=f)),u>>>=3,d-=3}else{for(I=f+7;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=f,k=0,p=11+(127&(u>>>=f)),u>>>=7,d-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=jD;break}for(;p--;)r.lens[r.have++]=k}}if(r.mode===jD)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=jD;break}if(r.lenbits=9,T={bits:r.lenbits},E=ND(MD,r.lens,0,r.nlen,r.lencode,0,r.work,T),r.lenbits=T.bits,E){e.msg="invalid literal/lengths set",r.mode=jD;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},E=ND(LD,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,T),r.distbits=T.bits,E){e.msg="invalid distances set",r.mode=jD;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,DD(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===BD&&(r.back=-1);break}for(r.back=0;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(m&&0==(240&m)){for(y=f,S=m,b=g;m=(R=r.lencode[b+((u&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=y,d-=y,r.back+=y}if(u>>>=f,d-=f,r.back+=f,r.length=g,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=BD;break}if(64&m){e.msg="invalid literal/length code",r.mode=jD;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(R=r.distcode[u&(1<<r.distbits)-1])>>>16&255,g=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(0==(240&m)){for(y=f,S=m,b=g;m=(R=r.distcode[b+((u&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=y,d-=y,r.back+=y}if(u>>>=f,d-=f,r.back+=f,64&m){e.msg="invalid distance code",r.mode=jD;break}r.offset=g,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=jD;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=jD;break}p>r.wnext?(p-=r.wnext,v=r.wsize-p):v=r.wnext-p,p>r.length&&(p=r.length),_=r.window}else _=i,v=a-r.offset,p=r.length;p>c&&(p=c),c-=p,r.length-=p;do{i[a++]=_[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=kD(r)?PD(r.check,i,h,a-h):OD(r.check,i,h,a-h)),h=c,(kD(r)?u:zD(u))!==r.check){e.msg="incorrect data check",r.mode=jD;break}u=0,d=0}r.mode=28;case 28:if(r.wrap&&kD(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=jD;break}u=0,d=0}r.mode=29;case 29:E=1;break e;case jD:E=-3;break e;case 31:return-4;default:return VD}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<jD&&(r.mode<27||4!==t))&&eN(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=kD(r)?PD(r.check,i,h,e.next_out-h):OD(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===BD?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&E===UD&&(E=-5),E},ED.inflateEnd=function(e){if(!e||!e.state)return VD;var t=e.state;return t.window&&(t.window=null),e.state=null,UD},ED.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?VD:(r.head=t,t.done=!1,UD):VD},ED.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?VD:11===r.mode&&OD(1,t,n,0)!==r.check?-3:eN(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,UD):VD},ED.inflateInfo="pako inflate (from Nodeca project)";var tN={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 rN=ED,nN=Jx,iN=WP,oN=tN,aN=$O,sN=$P,cN=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},uN=Object.prototype.toString;function dN(e){if(!(this instanceof dN))return new dN(e);this.options=nN.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 sN,this.strm.avail_out=0;var r=rN.inflateInit2(this.strm,t.windowBits);if(r!==oN.Z_OK)throw new Error(aN[r]);if(this.header=new cN,rN.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=iN.string2buf(t.dictionary):"[object ArrayBuffer]"===uN.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=rN.inflateSetDictionary(this.strm,t.dictionary))!==oN.Z_OK))throw new Error(aN[r])}function lN(e,t){var r=new dN(t);if(r.push(e,!0),r.err)throw r.msg||aN[r.err];return r.result}dN.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?oN.Z_FINISH:oN.Z_NO_FLUSH,"string"==typeof e?s.input=iN.binstring2buf(e):"[object ArrayBuffer]"===uN.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 nN.Buf8(c),s.next_out=0,s.avail_out=c),(r=rN.inflate(s,oN.Z_NO_FLUSH))===oN.Z_NEED_DICT&&u&&(r=rN.inflateSetDictionary(this.strm,u)),r===oN.Z_BUF_ERROR&&!0===d&&(r=oN.Z_OK,d=!1),r!==oN.Z_STREAM_END&&r!==oN.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==oN.Z_STREAM_END&&(0!==s.avail_in||n!==oN.Z_FINISH&&n!==oN.Z_SYNC_FLUSH)||("string"===this.options.to?(i=iN.utf8border(s.output,s.next_out),o=s.next_out-i,a=iN.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&nN.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(nN.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!==oN.Z_STREAM_END);return r===oN.Z_STREAM_END&&(n=oN.Z_FINISH),n===oN.Z_FINISH?(r=rN.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===oN.Z_OK):n!==oN.Z_SYNC_FLUSH||(this.onEnd(oN.Z_OK),s.avail_out=0,!0)},dN.prototype.onData=function(e){this.chunks.push(e)},dN.prototype.onEnd=function(e){e===oN.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=nN.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},hD.Inflate=dN,hD.inflate=lN,hD.inflateRaw=function(e,t){return(t=t||{}).raw=!0,lN(e,t)},hD.ungzip=lN;var hN={};(0,Jx.assign)(hN,Qx,hD,tN);var pN=r(hN),vN=1,_N=function(){function e(t){Fh(this,e),ql(this,"lockingPromise",jI.resolve()),ql(this,"locks",0),ql(this,"name",""),ql(this,"lockId",void 0),this.lockId=vN++,t&&(this.name=t)}return Vh(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t=this;this.locks+=1;var r=new jI((function(r){e=function(){t.locks-=1,r()}})),n=this.lockingPromise.then((function(){return e}));return this.lockingPromise=this.lockingPromise.then((function(){return r})),n}}]),e}(),fN="BytePlusRTC",mN=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},gN=function(){function e(t){Fh(this,e),ql(this,"storeName",void 0),ql(this,"pendingList",[]),this.storeName=t,!hx()&&mN()&&this._checkAndCreateStore(t)}var t,r,n,i,o,a,s;return Vh(e,[{key:"_checkAndCreateStore",value:(s=Ng(Pg().mark((function t(r,n){var i,o,a=this;return Pg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e._promiseLock.lock();case 2:if(i=t.sent,!mN.databases){t.next=6;break}return t.next=6,new jI((function(e){var t=function(){return mN.databases().finally(e)};o=setInterval(t,100),t()})).finally((function(){return clearInterval(o)}));case 6:return t.abrupt("return",new jI((function(t){e.db&&(e.db.close(),delete e.db);var o=n?mN().open(fN,n):mN().open(fN);o.onupgradeneeded=function(){o.result.createObjectStore(r)},o.onerror=function(){console.error("IndexedDBInterface error",o.error)},o.onsuccess=function(){var n=o.result;e.db=n;try{e.db.transaction(a.storeName,"readonly"),a.pendingList.forEach(function(){var e=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.txMode,n=t.pendResolve,i=t.pendReject,e.prev=1,e.next=4,a._getStore(r);case 4:o=e.sent,n(o),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),i();case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}()),t()}catch(s){t(a._checkAndCreateStore(r,n.version+1))}finally{i()}}})));case 7:case"end":return t.stop()}}),t)}))),function(e,t){return s.apply(this,arguments)})},{key:"_getStore",value:(a=Ng(Pg().mark((function t(r){var n,i=this;return Pg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e._promiseLock.lock();case 2:return n=t.sent,t.abrupt("return",new jI((function(t,o){if(!e.db)return i.pendingList.push({txMode:r,pendResolve:t,pendReject:o}),void n();try{t(e.db.transaction(i.storeName,r).objectStore(i.storeName))}catch(a){return void i.pendingList.push({txMode:r,pendResolve:t,pendReject:o})}finally{n()}})));case 4:case"end":return t.stop()}}),t)}))),function(e){return a.apply(this,arguments)})},{key:"put2String",value:(o=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{n=Gg(t)}catch(i){n=t}return e.next=3,this.put(n,r);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"get4String",value:(i=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:r=e.sent;try{n=JSON.parse(r)}catch(i){n=r}return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"put",value:(n=Ng(Pg().mark((function e(t,r){var n;return Pg().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 jI((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 n.apply(this,arguments)})},{key:"get",value:(r=Ng(Pg().mark((function e(t){var r;return Pg().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 jI((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 r.apply(this,arguments)})},{key:"del",value:(t=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readwrite");case 2:return r=e.sent,e.abrupt("return",new jI((function(e,n){var i=r.delete(t);i.onsuccess=function(){e()},i.onerror=function(e){n(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();function yN(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=cn(e);for(n=0;n<o.length;n++)r=o[n],gI(t).call(t,r)>=0||(i[r]=e[r]);return i}(e,t);if(Hs){var o=Hs(e);for(n=0;n<o.length;n++)r=o[n],gI(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}ql(gN,"db",void 0),ql(gN,"state","init"),ql(gN,"_promiseLock",new _N("iDB"));var SN=["message"];var bN,kN,EN,TN=new(function(){function e(){Fh(this,e),ql(this,"name","LongStringReportor"),ql(this,"inBuffer",[]),ql(this,"outBuffer",[])}return Vh(e,[{key:"push",value:function(e){var t;e.message&&this.inBuffer.push(Ql(Ql({},e),{},{message:{id:sI(t=px()).call(t,0,3),index:0,end:!0,msg:e.message}}))}},{key:"splice",value:function(e){for(var t=[],r=0;this.outBuffer.length;){var n=Gg(this.outBuffer[0]).length;if(!(n<e))break;e-=n,r+=n,t.push(this.outBuffer.shift())}for(;this.inBuffer[0]&&e>0;){var i=this.inBuffer[0],o=i.message,a=Ql(Ql({},yN(i,SN)),{},{message:Ql(Ql({},o),{},{msg:""})}),s=Gg(a).length,c=e-s,u=Ql({},a);if(c>o.msg.length)u.message.msg=o.msg,this.inBuffer.shift();else{if(!(c>=10))break;var d,l,h=sI(d=o.msg).call(d,0,c);u.message.msg=h,u.message.end=!1,this.inBuffer[0].message.msg=sI(l=o.msg).call(l,c),this.inBuffer[0].message.index++}var p=Gg(u.message),v=p.length;e-=v+s,r+=v+s,t.push(Ql(Ql({},u),{},{message:p}))}return{payload:t,payloadSize:r}}},{key:"unshift",value:function(e){this.outBuffer=Fg(e).call(e,this.outBuffer)}},{key:"get",value:function(){var e,t;return Fg(e=[]).call(e,tR(this.outBuffer),tR(qg(t=this.inBuffer).call(t,(function(e){return Ql(Ql({},e),{},{message:Gg(e.message)})}))))}},{key:"set",value:function(e){var t=this,r=[],n=[];e.forEach((function(e){!function(e){return void 0!==e.report_id}(e)?(e.message||(e.message=""),t.inBuffer.push(Ql(Ql({},e),{},{message:JSON.parse(e.message)}))):t.outBuffer.push(e)})),this.outBuffer=Fg(r).call(r,this.outBuffer),this.inBuffer=Fg(n).call(n,this.inBuffer)}},{key:"isEmpty",value:function(){return 0===this.inBuffer.length&&0===this.outBuffer.length}}]),e}()),IN={product_line:"rtc",report_version:"5",os:"web",user_agent:hx()?"":null===(bN=navigator)||void 0===bN?void 0:bN.userAgent,platform:"web",product:"webrtc",app_state:"active"},RN="LogReportor",AN="undefined"!=typeof window&&(Xy(kN=window.location.search).call(kN,"_rtc_debug_")||(null===(EN=window.localStorage)||void 0===EN?void 0:EN.getItem("_rtc_debug_"))),wN=function(){function e(t){Fh(this,e),ql(this,"_buffer",void 0),this._buffer=new gN(t)}var t,r;return Vh(e,[{key:"set",value:(r=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put2String(t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"get",value:(t=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[],e.prev=1,e.next=4,this._buffer.get4String(t);case 4:n=e.sent,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(1);case 9:return e.abrupt("return",null!==(r=n)&&void 0!==r?r:[]);case 10:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e){return t.apply(this,arguments)})}]),e}(),CN=function(){function e(){var t=this;Fh(this,e),ql(this,"reportCommon",IN),ql(this,"reportIds",new cT),ql(this,"dataBuffer",[]),ql(this,"reportorList",[]),ql(this,"dbBuffer",void 0),ql(this,"posting",!1),ql(this,"sucSendTimer",void 0),ql(this,"preSucTime",0),ql(this,"errSendTimer",void 0),ql(this,"errSendDelay",100),ql(this,"_logServerUrl",void 0),ql(this,"_retryCount",0),ql(this,"_reportLimit",5e5),ql(this,"_disableTimeout",!1),hx()||(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"})})),AN&&(window.__rtc_debug_reportor__=this)),Nx.on("UPLOAD_REPORT_LIMIT",(function(e){t.setReportLimit(e)})),Nx.on("ENABLE_REPORT_IDB_BUFFER",(function(e){e&&t.enableIndexedDBBuffer()})),setTimeout((function(){t.reportorList.push(aM),t.reportorList.push(TN)}))}var t;return Vh(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.reportCommon=TT(this.reportCommon,e)}},{key:"getCommonStats",value:function(){return this.reportCommon}},{key:"setReportLimit",value:function(e){this._reportLimit=Math.max(e,5e4),this._reportLimit=Math.min(e,5e5)}},{key:"getReportId",value:function(e){var t;e=null!==(t=e)&&void 0!==t?t:"__global__",this.reportIds.has(e)||this.reportIds.set(e,0);var r=this.reportIds.get(e);return void 0===r&&(HN("no reportId in reportId map with engine-session-id ".concat(e),0,{}),r=0),this.reportIds.set(e,r+1),r}},{key:"push",value:function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])this.send(e);else{var t,r=null!==(t=e.engine_session_id)&&void 0!==t?t:"__global__";this.reportIds.has(r)||this.reportIds.set(r,0),this.dataBuffer.push(e),!this.posting&&!this.errSendTimer&&Date.now()-this.preSucTime>2e3&&(clearTimeout(this.sucSendTimer),this.send())}}},{key:"enableIndexedDBBuffer",value:function(){var e=this;this.dbBuffer||(this.dbBuffer=new wN("ReportorDBBuffer"),this.dbBuffer.get(RN).then((function(t){t.forEach((function(t){e.push(t)}))})),this.reportorList.forEach((function(t){var r;null===(r=e.dbBuffer)||void 0===r||r.get(t.name).then((function(e){t.set(e)}))})))}},{key:"backup",value:function(){var e=this;try{var t;null===(t=this.dbBuffer)||void 0===t||t.set(tR(this.dataBuffer),RN),this.reportorList.forEach((function(t){var r;null===(r=e.dbBuffer)||void 0===r||r.set(tR(t.get()),t.name)}))}catch(r){HN("Error when save log into IDB",-1,r)}}},{key:"unshift",value:function(e){var t;this.dataBuffer=Fg(t=e[0]).call(t,this.dataBuffer),this.reportorList.forEach((function(t,r){var n;t.unshift(null!==(n=e[r+1])&&void 0!==n?n:[])}))}},{key:"_splice",value:function(){var e,t=this,r=function(e,t){for(var r=0,n=0;n<e.length;n++)if((r+=Gg(e[n]).length)>t)return n;return e.length}(this.dataBuffer,this._reportLimit);0===r&&this.dataBuffer.length>0&&(this._reportLimit=Gg(this.dataBuffer[0]).length+10,r=1,HN("update report limit to ".concat(this._reportLimit),0,null));var n=BI(e=this.dataBuffer).call(e,0,r),i=Gg(n).length,o=[n],a=this._reportLimit-i;return this.reportorList.forEach((function(e){var r=BI(e).call(e,a),n=r.payload,i=r.payloadSize;n.forEach((function(e){var r,n,i;void 0===e.report_id&&(e.report_id=t.getReportId(e.engine_session_id),!hx()&&window.__onRTCReport&&(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,null!==(i=e.engine_session_id)&&void 0!==i?i:"global",e,t.getCommonStats())))})),o.push(n),a-=i})),o}},{key:"send",value:(t=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.backup(),i=oS(n=this.reportorList).call(n,(function(e,t){return e&&t.isEmpty()}),!0),(t||this.dataBuffer.length||!i)&&this._logServerUrl){e.next=4;break}return e.abrupt("return");case 4:if(t||(this.posting=!0),o=[],t||(o=this._splice()),a=AN,s={data:t||qx(o).call(o),header:Ql(Ql({},this.reportCommon),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},c={method:"POST",body:a?Gg(s):pN.gzip(Gg(s))},!this._disableTimeout)try{u=new AbortController,c.signal=u.signal,setTimeout((function(){u.abort()}),1e4)}catch(p){console.warn("AbortController is not supported"),this._disableTimeout=!0}return a||(c.headers={"Content-Encoding":"gzip","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}),h=null,e.prev=13,e.next=16,fetch(this._logServerUrl,c);case 16:if(200!==(d=e.sent).status&&304!==d.status){e.next=23;break}return e.t0=JSON,e.next=21,d.text();case 21:e.t1=e.sent,h=e.t0.parse.call(e.t0,e.t1);case 23:e.next=28;break;case 25:e.prev=25,e.t2=e.catch(13),l=e.t2;case 28:t||(this.posting=!1),h&&0===h.StatusCode?t||r||this.sucSend():(setTimeout((function(){var e,t,r,n;HN(Fg(e="reportor post error, resJSON:".concat(null===(t=h)||void 0===t?void 0:t.toString()," err:")).call(e,l),null!==(r=null===(n=d)||void 0===n?void 0:n.status)&&void 0!==r?r:-1,l)}),0),t?this.send(t):(this.unshift(o),r?this.send():this.errSend()));case 30:case"end":return e.stop()}}),e,this,[[13,25]])}))),function(e,r){return t.apply(this,arguments)})},{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++}}]),e}();var xN,ON=new CN,PN=function(){function e(t){Fh(this,e),ql(this,"modifyIds",{}),this.id=t}return Vh(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=Ql(Ql(Ql({event_key:e,rtc_timestamp:Date.now()},this.modifyIds),t),{},{common_extra_info:Gg(i),report_id:ON.getReportId(this.modifyIds.engine_session_id)});!hx()&&window.__onRTCReport&&(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.modifyIds.engine_session_id,o,ON.getCommonStats()));ON.push(o)}},{key:"reportLog",value:function(e){var t=Ql(Ql({event_key:"rtc_invoke_status",sdk_api_name:"console_log",rtc_timestamp:Date.now()},this.modifyIds),{},{message:e});aM.push(t)}},{key:"reportLongString",value:function(e,t){var r=Ql(Ql({event_key:"rtc_invoke_status",sdk_api_name:"sdk_long_string_".concat(e),rtc_timestamp:Date.now()},this.modifyIds),{},{message:t});TN.push(r)}},{key:"set",value:function(e){this.modifyIds=TT(this.modifyIds,e)}},{key:"destroy",value:function(){}}]),e}();setTimeout((function(){xN=new pM("MessageReportor",1)}),0);var DN=function(){function e(t){Fh(this,e),ql(this,"_preTime",Date.now()),ql(this,"_one2oneNum",0),ql(this,"_one2manyNum",0),ql(this,"_one2oneMsgCache",new cT),ql(this,"_one2manyMsgCache",new cT),ql(this,"roomId",""),ql(this,"userId",""),ql(this,"rtsSessionId",""),this.id=t}return Vh(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,Ql({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,Ql(Ql({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,Ql({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,Ql(Ql({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(xN.info("reportP2PMsg",r.type,Gg(r)),null===(t=KN(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(xN.info("reportOne2ManyMsg",r.type,Gg(r)),null===(t=KN(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)||"",xN.info("reportMsgRecv",t.type,Gg(t)),null===(n=KN(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}();ql(DN,"config",void 0);var NN=new cT,MN={_cache:NN,setConfig:function(e){xN.info("setConfig","get config: ".concat(Gg(e))),DN.config=e},setRtsSessionId:function(e,t){var r=NN.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=NN.get(e)||new DN(e);return NN.set(e,t),t},destroyRTSMsgReportor:function(e){var t=NN.get(e);t&&(t.destroy(),NN.delete(e))},setRoomId:function(e,t){var r=NN.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=NN.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=NN.get(e);if(null!=r&&r.needReport("one2one")){var n,i=Fg(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&&vx(t.report_msg_id)&&(null===(n=NN.get(e))||void 0===n||n.updateP2PMsg(Fg(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&&vx(t.report_msg_id)){var n,i,o=NN.get(e);null==o||o.updateP2PMsg(Fg(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(Fg(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n,i=NN.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:Fg(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&&vx(t.report_msg_id)){var n,i=NN.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Fg(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&&vx(t.report_msg_id)){var n,i,o=NN.get(e);if(o)null==o||o.updateOne2ManyMsg(Fg(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(Fg(i="".concat(t.clientId)).call(i,t.report_msg_id))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&vx(t.report_msg_id)){var n,i=NN.get(e);if(i)i.updateOne2ManyMsg(Fg(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&&vx(t.report_msg_id)){var n,i=NN.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Fg(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})}}},LN=function(){function e(t){Fh(this,e),ql(this,"_timer",void 0),ql(this,"userMessage",{}),ql(this,"roomMessage",{}),this.id=t,this._setTimer()}return Vh(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(MS(this.userMessage).length||MS(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e,t,r,n=this;null===(e=KN(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:qg(t=MS(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:qg(r=MS(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[Fg(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Fg(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[Fg(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Fg(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Fg(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Fg(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)&&(Xy(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[Fg(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}(),UN=function(e){ON.setCommonStats(e)},VN=function(e){ON.setUrl(e)},FN=new PN("global"),BN=function(e,t,r){FN.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},jN=function(e,t,r){FN.report("rtc_sdk_callback",{sdk_callback_name:e,error_code:t,message:r})},HN=function(e,t,r){FN.report("rtc_error",{message:e,error_code:t},r)},GN=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;FN.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)};var zN=new cT,KN=function(e){return zN.get(e)},WN=function(e,t){var r=new PN(e);return r.set(Ql(Ql({},t),{},{engine_session_id:px()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),zN.set(e,r),r};function XN(){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=KN(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=KN(u))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:Gg(ZN(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 qN(u,r,[e||{}]),e})).catch((function(e){throw qN(u,r,e.message,e.code),e})):(qN(u,r,[l||{}]),l)}}}}var YN,qN=function(e,t,r){var n,i=arguments.length>4?arguments[4]:void 0,o={sdk_callback_name:t,error_code:arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,message:Gg(Array.isArray(r)?ZN(r):r)};i&&(o.room_id=i),null===(n=KN(e))||void 0===n||n.report("rtc_sdk_callback",o)},JN=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=KN(e))||void 0===n||n.report("rtc_invoke_status",{sdk_api_name:t,message:r,error_code:i,stream_id:o,elapse:0},a)},QN=10;function ZN(e){return qg(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>QN){var c,u,d,l,h,p=new DataView(o),v=qg(c=KC({length:QN/2})).call(c,(function(e,t){return p.getUint8(t)})),_=qg(u=WC(d=qg(l=KC({length:QN/2})).call(l,(function(e,t){return a-1-t}))).call(d)).call(u,(function(e){return p.getUint8(e)}));s=Fg(h=[]).call(h,tR(v),["..."],tR(_))}else s=KC(new Uint8Array(o));return Fg(n=Fg(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return qg(t).call(t,e);if(Xy(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var f={};for(var m in t)f[m]=e(t[m]);return f}return t}))}var $N="undefined"!=typeof window&&Xy(YN=window.location.search).call(YN,"_rtc_upload_console_"),eM=function(){function e(){var t=this;Fh(this,e),ql(this,"name","ConsoleReportor"),ql(this,"_uuid","".concat(Math.floor(899*Math.random())+100)),ql(this,"_consoleReportId",0),ql(this,"_engineReportIdMap",new cT),ql(this,"_enabled","NULL"),ql(this,"_consoleCutLength",Nx.getParameter("UPLOAD_CONSOLE_LENGTH_CUT")),ql(this,"buffer",[]),$N&&setTimeout((function(){t.switchOn()}),0),Nx.on("UPLOAD_CONSOLE_ON",(function(e){e?t.switchOn():t.turnOff()})),Nx.on("UPLOAD_CONSOLE_LENGTH_CUT",(function(e){t._consoleCutLength=e}))}return Vh(e,[{key:"enabled",get:function(){return"OFF"!==this._enabled}},{key:"switchOn",value:function(){"NULL"===this._enabled&&(console.log("[LoggerReportor.constructor] console upload switch ON"),this._enabled="ON")}},{key:"turnOff",value:function(){"NULL"===this._enabled&&(console.log("[LoggerReportor.constructor] console upload switch OFF"),this._enabled="OFF",this.buffer=[])}},{key:"getEngineConsoleId",value:function(e){var t,r=null!==(t=this._engineReportIdMap.get(e))&&void 0!==t?t:0;return this._engineReportIdMap.set(e,r+1),r}},{key:"report",value:function(e,t,r,n,i,o,a,s,c){var u,d,l,h,p,v,_,f,m,g,y,S=this;if("OFF"!==this._enabled){var b,k=KN(t),E=this._consoleReportId++,T=this.getEngineConsoleId(t),I=tM(c,this._consoleCutLength),R=tR(c),A="".concat(s).replace(/%o|%s/gi,(function(){return tM([R.shift()],S._consoleCutLength)})),w=Fg(u=Fg(d=Fg(l=Fg(h=Fg(p=Fg(v=Fg(_=Fg(f=Fg(m=Fg(g=Fg(y="[".concat(this._uuid,"-")).call(y,E,"][")).call(g,t,"-")).call(m,T,"]-")).call(f,r,"-")).call(_,e,"[")).call(v,n,"]")).call(p,i,"[")).call(h,o,".")).call(l,a,"] ")).call(d,A," ")).call(u,I);k?k.reportLog(w):(b=w,FN.reportLog(b))}}},{key:"push",value:function(e){"OFF"!==this._enabled&&this.buffer.push(e)}},{key:"splice",value:function(e){var t;if("ON"!==this._enabled)return{payload:[],payloadSize:0};var r=function(e,t){for(var r=0,n=0;n<e.length;n++){var i=Gg(e[n]).length;if((r+=i)>t)return{index:n,size:r-i}}return{index:e.length,size:r}}(this.buffer,e),n=r.index,i=r.size;return{payload:BI(t=this.buffer).call(t,0,n),payloadSize:i}}},{key:"unshift",value:function(e){this.buffer=Fg(e).call(e,this.buffer)}},{key:"get",value:function(){return this.buffer}},{key:"set",value:function(e){this.buffer=Fg(e).call(e,this.buffer)}},{key:"isEmpty",value:function(){return"OFF"===this._enabled||0===this.buffer.length}}]),e}();function tM(e,t){return qg(e).call(e,(function(e){var r="";try{if("string"==typeof e)return e;if(void 0===e)return"undefined";if(null===e)return"null";if(e instanceof MediaStreamTrack)return fx(e);if(e instanceof MediaStream)return mx(e);if(e instanceof RTCRtpSender)return gx(e);if(e instanceof RTCRtpReceiver)return yx(e);if(e instanceof RTCRtpTransceiver)return Sx(e);r=Gg(e)}catch(n){r=e.toString()}return r&&r.length>=t&&(r=sI(r).call(r,0,t)),r})).join(", ")}var rM,nM,iM,oM,aM=new eM,sM="[VERTC]",cM="#0050b3",uM=(ql(rM={},"DEBUG","rgba(0, 0, 0, 0)"),ql(rM," INFO","rgba(93, 173, 226, 0)"),ql(rM," WARN","rgba(255, 119, 0, 0.3)"),ql(rM,"ERROR","rgba(255, 0, 0, 0.3)"),ql(rM," SUCC","rgba(0, 119, 0, 0.3)"),rM),dM="undefined"!=typeof window&&(Xy(nM=window.location.search).call(nM,"_rtc_debug_")||(null===(iM=window.localStorage)||void 0===iM?void 0:iM.getItem("_rtc_debug_"))),lM=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"global";Fh(this,e),ql(this,"indent",void 0),ql(this,"module",void 0),ql(this,"_engineId",void 0),this.module=t,this.indent=r,this._engineId=n}return Vh(e,[{key:"_print",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,g=Fg(v=[]).call(v,l),y="".concat(p).replace(/%o/gi,(function(){var e=g.shift();return Gg(e)}));Tx.set(Fg(_=Fg(f=Fg(m="".concat(sM,"[").concat(this.module,".")).call(m,t,"] ")).call(f,y," ")).call(_,qg(g).call(g,(function(e){return Gg(e)})).join(", ")))}catch(jZ){}for(var S="",b=0;b<this.indent;b++)S+=" ";var k=hM();aM.report(sM,this._engineId,k,e,S,this.module,t,p,l),dM&&(r=console).log.apply(r,Fg(n=[Fg(i=Fg(o=Fg(a=Fg(s=Fg(c=Fg(u="%c".concat(k,"-")).call(u,sM,"%c[")).call(c,e,"]%c")).call(s,S,"[")).call(a,this.module,".")).call(o,t,"] ")).call(i,p),"color:".concat(cM,";"),"background-color:".concat(uM[e],";"),"color:".concat(cM,";")]).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._print.apply(this,Fg(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._print.apply(this,Fg(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._print.apply(this,Fg(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._print.apply(this,Fg(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._print.apply(this,Fg(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._print.apply(this,Fg(t=[" SUCC",e]).call(t,n))}}]),e}(),hM=function(){var e,t,r=new Date;return Fg(e="".concat(r.toTimeString().split(" ")[0],":")).call(e,xx(t=r.getMilliseconds().toString()).call(t,3,"0"))},pM=lM,vM=function(e){var t,r=KN(e.engineId),n={keys:ix(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId,deviceId:e.deviceId},i=qg(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:Gg(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=qg(i).call(i,function(){var e=Ng(Pg().mark((function e(t,r){var i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:Gg(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 jI((function(e){(function(e){return new jI((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:Gg(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})}))}))},_M=new Uint8Array(16);function fM(){if(!oM&&!(oM="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return oM(_M)}for(var mM=[],gM=0;gM<256;++gM){var yM;mM.push(sI(yM=(gM+256).toString(16)).call(yM,1))}var SM={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function bM(e,t,r){if(SM.randomUUID&&!t&&!e)return SM.randomUUID();var n=(e=e||{}).random||(e.rng||fM)();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;return(mM[e[t+0]]+mM[e[t+1]]+mM[e[t+2]]+mM[e[t+3]]+"-"+mM[e[t+4]]+mM[e[t+5]]+"-"+mM[e[t+6]]+mM[e[t+7]]+"-"+mM[e[t+8]]+mM[e[t+9]]+"-"+mM[e[t+10]]+mM[e[t+11]]+mM[e[t+12]]+mM[e[t+13]]+mM[e[t+14]]+mM[e[t+15]]).toLowerCase()}(n)}var kM=new TextDecoder,EM=new TextEncoder,TM=function(){return bM()},IM=function(){return Date.now()},RM=!hx()&&"function"==typeof HTMLVideoElement.prototype.requestVideoFrameCallback;function AM(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++){t+=a[o].length}for(var s=new e(t),c=0,u=0,d=n;u<d.length;u++){var l=d[u];s.set(l,c),c+=l.length}return s}var wM=function(){function e(){Fh(this,e)}var t,r;return Vh(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(Ty(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=NS(t);n<i.length;n++){var o=gy(i[n],2),a=o[0],s=o[1];null!==s&&"object"===Wl(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return kM.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 EM.encode(e).buffer}},{key:"ab2b64str",value:(r=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new jI((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=Ng(Pg().mark((function e(t,r){return Pg().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()})).catch((function(e){var n;throw r&&r.report("rtc_error",{error_code:2001,message:Fg(n="".concat(e.message," -> ")).call(n,t)}),e})));case 1:case"end":return e.stop()}}),e)}))),function(e,r){return t.apply(this,arguments)})}]),e}();function CM(){for(var e,t,r=Number(HC(e=sI(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=HC(r).call(r,28,"1").split(""),i=[];n.length;)i.push(BI(n).call(n,0,7));return qg(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return zC(r+e.join(""),2)}))}var xM=function(){return Math.floor(65535*Math.random())};function OM(e){return"string"==typeof e&&yI(e).call(e,"__web__rtc__rtt__")>-1}var PM,DM,NM,MM,LM,UM,VM,FM,BM=function(){var e=Ng(Pg().mark((function e(){var t,r,n,i=arguments;return Pg().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)}}(),jM=function(e){return new jI((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 HM(e){return Number(Math.max(-127,10*JC(Math.pow(e/255,2))).toFixed(2))}function GM(e){return(e&ch.AUDIO)===ch.AUDIO}function zM(e){return(e&ch.VIDEO)===ch.VIDEO}function KM(e){var t={};return MS(e).forEach((function(r){"object"===Wl(e[r])?t[r]=KM(e[r]):_C(r).call(r,"_")||(t[r]=e[r])})),t}function WM(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 XM(e){return void 0===e}function YM(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Fg(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 qM(e){console.warn("[RTC WebSDK]: ".concat(e))}function JM(e){return"number"==typeof e?e:"number"==typeof(null==e?void 0:e.exact)?e.exact:"number"==typeof(null==e?void 0:e.ideal)?e.ideal:"number"==typeof(null==e?void 0:e.max)?e.max:"number"==typeof(null==e?void 0:e.min)?e.min:1}var QM=function(){return"undefined"==typeof window},ZM=QM()?"":window.navigator.userAgent;function $M(){var e="none";return QM()||(null!==ZM.match("Firefox")?e="mozilla":null!==ZM.match("Chrome")?(e="chrome-stable",null!==ZM.match("Electron")&&(e="electron")):(null!==ZM.match("Safari")||null!==ZM.match("AppleWebKit"))&&(e="safari")),e}var eL,tL="mozilla"===$M(),rL="safari"===$M(),nL="chrome-stable"===$M(),iL=!QM()&&/CriOS/i.test(ZM),oL=!QM()&&/Edg\//i.test(ZM),aL=!QM()&&/EdgA/i.test(ZM),sL=!QM()&&/EdgiOS/i.test(ZM),cL=oL||aL||sL,uL=!QM()&&/DingTalk/i.test(navigator.userAgent),dL=!QM()&&(!!/(iPad)/i.exec(ZM)||/Macintosh/i.test(ZM)&&"ontouchend"in document),lL=!QM()&&/Macintosh/i.test(ZM),hL=!QM()&&/MicroMessenger/i.test(ZM),pL=!QM()&&Xy(PM=ZM.toLowerCase()).call(PM,"mobile"),vL=!QM()&&!!/(iPhone|iPad|iPod)/i.exec(ZM),_L=!QM()&&/Android/i.test(ZM),fL=!QM()&&/Windows/i.test(ZM),mL=0,gL="0",yL=!QM()&&(null===(DM=ZM.match(/version\/(\d+)/i))||void 0===DM?void 0:DM[1]);rL&&yL&&(mL=Number(yL),gL=null===(eL=navigator.userAgent.match(/version\/(\d+\.\d+)/i))||void 0===eL?void 0:eL[1]);var SL=!QM()&&(null===(NM=ZM.match(/Firefox\/(\d+)/i))||void 0===NM?void 0:NM[1]);tL&&SL&&(mL=Number(SL));var bL=mL,kL=mL,EL=gL,TL=null!==(MM=!QM()&&(null===(LM=ZM.match(/ ([\d_]+) like Mac OS X/i))||void 0===LM||null===(UM=LM[1])||void 0===UM?void 0:qg(VM=UM.split("_")).call(VM,(function(e){return _b(e)}))))&&void 0!==MM?MM:[],IL=0,RL=!QM()&&(null===(FM=ZM.match(/Chrome\/(\d+)/i))||void 0===FM?void 0:FM[1]);RL&&(IL=Number(RL));var AL=IL,wL="BytePlus",CL="RTC_DEVICE_ID",xL="RTC_ACCESS_NODE",OL="RTC_ACCESS_URLS",PL="ENGINE_WEB_CONFIG",DL="SERVER_CONFIG",NL=function(){function e(){Fh(this,e)}return Vh(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={ttl:arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,saveTime:Date.now(),message:t};try{return localStorage.setItem(e,Gg(r)),!0}catch(n){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}(),ML=function(e){UA(r,e);var t=ew(r);function r(){return Fh(this,r),t.apply(this,arguments)}return Vh(r,[{key:"getDeviceId",value:function(){if(QM())return"";var e=this.get(CL);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 UN({device_id:e}),this.set(CL,e),e}},{key:"getAccessNode",value:function(e){var t;return this.get(Fg(t="".concat(xL,"_").concat(e,"-")).call(t,wL))}},{key:"setAccessNode",value:function(e,t,r){var n;return this.set(Fg(n="".concat(xL,"_").concat(e,"-")).call(n,wL),t,1e3*r)}},{key:"deleteAccessNode",value:function(e,t){var r,n=this.getAccessNode(e),i=this.getTtl(Fg(r="".concat(xL,"_").concat(e,"-")).call(r,wL));Array.isArray(n)&&n.length>0&&((n=Ty(n).call(n,(function(e){return e.mediaID!==t.mediaID&&e.msgKey!==t.msgKey}))).length>0?this.setAccessNode(e,n,i||0):this.clearAccessNode(e))}},{key:"clearAccessNode",value:function(e){var t;this.delete(Fg(t="".concat(xL,"_").concat(e,"-")).call(t,wL))}},{key:"getAccessUrls",value:function(){return this.get("".concat(OL,"-").concat(wL))}},{key:"setAccessUrls",value:function(e){var t=qg(e).call(e,(function(e){var t,r=e.host,n=e.path;return Fg(t="https://".concat(r)).call(t,n)}));return this.set("".concat(OL,"-").concat(wL),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(OL,"-").concat(wL))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Fg(r=Fg(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(PL);return(null==a||null===(i=aI(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=Fg(n=Fg(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(PL)||[];return(a=Ty(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(PL,sI(a).call(a,-5))}}},{key:"getServerConfig",value:function(e){var t,r="".concat(e),n=this.get(DL);return(null==n||null===(t=aI(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(DL)||[];return(n=Ty(n).call(n,(function(e){return e.key!==r}))).push({key:r,config:t}),this.set(DL,sI(n).call(n,-5))}}}]),r}(NL),LL=new ML,UL=new pM("JoinRoomConfig",0),VL=function(){function e(t){var r;Fh(this,e),ql(this,"_useTcpAfterJoinTimeout",e.DEFAULT_CONF.useTcpAfterJoinTimeout),ql(this,"_joinWithTcpOnly",e.DEFAULT_CONF.joinWithTcpOnly),ql(this,"_joinWithTcpOnlyDelay",e.DEFAULT_CONF.joinWithTcpOnlyDelay),ql(this,"_blackBrowserRegexList",[]),this._engineId=t,yI(r=location.search).call(r,"__rtc_tcp_only__")>-1&&(this._joinWithTcpOnly=!0,this._joinWithTcpOnlyDelay=0),this._report()}return Vh(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 aI(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 Gg({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(){UL.print("_report",this.toString()),JN(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}();ql(VL,"DEFAULT_CONF",{useTcpAfterJoinTimeout:!0,joinWithTcpOnly:!1,joinWithTcpOnlyDelay:5e3});var FL="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function BL(){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 jL="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",HL="rtc.rtcplus.com".split(","),GL={VERSION:"4.58.12",ICE_CONFIG_REQUEST_URLS_INTERNAL:qg(FL).call(FL,BL),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:jL,CONFIG_REQUEST_DOMAINS:HL,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",FORCE_ENABLED_REPORT_CALLBACKS:[],SKIP_WEB_AUDIO_IN_TRACK:!1,AUDIO_STALL:!0,VIDEO_STALL:!0,VIDEO_STALL_100MS:!1,STATS_SCALLBACK_SUPPORT:!0,JOIN_ROOM_CONFIG:VL.DEFAULT_CONF,SIGNAL_COMPRESSION:!0,SIGNAL_CROP_JOINROOM:!0,VIDEO_STALL_DATA:500,AUDIO_STALL_DATA:200,IOS_SAFARI_ORIENTATION:!1,FALLBACK_ENCODE_CODEC:""};function zL(e,t){var r;if(BN("setParameter",0,Fg(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("JOIN_ROOM_CONFIG"===e)return VL.setDefaulConf(t);if("ICE_CONFIG_REQUEST_URLS"!==e)if("VIDEO_STALL_DATA"!==e)if("AUDIO_STALL_DATA"!==e)if("VIDEO_STALL_100MS"!==e)if("PLATFORM"!==e||"string"!=typeof t)if("PRODUCT"!==e||"string"!=typeof t)if("FORCE_ENABLED_REPORT_CALLBACKS"!==e){if("LOG_SERVER_URL"===e){var n=t===vh.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===vh.domestic?jL:"string"==typeof t?t:void 0;n&&(GL.LOG_SERVER_URL=n,VN(n))}else if("OVERSEA"===e)return UN({extra_is_oversea:t?"1":"0"}),void(GL.OVERSEA=t);if("CONFIG_REQUEST_DOMAINS"===e&&Array.isArray(t)&&t.length>0)GL.CONFIG_REQUEST_DOMAINS=t;else{"DEVICE_ID"===e&&LL.setDeviceId(t);var i=Nx.getKeys();Xy(i).call(i,e)?Nx.setParameter(e,t):GL[e]=t}}else{var o="string"==typeof t?[t]:t;GL.FORCE_ENABLED_REPORT_CALLBACKS=o}else UN({product:t});else UN({platform:t});else GL.VIDEO_STALL_100MS=RM&&!!t;else GL.AUDIO_STALL_DATA=Math.max(200,Number(t));else GL.VIDEO_STALL_DATA=Math.max(500,Number(t));else{var a="string"==typeof t?[t]:t;GL.ICE_CONFIG_REQUEST_URLS=qg(a).call(a,BL)}}}function KL(e){return"DEVICE_ID"===e?LL.getDeviceId():GL[e]}function WL(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)||mh.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:qg(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 XL=[];function YL(e){XL=e}var qL={width:640,height:480,frameRate:15,maxKbps:600},JL={width:1920,height:1080,frameRate:15,maxKbps:3e3};function QL(e,t){if("boolean"!=typeof e)throw new bC(fC.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function ZL(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(e<i||e>o||"number"!=typeof e)throw new bC(fC.INVALID_PARAMS,Fg(r=Fg(n="Invalid ".concat(t,": the value range is [")).call(n,i,", ")).call(r,o,"]. integer only"))}function $L(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 bC(fC.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!function(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}(e,i,o))throw new bC(fC.INVALID_PARAMS,Fg(r=Fg(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function eU(e,t,r){var n;if(!Xy(r).call(r,e))throw new bC(fC.INVALID_PARAMS,Fg(n="Invalid ".concat(t,": The value can only be set as ")).call(n,Gg(r)))}function tU(e){if(!(e instanceof MediaStreamTrack))throw new bC(fC.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function rU(e,t){if(oU(e))throw new bC(fC.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function nU(e,t){if(!(e instanceof ArrayBuffer))throw new bC(fC.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function iU(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=MS(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(o){}}function oU(e){return null==e}function aU(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new bC(fC.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function sU(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new bC(fC.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function cU(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new bC(fC.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function uU(e){rU(e,"userInfo"),sU(e.userId),oU(e.extraInfo)||$L(e.extraInfo,"userInfo.extraInfo",1,200)}function dU(e){rU(e,"roomConfig"),QL(e.isAutoPublish,"roomConfig.isAutoPublish"),QL(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),QL(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),oU(e.roomProfileType)||eU(e.roomProfileType,"roomConfig",[kh.communication,kh.chat,kh.chatRoom,kh.coHost,kh.meeting,kh.classRoom])}function lU(e){rU(e,"videoPlayerOption")}function hU(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 bC(fC.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:wM.str2ab(Gg(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new bC(fC.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function pU(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new bC(fC.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function vU(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 bC(fC.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function _U(e){var t,r=my(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;ZL(null==n?void 0:n.maxKbps,"maxKbps"),vU(null==n?void 0:n.width,"width"),vU(null==n?void 0:n.height,"height"),vU(null==n?void 0:n.frameRate,"frameRate")}}catch(HZ){r.e(HZ)}finally{r.f()}}function fU(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 ZL(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var mU=r(js),gU={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?sI(n).call(n,1):n);return mU?Fg(i).call(i,mU(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}(gU);var yU=gU.exports,SU=r(yU),bU=new pM("VERTC",0),kU=function(e){UA(r,e);var t=ew(r);function r(){return Fh(this,r),t.apply(this,arguments)}return Vh(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=MA(NA(r.prototype),"emit",this)).call.apply(n,Fg(i=[this,e]).call(i,a))}catch(jZ){return bU.error("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,jZ),console.error(jZ),Boolean(t)}}}]),r}(yU.EventEmitter),EU=r(_A),TU=P,IU=rr,RU=ee,AU=cA,wU=Qt,CU=w,xU=Wc,OU=F;wr({target:"Reflect",stat:!0,forced:o((function(){var e=function(){},t=wU.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=CU.f(IU(t),r);if(!c){if(RU(o=xU(t)))return e(o,r,n,s);c=OU(0)}if(AU(c)){if(!1===c.writable||!RU(s))return!1;if(i=CU.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,wU.f(s,r,i)}else wU.f(s,r,OU(0,n))}else{if(void 0===(a=c.set))return!1;TU(a,s,n)}return!0}});var PU=r(te.Reflect.set),DU=r(mi.f("asyncIterator"));function NU(e){var t,r,n,i=2;for(void 0!==Al&&(r=DU,n=Kl);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new MU(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function MU(e){function t(e){if(Object(e)!==e)return tg.reject(new TypeError(e+" is not an object."));var t=e.done;return tg.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(MU=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?tg.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?tg.reject(e):t(r.apply(this.s,arguments))}},new MU(e)}var LU=[{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}];nk("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Sk);var UU=te.Set,VU=Ae,FU=function(e){if("object"==typeof e&&"size"in e&&"has"in e&&"add"in e&&"delete"in e&&"keys"in e)return e;throw TypeError(VU(e)+" is not a set")},BU=kk,jU=ae("Set"),HU=jU.prototype,GU={Set:jU,add:BU("add",1),has:BU("has",1),remove:BU("delete",1),proto:HU},zU=tE,KU=function(e,t,r){return r?zU(e.keys(),t,!0):e.forEach(t)},WU=KU,XU=GU.Set,YU=GU.add,qU=function(e){var t=new XU;return WU(e,(function(e){YU(t,e)})),t},JU=function(e){return e.size},QU=Oe,ZU=rr,$U=P,eV=Pr,tV=function(e){return{iterator:e,next:e.next,done:!1}},rV="Invalid size",nV=RangeError,iV=TypeError,oV=Math.max,aV=function(e,t,r,n){this.set=e,this.size=t,this.has=r,this.keys=n};aV.prototype={getIterator:function(){return tV(ZU($U(this.keys,this.set)))},includes:function(e){return $U(this.has,this.set,e)}};var sV=function(e){ZU(e);var t=+e.size;if(t!=t)throw iV(rV);var r=eV(t);if(r<0)throw nV(rV);return new aV(e,oV(r,0),QU(e.has),QU(e.keys))},cV=FU,uV=qU,dV=JU,lV=sV,hV=KU,pV=tE,vV=GU.has,_V=GU.remove,fV=function(e){var t=cV(this),r=lV(e),n=uV(t);return dV(t)<=r.size?hV(t,(function(e){r.includes(e)&&_V(n,e)})):pV(r.getIterator(),(function(e){vV(t,e)&&_V(n,e)})),n},mV=function(){return!1},gV=fV;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{difference:gV});var yV=FU,SV=JU,bV=sV,kV=KU,EV=tE,TV=GU.Set,IV=GU.add,RV=GU.has,AV=function(e){var t=yV(this),r=bV(e),n=new TV;return SV(t)>r.size?EV(r.getIterator(),(function(e){RV(t,e)&&IV(n,e)})):kV(t,(function(e){r.includes(e)&&IV(n,e)})),n},wV=AV;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{intersection:wV});var CV=FU,xV=GU.has,OV=JU,PV=sV,DV=KU,NV=tE,MV=Op,LV=function(e){var t=CV(this),r=PV(e);if(OV(t)<=r.size)return!1!==DV(t,(function(e){if(r.includes(e))return!1}),!0);var n=r.getIterator();return!1!==NV(n,(function(e){if(xV(t,e))return MV(n,"normal",!1)}))},UV=LV;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{isDisjointFrom:UV});var VV=FU,FV=JU,BV=KU,jV=sV,HV=function(e){var t=VV(this),r=jV(e);return!(FV(t)>r.size)&&!1!==BV(t,(function(e){if(!r.includes(e))return!1}),!0)},GV=HV;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{isSubsetOf:GV});var zV=FU,KV=GU.has,WV=JU,XV=sV,YV=tE,qV=Op,JV=function(e){var t=zV(this),r=XV(e);if(WV(t)<r.size)return!1;var n=r.getIterator();return!1!==YV(n,(function(e){if(!KV(t,e))return qV(n,"normal",!1)}))},QV=JV;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{isSupersetOf:QV});var ZV=FU,$V=qU,eF=sV,tF=tE,rF=GU.add,nF=GU.has,iF=GU.remove,oF=function(e){var t=ZV(this),r=eF(e).getIterator(),n=$V(t);return tF(r,(function(e){nF(t,e)?iF(n,e):rF(n,e)})),n},aF=oF;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{symmetricDifference:aF});var sF=FU,cF=GU.add,uF=qU,dF=sV,lF=tE,hF=function(e){var t=sF(this),r=dF(e).getIterator(),n=uF(t);return lF(r,(function(e){cF(n,e)})),n},pF=hF;wr({target:"Set",proto:!0,real:!0,forced:!mV()},{union:pF});var vF=UU;wr({target:"Set",stat:!0,forced:!0},{from:Gk}),wr({target:"Set",stat:!0,forced:!0},{of:Kk});var _F=FU,fF=GU.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=_F(this),t=0,r=arguments.length;t<r;t++)fF(e,arguments[t]);return e}});var mF=FU,gF=GU.remove;wr({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=mF(this),r=!0,n=0,i=arguments.length;n<i;n++)e=gF(t,arguments[n]),r=r&&e;return!!r}});var yF=Jt,SF=FU,bF=KU;wr({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=SF(this),r=yF(e,arguments.length>1?arguments[1]:void 0);return!1!==bF(t,(function(e){if(!r(e,e,t))return!1}),!0)}});var kF=mn,EF=Ze,TF=K,IF=Oc,RF=ht("iterator"),AF=Object,wF=A,CF=function(e){if(TF(e))return!1;var t=AF(e);return void 0!==t[RF]||"@@iterator"in t||EF(IF,kF(t))},xF=ee,OF=ae("Set"),PF=function(e){return function(e){return xF(e)&&"number"==typeof e.size&&wF(e.has)&&wF(e.keys)}(e)?e:CF(e)?new OF(e):e},DF=P,NF=PF,MF=fV;wr({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){return DF(MF,this,NF(e))}});var LF=Jt,UF=FU,VF=KU,FF=GU.Set,BF=GU.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=UF(this),r=LF(e,arguments.length>1?arguments[1]:void 0),n=new FF;return VF(t,(function(e){r(e,e,t)&&BF(n,e)})),n}});var jF=Jt,HF=FU,GF=KU;wr({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=HF(this),r=jF(e,arguments.length>1?arguments[1]:void 0),n=GF(t,(function(e){if(r(e,e,t))return{value:e}}),!0);return n&&n.value}});var zF=P,KF=PF,WF=AV;wr({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){return zF(WF,this,KF(e))}});var XF=P,YF=PF,qF=LV;wr({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){return XF(qF,this,YF(e))}});var JF=P,QF=PF,ZF=HV;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){return JF(ZF,this,QF(e))}});var $F=P,eB=PF,tB=JV;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){return $F(tB,this,eB(e))}});var rB=wr,nB=f,iB=FU,oB=KU,aB=Sn,sB=nB([].join),cB=nB([].push);rB({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=iB(this),r=void 0===e?",":aB(e),n=[];return oB(t,(function(e){cB(n,e)})),sB(n,r)}});var uB=Jt,dB=FU,lB=KU,hB=GU.Set,pB=GU.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=dB(this),r=uB(e,arguments.length>1?arguments[1]:void 0),n=new hB;return lB(t,(function(e){pB(n,r(e,e,t))})),n}});var vB=Oe,_B=FU,fB=KU,mB=TypeError;wr({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=_B(this),r=arguments.length<2,n=r?void 0:arguments[1];if(vB(e),fB(t,(function(i){r?(r=!1,n=i):n=e(n,i,i,t)})),r)throw mB("Reduce of empty set with no initial value");return n}});var gB=Jt,yB=FU,SB=KU;wr({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=yB(this),r=gB(e,arguments.length>1?arguments[1]:void 0);return!0===SB(t,(function(e){if(r(e,e,t))return!0}),!0)}});var bB=P,kB=PF,EB=oF;wr({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){return bB(EB,this,kB(e))}});var TB=P,IB=PF,RB=hF;wr({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){return TB(RB,this,IB(e))}});var AB=r(vF),wB=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!QM()&&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,UB();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,LB();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)}}(),CB=function(){var e=Ng(Pg().mark((function e(){var t;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.next=3,UB();case 3:if(e.t0=e.sent,!e.t0){e.next=8;break}return e.next=7,LB();case 7:e.t0=e.sent;case 8:if(!e.t0){e.next=10;break}t.push("H264");case 10:return e.next=12,FB();case 12:if(e.t1=e.sent,!e.t1){e.next=17;break}return e.next=16,VB();case 16:e.t1=e.sent;case 17:if(!e.t1){e.next=19;break}t.push("vp8");case 19:return e.abrupt("return",t);case 20:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),xB=function(){var e=Ng(Pg().mark((function e(){var t;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,CB();case 2:return t=e.sent,e.abrupt("return",qg(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),OB={};function PB(e){var t,r=!1,n=my(e.split("\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value;if(Xy(i).call(i,"level-asymmetry-allowed=1")&&Xy(i).call(i,"packetization-mode=1")&&Xy(i).call(i,"profile-level-id=42e0")){r=!0;break}}}catch(HZ){n.e(HZ)}finally{n.f()}if(r){for(var o=navigator.userAgent.toLowerCase(),a=!1,s=0,c=[/miuibrowser/,/70.*HeyTapBrowser/i];s<c.length;s++){c[s].test(o)&&(a=!0)}return!a}return!1}var DB=function(){var e=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection({sdpSemantics:"unified-plan"})).addTransceiver("video",{direction:t}),e.next=4,r.createOffer();case 4:return n=e.sent,r.close(),e.abrupt("return",n.sdp.toLowerCase());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),NB=function(){var e=Ng(Pg().mark((function e(){var t,r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,DB("sendonly");case 2:if(r=e.sent,!Xy(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,DB("sendonly");case 6:r=e.sent;case 7:return OB.h264encode=PB(r),OB.vp8encode=yI(r).call(r,"vp8")>-1,e.abrupt("return",OB);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),MB=function(){var e=Ng(Pg().mark((function e(){var t,r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,DB("recvonly");case 2:if(r=e.sent,!Xy(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,DB("recvonly");case 6:r=e.sent;case 7:return OB.h264decode=PB(r),OB.vp8decode=yI(r).call(r,"vp8")>-1,e.abrupt("return",OB);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),LB=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==OB.h264encode){e.next=9;break}return e.prev=1,e.next=4,NB();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",OB.h264encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),UB=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==OB.h264decode){e.next=9;break}return e.prev=1,e.next=4,MB();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",OB.h264decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),VB=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==OB.vp8encode){e.next=9;break}return e.prev=1,e.next=4,NB();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",OB.vp8encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),FB=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==OB.vp8decode){e.next=9;break}return e.prev=1,e.next=4,MB();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",OB.vp8decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),BB=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},jB=function(){return lL?nL&&AL>=70||tL&&kL>=80||rL&&bL>=14:fL?nL&&AL>=70||tL&&kL>=80:vL?TL[0]>=14:!!_L&&(nL&&AL>=86)},HB=nL&&AL<=114,GB=!tL||kL>=96,zB=!(rL&&bL<=14),KB=_L&&nL||vL&&(17===TL[0]||16===TL[0]),WB=new cT,XB=!0,YB=function(){var e=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new jI((function(e){var r={all:[],getTrackStats:function(){return[]}},n=KL("STATS_SCALLBACK_SUPPORT");if(XB&&nL&&void 0===window.InstallTrigger&&HB&&n)try{var i,o,a,s;null===(i=t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!Xy(ZB).call(ZB,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(Ql(Ql({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return Ty(r).call(r,(function(t){return"ssrc"!==t.type||t.googTrackId===e}))}})})))||void 0===i||null===(o=i.then)||void 0===o||null===(a=o.call(i,(function(){e(r)})))||void 0===a||null===(s=a.catch)||void 0===s||s.call(a,(function(){XB=!1,e(r)}))}catch(c){XB=!1,e(r)}else e(r)})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),qB=function(){var e=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c;return Pg().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 cT,n.forEach((function(e){var t=o.get(e.type)||new cT;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(QB.codec))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=o.get(QB.transport))||void 0===n||n.forEach((function(e){e.id===d&&(s=e,t.add(e))})),null===(i=o.get(QB.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(a=o.get(QB.mediaPlayout))||void 0===a||a.forEach((function(e){e.id===h&&t.add(e)})),s){var p,v,_=s,f=_.localCertificateId,m=_.remoteCertificateId,g=_.selectedCandidatePairId;null===(p=o.get(QB.certificate))||void 0===p||p.forEach((function(e){(e.id===f||e.id===m)&&t.add(e)})),null===(v=o.get(QB.candidatePair))||void 0===v||v.forEach((function(e){e.id===g&&(c=e,t.add(e))}))}if(c){var y,S,b=c,k=b.localCandidateId,E=b.remoteCandidateId;null===(y=o.get(QB.localCandidate))||void 0===y||y.forEach((function(e){e.id===k&&t.add(e)})),null===(S=o.get(QB.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===E&&t.add(e)}))}}))},o.get(QB.mediaSource)?null===(s=o.get(QB.mediaSource))||void 0===s||s.forEach((function(e){var t,r=new AB;r.add(e);var n=[];null===(t=o.get(QB.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=o.get(QB.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=KC(r)})):o.get(QB.track)&&(null===(c=o.get(QB.track))||void 0===c||c.forEach((function(e){var t,r=new AB;r.add(e);var n=[];null===(t=o.get(QB.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.trackId===e.id&&(r.add(t),n.push(t),null===(i=o.get(QB.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=KC(r)}))),null===(r=o.get(QB.inboundRtp))||void 0===r||r.forEach((function(e){var t,r=new AB;r.add(e),null===(t=o.get(QB.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(QB.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(s=t.trackIdentifier)})));i[s]=KC(r)})),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),JB=function(){var e=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u;return Pg().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(!tL&&!rL){e.next=15;break}return o=[],e.prev=5,e.next=8,t.getStats(r);case 8:e.sent.forEach((function(e){o.push(e)})),e.next=14;break;case 12:e.prev=12,e.t0=e.catch(5);case 14:return e.abrupt("return",o);case 15:return(!(a=WB.get(t))||Date.now()-a.timestamp>150)&&(a={timestamp:Date.now(),statsPromise:qB(t),extraStatsPromise:YB(t)},WB.set(t,a)),e.next=19,a.statsPromise;case 19:if(s=e.sent,c=(i?s[i]:s.all)||[],n){e.next=26;break}return e.next=24,a.extraStatsPromise;case 24:u=e.sent,c=Fg(c).call(c,(i?u.getTrackStats(i):u.all)||[]);case 26:return e.abrupt("return",c);case 27:case"end":return e.stop()}}),e,null,[[5,12]])})));return function(t,r,n){return e.apply(this,arguments)}}(),QB=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}(QB||{}),ZB=["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"],$B={},ej={},tj={exports:{}},rj=tj.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"]}]};MS(rj).forEach((function(e){rj[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}));var nj=tj.exports;!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=nj,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t,o={},a=[],s=o;return Ty(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=sI(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 oS(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return qg(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=qg(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 qg(t=e.split(" ")).call(t,(function(e){var t;return oS(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return qg(r=e.split(";")).call(r,(function(e){var r;return qg(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}}))}))}}(ej);var ij=nj,oj=/%[sdv%]/g,aj=function(e){var t=1,r=arguments,n=r.length;return e.replace(oj,(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""}}))},sj=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 aj.apply(null,n)},cj=["v","o","s","i","u","e","p","c","b","t","r","z","a"],uj=["i","c","b","a"],dj=ej,lj=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||cj,n=t.innerOrder||uj,i=[];return r.forEach((function(t){ij[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(sj(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(sj(t,r,e))}))}))})),e.media.forEach((function(e){i.push(sj("m",ij.m[0],e)),n.forEach((function(t){ij[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(sj(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(sj(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};$B.write=lj,$B.parse=dj.parse,$B.parseParams=dj.parseParams,$B.parseFmtpConfig=dj.parseFmtpConfig,$B.parsePayloads=dj.parsePayloads,$B.parseRemoteCandidates=dj.parseRemoteCandidates,$B.parseImageAttributes=dj.parseImageAttributes,$B.parseSimulcastStreamList=dj.parseSimulcastStreamList;var hj=new pM("FirefoxHandler",3),pj=Math.pow(2,32),vj="kp34Za0H+aVf862l";function _j(e){return e>pj-18?(hj.warn("generateAllSsrc","reset start id",e),_j(e=e-pj+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var fj=function(e,t,r){var n,i,o;return[{id:r,attribute:"cname",value:arguments.length>3&&void 0!==arguments[3]?arguments[3]:"o/i14u9pJrxRKAsu"},{id:r,attribute:"msid",value:Fg(n=Fg(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Fg(o="".concat(e,"-")).call(o,t)}]},mj=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=oS(s).call(s,(function(t,r){return Fg(t).call(t,fj(e,"video",r,c))}),[]),h=[{semantics:"FID",ssrcs:Fg(r="".concat(i," ")).call(r,o)}];u&&h.push({semantics:"FEC-FR",ssrcs:Fg(d="".concat(i," ")).call(d,a)});return{ssrcs:l,ssrcGroups:h}};function gj(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 yj=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=Ql(Ql({},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,$B.write(i)};function Sj(e){return bj.apply(this,arguments)}function bj(){return(bj=Ng(Pg().mark((function e(t){var r,n,i,o,a;return Pg().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,Ej(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=kj(n,a),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function kj(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(Ql(Ql({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(Ql(Ql({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var Ej=function(){var e=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c;return Pg().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,wM.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=AM(Uint8Array,n,i,o,a),e.next=15,wM.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)}}(),Tj=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=my(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(Xy(o=c.config).call(o,"level-asymmetry-allowed=1")&&Xy(a=c.config).call(a,"packetization-mode=1")&&Xy(s=c.config).call(s,"profile-level-id=42e0")){r=c.payload;break}}}catch(HZ){i.e(HZ)}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(BI(l=e.rtp).call(l,u,1)[0]);break}}else if(d.codec===t){var h;e.rtp.unshift(BI(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(" ")}},Ij=function(e){var t,r=$B.parse(e);return r.media=qg(t=r.media).call(t,(function(e){return"audio"===e.type?wj(e,r):Aj(e,["H264","VP8"],r)})),$B.write(r)},Rj=function(e){e.media.forEach((function(e){"audio"!==e.type&&"video"!==e.type||e.rtp.forEach((function(t){var r;e.rtcpFb||(e.rtcpFb=[]),aI(r=e.rtcpFb).call(r,(function(e){return e.payload===t.payload&&"rrtr"===e.type}))||e.rtcpFb.push({payload:t.payload,type:"rrtr"})}))}))},Aj=function(e,t,r){var n,i,o,a,s,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{rrtr:!1},u={},d={},l=-1,h=[];(Array.isArray(e.fmtp)&&e.fmtp.forEach((function(e){var t=e.payload,r=e.config;if(_C(r).call(r,"apt=")){var n=sI(r).call(r,4);u[t]=n}else Xy(r).call(r,"42e0")&&Xy(r).call(r,"packetization-mode=1")&&(l=t)})),Array.isArray(e.rtp))&&(e.rtp=Ty(n=e.rtp).call(n,(function(e){var r,n=e.codec,i=e.payload;switch(n){case"H264":return r=!1,qg(t).call(t,(function(e){"H264"===e&&i===l&&(d[i]=i,h.push(i),r=!0)})),r;case"rtx":return!!d[u[i]]&&(d[i]=i,!0);case"red":case"ulpfec":case"flexfec-03":return d[i]=i,!0;default:return r=!1,qg(t).call(t,(function(e){e===n&&(d[i]=i,h.push(i),r=!0)})),r}})));Array.isArray(e.fmtp)&&(e.fmtp=Ty(i=e.fmtp).call(i,(function(e){return d[e.payload]})));Array.isArray(e.rtcpFb)?e.rtcpFb=Ty(o=e.rtcpFb).call(o,(function(e){return d[e.payload]})):e.rtcpFb=[];(c.rrtr&&h.forEach((function(t){var r;null===(r=e.rtcpFb)||void 0===r||r.push({payload:t,type:"rrtr"})})),Cj(e,r),Array.isArray(e.ext))&&(e.ext=Ty(a=e.ext).call(a,(function(e){if("http://www.webrtc.org/experiments/rtp-hdrext/video-content-type"!==e.uri&&"http://www.webrtc.org/experiments/rtp-hdrext/video-timing"!==e.uri&&"http://www.webrtc.org/experiments/rtp-hdrext/color-space"!==e.uri)return e})));"string"==typeof e.payloads&&(e.payloads=Ty(s=e.payloads.split(" ")).call(s,(function(e){return d[e]})).join(" "));return e},wj=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{rrtr:!1},i={};Array.isArray(e.rtp)&&(e.rtp=Ty(r=e.rtp).call(r,(function(e){var t=e.codec,r=e.payload;return("opus"===t||"red"===t)&&(i[r]=r,!0)})));if(Array.isArray(e.rtcpFb)||(e.rtcpFb=[]),n.rrtr&&MS(i).forEach((function(t){var r;null===(r=e.rtcpFb)||void 0===r||r.push({payload:Number(t),type:"rrtr"})})),Cj(e,t),"string"==typeof e.payloads){var o=[];e.payloads.split(" ").forEach((function(e){i[e]&&o.push(e)})),e.payloads=o.join(" ")}return e},Cj=function(e,t){e.iceOptions&&delete e.iceOptions,e.icePwd&&(t.icePwd=e.icePwd,delete e.icePwd),e.iceUfrag&&(t.iceUfrag=e.iceUfrag,delete e.iceUfrag),e.fingerprint&&(t.fingerprint=e.fingerprint,delete e.fingerprint)},xj=function(e){UA(n,e);var t,r=ew(n);function n(e,t){var i;return Fh(this,n),ql(aA(i=r.call(this)),"_peerConnection",void 0),ql(aA(i),"_dataChannel",void 0),ql(aA(i),"_context",void 0),ql(aA(i),"peerConnectionMode",0),ql(aA(i),"id",void 0),ql(aA(i),"_monitor",void 0),ql(aA(i),"logger",void 0),ql(aA(i),"_nextSsrc",Math.floor(Math.random()*pj+1e4)),ql(aA(i),"_aSendonlyAnswerTpl",void 0),ql(aA(i),"_vSendonlyAnswerTpl",void 0),ql(aA(i),"_enableSubFlexfec",!1),ql(aA(i),"audioTrack4ff",void 0),ql(aA(i),"setLocalDescription",void 0),ql(aA(i),"setRemoteDescription",void 0),i.peer=t,i.id=e.id,i._monitor=KN(i.id),i.logger=new pM("BasicHandler",3,e.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 Vh(n,[{key:"destroy",value:function(){this.logger.info("destroy",this.peerConnectionId||""),MA(NA(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),this.logger.info("simulcast() ","simulcastLayers: %o",c)):(c=qg(o=sI(a=sI(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){if(e.width>e.height&&t.width<t.height||e.width<e.height&&t.width>t.height){var r=e.width;e.width=e.height,e.height=r}var n=JM(e.width),i=t.width/n;return{width:n,height:Math.floor(t.height/i),scaleResolutionDownBy:i,frameRate:JM(e.frameRate)||15,maxkbps:e.maxKbps||600}})),this.logger.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,h,p=null==r?void 0:r.preprocessingTrack,v=Ql({},qL);if(p){var _=null==p?void 0:p.getSettings();v={width:Math.floor(_.width),height:Math.floor(_.height),frameRate:Math.floor(_.frameRate)}}"number"!=typeof v.frameRate&&(v.frameRate=30);var f=null==e?void 0:e.videoEncodeConfig[0],m={maxBitrate:1e3*f.maxKbps,rid:"0"};if(e.prevBitrate=f.maxKbps,c.sendEncodings=[m],u.push({width:v.width,height:v.height,framerate:v.frameRate,maxkbps:f.maxKbps,rid:"0"}),i&&(!tL||"VP8"===(null===(l=this._context)||void 0===l||null===(h=l.serverConfig)||void 0===h?void 0:h.videoCodec))){var g,y,S=function(e){for(var t=0,r=e.width*e.height,n=0;n<LU.length;n++)if(r>=LU[n].totalPixels){t=n;break}if(0===t)return LU[t].maxLayers;var i=LU[t-1].totalPixels;return(i-r)/(i-LU[t].totalPixels)<.1?LU[t-1].maxLayers:LU[t].maxLayers}(v);if(this.logger.info("simulcast() ","maxLayers: %o",S),S>1)this._simulcast(e,Ql(Ql({},v),{},{maxKbps:f.maxKbps}),c,u,S),null!==(g=this._context)&&void 0!==g&&null!==(y=g.serverConfig)&&void 0!==y&&y.simulcastOnDemand&&(d=qg(u).call(u,(function(e,t){return Ql(Ql({},e),{},{video_index:t,sub_index:t})})))}}this.logger.info("publish videoTransceiverInit videoDescriptions","",c,u);var b=null==n?void 0:n.preprocessingTrack;(null==n?void 0:n.mixType)!==Dh.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(b=null==n?void 0:n.mixedAudioTrack),b=o&&b?b:"audio";var k=null==r?void 0:r.preprocessingTrack;k=a&&k?k:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",Gg({aTrack:fx(b),vTrack:fx(k),audioTransceiverInit:s,videoTransceiverInit:c}))}catch(jZ){}return{semantics:"unified-plan",videoDescriptions:u,subVideoDescriptions:d,audioTransceiverInit:{track:b,init:s},videoTransceiverInit:{track:k,init:c}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;this.logger.info("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.preprocessingTrack,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 this.logger.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:qg(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",Gg(c.encodings))}catch(jZ){}}}else this.logger.warn("updateMaxBitrate()","no pub")}},{key:"getStats",value:function(e,t){return JB(this._peerConnection,e,t)}},{key:"setCurrentDescription",value:(t=Ng(Pg().mark((function e(){return Pg().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,r=$B.parse(e);r.media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:aI(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:aI(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&&Xy(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))})),zB&&Rj(r)}},{key:"pc",get:function(){return this._peerConnection}},{key:"peerConnectionId",get:function(){return this.peer.getConnectionId()||""}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n,i=r.codec,o=r.payload;if(Xy(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=aI(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=Fg(s=[]).call(s,tR(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,Ql(Ql({},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}(yU.EventEmitter),Oj=function(e){UA(v,e);var t,r,n,i,o,a,s,c,u,d,l,h,p=ew(v);function v(){var e,t,r;return Fh(this,v),ql(aA(r=p.call(this)),"deviceMap",{audioinput:new cT,audiooutput:new cT,videoinput:new cT}),ql(aA(r),"checkDeviceChangeTimer",null),ql(aA(r),"isSupportedPermissionsQuery",!1),ql(aA(r),"isGrantedMicrophonePermission",!1),ql(aA(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!QM()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(aA(r)),!QM()&&r.initListener().then((function(){r.updateDeviceListInSilent()})),r}return Vh(v,[{key:"refreshDevices",value:(h=Ng(Pg().mark((function e(){var t,r,n,i=this,o=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:"audio",navigator.mediaDevices){e.next=3;break}return e.abrupt("return");case 3:if(r=void 0,!tL){e.next=19;break}if(e.prev=5,"audio"!==t){e.next=12;break}return e.next=9,navigator.mediaDevices.getUserMedia({audio:!0});case 9:r=e.sent,e.next=15;break;case 12:return e.next=14,navigator.mediaDevices.getUserMedia({video:!0});case 14:r=e.sent;case 15:e.next=19;break;case 17:e.prev=17,e.t0=e.catch(5);case 19:return e.next=21,navigator.mediaDevices.enumerateDevices();case 21:n=e.sent,r&&r.getTracks().forEach((function(e){return e.stop()})),n.forEach((function(e){var t;e.deviceId&&(null===(t=i.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))}));case 24:case"end":return e.stop()}}),e,null,[[5,17]])}))),function(){return h.apply(this,arguments)})},{key:"initListener",value:(l=Ng(Pg().mark((function e(){var t,r,n,i,o=this;return Pg().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 l.apply(this,arguments)})},{key:"_handleDeviceChange",value:(d=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c=this;return Pg().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(o=void 0,!tL){e.next=7;break}return e.next=6,navigator.mediaDevices.getUserMedia({audio:!0});case 6:o=e.sent;case 7:return e.next=9,navigator.mediaDevices.enumerateDevices();case 9:a=e.sent,a=Ty(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=KC(Fg(t=[]).call(t,tR(cw(r=this.deviceMap.audioinput).call(r)),tR(cw(n=this.deviceMap.videoinput).call(n)),tR(cw(i=this.deviceMap.audiooutput).call(i)))),(pL||dL)&&!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||(Xy(t=e.kind).call(t,"video")?c.emit(Lh.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):Xy(r=e.kind).call(r,"audio")&&c.emit(Lh.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;aI(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),Xy(t=e.kind).call(t,"video")?c.emit(Lh.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):Xy(r=e.kind).call(r,"audio")&&c.emit(Lh.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 16:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"getUserMedia",value:(u=Ng(Pg().mark((function e(t){var r;return Pg().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),null!=t&&t.video?this.refreshDevices("video"):this.refreshDevices("audio"),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(c=Ng(Pg().mark((function e(){var t,r;return Pg().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=Ty(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=Ty(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 c.apply(this,arguments)})},{key:"getPermissions",value:(s=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=(r=l.length>0&&void 0!==l[0]?l[0]:{}).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:if(!n){e.next=75;break}return e.next=73,this.refreshDevices("audio");case 73:e.next=77;break;case 75:return e.next=77,this.refreshDevices("video");case 77:return e.abrupt("return",a);case 78:case"end":return e.stop()}}),e,this,[[31,38]])}))),function(){return s.apply(this,arguments)})},{key:"updateDeviceListInSilent",value:(a=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.isGrantedCameraPermission&&this.isGrantedMicrophonePermission&&this.refreshDevices("audio");case 1:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=Ng(Pg().mark((function e(){var t,r,n,i;return Pg().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",KC(Fg(t=[]).call(t,tR(cw(r=this.deviceMap.audioinput).call(r)),tR(cw(n=this.deviceMap.videoinput).call(n)),tR(cw(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=Ng(Pg().mark((function e(){var t;return Pg().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",KC(cw(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=Ng(Pg().mark((function e(){var t;return Pg().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("video");case 4:return e.abrupt("return",KC(cw(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=Ng(Pg().mark((function e(){var t;return Pg().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("audio");case 4:return e.abrupt("return",KC(cw(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=Ng(Pg().mark((function e(t){var r;return Pg().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",aI(r).call(r,(function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),v}(kU),Pj=new Oj;!QM()&&(window.__rtc_dd__=Pj);var Dj=new pM("InternalEventBus",1),Nj=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}(Nj||{}),Mj=function(e){UA(r,e);var t=ew(r);function r(){return Fh(this,r),t.apply(this,arguments)}return Vh(r,[{key:"emit",value:function(e){var t,n;Dj.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=MA(NA(r.prototype),"emit",this)).call.apply(t,Fg(n=[this,e]).call(n,o))}}]),r}(yU.EventEmitter),Lj=new Mj,Uj=new pM("AudioContext",1),Vj=function(){function e(){var t=this;Fh(this,e),ql(this,"_audioContextInstance",void 0),ql(this,"_previousState",""),ql(this,"_currentState",""),ql(this,"_contextStuckAt",0);var r=0;QM()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,Uj.info("currentTime resume"),GN("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,Uj.warn("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),GN("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return Vh(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;Uj.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(),(vL||dL)&&("running"===e._previousState&&"interrupted"===e._currentState&&Lj.emit(Nj.ON_IOS_INTERRUPTION_START),"interrupted"===e._previousState&&"running"===e._currentState&&Lj.emit(Nj.ON_IOS_INTERRUPTION_END))}}return this._audioContextInstance}}]),e}(),Fj=function(){function e(t){Fh(this,e),ql(this,"_ctx",void 0),ql(this,"_analyserNode",void 0),ql(this,"_audioSource",void 0),ql(this,"currentTrackId",void 0),this.currentTrackId=t.id;var r=Bj.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 Vh(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=Ng(Pg().mark((function e(){var t;return Pg().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}(),Bj=new Vj,jj=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}(jj||{}),Hj=function(){function e(t){Fh(this,e),ql(this,"_plugins",new cT),this.id=t}var t;return Vh(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(eC(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 aI(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=Ng(Pg().mark((function e(t){var r,n,i,o,a;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.mediaTrack,i=my(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}(),Gj=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(Gj||{}),zj=new pM("VERTC",0),Kj=function(){function e(){Fh(this,e),ql(this,"_ac",void 0),ql(this,"_sourceNode",void 0),ql(this,"_gainNode",void 0),ql(this,"_destNode",void 0),this._ac=Bj.getAudioContextInstance(),this._gainNode=this._ac.createGain(),this._destNode=this._ac.createMediaStreamDestination(),this._gainNode.connect(this._destNode)}return Vh(e,[{key:"setVolume",value:function(e){this._gainNode.gain.value=e/100}},{key:"getVolume",value:function(){return Math.round(100*this._gainNode.gain.value)}},{key:"updateInputTrack",value:function(e){this._sourceNode&&(this._sourceNode.mediaStream.getTracks().forEach((function(e){e.stop()})),delete this._sourceNode);var t=new MediaStream;t.addTrack(e),this._sourceNode=this._ac.createMediaStreamSource(t),this._sourceNode.connect(this._gainNode)}},{key:"getOutputTrack",value:function(){return this._destNode.stream.getTracks()[0]}},{key:"destroy",value:function(){var e,t;null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),13!==bL&&this._destNode.stream.getTracks().forEach((function(e){e.stop()})),null===(t=this._sourceNode)||void 0===t||t.disconnect(),this._gainNode.disconnect(),delete this._sourceNode}}]),e}(),Wj=function(e){UA(r,e);var t=ew(r);function r(e,n){var i;return Fh(this,r),ql(aA(i=t.call(this)),"sourceType",1),ql(aA(i),"_originTrack",void 0),ql(aA(i),"_trackId",void 0),ql(aA(i),"_channelCount",void 0),i._trackId=n,i._originTrack=e,i._channelCount=e.getSettings().channelCount,i}return Vh(r,[{key:"getId",value:function(){return this._trackId}},{key:"channelCount",get:function(){var e;return null!==(e=this._channelCount)&&void 0!==e?e:0}},{key:"originTrack",get:function(){return this._originTrack},set:function(e){this._originTrack=e,this._channelCount=mediaTrack.getSettings().channelCount}},{key:"destroy",value:function(){this._originTrack.stop()}}]),r}(kU),Xj=function(e){UA(n,e);var t,r=ew(n);function n(e,t){var i;return Fh(this,n),ql(aA(i=r.call(this,e,t)),"_mediaTrack",void 0),ql(aA(i),"_preProcessingTrack",void 0),ql(aA(i),"_ap",void 0),ql(aA(i),"_extensionManager",void 0),ql(aA(i),"captureSessionId",""),ql(aA(i),"handleTrackEnded",(function(){i.emit("track-ended",aA(i)),i.close()})),ql(aA(i),"handleMute",(function(){i.emit("track-mute",aA(i))})),ql(aA(i),"handleUnmute",(function(){i.emit("track-unmute",aA(i))})),i._initListeners(),i}return Vh(n,[{key:"withWebAudio",get:function(){return!!this._ap}},{key:"mediaTrack",get:function(){var e;return null!==(e=this._mediaTrack)&&void 0!==e?e:this._originTrack}},{key:"preprocessingTrack",get:function(){var e;return null!==(e=this._preProcessingTrack)&&void 0!==e?e:this.mediaTrack}},{key:"setTrack",value:function(e,t){this._originTrack=e,this._ap&&(this._ap.updateInputTrack(e),this._mediaTrack=this._ap.getOutputTrack()),t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._extensionManager=t,this._preProcessingTrack=void 0,e.prev=2,e.next=5,t.getPreProcessingTrack(this);case 5:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),console.error(e.t0);case 12:case"end":return e.stop()}}),e,this,[[2,9]])}))),function(e){return t.apply(this,arguments)})},{key:"close",value:function(){var e,t;this._originTrack.removeEventListener("ended",this.handleTrackEnded),this._originTrack.removeEventListener("mute",this.handleMute),this._originTrack.removeEventListener("unmute",this.handleUnmute),null===(e=this._preProcessingTrack)||void 0===e||e.stop(),null===(t=this._mediaTrack)||void 0===t||t.stop(),this._ap&&this._ap.destroy(),MA(NA(n.prototype),"destroy",this).call(this)}},{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}(Wj),Yj=function(e){UA(r,e);var t=ew(r);function r(e,n){var i;return Fh(this,r),ql(aA(i=t.call(this,e,n)),"_mediaTrack",void 0),ql(aA(i),"_ap",void 0),ql(aA(i),"player",void 0),i._originTrack=e,i}return Vh(r,[{key:"mediaTrack",get:function(){var e;return null!==(e=this._mediaTrack)&&void 0!==e?e:this._originTrack}},{key:"preprocessingTrack",get:function(){return this.mediaTrack}},{key:"withWebAudio",get:function(){return!!this._ap}},{key:"setPlayer",value:function(e){this.player=e}},{key:"close",value:function(){this._ap&&this._ap.destroy()}}]),r}(Wj),qj=function(e){UA(n,e);var t,r=ew(n);function n(e,t){var i;return Fh(this,n),ql(aA(i=r.call(this,e,t)),"mediaType","video"),ql(aA(i),"resolution",void 0),ql(aA(i),"dummy",!1),ql(aA(i),"videoPlayer",void 0),i.resolution={width:0,height:0},i}return Vh(n,[{key:"updateVideoCaptureConfig",value:(t=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return zj.info("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=Ql({},t)).contentHint,tL&&this.streamIndex===sh.STREAM_INDEX_MAIN&&(r.frameRate={ideal:30,max:30}),e.next=6,this.originTrack.applyConstraints(r);case 6:((n=this.originTrack.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 8: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;"contentHint"in this.originTrack&&Xy(t=["text","motion","detail"]).call(t,e)&&(this.originTrack.contentHint=e)}}]),n}(Xj),Jj=function(e){UA(n,e);var t,r=ew(n);function n(){var e,t;Fh(this,n);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(t=r.call.apply(r,Fg(e=[this]).call(e,o))),"mediaType","audio"),ql(aA(t),"audioCaptureConfig",void 0),ql(aA(t),"mixedAudioTrack",void 0),ql(aA(t),"mixType",Dh.PLAYOUT_AND_PUBLISH),ql(aA(t),"_audioFetchMap",new cT),ql(aA(t),"notSupportedWebAudio",!1),t}return Vh(n,[{key:"getAudioLevel",value:function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ph.MICROPHONE,n=r===ph.AUDIOMIXING&&this.mixType!==Dh.PLAYOUT&&null!==(e=this.mixedAudioTrack)&&void 0!==e?e:this.preprocessingTrack,i=this._audioFetchMap.get(r);i&&i.currentTrackId===n.id||(null===(t=i)||void 0===t||t.destroy(),i=new Fj(n),this._audioFetchMap.set(r,i));return i.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=Ng(Pg().mark((function e(){return Pg().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 zj.info("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,this.originTrack.applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){this._audioFetchMap.forEach((function(e){return e.destroy()})),this._audioFetchMap.clear(),MA(NA(n.prototype),"close",this).call(this)}},{key:"setVolume",value:function(e){var t=!KL("SKIP_WEB_AUDIO_IN_TRACK")&&jB();t||(this.notSupportedWebAudio=!0);var r,n=!this.withWebAudio&&100!==e;try{t&&n&&(zj.print("Create AudioProcess"),this._ap=new Kj,this._ap.updateInputTrack(this.originTrack),this._mediaTrack=this._ap.getOutputTrack(),this._extensionManager&&this.generatePreProcessingTrack(this._extensionManager))}catch(i){zj.print("WebAudio may not supported, quired return"),this.notSupportedWebAudio=!0}this.notSupportedWebAudio||(null===(r=this._ap)||void 0===r||r.setVolume(e));t&&n&&this.emit("needReplaceTrack",this)}},{key:"getVolume",value:function(){return this._ap?this._ap.getVolume():100}}]),n}(Xj),Qj=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"mediaType","video"),ql(aA(n),"videoPlayer",void 0),n}return Vh(r)}(Yj),Zj=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"mediaType","audio"),ql(aA(n),"_audioLevelFetcher",void 0),ql(aA(n),"notSupportedWebAudio",!1),n}return Vh(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new Fj(this.originTrack)),this._audioLevelFetcher.getAudioLevel()}},{key:"setVolume",value:function(e){var t=!KL("SKIP_WEB_AUDIO_IN_TRACK")&&jB();t||(this.notSupportedWebAudio=!0);var r,n,i=!this.withWebAudio&&100!==e;try{t&&i&&(zj.print("Create AudioProcess"),this._ap=new Kj,this._ap.updateInputTrack(this.originTrack),this._mediaTrack=this._ap.getOutputTrack())}catch(o){zj.print("WebAudio may not supported, quite return"),this.notSupportedWebAudio=!0}this.notSupportedWebAudio||(null===(r=this._ap)||void 0===r||r.setVolume(e));t&&i&&(this.emit("needReplaceTrack",this),null===(n=this.player)||void 0===n||n.playAudio(this))}},{key:"getVolume",value:function(){return this.notSupportedWebAudio?100:this._ap?this._ap.getVolume():100}},{key:"close",value:function(){var e;null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),MA(NA(r.prototype),"close",this).call(this)}}]),r}(Yj),$j=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_MAIN),n}return Vh(r)}(Jj),eH=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_MAIN),n}return Vh(r)}(qj),tH=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_MAIN),ql(aA(n),"sourceType",0),n}return Vh(r)}(qj),rH=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_MAIN),ql(aA(n),"sourceType",0),n}return Vh(r)}(Jj),nH=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_SCREEN),n}return Vh(r)}(qj),iH=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_SCREEN),n}return Vh(r)}(Jj),oH=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_SCREEN),ql(aA(n),"sourceType",0),n}return Vh(r)}(qj),aH=function(e){UA(r,e);var t=ew(r);function r(){var e,n;Fh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return ql(aA(n=t.call.apply(t,Fg(e=[this]).call(e,o))),"streamIndex",sh.STREAM_INDEX_SCREEN),ql(aA(n),"sourceType",0),n}return Vh(r)}(Jj);function sH(e,t){return cH.apply(this,arguments)}function cH(){return(cH=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new eH(t,TM())).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 uH(e,t){return dH.apply(this,arguments)}function dH(){return(dH=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new nH(t,TM())).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 lH(e,t){return hH.apply(this,arguments)}function hH(){return(hH=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=(null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=KN(r.id),s=TM(),e.prev=3,zj.info("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o,capture_session_id:s}),u=IM(),tL&&(t.frameRate={ideal:30,max:30}),e.next=10,Pj.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,media_device_name:(null===(c=i.getVideoTracks()[0])||void 0===c?void 0:c.label)||"",reason:"success",elapse:IM()-u,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 bC(fC.GET_VIDEO_TRACK_FAILED,Fg(d="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(d,e.t0.message||"unknown message","."),e.t0);case 18:return l=i.getVideoTracks()[0],(h=new eH(l,TM())).captureSessionId=s,e.next=23,h.generatePreProcessingTrack(r);case 23:return e.abrupt("return",h);case 24:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function pH(e,t){return vH.apply(this,arguments)}function vH(){return(vH=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return zj.info("createMicrophoneAudioTrack","constraints:",t),o=(null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=KN(r.id),s=TM(),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=IM(),(d=r.getPluginByName(jj.PRE_PROCESSING,"RTCAIAnsExtension"))&&(d.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=11,Pj.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:IM()-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 bC(fC.GET_AUDIO_TRACK_FAILED,Fg(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],(p=new $j(h,TM())).captureSessionId=s,e.next=24,p.generatePreProcessingTrack(r);case 24:return e.abrupt("return",p);case 25:case"end":return e.stop()}}),e,null,[[4,15]])})))).apply(this,arguments)}function _H(e,t,r){return fH.apply(this,arguments)}function fH(){return(fH=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return zj.print("createCameraAndMicrophoneTrack","audioConstraints:",t,"videoConstraints:",r),a=KN(n.id),c=(null===(i=t.deviceId)||void 0===i?void 0:i.exact)||"default",u=(null===(o=r.deviceId)||void 0===o?void 0:o.exact)||"default",d=TM(),l=TM(),TM(),TM(),e.prev=8,null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:u,capture_session_id:d}),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_begin",media_device_id:c,event_session_id:l}),v=IM(),tL&&(r.frameRate={ideal:30,max:30}),(_=n.getPluginByName(jj.PRE_PROCESSING,"RTCAIAnsExtension"))&&(_.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=17,Pj.getUserMedia({audio:t,video:r});case 17:s=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:u,media_device_name:(null===(h=s.getVideoTracks()[0])||void 0===h?void 0:h.label)||"",reason:"success",elapse:IM()-v,capture_session_id:d}),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_result",media_device_id:c,media_device_name:(null===(p=s.getAudioTracks()[0])||void 0===p?void 0:p.label)||"",reason:"success",elapse:IM()-v,event_session_id:l}),e.next=27;break;case 22:throw e.prev=22,e.t0=e.catch(8),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:u,error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:d}),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_end",media_device_id:c,error_code:e.t0.code,reason:e.t0.name+e.t0.message,event_session_id:l}),new bC(fC.GET_VIDEO_TRACK_FAILED,Fg(f="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(f,e.t0.message||"unknown message","."),e.t0);case 27:return m=s.getVideoTracks()[0],(g=new eH(m,TM())).captureSessionId=d,e.next=32,g.generatePreProcessingTrack(n);case 32:return y=s.getAudioTracks()[0],(S=new $j(y,TM())).captureSessionId=l,e.next=37,S.generatePreProcessingTrack(n);case 37:return e.abrupt("return",{videoTrack:g,audioTrack:S});case 38:case"end":return e.stop()}}),e,null,[[8,22]])})))).apply(this,arguments)}function mH(){return gH.apply(this,arguments)}function gH(){return gH=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=_.length>0&&void 0!==_[0]&&_[0],r=_.length>1?_[1]:void 0,n=_.length>2?_[2]:void 0,zj.info("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=KN(r.id),a=TM(),e.prev=6,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen",capture_session_id:a}),d=IM(),e.next=11,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!rL||"16.1"!==EL))||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",media_device_name:Fg(s="".concat((null===(c=i.getVideoTracks()[0])||void 0===c?void 0:c.label)||"",", ")).call(s,(null===(u=i.getAudioTracks()[0])||void 0===u?void 0:u.label)||""),reason:"success",elapse:IM()-d,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 bC(fC.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 19:return l=i.getVideoTracks()[0],(h=new nH(l,TM())).captureSessionId=a,e.next=24,h.generatePreProcessingTrack(r);case 24:if(!(p=i.getAudioTracks()[0])){e.next=30;break}return v=new iH(p,TM()),e.next=29,v.generatePreProcessingTrack(r);case 29:return e.abrupt("return",[h,v]);case 30:return e.abrupt("return",[h,void 0]);case 31:case"end":return e.stop()}}),e,null,[[6,15]])}))),gH.apply(this,arguments)}function yH(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:TM();return new Zj(e,t)}function SH(e,t){return bH.apply(this,arguments)}function bH(){return(bH=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new tH(t,TM()),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 kH(e,t){return EH.apply(this,arguments)}function EH(){return(EH=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new rH(t,TM()),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 TH(e,t){return IH.apply(this,arguments)}function IH(){return(IH=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new oH(t,TM()),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 RH(e,t){return AH.apply(this,arguments)}function AH(){return(AH=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new aH(t,TM()),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 wH=Jj,CH=Zj,xH=function(e){return e[e.NONE=0]="NONE",e}(xH||{}),OH={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)?OH.getAnnexbNals(e):OH.getAvccNals(e)},getAnnexbNals:function(e){for(var t=[],r=OH.getHeaderPositionAnnexB(e),n=r.pos,i=n;n<e.length-4;){var o,a,s=new Uint8Array(sI(o=e.buffer).call(o,n,n+r.headerLength));r.pos===e.position&&e.skip(r.headerLength),i=(r=OH.getHeaderPositionAnnexB(e)).pos;var c={header:s,body:new Uint8Array(sI(a=e.buffer).call(a,n+s.byteLength,i)),type:-1};OH.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(sI(n=e.buffer).call(n,e.position,e.position+4));e.skip(4);var a=new Uint8Array(sI(i=e.buffer).call(i,e.position,e.position+r));e.skip(r);var s={header:o,body:a,type:-1};OH.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}}},PH=function(){function e(t){Fh(this,e),ql(this,"_position",0),ql(this,"_dataview",void 0),this._dataview=new DataView(t)}return Vh(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}(),DH=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(DH||{}),NH=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),MH=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]);function LH(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function UH(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 VH=function(){function e(){Fh(this,e)}return Vh(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?NH:MH,s=LH(e.byteLength+a.byteLength),c=function(e){var t,r=[],n=0,i=my(e);try{for(i.s();!(t=i.n()).done;){var o=t.value;n>=2&&o<=3&&(r.push(3),n=0),0===o?n++:n=0,r.push(o)}}catch(HZ){i.e(HZ)}finally{i.f()}return new Uint8Array(r)}(e);return new Uint8Array(Fg(t=[]).call(t,tR(n),tR(i),tR(o),tR(s),tR(a),tR(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=sI(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=gy(UH(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=MH.byteLength&&i>=MH.byteLength&&sI(t).call(t,r,r+MH.byteLength).toString()===MH.toString()?(r+=MH.byteLength,o=1):t.byteLength>=MH.byteLength&&i>=MH.byteLength&&sI(t).call(t,r,r+NH.byteLength).toString()===NH.toString()&&(r+=NH.byteLength,o=0),{type:o,payload:sI(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new cT,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=gy(UH(e.payload,r),2),i=n[0];r=n[1];var o,a=gy(UH(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,sI(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=my(e);try{for(n.s();!(t=n.n()).done;){var i=gy(t.value,2),o=i[0],a=i[1],s=LH(o),c=LH(a.byteLength);r.push(s,c,a)}}catch(HZ){n.e(HZ)}finally{n.f()}var u=oS(r).call(r,(function(e,t){return e+t.byteLength}),0),d=new Uint8Array(u);return oS(r).call(r,(function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),FH=function(){function e(t){Fh(this,e),ql(this,"_timer",void 0),ql(this,"handler",void 0),ql(this,"_monitor",void 0),ql(this,"logger",void 0),ql(this,"_destroyed",!1),this._context=t,this._monitor=KN(t.id),this.logger=new pM("Stats",3,t.id)}return Vh(e,[{key:"setVar",value:function(e){this.handler=e}},{key:"stopReport",value:function(e){var t;this._timer&&(this.logger.info("stopReport","invoke"),clearTimeout(this._timer),delete this._timer,JN(this._context.id,"del_media_statistics_timer",Fg(t="reason: ".concat(e,", stack: ")).call(t,(new Error).stack),0,this._stream.streamId||""))}},{key:"filterIllegal",value:function(e){var t={};return MS(e).forEach((function(r){null===e[r]||void 0===e[r]||Number.isNaN(e[r])||(t[r]=e[r])})),t}},{key:"destroy",value:function(){this.logger.info("destroy","invoke"),JN(this._context.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.stopReport("destroy"),this._destroyed=!0}}]),e}(),BH=function(e){UA(i,e);var t,r,n=ew(i);function i(e,t){var r;return Fh(this,i),(r=n.call(this,e))._stream=t,r}return Vh(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t){var r,n,i,o=this;if(!this._timer){this.logger.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.preprocessingTrack,u=null===(n=s.videoTrack)||void 0===n?void 0:n.preprocessingTrack;this.getAudioStats(c,a,null===(i=s.audioTrack)||void 0===i?void 0:i.getAudioLevel()),this.getVideoStats(u,a);var d=function(){var e=Ng(Pg().mark((function e(){var t,r,n,i,c,u,d;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=s.audioTrack)||void 0===t?void 0:t.preprocessingTrack,c=null===(r=s.videoTrack)||void 0===r?void 0:r.preprocessingTrack,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=Ng(Pg().mark((function t(){var r;return Pg().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=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a={},s={timestamp:Date.now()},c=this._stream,u=c.streamId,d=c.audioMid,l=c.isScreen,h=c.pubAttributes,p=c.pubAudio,v=c.audioTrack,_={media_type:"audio",is_screen:!!l,direction:"up",stream_id:u,vid:d,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:h.localaudio?"capture_state_on":"capture_state_off",mute_state:p?"mute_state_off":"mute_state_on"},v&&(_.playback_volume=v.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",a);case 7:return e.next=9,this.handler.getStats(t);case 9:if((f=e.sent).length){e.next=12;break}return e.abrupt("return",a);case 12:if(f.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,o=e.clockRate,c=e.roundTripTime,u=e.channels,d=e.audioLevel,l=e.mimeType,h=e.availableIncomingBitrate,p=e.availableOutgoingBitrate,v=e.bytesReceived,f=e.nominated,m=e.id,g=e.currentRoundTripTime,y=e.state,S=e.writable,b=e.requestsReceived,k=e.responsesReceived,E=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,P=e.protocol,D=e.nackCount,N=e.retransmittedBytesSent,M=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(s.packetsSent=r,s.bytesSent=i,_.bytes=i,_.packetsSent=r,_.nackCount=D,_.ssrc=U,_.retransmitted_bytes_sent=N,_.retransmitted_packets_sent=M,s.retransmittedBytesSent=N,s.retransmittedPacketsSent=M):"remote-inbound-rtp"===t?(s.packetsLost=n,_.packetsLost=n,_.net_jitter=1e3*R,a.rtt=1e3*c,_.rtt=a.rtt,a._fractionLost=j||0):"codec"===t?(a.recordSampleRate=o,a.numChannels=u,_.codecName=l):"media-source"===t&&void 0!==d?(_.audio_level=d?-10*JC(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=g,_.ice_pair_state=y,_.ice_pair_writable=S,_.recv_ping_requests=b,_.recv_ping_responses=k,_.sent_ping_requests_before_first_response=E,_.sent_ping_requests_total=E+(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=P):"remote-candidate"===t&&(_.remote_candidate_type=A,_.remote_ip=w||C,_.remote_port=O);var H=KL("STATS_SCALLBACK_SUPPORT");HB&&H||"media-source"===t&&(_.send_level=d)})),void 0===_.volume&&void 0!==n&&(_.volume=n,_.audio_level=n?-10*JC(Math.pow(n/255,2)):n),(m=r.audio).timestamp){e.next=18;break}return r.audio=s,e.abrupt("return",this.filterIllegal(a));case 18:return void 0!==s.packetsLost&&(a.audioLossRate=(s.packetsLost-m.packetsLost)/(s.packetsSent-m.packetsSent),a.audioLossRate=Number.isNaN(a.audioLossRate)?0:a.audioLossRate,_.fraction_lost=a.audioLossRate),a.statsInterval=s.timestamp-m.timestamp,_.stats_interval=a.statsInterval,a.sendKBitrate=(s.bytesSent-m.bytesSent||0)/a.statsInterval*8,_.mediaBitratebps=Math.round(1e3*a.sendKBitrate),_.bandwidth=Math.round(_.mediaBitratebps/1024),void 0!==s.retransmittedBytesSent&&(_.retransmitBitratebps=(s.retransmittedBytesSent-m.retransmittedBytesSent||0)/a.statsInterval),r.audio=s,_.vendor_mode=this._stream.vendorCode||0,_.pc_session_id=null===(i=this.handler)||void 0===i?void 0:i.peerConnectionId,null===(o=this._monitor)||void 0===o||o.report("rtc_media_statistics",_),a._retransmittedRate=(s.retransmittedPacketsSent-m.retransmittedPacketsSent)/(s.packetsSent-m.packetsSent),void 0===a.audioLossRate&&(a.audioLossRate=a._retransmittedRate,_.fraction_lost=a.audioLossRate),a._fractionLost=Math.max(a._fractionLost,a.audioLossRate),e.abrupt("return",this.filterIllegal(a));case 33:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(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,h={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"},t&&this.handler){e.next=6;break}return e.abrupt("return",n);case 6: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=12,this.handler.getStats(t);case 12:if((p=e.sent).length){e.next=15;break}return e.abrupt("return",n);case 15: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,_=e.firCount,f=e.targetBitrate,m=e.roundTripTime,g=e.mimeType,y=e.frameWidth,S=e.frameHeight,b=e.packetsSent,k=e.googActualEncBitrate,E=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,P=e.nominated,D=e.id,N=e.currentRoundTripTime,M=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,W=e.requestsReceived,X=e.responsesReceived,Y=e.googRetransmitBitrate,q=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!==y&&((!n.encodedFrameWidth||y>n.encodedFrameWidth)&&(n.encodedFrameWidth=y),(!n.encodedFrameHeight||S>n.encodedFrameHeight)&&(n.encodedFrameHeight=S),h.frame_size_height=S,h.frame_size_width=y)):"track"===t?(n.encodedFrameWidth=y,n.encodedFrameHeight=S,h.frame_size_height=S,h.frame_size_width=y):"remote-inbound-rtp"===t?(i.packetsLost=a,n.rtt=1e3*m,h.rtt=n.rtt,h.jitter=1e3*ne,h.packetsLost=a,n._fractionLost=oe||0):"codec"===t?(n.codecType=g,h.codecName=g):"candidate-pair"===t?(h.ice_available_incoming_bitrate=C,h.ice_available_outgoing_bitrate=x,h.ice_bytes_received=O,h.ice_bytes_sent=s,h.ice_nominated=Number(P),h.ice_pair_id=D,h.ice_pair_rtt=N,h.ice_pair_state=M,h.ice_pair_writable=L,h.recv_ping_requests=W,h.recv_ping_responses=X,h.sent_ping_requests_before_first_response=q,h.sent_ping_requests_total=q+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=k,h.available_receive_bandwidth=E,h.available_send_bandwidth=T,h.bucket_delay=R,h.retransmitBitratebps=Y,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 _e=KL("STATS_SCALLBACK_SUPPORT");if(!HB||!_e){var fe=r.video,me=i.timestamp-fe.timestamp;if("outbound-rtp"===t){var ge=s-fe.bytesSent,ye=u-fe.retransmittedBytesSent;h.encBitratebps=Math.round(8e3*(ge-ye)/me),h.bucket_delay=l/b,h.retransmitBitratebps=Math.round(8e3*ye/me),h.targetEncBitratebps=f,h.transmit_bitrate=Math.round(1e3*(s-fe.bytesSent)*8/me),h.avg_encode_ms=1e3*p/o,h.firsReceived=_+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)}})),(_=r.video).timestamp){e.next=21;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 21:return n.statsInterval=i.timestamp-_.timestamp,h.stats_interval=n.statsInterval,f=MS(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=this._context.activeSimStreams||[],h.sim_retransmittedRate=[],y=!1,Kw(f).call(f,(function(e,t){return Number(e)-Number(t)})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,p=t.qualityLimitationDurations,v=t.qualityLimitationResolutionChanges,f=t.retransmittedPacketsSent,m=t.pliCount,g=t.keyFramesEncoded;void 0!==l&&(h.sim_qualityLimitationReason||(h.sim_qualityLimitationReason=[],h.sim_qualityLimitationDurations=[],h.sim_qualityLimitationResolutionChanges=[]),h.sim_qualityLimitationReason.push(l),h.sim_qualityLimitationDurations.push(p),h.sim_qualityLimitationResolutionChanges.push(v));var S=_.simulcast[e];if(h.sim_enc_width.push(r||0),h.sim_enc_height.push(o||0),h.sim_enc_key_frames.push(g||0),S){var b=(a-S.bytesSent||0)/n.statsInterval;h.sim_enc_bps.push(Math.round(8e3*b)),h.sim_enc_bandwidth.push(Math.round(8e3*b/1024));var k=1e3*(s-S.framesEncoded)/n.statsInterval;h.sim_enc_framerate.push(Math.round(k)),h.sim_rids.push(e);var E=void 0!==c?c-S.framesSent:s-S.framesEncoded,T=1e3*E/n.statsInterval;h.sim_sent_framerate.push(Math.round(T));var I=(u-S.packetsLost)/(d-S.packetsSent);n._retransmittedRate=(f-S.retransmittedPacketsSent)/(d-S.packetsSent),I=Number.isNaN(I)?0:I,h.sim_fraction_lost.push(I),h.sim_keyencoded.push(m-S.pliCount>0),h.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!y&&(n.sentKBitrate=8*b,n.encoderOutputFrameRate=k,n.encodedFrameCount=E,n.sentFrameRate=T,n.videoLossRate=I,y=!0)}})),h.vendor_mode=this._stream.vendorCode||0,h.pc_session_id=null===(m=this.handler)||void 0===m?void 0:m.peerConnectionId,null===(g=this._monitor)||void 0===g||g.report("rtc_media_statistics",h)):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-_.framesSent:i.framesEncoded-_.framesEncoded,n.sentKBitrate=(i.bytesSent-_.bytesSent||0)/n.statsInterval*8,h.bitrate=Math.round(1e3*n.sentKBitrate),h.bandwidth=Math.round(h.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-_.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-_.packetsLost)/(i.packetsSent-_.packetsSent),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,h.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-_.retransmittedPacketsSent)/(i.packetsSent-_.packetsSent),h.vendor_mode=this._stream.vendorCode||0,h.pc_session_id=null===(S=this.handler)||void 0===S?void 0:S.peerConnectionId,null===(b=this._monitor)||void 0===b||b.report("rtc_media_statistics",h)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 28:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(FH),jH=function(e){UA(o,e);var t,r,n,i=ew(o);function o(e,t){var r;return Fh(this,o),(r=i.call(this,e))._stream=t,r}return Vh(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._timer){e.next=2;break}return e.abrupt("return");case 2:return this.logger.info("setRemoteStreamStatsEvtInterval","invoke"),this.setVar(r),a={audio:{},video:{}},this._destroyed=!1,s=this._stream,c=null===(n=s.audioTrack)||void 0===n?void 0:n.originTrack,u=null===(i=s.videoTrack)||void 0===i?void 0:i.originTrack,this.getRemoteVideoStats(u,a),e.next=12,this.getRemoteAudioStats(c,a,null===(o=this._stream.audioTrack)||void 0===o?void 0:o.getAudioLevel());case 12:d=function(){var e=Ng(Pg().mark((function e(){var r,n,i,o,c,u,h;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=null===(r=s.audioTrack)||void 0===r?void 0:r.originTrack,c=null===(n=s.videoTrack)||void 0===n?void 0:n.originTrack,e.next=4,l.getRemoteAudioStats(o,a,null===(i=l._stream.audioTrack)||void 0===i?void 0:i.getAudioLevel());case 4:return u=e.sent,e.next=7,l.getRemoteVideoStats(c,a);case 7:h=e.sent,t({audioStats:u,videoStats:h,isScreen:s.isScreen,userId:s.userId,streamId:s.streamId}),l._destroyed||(l._timer=setTimeout(d,2e3));case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this.stopReport("start a new timer."),this._timer=setTimeout(d,2e3);case 15:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"unsubscribe",value:function(){this.logger.info("unsubscribe","invoke"),MA(NA(o.prototype),"stopReport",this).call(this,"unsubscribe"),this._stream.stopAudioStallObserve()}},{key:"getRemoteAudioStats",value:(r=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c={},u={},d=this._stream,l=d.streamId,h=d.userId,p=d.isScreen,v=d.audioMid,_=d.subMediaType,f=d._attributes,m=d.virtual,g=d.audioTrack,y={media_type:"audio",is_screen:!!p,direction:"down",stream_id:l,stream_user_id:h,vid:v,audio_mux:m,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:GM(_)?"mute_state_off":"mute_state_on",remote_user_capture_state:f.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:f.localaudio&&f.audiostream?"mute_state_off":"mute_state_on"},g&&(y.playback_volume=g.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",c);case 7:return e.next=9,this.handler.getStats(t);case 9:if((S=e.sent).length){e.next=12;break}return e.abrupt("return",c);case 12:if(S.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,o=e.bytesReceived,a=e.jitterBufferDelay,s=e.jitterBufferEmittedCount,d=e.clockRate,h=e.channels,p=e.totalSamplesReceived,v=e.concealedSamples,_=e.silentConcealedSamples,f=e.concealmentEvents,m=e.totalRoundTripTime,g=e.packetsDiscarded,S=e.state,b=e.currentRoundTripTime,k=e.audioLevel,T=e.totalAudioEnergy,I=e.totalSamplesDuration,R=e.mimeType,A=e.googDecodingNormal,w=e.googDecodingMuted,C=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,O=e.bytesSent,P=e.nominated,D=e.id,N=e.writable,M=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,W=e.consentRequestsSent,X=e.responsesSent,Y=e.ssrc,q=e.nackCount,J=e.lastPacketReceivedTimestamp,Q=e.concealmentevents,Z=e.fecPacketsReceived;if("inbound-rtp"===t)u.packetsLost=r,u.packetsReceived=i,y.packetsLost=r,y.packetsReceived=i,y.packetsDiscarded=g,y.nackCount=q,y.lastPacketReceivedTimestamp=J,y.concealmentevents=Q,u.bytesReceived=o,void 0!==a&&(c.jitterBufferDelay=a/s*1e3,y.average_jitter_buffer_delay_ms=c.jitterBufferDelay),void 0!==p&&(u.totalSamplesReceived=p,c.concealedSamples=v,u.concealedSamples=v,u.silentConcealedSamples=_,y.concealedSamples=v,c.concealmentEvents=f,y.totalSamplesReceived=p),void 0!==Z&&(y.fec_packets_received=Z,u.fecPacketsReceived=Z),y.jitter=1e3*M,y.ssrc=Y,void 0!==k&&0!==k?(y.audio_level=k?-10*JC(Math.pow(k,2)):k,y.volume=255*k):(y.volume=null!=n?n:255*k,y.audio_level=n?-10*JC(Math.pow(n/255,2)):n),void 0!==T&&(y.total_audio_energy=T),void 0!==I&&(y.totalAudioDuration=I);else if("codec"===t)c.recordSampleRate=d,h&&(c.numChannels=h),y.codecName=R;else if("candidate-pair"===t){var $,ee;y.ice_available_incoming_bitrate=C,y.ice_available_outgoing_bitrate=x,y.ice_bytes_received=o,y.ice_bytes_sent=O,y.ice_nominated=Number(P),y.ice_pair_id=D,y.ice_pair_rtt=b,y.rtt=1e3*b,y.rtt&&null!==($=E._context.streamRTT)&&void 0!==$&&null!==(ee=$[l])&&void 0!==ee&&ee.audio&&(y.total_rtt_ms=Math.round(y.rtt+E._context.streamRTT[l].audio)),y.ice_pair_state=S,y.ice_pair_writable=N,y.recv_ping_requests=G,y.recv_ping_responses=z,y.sent_ping_requests_before_first_response=K,y.sent_ping_requests_total=K+(W||0),y.sent_ping_responses=X,"succeeded"===S&&(c.rtt=1e3*b,c.total_rtt=1e3*m)}else"track"===t&&void 0!==k?(0===k&&0!==n?(y.volume=n,y.audio_level=n?-10*JC(Math.pow(n/255,2)):n):(y.audio_level=k?-10*JC(Math.pow(k,2)):k,y.volume=255*k),y.total_audio_energy=T,y.totalAudioDuration=I):"ssrc"===t?(y.decodingNormal=A,y.recvAudioLevel=H,y.decodingMuted=w):"local-candidate"===t?(y.local_candidate_type=L,y.local_ip=U||V,y.local_network_type=F,y.local_port=B,y.protocol=j):"remote-candidate"===t&&(y.remote_candidate_type=L,y.remote_ip=U||V,y.remote_port=B)})),(b=r.audio).timestamp){e.next=18;break}return u.timestamp=Date.now(),r.audio=u,e.abrupt("return",this.filterIllegal(c));case 18:if(void 0===u.concealedSamples){e.next=25;break}return y.interval_concealed_samples=u.concealedSamples-b.concealedSamples,y.interval_samples_received=u.totalSamplesReceived-b.totalSamplesReceived,y.interval_silent_concealed_samples=u.silentConcealedSamples-b.silentConcealedSamples,e.next=24,this._stream.updateAudioStallInfo(y,c,u);case 24:k=e.sent;case 25:return u.timestamp=Date.now(),c.audioLossRate=(u.packetsLost-b.packetsLost)/(u.packetsReceived-b.packetsReceived+(u.packetsLost-b.packetsLost)),c.audioLossRate=Number.isNaN(c.audioLossRate)?0:c.audioLossRate,y.fraction_lost=c.audioLossRate,c.statsInterval=u.timestamp-b.timestamp,y.stats_interval=c.statsInterval,c.receivedKBitrate=(u.bytesReceived-b.bytesReceived||0)/c.statsInterval*8,y.bandwidth=Math.round(1e3*c.receivedKBitrate/1024),void 0!==u.concealedSamples&&(c.receivedSampleRate=1e3*y.interval_samples_received/c.statsInterval),void 0!==u.fecPacketsReceived&&(y.fecBitratebps=(u.fecPacketsReceived-b.fecPacketsReceived||0)/c.statsInterval),y.average_jitter_buffer_delay_ms&&y.total_rtt_ms&&(c.e2eDelay=y.average_jitter_buffer_delay_ms+y.total_rtt_ms),null!==(i=this._context.streamRTT)&&void 0!==i&&null!==(o=i[l])&&void 0!==o&&o.audio&&(c.totalRtt=(y.rtt?y.rtt:0)+this._context.streamRTT[l].audio),r.audio=u,y.vendor_mode=this._stream.vendorCode||0,y.pc_session_id=null===(a=this.handler)||void 0===a?void 0:a.peerConnectionId,null===(s=this._monitor)||void 0===s||s.report("rtc_media_statistics",y,k),e.abrupt("return",this.filterIllegal(c));case 42:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k=this;return Pg().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.userId,h=u.isScreen,p=u.subMediaType,v=u._attributes,_=Ql({media_type:"video",is_screen:!!h,direction:"down",stream_id:d,stream_user_id:l,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:zM(p)?"mute_state_off":"mute_state_on",remote_user_capture_state:v.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:v.localvideo&&v.videostream?"mute_state_off":"mute_state_on"},this._stream.getVideoRenderInfo()),t&&this.handler){e.next=6;break}return e.abrupt("return",s);case 6:return s.isScreen=h,e.next=9,this.handler.getStats(t);case 9:if((f=e.sent).length){e.next=12;break}return e.abrupt("return",s);case 12:if(f.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,i=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,u=e.framesDecoded,l=e.jitterBufferDelay,h=e.jitterBufferEmittedCount,p=e.mimeType,v=e.firCount,f=e.availableIncomingBitrate,m=e.availableOutgoingBitrate,g=e.bytesSent,y=e.nominated,S=e.id,b=e.currentRoundTripTime,E=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,P=e.protocol,D=e.requestsReceived,N=e.responsesReceived,M=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)c.packetsLost=i,_.packetsLost=i,c.packetsReceived=o,_.packetsReceived=o,c.bytesReceived=a,_.bytes=a,c.framesDecoded=u,c.totalDecodeTime=H,void 0!==l&&(c.jitterBufferDelay=l/h*1e3,_.average_jitter_buffer_delay_ms=c.jitterBufferDelay),_.fir_count=v,_.nackCount=x,c.nackCount=x,_.pli_count=O,_.ssrc=V,_.framesDropped=K,_.jitter=1e3*F,_.framesReceived=B,c.framesReceived=B,_.framesDecoded=u,_.key_frames_decoded=j,_.decoder_name=G,_.last_packet_received_timestamp=z,void 0!==n&&(s.width=n,_.frame_size_width=n,s.height=r,_.frame_size_height=r);else if("track"===t&&void 0!==n)s.width=n,_.frame_size_width=n,s.height=r,_.frame_size_height=r,void 0!==B&&(_.framesReceived=B,c.framesReceived=B);else if("codec"===t)_.codecName=p;else if("candidate-pair"===t){var W,X;_.ice_available_incoming_bitrate=f,_.ice_available_outgoing_bitrate=m,_.ice_bytes_received=a,_.ice_bytes_sent=g,_.ice_nominated=Number(y),_.ice_pair_id=S,_.ice_pair_rtt=b,_.rtt=1e3*b,_.rtt&&null!==(W=k._context.streamRTT)&&void 0!==W&&null!==(X=W[d])&&void 0!==X&&X.video&&(_.total_rtt_ms=Math.round(_.rtt+(k._context.streamRTT[d].video||0))),s.rtt=_.rtt,_.ice_pair_state=E,_.ice_pair_writable=T,_.recv_ping_requests=D,_.recv_ping_responses=N,_.sent_ping_requests_before_first_response=M,_.sent_ping_requests_total=M+(L||0),_.sent_ping_responses=U}else"local-candidate"===t?(_.local_candidate_type=I,_.local_ip=R||A,_.local_network_type=w,_.local_port=C,_.protocol=P):"remote-candidate"===t&&(_.remote_candidate_type=I,_.remote_ip=R||A,_.remote_port=C)})),(m=r.video).timestamp){e.next=17;break}return r.video=c,e.abrupt("return",this.filterIllegal(s));case 17:return g=c.packetsLost-m.packetsLost,y=c.packetsReceived-m.packetsReceived,s.videoLossRate=g/(y+g),m.totalDecodeTime&&m.framesDecoded&&c.framesDecoded!==m.framesDecoded&&(S=c.totalDecodeTime-m.totalDecodeTime,b=c.framesDecoded-m.framesDecoded,_.decode_elapse_per_frame=Number((S/b*1e3).toFixed(2))),s._retransmittedRate=(c.nackCount-m.nackCount)/(y+g),s.videoLossRate=Number.isNaN(s.videoLossRate)?0:s.videoLossRate,_.fraction_lost=s.videoLossRate,s.statsInterval=c.timestamp-m.timestamp,_.stats_interval=s.statsInterval,s.receivedKBitrate=(c.bytesReceived-m.bytesReceived||0)/s.statsInterval*8,_.bitrate=Math.round(1e3*s.receivedKBitrate),_.bandwidth=Math.round(_.bitrate/1024),s.decoderOutputFrameRate=1e3*(c.framesDecoded-m.framesDecoded)/s.statsInterval,s.receivedFrameRate=1e3*(c.framesReceived-m.framesReceived)/s.statsInterval,_.frame_rate_decoded=Math.round(s.decoderOutputFrameRate),_.frame_rate_received=Math.round(s.receivedFrameRate),_.average_jitter_buffer_delay_ms&&_.total_rtt_ms&&(s.e2eDelay=_.average_jitter_buffer_delay_ms+_.total_rtt_ms),null!==(n=this._context.streamRTT)&&void 0!==n&&null!==(i=n[d])&&void 0!==i&&i.video&&(s.totalRtt=(_.rtt?_.rtt:0)+(this._context.streamRTT[d].video||0)),r.video=c,this._stream.updateVideoStallInfo(_,s),_.vendor_mode=this._stream.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",_),e.abrupt("return",this.filterIllegal(s));case 41:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){MA(NA(o.prototype),"destroy",this).call(this),MA(NA(o.prototype),"stopReport",this).call(this,"destroy"),this._stream.stopAudioStallObserve()}}]),o}(FH),HH=function(){function e(t,r){Fh(this,e),ql(this,"_removeHandler",void 0),ql(this,"_remotePauseHandler",void 0),ql(this,"_prePts",void 0),ql(this,"_stallList",void 0),ql(this,"_videoInWaiting",!1),ql(this,"_videoInWaitingCallback",!1),ql(this,"_videoInWaiting100ms",!1),ql(this,"_isPaused",void 0),ql(this,"_pauseStart",0),ql(this,"_pauseDuration",0),ql(this,"_requestVideoFrameCallbackTimer",void 0),ql(this,"_logger",void 0),ql(this,"_player",void 0),ql(this,"_recentVideoInfo",void 0),ql(this,"_stallTimeThreshold",void 0),ql(this,"_openVideoStall100ms",GL.VIDEO_STALL_100MS);var n=t?1500:rL||tL?550:500;this._stallTimeThreshold={report:n,callback:Math.max(GL.VIDEO_STALL_DATA,n)},this._logger=new pM("VideoStallObserver",1,r)}return Vh(e,[{key:"start",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this._logger.print("start","invoke"),this._player=e,RM&&!r)e.domElement&&(this._requestVideoFrameCallbackTimer=e.domElement.requestVideoFrameCallback(this._onVideoRefresh.bind(this)),this._removeHandler=function(){var r;t._requestVideoFrameCallbackTimer&&(null===(r=e.domElement)||void 0===r||r.cancelVideoFrameCallback(t._requestVideoFrameCallbackTimer))});else{var n=function(r){return t._onVideoTimeupdate(r,e)};e.on("playback_event",n),this._removeHandler=function(){return e.off("playback_event",n)}}var i=function(e){return t._onVideoPause(e)};e.on("playback_event",i),this._remotePauseHandler=function(){return e.off("playback_event",i)}}},{key:"getRecentRenderInfo4Report",value:function(){var e=this,t={};return this._recentVideoInfo&&MS(this._recentVideoInfo).forEach((function(r){var n,i=r.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return Fg(t="".concat(e[0],"_")).call(t,e[1].toLowerCase())}));t["video_".concat(i)]=null===(n=e._recentVideoInfo)||void 0===n?void 0:n[r]})),t}},{key:"stop",value:function(){var e,t;this._logger.print("stop","invoke"),delete this._player,null===(e=this._removeHandler)||void 0===e||e.call(this),delete this._removeHandler,null===(t=this._remotePauseHandler)||void 0===t||t.call(this),delete this._remotePauseHandler,delete this._stallList,delete this._prePts,delete this._recentVideoInfo,this._videoInWaiting=!1,this._videoInWaitingCallback=!1,this._videoInWaiting100ms=!1}},{key:"destroy",value:function(){this.stop()}},{key:"getStallInfo",value:function(e){var t=this,r=e.interval,n=e.frameRateReceived,i=e.frameRateDecoded,o=e.bitrate,a={pts:0,report:{stallCount:0,stallDuration:0,list:[]},callback:{stallCount:0,stallDuration:0},pauseDuration:this._getPauseDuration()};this._stallList&&((rL||tL)&&(0===o||(i||1/0)<=1||(n||1/0)<=1)||0===this._stallList.length?(a.report.stallDuration=a.callback.stallDuration=2e3,a.report.stallCount=a.callback.stallCount=this._videoInWaiting?0:1,this._openVideoStall100ms&&(a.stall100ms={count:this._videoInWaiting100ms?0:1,duration:2e3}),this._videoInWaiting=!0,this._videoInWaitingCallback=!0,this._videoInWaiting100ms=!0):this._stallList.forEach((function(e,n){var i=e.timeUpdateInterval;0===n&&t._videoInWaiting&&(i=Math.round(e.timeUpdateInterval%r));var o=e.timeUpdateInterval>t._stallTimeThreshold.report;o&&(a.report.list.push(e.timeUpdateInterval),a.report.stallDuration+=i,t._videoInWaiting||a.report.stallCount++),t._videoInWaiting=o,e.timeUpdateInterval>t._stallTimeThreshold.callback?(a.callback.stallDuration+=i,t._videoInWaitingCallback||a.callback.stallCount++,t._videoInWaitingCallback=!0):t._videoInWaitingCallback=!1,t._openVideoStall100ms&&(a.stall100ms||(a.stall100ms={count:0,duration:0}),e.timeUpdateInterval>100?(a.stall100ms.duration+=i,t._videoInWaiting100ms||a.stall100ms.count++,t._videoInWaiting100ms=!0):t._videoInWaiting100ms=!1),a.pts=e.playTime})),this._stallList=[]);return a}},{key:"_getPauseDuration",value:function(){var e=this._pauseDuration;if(this._pauseDuration=0,this._isPaused){var t=IM(),r=t-(this._pauseStart||0);r>500&&(this._pauseStart=t,e+=r)}return e}},{key:"_onVideoPause",value:function(e){if("pause"===e.eventName)this._isPaused=!0,this._pauseStart=IM();else if("play"===e.eventName&&this._isPaused){this._isPaused=!1;var t=IM()-this._pauseStart;t>500&&(this._pauseDuration+=t)}}},{key:"_onVideoTimeupdate",value:function(e,t){if("timeupdate"===e.eventName){var r=t.domElement;if(!r||0===r.currentTime)return;if(void 0===this._prePts)return void(this._prePts=r.currentTime);if(this._stallList||(this._stallList=[]),r.currentTime>this._prePts){var n=r.currentTime-this._prePts;this._stallList.push({playTime:r.currentTime,timeUpdateInterval:Math.round(1e3*n)})}this._prePts=r.currentTime}}},{key:"_onVideoRefresh",value:function(e,t){var r,n;if(this._stallList||(this._stallList=[]),this._prePts){var i=t.presentationTime-this._prePts;this._stallList.push({playTime:t.presentationTime,timeUpdateInterval:Math.round(i)})}this._recentVideoInfo=t,this._prePts=t.presentationTime,null===(r=this._player)||void 0===r||null===(n=r.domElement)||void 0===n||n.requestVideoFrameCallback(this._onVideoRefresh.bind(this))}}]),e}(),GH=function(){function e(t){Fh(this,e),ql(this,"_audioStallTimer",void 0),ql(this,"_preSample",void 0),ql(this,"_isStallInPreCallbackEnd",!1),ql(this,"_isStallInPreReportEnd",!1),ql(this,"_stallList",[]),this._stream=t}var t,r;return Vh(e,[{key:"start",value:function(t,r){this.stop(),GL.AUDIO_STALL&&e.interval>0&&"number"==typeof t&&"number"==typeof r&&(this._preSample={ts:IM(),concealedSamples:t,totalSamplesReceived:r},this._startStallCountInterval())}},{key:"stop",value:function(){this._stallList=[],this._audioStallTimer&&(clearTimeout(this._audioStallTimer),delete this._audioStallTimer)}},{key:"destroy",value:function(){this.stop()}},{key:"getAudioStallInfo",value:(r=Ng(Pg().mark((function t(){var r,n,i,o,a;return Pg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={stats_count:Ty(r=this._stallList).call(r,(function(e){return!!e.get_stats_cost})).length,stall_list:tR(this._stallList)},t.prev=1,t.next=4,this._audioStallCount();case 4:t.next=8;break;case 6:t.prev=6,t.t0=t.catch(1);case 8:return i=WH(this._stallList,2,this._isStallInPreReportEnd),this._isStallInPreReportEnd=i.isStallInEnd,o=GL.AUDIO_STALL_DATA/e.interval,a=WH(this._stallList,o,this._isStallInPreCallbackEnd),this._isStallInPreCallbackEnd=a.isStallInEnd,this.stop(),this._startStallCountInterval(),t.abrupt("return",{report:{stall_count:i.stall_count,stall_duration:i.stall_duration,list:i.list},callback:{stall_count:a.stall_count,stall_duration:a.stall_duration,list:a.list},extra:n});case 16:case"end":return t.stop()}}),t,this,[[1,6]])}))),function(){return r.apply(this,arguments)})},{key:"_startStallCountInterval",value:function(){var t=this,r=function(){var n=Ng(Pg().mark((function n(){return Pg().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return clearTimeout(t._audioStallTimer),delete t._audioStallTimer,n.next=4,t._audioStallCount();case 4:t._audioStallTimer||(t._audioStallTimer=setTimeout(r,e.interval));case 5:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}();this._audioStallTimer=setTimeout(r,e.interval)}},{key:"_audioStallCount",value:(t=Ng(Pg().mark((function t(){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R;return Pg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._preSample&&!(IM()-this._preSample.ts<.5*e.interval)){t.next=2;break}return t.abrupt("return");case 2:if(r=this._stream,n=r.hasAudio,i=r.subAudio,o=r.virtual,a=r.virtualOccupy,s=r.removeTrack,c=r.audioTrack,!s&&c){t.next=7;break}return clearTimeout(this._audioStallTimer),delete this._audioStallTimer,t.abrupt("return");case 7:if((u=n&&i)&&(!o||a)){t.next=13;break}this._preSample.ts=IM(),this._stallList.push({reason:u?Fg(l="virtual: ".concat(o,", virtualOccupy: ")).call(l,a):Fg(d="hasAudio: ".concat(n,", subAudio: ")).call(d,i)}),t.next=29;break;case 13:return h=IM(),_=0,t.prev=15,t.next=18,null===(f=this._stream.audioTransceiver)||void 0===f?void 0:f.receiver.getStats();case 18:null==(m=t.sent)||m.forEach((function(e){"inbound-rtp"===e.type&&(p=e),_++})),t.next=25;break;case 22:t.prev=22,t.t0=t.catch(15),v=t.t0.message||Gg(t.t0);case 25:g=IM(),y=IM(),S=y-this._preSample.ts,p?(k=(b=p).concealedSamples,E=b.totalSamplesReceived,T=k-this._preSample.concealedSamples,I=E-this._preSample.totalSamplesReceived,R=T>=0&&I>=0&&T>=e.ratio*I,this._stallList.push({concealed:T,received:I,diff:S,start:this._preSample.ts,end:y,get_stats_cost:g-h,get_stats_start:h,get_stats_end:g,is_stall:R}),this._preSample.concealedSamples=k,this._preSample.totalSamplesReceived=E,this._preSample.ts=y):this._stallList.push({diff:S,start:this._preSample.ts,end:y,get_stats_cost:g-h,get_stats_start:h,get_stats_end:g,reason:_?v||"no inbound-rtp":"no report"});case 29:case"end":return t.stop()}}),t,this,[[15,22]])}))),function(){return t.apply(this,arguments)})}],[{key:"setAudioStallConfig",value:function(t){e.interval=((null==t?void 0:t.audio_stall_interval)||200)/2,e.ratio=(null==t?void 0:t.audio_stall_ratio)||.6}}]),e}();ql(GH,"interval",100),ql(GH,"ratio",.6);var zH,KH,WH=function(e,t,r){for(var n,i={stall_count:0,stall_duration:0,isStallInEnd:!1,list:[]},o=0,a=0,s=0;s<e.length;s++){var c=e[s];c.is_stall&&(o++,a+=c.diff||0);var u=s===e.length-1;if(!c.is_stall||u){var d=o>=t,l=s+t-o-1;if(!d&&o>2){var h=0;sI(e).call(e,s+1,l+1).forEach((function(e){e.is_stall&&(h+=e.diff||0)})),(d=a+h>GH.interval*t*GH.ratio)&&(s=l,a+=h)}d&&(i.stall_count++,i.stall_duration+=a,i.list.push(a)),u&&(i.isStallInEnd=d),o=a=0}}return!0===(null===(n=e[0])||void 0===n?void 0:n.is_stall)&&r&&i.stall_count>0&&i.stall_count--,i},XH=function(e){UA(r,e);var t=ew(r);function r(e){var n;return Fh(this,r),ql(aA(n=t.call(this)),"_videoPlayer",void 0),ql(aA(n),"isScreen",!1),ql(aA(n),"audioMid",void 0),ql(aA(n),"videoMid",void 0),ql(aA(n),"videoTransceiver",void 0),ql(aA(n),"audioTransceiver",void 0),ql(aA(n),"vendorHandler",void 0),ql(aA(n),"vendorCode",0),ql(aA(n),"engineId",void 0),ql(aA(n),"logger",void 0),n.engineId=e.id,n.logger=new pM("Stream",0,e.id),n}return Vh(r,[{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}(kU),YH=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(YH||{}),qH=function(e){UA(r,e);var t=ew(r);function r(e){var n;return Fh(this,r),ql(aA(n=t.call(this,e)),"id",void 0),ql(aA(n),"stream",void 0),ql(aA(n),"streamId",void 0),ql(aA(n),"seiList",[]),ql(aA(n),"videoTrack",void 0),ql(aA(n),"audioTrack",void 0),ql(aA(n),"videoEncodeConfig",[qL]),ql(aA(n),"subVideoDescriptions",[]),ql(aA(n),"enableSimulcast",!1),ql(aA(n),"observer",void 0),ql(aA(n),"statsReport",void 0),ql(aA(n),"prevBitrate",0),ql(aA(n),"pubAudio",!1),ql(aA(n),"pubVideo",!1),ql(aA(n),"pubAttributes",void 0),ql(aA(n),"pcSessionId",void 0),n.stream=new MediaStream,n.id=px(),n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1,videoDescriptions:[]},n.statsReport=new BH(e,aA(n)),n}return Vh(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(BB()){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=VH.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)BI(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 this.logger.warn("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender){var e=this.audioTransceiver.sender.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else this.logger.warn("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){JN(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),MA(NA(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.mediaTrack;return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}},{key:"resetStream",value:function(){this.stream=new MediaStream}}]),r}(XH),JH=function(e){UA(n,e);var t,r=ew(n);function n(e,t,i,o,a,s){var c;return Fh(this,n),ql(aA(c=r.call(this,e)),"streamId",void 0),ql(aA(c),"userId",void 0),ql(aA(c),"isPublic",void 0),ql(aA(c),"hasVideo",void 0),ql(aA(c),"hasAudio",void 0),ql(aA(c),"_attributes",void 0),ql(aA(c),"streamState",void 0),ql(aA(c),"removeTrack",!1),ql(aA(c),"observer",void 0),ql(aA(c),"statsReport",void 0),ql(aA(c),"subVideo",void 0),ql(aA(c),"subAudio",void 0),ql(aA(c),"subMediaType",void 0),ql(aA(c),"subLayer",void 0),ql(aA(c),"_sequenceId",void 0),ql(aA(c),"stream",void 0),ql(aA(c),"videoTrack",void 0),ql(aA(c),"audioTrack",void 0),ql(aA(c),"recordedVideoFrames",void 0),ql(aA(c),"stillExist",void 0),ql(aA(c),"originalMediaType",void 0),ql(aA(c),"priority",void 0),ql(aA(c),"originalStreamIndex",0),ql(aA(c),"virtual",void 0),ql(aA(c),"pcSessionId",void 0),ql(aA(c),"_virtualOccupy",void 0),ql(aA(c),"_videoStallObserver",void 0),ql(aA(c),"_audioStallObserver",void 0),ql(aA(c),"_handler",void 0),c.virtual=!1,c._virtualOccupy=!1,c.userId=t,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=xH.NONE,c.subLayer={spatialLayer:0,spatialSubLayer:-1},c.streamState=0,c.statsReport=new jH(e,aA(c)),c.enableVendorMode&&(c.pcSessionId=px()),c}return Vh(n,[{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:"startReport",value:function(e,t){this.statsReport.setRemoteStreamStatsEvtInterval(e,t),this._handler=t}},{key:"getStats",value:function(e,t){var r;return null===(r=this._handler)||void 0===r?void 0:r.getStats(e,t)}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){OH.getNalunits(new PH(t.data)).forEach((function(t){if(t.sei){var r=VH.decodeSeiBody(t.body);r&&r.type!==DH.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else this.logger.warn("no receiver found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){var e=this;if(this.audioTransceiver&&this.audioTransceiver.receiver){var t=this.audioTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){t.data.byteLength<=1e3?r.enqueue(t):e.logger.print("too large audio frame",t.data.byteLength)}})).pipeTo(n)}else this.logger.warn("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n;try{var i;JN(this.engineId,"Stream.ontrack",Gg({uid:this.userId,streamId:this.streamId,streams:oS(i=e.streams).call(i,(function(e,t){return e+mx(t)}),""),transceiver:Sx(e.transceiver),track:fx(e.track)}),0,this.streamId||"")}catch(jZ){}if(this.enableVendorMode||null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&Xy(n).call(n,this.streamId)){var o,a=e.track;"video"===(null==a?void 0:a.kind)?this._setVideoTrack(a):"audio"===(null===(o=e.track)||void 0===o?void 0:o.kind)&&this._setAudioTrack(a),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"startVideoStallObserve",value:function(e){this.logger.info("startVideoStallObserve","invoke"),this._videoStallObserver||(this._videoStallObserver=new HH(this.isScreen,this.engineId)),this._videoStallObserver.start(e),this._videoPlayer=e}},{key:"stopVideoStallObserve",value:function(){var e;this.logger.info("stopVideoStallObserve","invoke"),null===(e=this._videoStallObserver)||void 0===e||e.stop(),delete this._videoPlayer}},{key:"updateVideoStallInfo",value:function(e,t){var r,n=null===(r=this._videoStallObserver)||void 0===r?void 0:r.getStallInfo({interval:e.stats_interval||0,bitrate:e.bitrate,frameRateDecoded:e.frame_rate_decoded,frameRateReceived:e.frame_rate_received});if(n){var i=Math.min(n.report.stallDuration,e.stats_interval||0);if(e.play_time=n.pts,e.stall_count=n.report.stallCount,e.is_screen?e.stuck_length=i:e.stall_duration=i,e.pause_duration=Math.min(i,n.pauseDuration),t.stallCount=n.callback.stallCount,t.stallDuration=n.callback.stallDuration,n.stall100ms){var o=Math.min(n.stall100ms.duration,e.stats_interval||0);e.stall_duration_100ms=o,e.stall_count_100ms=n.stall100ms.count,t.stallDuration100MS=o,t.stallCount100MS=n.stall100ms.count}0===n.report.stallCount&&0===n.report.stallDuration||this.logger.print("video_stall_report",this.userId,Gg(n.report))}}},{key:"getVideoRenderInfo",value:function(){var e;return(null===(e=this._videoStallObserver)||void 0===e?void 0:e.getRecentRenderInfo4Report())||{}}},{key:"stopAudioStallObserve",value:function(){var e;this.logger.info("stopAudioStallObserve","invoke"),null===(e=this._audioStallObserver)||void 0===e||e.stop()}},{key:"updateAudioStallInfo",value:(t=Ng(Pg().mark((function e(t,r,n){var i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._audioStallObserver){e.next=6;break}this._audioStallObserver=new GH(this),this._audioStallObserver.start(n.concealedSamples,n.totalSamplesReceived),this.logger.print("startAduioObserver","start"),e.next=12;break;case 6:return e.next=8,this._audioStallObserver.getAudioStallInfo();case 8:return i=e.sent,t.concealedSamples===t.interval_concealed_samples&&t.totalSamplesReceived===t.interval_samples_received?(t.stall_count=0,t.stall_duration=0,r.stallCount=0,r.stallDuration=0):(t.stall_count=i.report.stall_count,t.stall_duration=i.report.stall_duration,r.stallCount=i.callback.stall_count,r.stallDuration=i.callback.stall_duration),0===i.report.stall_count&&0===i.report.stall_duration||this.logger.print("audio_stall_report",this.userId,Gg(Ql(Ql({},i.report),{},{callbackList:i.callback.list}))),e.abrupt("return",i.extra);case 12:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"clean",value:function(){var e,t;this.logger.info("clean",Fg(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),JN(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),MA(NA(n.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(){var e,t;this.clean(),null===(e=this._audioStallObserver)||void 0===e||e.destroy(),delete this._audioStallObserver,null===(t=this._videoStallObserver)||void 0===t||t.destroy(),delete this._videoStallObserver,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.preprocessingTrack)||void 0===r?void 0:r.id)!==e.id&&(this.audioTrack=yH(e),this.emit("ontrack",this.audioTrack))}},{key:"_setVideoTrack",value:function(e){var t,r;(null===(t=this.videoTrack)||void 0===t||null===(r=t.preprocessingTrack)||void 0===r?void 0:r.id)!==e.id&&(this.videoTrack=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:TM();return new Qj(e,t)}(e),this.emit("ontrack",this.videoTrack))}}]),n}(XH),QH=new pM("queue",4),ZH=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(ZH||{}),$H=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}($H||{}),eG=(ql(zH={},"publish","unpublish"),ql(zH,"subscribe","unsubscribe"),ql(zH,"pushtrack","removetrack"),zH),tG=(ql(KH={},"publish",0),ql(KH,"subscribe",0),ql(KH,"pushtrack",0),ql(KH,"unpublish",1),ql(KH,"unsubscribe",1),ql(KH,"removetrack",1),KH),rG=function(e){UA(r,e);var t=ew(r);function r(){var e;return Fh(this,r),ql(aA(e=t.call(this)),"_queue",void 0),e._queue=[],e}return Vh(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t,r=this._queue.length,n="";return this._queue=Ty(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==eG[t.action]||(n=t.streamId,QH.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;nL&&AL>=86&&AL<=92&&(t=Math.min(this._queue.length,5));for(var r=tG[this._queue[0].action],n=1;n<t;n++){var i;if(tG[this._queue[n].action]!==r)return{sdpStrategy:r,items:BI(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:BI(e=this._queue).call(e,0,t)}}}]),r}(SU),nG="object"==typeof global&&global&&global.Object===Object&&global,iG="object"==typeof self&&self&&self.Object===Object&&self,oG=nG||iG||Function("return this")(),aG=oG.Symbol,sG=Object.prototype,cG=sG.hasOwnProperty,uG=sG.toString,dG=aG?aG.toStringTag:void 0;var lG=Object.prototype.toString;var hG="[object Null]",pG="[object Undefined]",vG=aG?aG.toStringTag:void 0;function _G(e){return null==e?void 0===e?pG:hG:vG&&vG in Object(e)?function(e){var t=cG.call(e,dG),r=e[dG];try{e[dG]=void 0;var n=!0}catch(o){}var i=uG.call(e);return n&&(t?e[dG]=r:delete e[dG]),i}(e):function(e){return lG.call(e)}(e)}function fG(e){return null!=e&&"object"==typeof e}var mG=Array.isArray;function gG(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function yG(e){return e}var SG="[object AsyncFunction]",bG="[object Function]",kG="[object GeneratorFunction]",EG="[object Proxy]";function TG(e){if(!gG(e))return!1;var t=_G(e);return t==bG||t==kG||t==SG||t==EG}var IG,RG=oG["__core-js_shared__"],AG=(IG=/[^.]+$/.exec(RG&&RG.keys&&RG.keys.IE_PROTO||""))?"Symbol(src)_1."+IG:"";var wG=Function.prototype.toString;function CG(e){if(null!=e){try{return wG.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var xG=/^\[object .+?Constructor\]$/,OG=Function.prototype,PG=Object.prototype,DG=OG.toString,NG=PG.hasOwnProperty,MG=RegExp("^"+DG.call(NG).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function LG(e){return!(!gG(e)||(t=e,AG&&AG in t))&&(TG(e)?MG:xG).test(CG(e));var t}function UG(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return LG(r)?r:void 0}var VG=UG(oG,"WeakMap"),FG=Object.create,BG=function(){function e(){}return function(t){if(!gG(t))return{};if(FG)return FG(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();var jG=Date.now;var HG,GG,zG,KG=function(){try{var e=UG(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),WG=KG,XG=WG?function(e,t){return WG(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:yG,YG=(HG=XG,GG=0,zG=0,function(){var e=jG(),t=16-(e-zG);if(zG=e,t>0){if(++GG>=800)return arguments[0]}else GG=0;return HG.apply(void 0,arguments)}),qG=YG;var JG=9007199254740991,QG=/^(?:0|[1-9]\d*)$/;function ZG(e,t){var r=typeof e;return!!(t=null==t?JG:t)&&("number"==r||"symbol"!=r&&QG.test(e))&&e>-1&&e%1==0&&e<t}function $G(e,t,r){"__proto__"==t&&WG?WG(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function ez(e,t){return e===t||e!=e&&t!=t}var tz=Object.prototype.hasOwnProperty;function rz(e,t,r){var n=e[t];tz.call(e,t)&&ez(n,r)&&(void 0!==r||t in e)||$G(e,t,r)}function nz(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?$G(r,s,c):rz(r,s,c)}return r}var iz=Math.max;function oz(e,t){return qG(function(e,t,r){return t=iz(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=iz(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),function(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)}(e,this,s)}}(e,t,yG),e+"")}var az=9007199254740991;function sz(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=az}function cz(e){return null!=e&&sz(e.length)&&!TG(e)}var uz=Object.prototype;function dz(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||uz)}function lz(e){return fG(e)&&"[object Arguments]"==_G(e)}var hz=Object.prototype,pz=hz.hasOwnProperty,vz=hz.propertyIsEnumerable,_z=lz(function(){return arguments}())?lz:function(e){return fG(e)&&pz.call(e,"callee")&&!vz.call(e,"callee")},fz=_z;var mz="object"==typeof exports&&exports&&!exports.nodeType&&exports,gz=mz&&"object"==typeof module&&module&&!module.nodeType&&module,yz=gz&&gz.exports===mz?oG.Buffer:void 0,Sz=(yz?yz.isBuffer:void 0)||function(){return!1},bz={};function kz(e){return function(t){return e(t)}}bz["[object Float32Array]"]=bz["[object Float64Array]"]=bz["[object Int8Array]"]=bz["[object Int16Array]"]=bz["[object Int32Array]"]=bz["[object Uint8Array]"]=bz["[object Uint8ClampedArray]"]=bz["[object Uint16Array]"]=bz["[object Uint32Array]"]=!0,bz["[object Arguments]"]=bz["[object Array]"]=bz["[object ArrayBuffer]"]=bz["[object Boolean]"]=bz["[object DataView]"]=bz["[object Date]"]=bz["[object Error]"]=bz["[object Function]"]=bz["[object Map]"]=bz["[object Number]"]=bz["[object Object]"]=bz["[object RegExp]"]=bz["[object Set]"]=bz["[object String]"]=bz["[object WeakMap]"]=!1;var Ez="object"==typeof exports&&exports&&!exports.nodeType&&exports,Tz=Ez&&"object"==typeof module&&module&&!module.nodeType&&module,Iz=Tz&&Tz.exports===Ez&&nG.process,Rz=function(){try{var e=Tz&&Tz.require&&Tz.require("util").types;return e||Iz&&Iz.binding&&Iz.binding("util")}catch(t){}}(),Az=Rz&&Rz.isTypedArray,wz=Az?kz(Az):function(e){return fG(e)&&sz(e.length)&&!!bz[_G(e)]},Cz=Object.prototype.hasOwnProperty;function xz(e,t){var r=mG(e),n=!r&&fz(e),i=!r&&!n&&Sz(e),o=!r&&!n&&!i&&wz(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&&!Cz.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||ZG(u,c))||s.push(u);return s}function Oz(e,t){return function(r){return e(t(r))}}var Pz=Oz(Object.keys,Object),Dz=Object.prototype.hasOwnProperty;function Nz(e){return cz(e)?xz(e):function(e){if(!dz(e))return Pz(e);var t=[];for(var r in Object(e))Dz.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var Mz=Object.prototype.hasOwnProperty;function Lz(e){if(!gG(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=dz(e),r=[];for(var n in e)("constructor"!=n||!t&&Mz.call(e,n))&&r.push(n);return r}function Uz(e){return cz(e)?xz(e,!0):Lz(e)}var Vz,Fz=(Vz=function(e,t){nz(t,Uz(t),e)},oz((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=Vz.length>3&&"function"==typeof i?(n--,i):void 0,o&&function(e,t,r){if(!gG(r))return!1;var n=typeof t;return!!("number"==n?cz(r)&&ZG(t,r.length):"string"==n&&t in r)&&ez(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&&Vz(e,a,r,i)}return e}))),Bz=UG(Object,"create");var jz=Object.prototype.hasOwnProperty;var Hz=Object.prototype.hasOwnProperty;function Gz(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 zz(e,t){for(var r=e.length;r--;)if(ez(e[r][0],t))return r;return-1}Gz.prototype.clear=function(){this.__data__=Bz?Bz(null):{},this.size=0},Gz.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Gz.prototype.get=function(e){var t=this.__data__;if(Bz){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return jz.call(t,e)?t[e]:void 0},Gz.prototype.has=function(e){var t=this.__data__;return Bz?void 0!==t[e]:Hz.call(t,e)},Gz.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Bz&&void 0===t?"__lodash_hash_undefined__":t,this};var Kz=Array.prototype.splice;function Wz(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])}}Wz.prototype.clear=function(){this.__data__=[],this.size=0},Wz.prototype.delete=function(e){var t=this.__data__,r=zz(t,e);return!(r<0)&&(r==t.length-1?t.pop():Kz.call(t,r,1),--this.size,!0)},Wz.prototype.get=function(e){var t=this.__data__,r=zz(t,e);return r<0?void 0:t[r][1]},Wz.prototype.has=function(e){return zz(this.__data__,e)>-1},Wz.prototype.set=function(e,t){var r=this.__data__,n=zz(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var Xz=UG(oG,"Map");function Yz(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 qz(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 Jz(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}qz.prototype.clear=function(){this.size=0,this.__data__={hash:new Gz,map:new(Xz||Wz),string:new Gz}},qz.prototype.delete=function(e){var t=Yz(this,e).delete(e);return this.size-=t?1:0,t},qz.prototype.get=function(e){return Yz(this,e).get(e)},qz.prototype.has=function(e){return Yz(this,e).has(e)},qz.prototype.set=function(e,t){var r=Yz(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};var Qz=Oz(Object.getPrototypeOf,Object);function Zz(e){var t=this.__data__=new Wz(e);this.size=t.size}Zz.prototype.clear=function(){this.__data__=new Wz,this.size=0},Zz.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Zz.prototype.get=function(e){return this.__data__.get(e)},Zz.prototype.has=function(e){return this.__data__.has(e)},Zz.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Wz){var n=r.__data__;if(!Xz||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new qz(n)}return r.set(e,t),this.size=r.size,this};var $z="object"==typeof exports&&exports&&!exports.nodeType&&exports,eK=$z&&"object"==typeof module&&module&&!module.nodeType&&module,tK=eK&&eK.exports===$z?oG.Buffer:void 0,rK=tK?tK.allocUnsafe:void 0;function nK(){return[]}var iK=Object.prototype.propertyIsEnumerable,oK=Object.getOwnPropertySymbols,aK=oK?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}(oK(e),(function(t){return iK.call(e,t)})))}:nK;var sK=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Jz(t,aK(e)),e=Qz(e);return t}:nK;function cK(e,t,r){var n=t(e);return mG(e)?n:Jz(n,r(e))}function uK(e){return cK(e,Nz,aK)}function dK(e){return cK(e,Uz,sK)}var lK=UG(oG,"DataView"),hK=UG(oG,"Promise"),pK=UG(oG,"Set"),vK="[object Map]",_K="[object Promise]",fK="[object Set]",mK="[object WeakMap]",gK="[object DataView]",yK=CG(lK),SK=CG(Xz),bK=CG(hK),kK=CG(pK),EK=CG(VG),TK=_G;(lK&&TK(new lK(new ArrayBuffer(1)))!=gK||Xz&&TK(new Xz)!=vK||hK&&TK(hK.resolve())!=_K||pK&&TK(new pK)!=fK||VG&&TK(new VG)!=mK)&&(TK=function(e){var t=_G(e),r="[object Object]"==t?e.constructor:void 0,n=r?CG(r):"";if(n)switch(n){case yK:return gK;case SK:return vK;case bK:return _K;case kK:return fK;case EK:return mK}return t});var IK=TK,RK=Object.prototype.hasOwnProperty;var AK=oG.Uint8Array;function wK(e){var t=new e.constructor(e.byteLength);return new AK(t).set(new AK(e)),t}var CK=/\w*$/;var xK=aG?aG.prototype:void 0,OK=xK?xK.valueOf:void 0;var PK="[object Boolean]",DK="[object Date]",NK="[object Map]",MK="[object Number]",LK="[object RegExp]",UK="[object Set]",VK="[object String]",FK="[object Symbol]",BK="[object ArrayBuffer]",jK="[object DataView]",HK="[object Float32Array]",GK="[object Float64Array]",zK="[object Int8Array]",KK="[object Int16Array]",WK="[object Int32Array]",XK="[object Uint8Array]",YK="[object Uint8ClampedArray]",qK="[object Uint16Array]",JK="[object Uint32Array]";function QK(e,t,r){var n,i,o,a=e.constructor;switch(t){case BK:return wK(e);case PK:case DK:return new a(+e);case jK:return function(e,t){var r=t?wK(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case HK:case GK:case zK:case KK:case WK:case XK:case YK:case qK:case JK:return function(e,t){var r=t?wK(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,r);case NK:return new a;case MK:case VK:return new a(e);case LK:return(o=new(i=e).constructor(i.source,CK.exec(i))).lastIndex=i.lastIndex,o;case UK:return new a;case FK:return n=e,OK?Object(OK.call(n)):{}}}var ZK=Rz&&Rz.isMap,$K=ZK?kz(ZK):function(e){return fG(e)&&"[object Map]"==IK(e)};var eW=Rz&&Rz.isSet,tW=eW?kz(eW):function(e){return fG(e)&&"[object Set]"==IK(e)},rW=1,nW=2,iW=4,oW="[object Arguments]",aW="[object Function]",sW="[object GeneratorFunction]",cW="[object Object]",uW={};function dW(e,t,r,n,i,o){var a,s=t&rW,c=t&nW,u=t&iW;if(r&&(a=i?r(e,n,i,o):r(e)),void 0!==a)return a;if(!gG(e))return e;var d=mG(e);if(d){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&RK.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=IK(e),h=l==aW||l==sW;if(Sz(e))return function(e,t){if(t)return e.slice();var r=e.length,n=rK?rK(r):new e.constructor(r);return e.copy(n),n}(e,s);if(l==cW||l==oW||h&&!i){if(a=c||h?{}:function(e){return"function"!=typeof e.constructor||dz(e)?{}:BG(Qz(e))}(e),!s)return c?function(e,t){return nz(e,sK(e),t)}(e,function(e,t){return e&&nz(t,Uz(t),e)}(a,e)):function(e,t){return nz(e,aK(e),t)}(e,function(e,t){return e&&nz(t,Nz(t),e)}(a,e))}else{if(!uW[l])return i?e:{};a=QK(e,l,s)}}o||(o=new Zz);var p=o.get(e);if(p)return p;o.set(e,a),tW(e)?e.forEach((function(n){a.add(dW(n,t,r,n,e,o))})):$K(e)&&e.forEach((function(n,i){a.set(i,dW(n,t,r,i,e,o))}));var v=d?void 0:(u?c?dK:uK:c?Uz:Nz)(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]),rz(a,i,dW(n,t,r,i,e,o))})),a}uW[oW]=uW["[object Array]"]=uW["[object ArrayBuffer]"]=uW["[object DataView]"]=uW["[object Boolean]"]=uW["[object Date]"]=uW["[object Float32Array]"]=uW["[object Float64Array]"]=uW["[object Int8Array]"]=uW["[object Int16Array]"]=uW["[object Int32Array]"]=uW["[object Map]"]=uW["[object Number]"]=uW[cW]=uW["[object RegExp]"]=uW["[object Set]"]=uW["[object String]"]=uW["[object Symbol]"]=uW["[object Uint8Array]"]=uW["[object Uint8ClampedArray]"]=uW["[object Uint16Array]"]=uW["[object Uint32Array]"]=!0,uW["[object Error]"]=uW[aW]=uW["[object WeakMap]"]=!1;function lW(e){return dW(e,5)}function hW(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 pW(e){return null==e?[]:hW(e,Nz(e))}var vW,_W,fW=BB(),mW=function(e){UA(u,e);var t,r,n,i,o,a,s,c=ew(u);function u(e,t){var r;return Fh(this,u),ql(aA(r=c.call(this,e,t)),"name","chrome"),ql(aA(r),"_queueBusy",!1),ql(aA(r),"_sdpQueue",void 0),ql(aA(r),"_aSendonlyOfferTpl",void 0),ql(aA(r),"_vSendonlyOfferTpl",void 0),ql(aA(r),"_aRecvonlyOfferTpl",void 0),ql(aA(r),"_vRecvonlyOfferTpl",void 0),ql(aA(r),"_mid",10),ql(aA(r),"_inactiveMlineIndex",[]),ql(aA(r),"_mlinesCache",{}),ql(aA(r),"setDescription",void 0),r.logger=new pM("ChromeHandler",3,e.id),r.setDescription=t.setDescription.bind(t),r._sdpQueue=new rG,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(r.logger.info("dequeue start"),r.dequeue())})),r}return Vh(u,[{key:"destroy",value:function(){MA(NA(u.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(s=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M,L,U,V,F,B;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d=t.stream,l=t.enableSimulcast,h=MA(NA(u.prototype),"internalPublish",this).call(this,t),p=h.videoDescriptions,v=h.subVideoDescriptions,_=h.audioTransceiverInit,f=h.videoTransceiverInit,m=_j(this._nextSsrc),this._nextSsrc=m.next,g="".concat(this._mid++),y="".concat(this._mid++),S=Ql(Ql(Ql({},this._aSendonlyOfferTpl),this.peer._offerIce),{},{mid:g,msid:Fg(r="".concat(d.id," ")).call(r,d.id,"-audio"),ssrcs:fj(d.id,"audio",m.audio,vj)}),b=Ql(Ql(Ql({},this._vSendonlyOfferTpl),this.peer._offerIce),{},{mid:y,msid:Fg(n="".concat(d.id," ")).call(n,d.id,"-video")}),l?(this.logger.info("subVideoDesc","desc: %o ",v),delete b.ssrcGroups,delete b.ssrcs,k=[],b.rids=qg(p).call(p,(function(e){var t=e.rid;return k.unshift(t),{id:t,direction:"send"}})),b.simulcast={dir1:"send",list1:k.join(";")}):(E=mj(d.id,m,{cname:vj}),T=E.ssrcs,I=E.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=eC(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(C=BI(w=S.rtp).call(w,A,1),x=gy(C,1),O=x[0],S.rtp.unshift(O)),P=[],S.rtp.forEach((function(e){return P.push(e.payload)})),S.payloads=P.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&Tj(b,null===(D=this._context)||void 0===D||null===(N=D.serverConfig)||void 0===N?void 0:N.videoCodec),Array.isArray(b.ext)&&(KL("IOS_SAFARI_ORIENTATION")||!rL&&!vL||(b.ext=Ty(L=b.ext).call(L,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&Xy(t).call(t,"video-orientation"))}))),b.ext=Ty(M=b.ext).call(M,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&Xy(t).call(t,"framemarking"))}))),(U=null==S?void 0:aI(c=S.rtp).call(c,(function(e){return"opus"===e.codec})))&&S.fmtp&&(B=aI(V=S.fmtp).call(V,(function(e){return e.payload===U.payload})))&&null!==(F=this._context)&&void 0!==F&&F.audioProfileManager&&(B.config=this._context.audioProfileManager.getOpusConfigStr(B.config)),l||rL||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:yj(this.peer._offerSession,S,b),audioMid:g,videoMid:y,type:"incroffer",semantics:"unified-plan",videoDescriptions:p,subVideoDescriptions:v,audioTransceiverInit:_,videoTransceiverInit:f,peerConnectionMode:this.peerConnectionMode});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"subscribe",value:(a=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M,L,U;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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:return 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=Ql(Ql({},lW(this._aRecvonlyOfferTpl)),{},{mid:u})),l&&(this._mlinesCache[t.streamId][0]=p,_={track:"audio",init:{direction:"recvonly"}}),d&&(v=Ql(Ql({},lW(this._vRecvonlyOfferTpl)),{},{mid:d})),h&&(this._mlinesCache[t.streamId][1]=v,f={track:"video",init:{direction:"recvonly"}}),m=yj(this.peer._offerSession,p,v),g=void 0,y=void 0,t.enableVendorMode||r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl||(g=_j(this._nextSsrc),this._nextSsrc=g.next,A=Ql(Ql(Ql({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Fg(S=Fg(b="".concat(t.streamId)).call(b,null!==(k=this._context)&&void 0!==k&&k.avSync?"":"-audio"," ")).call(S,t.streamId,"-audio"),ssrcs:fj(t.streamId,"audio",g.audio)}),w=Ql(Ql(Ql({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:d,msid:Fg(E=Fg(T="".concat(t.streamId)).call(T,null!==(I=this._context)&&void 0!==I&&I.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},mj(t.streamId,g,{flexfec:this._enableSubFlexfec})),y={sdp:$B.write(Ql(Ql({},this.peer._answerSession),{},{media:[A,w]})),sequenceId:t.sequenceId?++t.sequenceId:0},null===(R=g)||void 0===R||delete R.next),(C=null===(n=p)||void 0===n?void 0:aI(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=p)&&void 0!==o&&o.fmtp&&(P=null===(x=p)||void 0===x?void 0:aI(O=x.fmtp).call(O,(function(e){return e.payload===C.payload})))&&this._context&&(P.config+=";stereo=1;sprop-stereo=1"),t.isPublic&&AL>=86&&null!=(L=null===(D=v)||void 0===D?void 0:Ty(N=D.rtp).call(N,(function(e){return"H264"===e.codec})))&&L.length&&null!==(M=v)&&void 0!==M&&M.fmtp&&(null===(U=v)||void 0===U||U.fmtp.forEach((function(e){aI(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:_,videoTransceiverInit:f,allSsrc:g,peerConnectionMode:this.peerConnectionMode,signalingAck:y});case 29:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handleAck",value:(o=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("handleAck()","item: %o",t),e.abrupt("return",this._sdpQueue.enqueue(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"dequeue",value:(i=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),this.logger.info("dequeue()","ret: %o",t),t){e.next=6;break}return this._queueBusy=!1,e.abrupt("return");case 6:if(r=[],e.prev=7,n=t.items,i=t.sdpStrategy,o=[],a=[],s=[],i!==ZH.ADD){e.next=16;break}return e.delegateYield(Pg().mark((function e(){var t,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=Ql({},m.peer._answerIce)).candidates,c=!1,u=!1,e.prev=4,l=NU(n);case 6:return e.next=8,l.next();case 8:if(!(c=!(h=e.sent).done)){e.next=16;break}if(i=h.value,"break"!==function(){var e=i.audioMid,n=i.videoMid,c=i.action,u=i.audioTransceiverInit,d=i.videoTransceiverInit,l=i.signalingAck,h=i.stream,p=h instanceof JH;if(i.onSuccess&&s.push(i.onSuccess),i.onFail&&r.push(i.onFail),p&&(null==l?void 0:l.sequenceId)<h.sequenceId)return"break";var v,_={},f={},g=$B.parse(l.sdp);Array.isArray(g.media)&&Kw(v=g.media).call(v,(function(e,t){var r;return null==e||null===(r=e.type)||void 0===r?void 0:r.localeCompare(null==t?void 0:t.type)})).forEach((function(r){"audio"===(r=Ql(Ql({},r),t)).type?(_=r).mid=e:(f=r).mid=n}));var y,S=h.streamId;if(c===$H.publish&&(S=null===(y=h.stream)||void 0===y?void 0:y.id),!m._mlinesCache[S])return"break";var b=gy(m._mlinesCache[S],2),k=b[0],E=b[1];if(u&&k){h.audioTransceiver=m._peerConnection.addTransceiver(u.track,u.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",Gg({audioStreamTrack:fx(u.track)}));var T=m._inactiveMlineIndex.shift();T||(T=m.peer._offerMlines.length),m.peer._offerMlines[T]=Ql({},k),m.peer._answerMlines[T]=_,fW&&h.initAudioEncodedTransform()}if(d&&E){var I,R;h.videoTransceiver=m._peerConnection.addTransceiver(d.track,d.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",Gg({videoStreamTrack:fx(d.track)}));var A,w,C=m._inactiveMlineIndex.shift();C||(C=m.peer._offerMlines.length),m.peer._offerMlines[C]=Ql({},E),c===$H.publish&&null!==(I=m._context)&&void 0!==I&&null!==(R=I.serverConfig)&&void 0!==R&&R.videoCodec&&Tj(f,null===(A=m._context)||void 0===A||null===(w=A.serverConfig)||void 0===w?void 0:w.videoCodec),m.peer._answerMlines[C]=f,fW&&h.initVideoEncodedTransform()}o.push(h.streamId||""),a.push(p?h.userId:"local"),p&&(h.sequenceId=null==l?void 0:l.sequenceId),delete m._mlinesCache[S]}()){e.next=13;break}return e.abrupt("break",16);case 13:c=!1,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),u=!0,d=e.t0;case 22:if(e.prev=22,e.prev=23,!c||null==l.return){e.next=27;break}return e.next=27,l.return();case 27:if(e.prev=27,!u){e.next=30;break}throw d;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",14);case 14:e.next=21;break;case 16:f={},n.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;f[t]=t,n!==$H.removetrack&&(f[r]=r),f[t]=t})),this.peer._offerMlines=qg(p=this.peer._offerMlines).call(p,(function(e,t){return f[e.mid]&&(e=gj(e),m._inactiveMlineIndex.push(t)),e})),Kw(v=this._inactiveMlineIndex).call(v,(function(e,t){return e-t})),this.peer._answerMlines=qg(_=this.peer._answerMlines).call(_,(function(e){return f[e.mid]&&(e=gj(e)),e}));case 21:return e.prev=21,e.next=24,this.setDescription(o.length?{streamId:o.join(","),streamUserId:a.join(",")}:void 0);case 24:e.next=32;break;case 26:if(e.prev=26,e.t1=e.catch(21),"have-local-offer"!==this._peerConnection.signalingState){e.next=31;break}return e.next=31,this._peerConnection.setLocalDescription({type:"rollback"});case 31:throw e.t1;case 32:try{s.forEach((function(e){return e()}))}catch(jZ){}this.logger.info("dequeue","loop"),e.next=40;break;case 36:e.prev=36,e.t2=e.catch(7),this.logger.error("dequeue","unknown error: %o",e.t2),r.forEach((function(t){return t(e.t2)}));case 40:return e.prev=40,this.dequeue(),e.finish(40);case 43:case"end":return e.stop()}}),e,this,[[7,36,40,43],[21,26]])}))),function(){return i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=Ng(Pg().mark((function e(){var t,r,n,i;return Pg().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=$B.parse(r),i=[],n.media=Ty(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=Ty(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"}],zB&&Rj(n),e.abrupt("return",{sdp:$B.write(n),semantics:"unified-plan",type:"incroffer"});case 10:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"rollback",value:(r=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.msid,delete this._mlinesCache[r];case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this,r=$B.parse(e);r.media.forEach((function(e){if("audio"===e.type)if("sendonly"===e.direction)t._aSendonlyOfferTpl=e;else{var r;if(Array.isArray(e.ext))e.ext=Ty(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=Ty(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}})),zB&&Rj(r)}},{key:"_genOfferSdp",value:(t=Ng(Pg().mark((function e(){var t,r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,BM(!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 bC(fC.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}(xj),gW=function(e){UA(d,e);var t,r,n,i,o,a,s,c,u=ew(d);function d(e,t){var r;return Fh(this,d),ql(aA(r=u.call(this,e,t)),"name","firefox"),ql(aA(r),"_aRecvonlyOfferTpl",void 0),r.logger=new pM("FirefoxHandler",3,e.id),r}return Vh(d,[{key:"publish",value:(c=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,_,f,m,g=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=MA(NA(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),Array.isArray(c.init.sendEncodings)&&1===c.init.sendEncodings.length&&(c.init.sendEncodings=qg(u=c.init.sendEncodings).call(u,(function(e){return delete e.rid,e}))),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),l=IM(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=8,this._peerConnection.createOffer();case 8:return h=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:IM()-l}),(p=$B.parse(h.sdp)).media=null===(r=p.media)||void 0===r?void 0:qg(r).call(r,(function(e){return Ql(Ql({},e),g.peer._offerIce)})),Rj(p),e.next=15,this.setLocalDescription($B.write(p));case 15:return v=t.audioTransceiver.mid,_=t.videoTransceiver.mid,f=null,m=null,p.media=null===(n=p.media)||void 0===n?void 0:qg(n).call(n,(function(e){if("".concat(e.mid)===v){var t,r,n=null===(t=f=e)||void 0===t?void 0:aI(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&f.fmtp){var i,o,a=aI(i=f.fmtp).call(i,(function(e){return e.payload===n.payload}));a&&null!==(o=g._context)&&void 0!==o&&o.audioProfileManager&&(a.config=g._context.audioProfileManager.getOpusConfigStr(a.config))}}else if("".concat(e.mid)===_){var s,c,u,d;null!==(s=g._context)&&void 0!==s&&null!==(c=s.serverConfig)&&void 0!==c&&c.videoCodec&&Tj(e,null===(u=g._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec),m=e}return e})),this.addBitrateLimit(m,t.videoEncodeConfig[0].maxKbps),e.next=23,this.setLocalDescription($B.write(p));case 23:return e.abrupt("return",{partialSdp:yj(p,f,m),audioMid:v,videoMid:_,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:c,peerConnectionMode:this.peerConnectionMode});case 24:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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=IM(),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 _=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:IM()-v}),(f=$B.parse(_.sdp)).media=null===(n=f.media)||void 0===n?void 0:qg(n).call(n,(function(e){return Ql(Ql({},e),w.peer._offerIce)})),qg(i=f.media).call(i,(function(e){var t,r,n,i;"video"===e.type&&(GB?(e.ext=null===(t=e.ext)||void 0===t?void 0:Ty(t).call(t,(function(e){var t;return-1===yI(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Ty(r).call(r,(function(e){return"goog-remb"!==e.type}))):(e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:Ty(n).call(n,(function(e){return"transport-cc"!==e.type})),e.ext=null===(i=e.ext)||void 0===i?void 0:Ty(i).call(i,(function(e){var t;return-1===yI(t=e.uri).call(t,"transport")}))))})),zB&&Rj(f),e.next=22,this.setLocalDescription($B.write(f),{streamId:t.streamId||"",streamUserId:t.userId});case 22:return c=null===(o=t.audioTransceiver)||void 0===o?void 0:o.mid,u=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid,null===(s=f.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===c?h=e:"".concat(e.mid)===u&&(p=e)})),c&&h||(c="audio_".concat(u),h=Ql(Ql({},this._aRecvonlyOfferTpl),{},{mid:c})),t.audioMid=c,t.videoMid=u,m=void 0,g=void 0,!r.multiChatMode&&!t.virtual&&this._aSendonlyAnswerTpl&&this._aSendonlyAnswerTpl&&(m=_j(this._nextSsrc),this._nextSsrc=m.next,R=Ql(Ql(Ql({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:c,msid:Fg(y=Fg(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:fj(t.streamId,"audio",m.audio)}),A=Ql(Ql(Ql({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Fg(k=Fg(E="".concat(t.streamId)).call(E,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(k,t.streamId,"-video")},mj(t.streamId,m,{flexfec:this._enableSubFlexfec})),g={sdp:$B.write(Ql(Ql({},this.peer._answerSession),{},{media:[R,A]})),sequenceId:t.sequenceId?++t.sequenceId:0},null===(I=m)||void 0===I||delete I.next),e.abrupt("return",{partialSdp:yj(f,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,signalingAck:g});case 32:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==$H.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==$H.unpublish&&i!==$H.unsubscribe){e.next=14;break}return e.prev=4,e.next=7,this.close(n);case 7:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(4),"function"==typeof t.onFail&&t.onFail(e.t0);case 13:return e.abrupt("return",n.streamId||"");case 14:return o=$B.parse(null==r?void 0:r.sdp),e.prev=15,e.next=18,this._internalSetRemoteDescription(o.media,n);case 18:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=24;break;case 21:e.prev=21,e.t1=e.catch(15),"function"==typeof t.onFail&&t.onFail(e.t1);case 24:return e.abrupt("return","");case 25:case"end":return e.stop()}}),e,this,[[4,10],[15,21]])}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=$B.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=Ql(Ql({},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 qH&&kL<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=Ty(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=Ty(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=Ty(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=Ty(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=$B.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=qg(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,qg(a=c.media).call(a,(function(e){var t,r,n,i;"video"===e.type&&(GB?(e.ext=null===(t=e.ext)||void 0===t?void 0:Ty(t).call(t,(function(e){var t;return-1===yI(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Ty(r).call(r,(function(e){return"goog-remb"!==e.type}))):(e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:Ty(n).call(n,(function(e){return"transport-cc"!==e.type})),e.ext=null===(i=e.ext)||void 0===i?void 0:Ty(i).call(i,(function(e){var t;return-1===yI(t=e.uri).call(t,"transport")}))))})),zB&&Rj(c),e.next=12,this.setRemoteDescription($B.write(c));case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Ng(Pg().mark((function e(){var t,r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=$B.parse(null===(t=this._peerConnection.localDescription)||void 0===t?void 0:t.sdp),this.createAVMlineOfferTpl(null===(r=this._peerConnection.localDescription)||void 0===r?void 0:r.sdp),o=[],i.media=Ty(n=i.media).call(n,(function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,o.push("".concat(e.mid)),!0)})),zB&&Rj(i),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:$B.write(i),semantics:"unified-plan",type:"incroffer"});case 7:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.msid,r=t.stream,n=t.audioMid,i=t.videoMid,this.logger.warn("rollback()"),e.abrupt("return",this.close(r,n,i));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"close",value:(r=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("close()"),s=t.audioMid||r,c=t.videoMid||n,u={},t.audioTransceiver&&s&&(t.audioTransceiver.stop(),u[s]=s),t.videoTransceiver&&c&&(t.videoTransceiver.stop(),u[c]=c),d=[],e.next=9,this._peerConnection.createOffer();case 9:return l=e.sent,(h=$B.parse(null==l?void 0:l.sdp)).media=qg(i=h.media).call(i,(function(e){return u[e.mid]&&(e=gj(e)),"inactive"!==e.direction&&d.push(e.mid),Ql(Ql({},e),_.peer._offerIce)})),p=$B.parse(null===(o=this._peerConnection.remoteDescription)||void 0===o?void 0:o.sdp),v={},p.media.forEach((function(e){void 0!==e.mid&&(v[e.mid]=e)})),p.media=qg(a=h.media).call(a,(function(e){return"inactive"===e.direction?e:v[e.mid]})),h.groups&&p.groups&&(h.groups[0].mids=d.join(" "),p.groups[0].mids=d.join(" ")),e.next=19,this.setLocalDescription($B.write(h));case 19:return e.next=21,this.setRemoteDescription($B.write(p));case 21:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Ng(Pg().mark((function e(){return Pg().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,r=$B.parse(e);r.media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)})),zB&&Rj(r)}}]),d}(xj),yW=function(e,t){return tL?new gW(e,t):new mW(e,t)},SW=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}(SW||{}),bW=function(e){return e.PushLimitWarn="PushLimitWarn",e}(bW||{}),kW=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}(kW||{}),EW=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(EW||{}),TW=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ON_VENDOR_CONNECTION_STATE_CHANGE="onVendorConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(TW||{}),IW=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(IW||{}),RW=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(RW||{}),AW=new pM("Locker",2),wW=1,CW=function(){function e(t){var r;Fh(this,e),ql(this,"lockingPromise",jI.resolve()),ql(this,"locks",0),ql(this,"name",""),ql(this,"lockId",void 0),this.lockId=wW++,t&&(this.name=t),AW.info(Fg(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return Vh(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,AW.info(Fg(e=Fg(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new jI((function(e){r=function(){var t,r;n.locks-=1,AW.info(Fg(t=Fg(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}(),xW=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_SUBSCRIBE_RESULT="ON_SUBSCRIBE_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.PUB_RETRY="PUB_RETRY",e.SUB_RETRY="SUB_RETRY",e}(xW||{}),OW=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}(OW||{}),PW=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(PW||{}),DW=(ql(vW={},kh.communication,[0]),ql(vW,kh.chat,[0]),ql(vW,kh.chatRoom,[1,"IES_chatroom"]),ql(vW,kh.coHost,[1,"IES_PK"]),ql(vW,kh.meeting,[16]),ql(vW,kh.classRoom,[0]),vW),NW=BB(),MW=function(e){UA(s,e);var t,r,n,i,o,a=ew(s);function s(e,t){var r;return Fh(this,s),ql(aA(r=a.call(this,e,t)),"_peerConnectionId",TM()),ql(aA(r),"peerConnectionMode",1),ql(aA(r),"name","vendor"),ql(aA(r),"direction","up"),ql(aA(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:""})})),t.on("disconnect",(function(){r.emit("disconnect")})),r}return Vh(s,[{key:"publish",value:(o=Ng(Pg().mark((function e(t){var r,n,i,o,a,c,u,d,l,h,p=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.enableSimulcast=!1,this.stream=t,r=MA(NA(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),NW&&(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=IM(),d=$B.parse(c.sdp),Array.isArray(d.media)&&(d.media=qg(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&&Tj(e,null===(i=p._context)||void 0===i||null===(o=i.serverConfig)||void 0===o?void 0:o.videoCodec),(rL||vL)&&Array.isArray(e.ext)&&(e.ext=Ty(a=e.ext).call(a,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&Xy(t).call(t,"video-orientation"))}))),rL||p.addBitrateLimit(e,t.videoEncodeConfig[0].maxKbps);else if("audio"===e.type){var s,c=null==e?void 0:aI(s=e.rtp).call(s,(function(e){return"opus"===e.codec}));if(c&&e.fmtp){var u,d,l=aI(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:$B.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:IM()-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:IM()-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=Ng(Pg().mark((function e(t){var r,n,i,o,a,s=this;return Pg().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"}),NW&&(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=IM(),i=$B.parse(r.sdp),Array.isArray(i.media)&&(i.media=qg(o=i.media).call(o,(function(e){if("audio"===e.type){var t,r=null==e?void 0:aI(t=e.rtp).call(t,(function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n,i=null==e?void 0:aI(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:$B.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:IM()-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:IM()-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=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.action!==$H.publish&&t.action!==$H.subscribe){e.next=16;break}return n=new RTCSessionDescription({sdp:null===(r=t.signalingAck)||void 0===r?void 0:r.sdp,type:"answer"}),i=IM(),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:IM()-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:IM()-i},{type:"offer"}),e.t0;case 13:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=17;break;case 16:t.action!==$H.unpublish&&t.action!==$H.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(),MA(NA(s.prototype),"destroy",this).call(this)}},{key:"getDefaultSdp",value:(r=Ng(Pg().mark((function e(){return Pg().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=Ng(Pg().mark((function e(){return Pg().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)})},{key:"peerConnectionId",get:function(){return this._peerConnectionId},set:function(e){this._peerConnectionId=e}}]),s}(xj),LW=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}(LW||{}),UW={start_interval:100,multiplier:2,max_interval:3e4},VW=function(){function e(){Fh(this,e),ql(this,"_times",0),ql(this,"_config",UW),ql(this,"initTs",IM())}return Vh(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}(),FW=function(){function e(t){Fh(this,e),ql(this,"_reconnectTimer",void 0),ql(this,"_abortControllers",[]),ql(this,"_monitor",void 0),ql(this,"logger",void 0),ql(this,"_groupConfigId",TM()),ql(this,"_retryLimiter",new VW),ql(this,"_timer",void 0),this._ctx=t,this._monitor=KN(t.id),this.logger=new pM("ICERequest",4,t.id)}var t,r,n,i;return Vh(e,[{key:"getICENode",value:(i=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 new Error("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 bC(fC.ICE_SERVER_WRONG,"get ICE config failed: ".concat(e.t0.message),e.t0);case 13:return this.logger.success("getICENode","success"),this._reportRtcInvokeStatus("es.join.getNodeSuccess",r),e.abrupt("return",r);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return i.apply(this,arguments)})},{key:"_getAccessWithRetry",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 0!==r&&this.logger.info("_getAccessWithRetry()","invoke feedbackInfo: %o, 201count: %o",e,r),new jI((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(eC(o).call(o,(function(e){return 400<=e.code&&e.code<500}))>-1)return t._retryLimiter.reset(),i(new Error("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(new Error("HTTP request failed(201)"))}var a=t._retryLimiter.getRetryDelay();t.logger.warn("_getAccessWithRetry()","_getAccessWithRetry error, will retry after ".concat(a,"ms"),o),t._reconnectTimer=self.setTimeout((function(){t._getAccessWithRetry(e,r).then(n).catch(i)}),a)}))}))}},{key:"_getAccessNode",value:(n=Ng(Pg().mark((function e(t){var r=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new jI((function(e,n){var i=LL.getAccessNode(r._ctx.appId);i?(r.logger.info("getAccessNode","use cache node."),e(Array.isArray(i)?i:[i]),r._timer=window.setTimeout((function(){r._getAccessNodeFromServer(t),r._reportRtcInvokeStatus("es.R.node.cache",i),delete r._timer}),0)):r._getAccessNodeFromServer(t).then(e).catch(n)})));case 1:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"_getAccessNodeFromServer",value:(r=Ng(Pg().mark((function e(t){var r,n,i,o=this;return Pg().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&&LL.setAccessNode(o._ctx.appId,t,e.ttl||11200),e.dispatchDomains&&!o._ctx.useCloudProxy&&LL.setAccessUrls(e.dispatchDomains),t})).catch((function(e){if(i)return o._reportRtcInvokeStatus("es.R.req.fallback",""),LL.clearAccessUrls(),o._getAccessNodeFromServer(t);throw e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_getAccessUrls",value:function(){var e=LL.getAccessUrls()||[],t=!0;return this._reportRtcInvokeStatus("es.R.req.cache.urls",e),0===e.length&&(e=GL.ICE_CONFIG_REQUEST_URLS,t=!1,this._reportRtcInvokeStatus("es.R.req.external.urls",e)),0===e.length&&(e=GL.ICE_CONFIG_REQUEST_URLS_INTERNAL,t=!1,this._reportRtcInvokeStatus("es.R.req.internal.urls",e)),{urls:e,needFallback:t}}},{key:"getICEConfigFromServer",value:(t=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=TM(),o={appID:this._ctx.appId,deviceID:LL.getDeviceId(),connectSessionID:i,os:"web",sdkVersion:GL.VERSION,isOversea:GL.OVERSEA,expectedAddr:KL("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC},r&&(o.feedbackInfo=r,"ICE_FAILED"!==(null===(a=r[0])||void 0===a||null===(s=a.feedbackReason)||void 0===s?void 0:s.type)&&delete o.expectedAddr),c=Date.now(),null===(n=this._monitor)||void 0===n||n.report("rtc_get_access",{error_code:0,message:Gg(o),elapse:0,type:"request",host:t.join(","),config_id:i,group_config_id:this._groupConfigId}),u=qg(t).call(t,function(){var e=Ng(Pg().mark((function e(t){var r,n,i,a,s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new AbortController,d._abortControllers.push(n),e.prev=2,e.next=5,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:Gg(o),signal:n.signal});case 5:i=e.sent,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(2),_x(fetch)||null===(a=d._monitor)||void 0===a||a.report("rtc_error",{error_code:LW.Fetch_MODIFY,message:"get access failed, possibly due to modifying the browser's Fetch API."},{origin_error:e.t0}),e.t0;case 12:if(d._abortControllers=Ty(r=d._abortControllers).call(r,(function(e){return e!==n})),200===i.status){e.next=15;break}throw{message:i.statusText,code:i.status};case 15:return e.next=17,i.json();case 17:if(200===(s=e.sent).code){e.next=20;break}throw s;case 20:if(0!==s.nodes.length){e.next=22;break}throw{code:s.code,message:Gg(s)};case 22:return e.abrupt("return",{url:t,result:s});case 23:case"end":return e.stop()}}),e,null,[[2,8]])})));return function(t){return e.apply(this,arguments)}}()),e.abrupt("return",jM(u).then((function(e){var t,r=e.result,n=e.url;return null===(t=d._monitor)||void 0===t||t.report("rtc_get_access",{error_code:200,message:Gg(r),elapse:Date.now()-c,type:"response",host:n,config_id:i,group_config_id:d._groupConfigId}),r})).catch((function(e){var r,n,o,a;throw null===(r=d._monitor)||void 0===r||r.report("rtc_get_access",{error_code:Number((null===(n=e[0])||void 0===n?void 0:n.code)||(null===(o=e[0])||void 0===o?void 0:o.server_code)),message:null===(a=e[0])||void 0===a?void 0:a.message,elapse:Date.now()-c,type:"response",host:t.join(","),config_id:i,group_config_id:d._groupConfigId},{error:Gg(e)}),e})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._abortControllers.forEach((function(e){return e.abort()})),this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer),this._timer&&(window.clearTimeout(this._timer),delete this._timer)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r;null===(r=this._monitor)||void 0===r||r.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:0,stream_id:"",elapse:0,group_config_id:this._groupConfigId})}}]),e}(),BW={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!BB()||void 0},jW=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}(jW||{}),HW=0,GW=function(e){UA(s,e);var t,r,n,i,o,a=ew(s);function s(e,t){var r;return Fh(this,s),ql(aA(r=a.call(this)),"uuid",(HW++).toString()),ql(aA(r),"_peerConnectionId",""),ql(aA(r),"audioTrack4ff",void 0),ql(aA(r),"_pc",void 0),ql(aA(r),"_dc",void 0),ql(aA(r),"_iceNode",void 0),ql(aA(r),"_initSctpEvents",!1),ql(aA(r),"_monitor",void 0),ql(aA(r),"_offerIce",{}),ql(aA(r),"_answerIce",{}),ql(aA(r),"_offerSession",void 0),ql(aA(r),"_answerSession",void 0),ql(aA(r),"_offerMlines",[]),ql(aA(r),"_answerMlines",[]),ql(aA(r),"_connectReject",void 0),ql(aA(r),"_logger",void 0),r._ctx=e,r._groupConnectionId=t,r._monitor=KN(e.id),r._logger=new pM("PeerConnection_".concat(r.uuid),4,e.id),r._pc=new RTCPeerConnection(BW),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",Fg(i=Fg(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(){var e;r._print("onconnectionstatechange",Fg(e="".concat(r._pc.connectionState,". ice -> ")).call(e,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 Vh(s,[{key:"getOriginRTCPeerConnection",value:function(){return this._pc}},{key:"getOriginRTCDataChannel",value:function(){return this._dc}},{key:"getConnectionId",value:function(){return this._peerConnectionId}},{key:"getGroupConnectionId",value:function(){return this._groupConnectionId}},{key:"connect",value:(o=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("connect","invoke. %o",t),this._iceNode=t,(r=this._pc.createDataChannel("signaling",{negotiated:!0,id:100})).binaryType="arraybuffer",this._dc=r,e.next=7,this._genIceInfo(t);case 7:return n=e.sent,i=n.offerIce,o=n.answerIce,this._offerIce=i,this._answerIce=o,this._peerConnectionId=o.iceUfrag||"",tL&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=16,this._pc.createOffer();case 16:if((a=e.sent).sdp){e.next=19;break}throw new bC(fC.NOT_SUPPORTED,"create offer sdp failed.");case 19:if(s=$B.parse(a.sdp),c=gy(s.media,1),u=c[0],this._offerIce.fingerprint=s.fingerprint||u.fingerprint,!tL){e.next=35;break}return s.media=qg(d=s.media).call(d,(function(e){var t,r,n,i,o=Ql(Ql({},e),p._offerIce);return"video"===o.type&&(GB?(o.ext=null===(t=o.ext)||void 0===t?void 0:Ty(t).call(t,(function(e){var t;return-1===yI(t=e.uri).call(t,"abs-send-time")})),o.rtcpFb=null===(r=o.rtcpFb)||void 0===r?void 0:Ty(r).call(r,(function(e){return"goog-remb"!==e.type}))):(o.rtcpFb=null===(n=o.rtcpFb)||void 0===n?void 0:Ty(n).call(n,(function(e){return"transport-cc"!==e.type})),o.ext=null===(i=o.ext)||void 0===i?void 0:Ty(i).call(i,(function(e){var t;return-1===yI(t=e.uri).call(t,"transport")})))),o})),zB&&Rj(s),(h=Ql({},s)).fingerprint=this._answerIce.fingerprint,h.media=qg(l=h.media).call(l,(function(e){return delete(e=Ql(Ql({},e),p._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})),zB&&Rj(h),e.next=31,this.setLocalDescription($B.write(s));case 31:return e.next=33,this.setRemoteDescription($B.write(h));case 33:e.next=43;break;case 35:delete s.media,this._offerSession=Ql({},s),this._answerSession=Ql({},s),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),this._offerMlines=[Ql(Ql(Ql({},u),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[Ql(Ql(Ql({},u),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription();case 43:return e.next=45,new jI((function(e,t){p._connectReject=t,r.onopen=function(){p._print("connect","dataChannel open"),p._reportRtcInvokeStatus("es.dc.open",""),e(""),delete p._connectReject},r.onerror=function(e){var t,r,n,i;p._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"}),p._reportRtcInvokeStatus("es.dc.error",""),null===(n=p._connectReject)||void 0===n||n.call(p,{message:"dc.onerror, ".concat(null===(i=e.error)||void 0===i?void 0:i.errorDetail),code:0}),p.emit("disconnect","dc onerror"),delete p._connectReject},r.onclose=function(){var e;p._reportRtcInvokeStatus("es.dc.close",""),null===(e=p._connectReject)||void 0===e||e.call(p,{message:"dc.onclose",code:1}),p.emit("disconnect","dc onclose"),delete p._connectReject},p._pc.addEventListener("connectionstatechange",(function(){var e,t;"failed"!==p._pc.iceConnectionState&&"closed"!==p._pc.iceConnectionState&&"failed"!==p._pc.connectionState||(null===(e=p._connectReject)||void 0===e||e.call(p,{message:Fg(t="pc.connectionstatechange -> ".concat(p._pc.connectionState,", ice -> ")).call(t,p._pc.iceConnectionState),code:2}),delete p._connectReject)})),setTimeout((function(){var e;null===(e=p._connectReject)||void 0===e||e.call(p,{code:4,message:"connect timeout"}),delete p._connectReject}),8e3)}));case 45:return this._print("connect","dataChannel establish success"),e.abrupt("return",r);case 47:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setDescription",value:(i=Ng(Pg().mark((function e(t){var r,n;return Pg().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&&e.mid&&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=IM(),t&&this._report("rtc_begin_create_offer",{direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,pc_session_id:this._peerConnectionId,vendor_mode:0}),e.next=10,this._pc.createOffer();case 10:return t&&this._report("rtc_create_offer",{error_code:0,direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,elapse:IM()-n}),e.next=13,this.setLocalDescription($B.write(this._offerSession),t);case 13:return e.next=15,this.setRemoteDescription($B.write(this._answerSession),t);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setLocalDescription",value:(n=Ng(Pg().mark((function e(t,r){var n,i,o,a=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=IM(),e.prev=1,e.next=4,this._pc.setLocalDescription(new RTCSessionDescription({type:"offer",sdp:t}));case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:IM()-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:IM()-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=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=IM(),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:IM()-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:IM()-n},{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"disconnect",value:function(){var e,t;null===(e=this._connectReject)||void 0===e||e.call(this,{code:3,message:"invoke destroy()"}),delete this._connectReject,this._pc.close(),null===(t=this._dc)||void 0===t||t.close(),this._pc.ontrack=null}},{key:"destroy",value:function(){this._print("destroy",this._peerConnectionId),MA(NA(s.prototype),"removeAllListeners",this).call(this),this.disconnect()}},{key:"_genIceInfo",value:(t=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().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,Sj(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,Fg(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,Ql(Ql({},t),{},{connection_id:this._peerConnectionId,group_connection_id:this._groupConnectionId}),Ql(Ql({},r),{},{tcp_only:null===(i=this._iceNode)||void 0===i?void 0:i.iceConfig.tcpOnly,ms_addr:Gg((null===(o=this._iceNode)||void 0===o?void 0:qg(a=o.publicIPs).call(a,(function(e){return{ip:e.ip,tcp:e.tcpPorts,udp:e.udpPorts}})))||[])}))}},{key:"_reportRtcInvokeStatus",value:function(e,t){this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:0,stream_id:"",elapse:0})}}],[{key:"checkSupported",value:function(){if(!RTCPeerConnection)throw new bC(fC.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 bC(fC.NOT_SUPPORTED,"missing peer.".concat(e," API."))}))}}]),s}(kU),zW=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(zW||{}),KW=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}(KW||{}),WW=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}(WW||{}),XW=(ql(_W={},0,[0,"success"]),ql(_W,1,[fC.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),ql(_W,2,[fC.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),ql(_W,3,[fC.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),ql(_W,4,[fC.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),ql(_W,5,[fC.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),ql(_W,17,[fC.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),ql(_W,18,[fC.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),ql(_W,100,[fC.USER_MESSAGE_NOT_JOIN,"not join room"]),ql(_W,105,[fC.USER_MESSAGE_NOT_LOGIN,"not login."]),ql(_W,106,[fC.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),ql(_W,1e3,[fC.USER_MESSAGE_UNKNOWN,"unknown."]),_W),YW=["msg"],qW=[],JW=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}(JW||{}),QW=function(e){UA(a,e);var t,r,n,i,o=ew(a);function a(e,t){var r;return Fh(this,a),ql(aA(r=o.call(this)),"_singlingCache",new cT),ql(aA(r),"_p2pCache",new cT),ql(aA(r),"_rttIds",{}),ql(aA(r),"_p2pMessageId",1),ql(aA(r),"_clearDataChannelListener",void 0),ql(aA(r),"_monitor",void 0),ql(aA(r),"logger",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=KN(e),r.logger=new pM("DataChannelSignaling",3,e),r}return Vh(a,[{key:"destroy",value:function(){var e=this;this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.forEach((function(t,r){t.error(new bC(fC.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:Gg(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new jI((function(n,a){var s,c=i._genHeader(r);c.id=CM();var u=c.id.join("-"),d="customMessage"===e;d&&MN.samplingOne2ManyMsg(i.id,Number(c.id.join("")),t);var l=setTimeout((function(){i._singlingCache.delete(u),a(new bC(fC.TIME_OUT,"".concat(e," message time out"))),d&&MN.updateOne2ManyMsgAck(i.id,t,999)}),o);i._singlingCache.set(u,{signalingType:e,success:function(e){clearTimeout(l),n(e),d&&MN.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(l),a(e),d&&MN.updateOne2ManyMsgAck(i.id,t,e.code)}}),i.logger.info("Signal",Fg(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=Ng(Pg().mark((function e(t,r){var n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=yN(t,YW),o=n instanceof ArrayBuffer,e.t0=this,e.t1=MN,e.t2=this.id,e.t3=Ql,e.t4=Ql({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:zW.SEND,type:KW.P2P,err:WW.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,wM.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 OM(e.msg)?this._rttIds[e.id]=e.id:e.dir===zW.SEND&&this.logger.info("_sendP2PMessage [DC Signaling p2p >>]",Gg(e)),new jI((function(n,i){var o=t._genHeader(Ql(Ql({needAck:!0,functionType:1},r),{},{id:CM()}));if(e.dir===zW.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new bC(fC.USER_MESSAGE_TIMEOUT,"P2P message timeout")),MN.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),MN.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),MN.updateP2PMsgAck(t.id,e,r.err);var o=gy(XW[r.err]||[fC.USER_MESSAGE_UNKNOWN,Fg(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===fC.NOT_CONNECTED_YET&&(s.code=fC.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new bC(fC.NOT_CONNECTED_YET,"DataChannel not open");var i=KL("SIGNAL_COMPRESSION")||t.zip,o=t.version+(Number(i)<<4)+(Number(t.encrypt)<<5),a=Number(t.needAck)+(Number(t.direction)<<1)+(Number(t.functionType)<<2)+(Number(t.binary)<<6),s=wM.str2ab(Gg([e,r])),c=AM(Uint8Array,Fg(n=[o,a]).call(n,tR(t.id||[])),i||t.zip?pN.deflate(new Uint8Array(s)):new Uint8Array(s));try{this._dataChannel.send(c.buffer)}catch(d){var u;throw null===(u=this._monitor)||void 0===u||u.report("rtc_error",{message:"datachannel send error: ".concat(d.message),error_code:LW.DC_SEND_ERROR}),d}"p2p"===e?MN.updateP2PMsgReq(this.id,r,c.buffer.byteLength):"customMessage"===e&&MN.updateOne2ManyMsgReq(this.id,r,c.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=KC(sI(t).call(t,2,r))}return{header:o,data:sI(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:qg(n=e.split("-")).call(n,(function(e){return Number(e)}))});Xy(qW).call(qW,t)||this.logger.info("Signal",Fg(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d;return Pg().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 pN.Inflate).push(o,!0),o=s.result),c=wM.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=Ng(Pg().mark((function e(t,r,n,i,o){var a,s,c,u,d;return Pg().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],Xy(qW).call(qW,u)||this.logger.info("Signal","<<<<<< ".concat(u),r,s),this._feedbackSignaling(s,u,u===kW.ON_CUSTOM_MESSAGE?Ql(Ql({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,wM.b64str2ab(r.message,this._monitor);case 13:r.message=e.sent;case 14:d=Date.now(),this.emit(u,Ql({},r)),u===kW.ON_CUSTOM_MESSAGE&&MN.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=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f;return Pg().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)===zW.FEEDBACK||OM(null===(a=t)||void 0===a?void 0:a.msg)?delete this._rttIds[c]:this.logger.info("Signal","<<<<<< p2p response",t),e.t0=t.dir,e.next=e.t0===zW.SEND?6:e.t0===zW.FEEDBACK?46:48;break;case 6:if(u=Date.now(),OM(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,_=d.from,f=""===p?l?kW.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:kW.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:l?kW.USER_BINARY_MESSAGE_RECEIVED:kW.USER_MESSAGE_RECEIVED,v){e.next=27;break}if(e.t1=this,e.t2=kW.ON_CUSTOM_MESSAGE,e.t3=_,e.t4=l,!l){e.next=21;break}return e.next=18,wM.b64str2ab(h,this._monitor);case 18:e.t5=e.sent,e.next=22;break;case 21:e.t5=h;case 22:e.t6=e.t5,e.t7={clientId:e.t3,binary:e.t4,message:e.t6},e.t1.emit.call(e.t1,e.t2,e.t7),e.next=43;break;case 27:if(e.t8=this,e.t9=f,e.t10=Ql,e.t11=Ql({},t),e.t12={},!l){e.next=38;break}return e.next=35,wM.b64str2ab(h,this._monitor);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(Ql(Ql({},t),{},{dir:zW.FEEDBACK,msg:""})),MN.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=gy(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(_){}break;case"RTT":try{var p=JSON.parse(l);p.length&&this.emit(d,p[0])}catch(_){}break;case"SSC":try{var v=JSON.parse(l);v.length&&this.emit(d,v[0])}catch(_){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(t){e.logger.warn("_handleHandler","dataChannel close",t)},r=function(t){e.logger.error("_handleHandler","dataChannel error",t)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){return Ql({version:2,zip:!1,encrypt:!1,needAck:!0,direction:0,functionType:0,binary:!1},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{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),this.logger.info("Signal",Fg(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===WW.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(yU.EventEmitter),ZW=function(e){UA(o,e);var t,r,n,i=ew(o);function o(e){var t;return Fh(this,o),ql(aA(t=i.call(this)),"id",void 0),ql(aA(t),"_monitor",void 0),ql(aA(t),"logger",void 0),ql(aA(t),"_getAccessManager",void 0),ql(aA(t),"_connectionPool",new cT),ql(aA(t),"_curConnection",void 0),ql(aA(t),"_hasReportBrowerWarning",!1),ql(aA(t),"_reconnectTimer",void 0),ql(aA(t),"_connecting",!1),ql(aA(t),"_isFirstTimeConnected",!0),ql(aA(t),"_feedbackNodes",[]),ql(aA(t),"_preIceStartTime",-1),ql(aA(t),"_tcpOnlyTimer",void 0),ql(aA(t),"_destroyed",!1),t._ctx=e,t.id=e.id,t._monitor=KN(t.id),t.logger=new pM("ConnectionManager",3,t.id),t.logger.info("constructor","invoke"),t._getAccessManager=new FW(e),t}return Vh(o,[{key:"connect",value:function(){var e=this;this.logger.info("connect","invoke");try{GW.checkSupported()}catch(t){this.safeEmit("disconnected",t)}this._connecting||(this._onConnectStart("init"),jI.resolve().then((function(){return e.emit("__onGetIceConfigHook")})),this._getAccess())}},{key:"reconnectByNodeChange",value:(n=Ng(Pg().mark((function e(t){var r,n,i,o,a,s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.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:Gg(t),reason:Gg(a)}),LL.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=Ng(Pg().mark((function e(t){var r,n=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.logger.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(){this.logger.info("destroy","invoke"),this._destroyed=!0,this.safeEmit("disconnected",new bC(fC.OPERATION_CANCEL,"destroy")),MA(NA(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){this.logger.info("_startIceConnect","invoke");var n=px();this._preIceStartTime=IM();var i=this._ctx.joinRoomConfig.useTcpJoin,o=this._ctx.joinRoomConfig.useTcpJoinDelay,a=function(){var e=Ng(Pg().mark((function e(i){var o,a,s,c;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r&&((i=lW(i)).iceConfig.tcpOnly=!0),o={node:i},e.prev=2,a=new GW(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 QW(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&&(this.logger.info("_startIceConnect","tcp-only will try after ".concat(o,"ms")),this._tcpOnlyTimer=window.setTimeout((function(){t.emit("connectWidthTcp"),e.forEach((function(e){(e=lW(e)).iceConfig.tcpOnly=!0,a(e)})),delete t._tcpOnlyTimer}),o))}}},{key:"_onConnectSuccess",value:function(e){var t,r,n,i=this;(this.logger.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),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;(this.logger.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!==jW.DESTROY&&t.code!==fC.OPERATION_CANCEL)&&(this._curConnection?this._feedbackBySignaling(e.node):this._feedbackNodes.push(e.node),this.logger.info("connect","remove cache node"),LL.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||(this.logger.error("connect","establish peerConnection failed"),this._checkBrowserUA(),IM()-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=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._onConnectStart("ice failed"),this.logger.warn("reconnect","because of ice failed"),this._getAccess(qg(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:LW.BLACK_BROWSER,message:"failed to establish data-channel, and the current browser is on the browser blacklist."}))}},{key:"_onConnectStart",value:function(e){var t;this.logger.info("_onConnectStart","invoke, reason: ".concat(e)),this._connecting=!0,this.safeEmit(this._isFirstTimeConnected?"connecting":"reconnecting");var r,n=px();(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;(this.logger.info("_onConnectEnded","invoke"),this._connecting=!1,this._isFirstTimeConnected)||(null===(t=this._monitor)||void 0===t||t.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"}));this._isFirstTimeConnected=!1,this.safeEmit("connected",e),e.node.iceConfig.tcpOnly&&(this.logger.info("_onConnectEnded","use tcp only"),JN(this._ctx.id,"connected_with_tcp_only",Gg(e.node))),this._tcpOnlyTimer&&(window.clearTimeout(this._tcpOnlyTimer),delete this._tcpOnlyTimer),this._clearConnectionPool()}},{key:"_addConnectionHandler",value:function(e){var t=this;e.on("disconnect",(function(e){t._closeCurrentConnection(),t._clearReconnectTimer(),navigator.onLine?t.reconnect(e):t._reconnectTimer=window.setTimeout((function(){return t.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}(kU),$W=uT,eX=HI,tX=function(e,t,r,n){for(var i,o=n>1?void 0:n?eX(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},rX=6e4,nX=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(nX||{}),iX=function(e,t,r){r.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)},oX=function(e){UA(A,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R=ew(A);function A(e){var t;return Fh(this,A),ql(aA(t=R.call(this)),"id",void 0),ql(aA(t),"publicStream",!1),ql(aA(t),"_token",void 0),ql(aA(t),"_roomId",void 0),ql(aA(t),"_roomAttributes",void 0),ql(aA(t),"_vendorConfig",{enableMultiVendor:!1,vendorCode:0}),ql(aA(t),"_clientId",void 0),ql(aA(t),"_businessId",void 0),ql(aA(t),"_userInfo",void 0),ql(aA(t),"_authorization",void 0),ql(aA(t),"_sessionId",""),ql(aA(t),"_liveControlMessage",void 0),ql(aA(t),"isReconnecting",!1),ql(aA(t),"_ontrackCallbackMap",new cT),ql(aA(t),"_subResolves",{}),ql(aA(t),"supportConcurrent",!1),ql(aA(t),"_handler",void 0),ql(aA(t),"_pubSubLock",void 0),ql(aA(t),"_joinLeaveLock",void 0),ql(aA(t),"_state",void 0),ql(aA(t),"_dataChannelSignal",void 0),ql(aA(t),"_joinRoomStartTs",void 0),ql(aA(t),"_monitor",void 0),ql(aA(t),"logger",void 0),ql(aA(t),"_roomProfile",kh.communication),ql(aA(t),"_context",void 0),ql(aA(t),"_connectionManager",void 0),ql(aA(t),"_joinRoom5xxTimer",void 0),ql(aA(t),"_joinResolve",void 0),ql(aA(t),"_joinReject",void 0),ql(aA(t),"_pubSubBackOff",{}),t.id=e.id,t._monitor=KN(t.id),t.logger=new pM("MediaServerClient",2,t.id),t.logger.info("constructor","invoke"),t._pubSubLock=new CW("pubSubLock"),t._joinLeaveLock=new CW("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._pubSubBackOff={},t._context=e,t._connectionManager=new ZW(e),t._addConnectHandler(),t}return Vh(A,[{key:"_addSignalEventHandler",value:function(){var e,t,r=this;[kW.ON_ADD_STREAM,kW.ON_ADD_STREAM_LIST,kW.ON_REMOVE_STREAM,kW.ON_REMOVE_STREAM_LIST,kW.USER_CONNECTION,kW.USER_CONNECTION_LIST,kW.USER_DISCONNECTION,kW.USER_DISCONNECTION_LIST,kW.ON_UPDATE_STREAM_ATTRIBUTES,kW.ON_UPDATE_ROOM_ATTRIBUTES,kW.ON_PUSH_TRACK,kW.ON_REMOVE_TRACK,kW.ON_CUSTOM_MESSAGE,kW.USER_MESSAGE_RECEIVED,kW.USER_BINARY_MESSAGE_RECEIVED,kW.POST_PROCESSING_MESSAGE,kW.ON_USER_TOKEN_WILL_EXPIRE,kW.STREAM_CONTROL_MESSAGE,kW.ON_UPDATE_USER_ATTRIBUTES,kW.ON_SPEAKER_CHANGE,EW.RSCP,EW.RTT,kW.ON_STREAM_FAILED,kW.ON_NOTIFY_RECONNECT,EW.SSC,kW.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(kW.NODE_CHANGE,(function(e){r._connectionManager.reconnectByNodeChange(e)})),null===(t=this._dataChannelSignal)||void 0===t||t.on(kW.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(TW.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 jI((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"join",value:(I=Ng(Pg().mark((function e(t){var r,n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 jI((function(e,t){n._joinResolve=e,n._joinReject=t,(n._handler?jI.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 I.apply(this,arguments)})},{key:"_callJoinRoom",value:(T=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T=this,I=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=I.length>0&&void 0!==I[0]&&I[0],this.logger.info("_callJoinRoom","invoke"),e.t0=wM.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,CB();case 12:if(e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=GL.VERSION,e.t9=LL.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=DW[this._roomProfile]?"".concat(DW[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},i={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17},this._context.joinRoomParams)for(o=0,a=NS(this._context.joinRoomParams);o<a.length;o++)s=gy(a[o],2),c=s[0],u=s[1],i.params[c]=u;return KL("SIGNAL_CROP_JOINROOM")&&null!==(r=i.sdpInfo)&&void 0!==r&&r.sdp&&(i.sdpInfo.sdp=Ij(i.sdpInfo.sdp)),jI.resolve().then((function(){return T.emit("onSendingJoinMessageHook")})),e.prev=29,l=n?"reconnected":"joinRoom",e.next=33,this._joinRoomWithRetry(l,i);case 33:h=e.sent,this.logger.success("join","send join message success"),p=h.config||{},v=p.engine_WEB,this.connectionState="connected",this._authorization=i.Authorization,LL.setEngineWebConfig(this._context.appId,this._roomId,v),this._context&&(this._context.serverConfig={videoCodec:(null==v?void 0:v.video_codec)||"H264",audioRed:!(null==v||!v.pub_audio_red),muteReplaceUnsub:!(null===(_=h.config)||void 0===_||!_.mute_replace_unsub),simulcastOnDemand:!(!1===(null===(f=h.config)||void 0===f||null===(m=f.engine_VPM)||void 0===m||null===(g=m.ondemand)||void 0===g?void 0:g.enable)),forceUniHandler:1===(null==h||null===(y=h.config)||void 0===y||null===(S=y.vendor_param)||void 0===S?void 0:S.vendor_stream_sub_mode)},"boolean"==typeof(null==v?void 0:v.av_sync)&&(this._context.avSync=v.av_sync)),h.vendorConfig&&(this._vendorConfig=h.vendorConfig),GH.setAudioStallConfig(v),null!=h&&null!==(d=h.relayMessage)&&void 0!==d&&d.sdp&&(null===(b=this._handler)||void 0===b||b.createAVMlineAnswerTpl(h.relayMessage.sdp)),this.emit("joinSuccess",{joinRes:h,reconnect:n}),this._joinRoomSuccess(h),e.next=51;break;case 47:e.prev=47,e.t18=e.catch(29),k={461:fC.ROOM_FORBIDDEN,462:fC.USER_FORBIDDEN},(null===e.t18||void 0===e.t18?void 0:e.t18.code)>=700&&(null===e.t18||void 0===e.t18?void 0:e.t18.code)<800?this._joinRoomFailed("token_error",fC.INVALID_TOKEN):k[null===e.t18||void 0===e.t18?void 0:e.t18.code]?this._joinRoomFailed((null===e.t18||void 0===e.t18?void 0:e.t18.message)||k[null===e.t18||void 0===e.t18?void 0:e.t18.code],k[null===e.t18||void 0===e.t18?void 0:e.t18.code]):(null===e.t18||void 0===e.t18?void 0:e.t18.code)===fC.TIME_OUT&&this._context.joinRoomConfig.useTcpAfterJoinTimeout?(E="joinRoom timeout, retry with tcp only",this.logger.error("join",E),this.safeEmit(xW.ON_REJOIN_WITH_TCP),this._connectionManager.reconnect(E,!0)):e.t18.code===fC.OPERATION_CANCEL&&"connecting"===this.connectionState||this._joinRoomFailed((null===e.t18||void 0===e.t18?void 0:e.t18.message)||"signaling_error");case 51:case"end":return e.stop()}}),e,this,[[29,47]])}))),function(){return T.apply(this,arguments)})},{key:"_getVendorPubSdpInfo",value:(E=Ng(Pg().mark((function e(t){var r,n,i,o=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new GW(this._context,""),t.vendorHandler=new MW(this._context,r),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),e.next=5,t.vendorHandler.publish(t);case 5:return n=e.sent,(i=t.vendorHandler).on("ice_state",(function(e){o.emit(TW.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:dh.CONNECTION_STATE_CONNECTING,connected:dh.CONNECTION_STATE_CONNECTED,disconnected:dh.CONNECTION_STATE_RECONNECTING}[e],userId:o._clientId})})),i.once("disconnect",Ng(Pg().mark((function e(){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i.removeAllListeners(),"connected"===(null===(r=o._handler)||void 0===r||null===(n=r.pc)||void 0===n?void 0:n.iceConnectionState)){e.next=4;break}return o.logger.info("vendor ice failed",t.streamId),e.abrupt("return");case 4:return e.next=6,o.unpublish(t);case 6:return e.next=8,o.publish(t);case 8:t.vendorHandler&&t.statsReport.setVar(t.vendorHandler);case 9:case"end":return e.stop()}}),e)})))),e.abrupt("return",[i,n]);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"publish",value:(k=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._publish(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"_publish",value:(b=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M,L,U,V=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publish()","localStream: %o",t),g=t.videoTrack,y=t.audioTrack,S=IM(),b="",k="",E=this._handler,"H264"!==(null===(r=this._context)||void 0===r||null===(n=r.serverConfig)||void 0===n?void 0:n.videoCodec)){e.next=17;break}return e.next=10,LB();case 10:if(e.sent){e.next=17;break}if("VP8"!==KL("FALLBACK_ENCODE_CODEC")){e.next=16;break}this._context.serverConfig.videoCodec="VP8",e.next=17;break;case 16:throw new bC(fC.PUBLISH_FAILED,"h264 is not supported");case 17:if(!this._vendorConfig.enableMultiVendor){e.next=26;break}return e.next=20,this._getVendorPubSdpInfo(t);case 20:I=e.sent,R=gy(I,2),E=R[0],T=R[1],e.next=29;break;case 26:return e.next=28,this._handler.publish(t);case 28:T=e.sent;case 29:return null===(i=t.observer)||void 0===i||i.setHandler(E),this.emit("_test_pub_sdpInfo_",T),b=T.audioMid,k=T.videoMid,t.pubAttributes={localaudio:!!y,localvideo:!!g,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(g instanceof tH),extaudio:!!(y instanceof rH),videoDescriptions:T.videoDescriptions},A={attributes:Ql({},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:b,videoMid:k,sdpInfo:{msid:t.stream.id,type:T.type,sdp:T.partialSdp,semantics:T.semantics},peerConnectionMode:null===(o=T)||void 0===o?void 0:o.peerConnectionMode,supportMultiVendor:!0},(w=!this._vendorConfig.enableMultiVendor&&t.enableSimulcast&&(null===(a=this._context)||void 0===a||null===(s=a.serverConfig)||void 0===s?void 0:s.simulcastOnDemand)&&(null===(c=T.subVideoDescriptions)||void 0===c?void 0:c.length))&&(A.attributes.subVideoDescriptions=T.subVideoDescriptions),null!==(u=T)&&void 0!==u&&u.peerConnectionId&&(A.peerConnectionId=T.peerConnectionId),e.prev=38,this.emit("_test_pub_body_",A),e.next=42,null===(x=this._dataChannelSignal)||void 0===x?void 0:x.sendSignaling("publish",A);case 42:C=e.sent,e.next=67;break;case 45:return e.prev=45,e.t0=e.catch(38),e.t0 instanceof Error?null===(P=this._monitor)||void 0===P||P.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:S,message:Fg(D="".concat(e.t0.name,": ")).call(D,e.t0.message)}):e.t0 instanceof bC&&(null===(N=this._monitor)||void 0===N||N.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:S,message:Fg(M="".concat(e.t0.code,": ")).call(M,e.t0.message)})),e.next=50,null===(O=E)||void 0===O?void 0:O.rollback({msid:t.stream.id,stream:t,audioMid:b,videoMid:k});case 50:if(!(e.t0.code>=500&&e.t0.code<600)){e.next=66;break}if(this.emit("_test_pub_5xx_"),!((L=this.getPubSubBackOff(t.id)).retryDuration<6e4)){e.next=64;break}return this.logger.info("pubRetry",t.id,L.retryDuration),e.next=57,new jI((function(e){return setTimeout(e,L.interval)}));case 57:return L.retryDuration+=L.interval,L.interval=L.interval>4e3?8e3:2*L.interval,t.resetStream(),this.emit(xW.PUB_RETRY,{screen:t.isScreen}),e.abrupt("return",this._publish(t));case 64:this.logger.info("pubRetry","end"),delete this._pubSubBackOff[t.id];case 66:throw e.t0;case 67:if(null===(d=this._monitor)||void 0===d||d.report("rtc_recv_answer",{error_code:0,answer_type:null===(l=C)||void 0===l?void 0:l.relayMessage.type,sequence_id:(null===(h=C)||void 0===h||null===(p=h.relayMessage)||void 0===p?void 0:p.sequenceId)||0,message:null===(v=C)||void 0===v||null===(_=v.relayMessage)||void 0===_?void 0:_.sdp,direction:"up",stream_id:"",stream_user_id:"",pc_session_id:(null===(f=E)||void 0===f?void 0:f.peerConnectionId)||""}),U=new jI((function(e,r){var n,i,o,a,s,c,u,d;null===(n=E)||void 0===n||n.handleAck({action:$H.publish,streamId:C.streamId,audioMid:b,videoMid:k,audioTransceiverInit:null===(i=T)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=T)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:{sdp:null===(a=C)||void 0===a||null===(s=a.relayMessage)||void 0===s?void 0:s.sdp,sequenceId:null===(c=C)||void 0===c||null===(u=c.relayMessage)||void 0===u?void 0:u.sequenceId},sdp:null===(d=T)||void 0===d?void 0:d.sdp,stream:t,onSuccess:function(){V.logger.info("publish()","publish success"),e(0)},onFail:function(e){V.logger.info("publish()","publish fail"),r(e)}})})),e.t1=!tL,!e.t1){e.next=73;break}return e.next=73,U;case 73:this.emit("___afterHandleAckInPub"),w&&this.emit(EW.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}],!0),t.streamId=C.streamId,t.videoMid=k,t.audioMid=b,t.subVideoDescriptions=T.subVideoDescriptions,null===(m=this._monitor)||void 0===m||m.report("rtc_publish_stat",{result:"success",is_screen:"0",start:S,message:"unknown"});case 80:case"end":return e.stop()}}),e,this,[[38,45]])}))),function(e){return b.apply(this,arguments)})},{key:"updatePubTrack",value:(S=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C,x;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updatePubTrack()","localStream: %o",t),n=t.videoTrack,i=t.audioTrack,o=t.pubAudio,a=t.pubVideo,s=t.vendorHandler||this.handler,c=null==i?void 0:i.preprocessingTrack,u=null==n?void 0:n.preprocessingTrack,!a||!u){e.next=11;break}return e.next=8,null===(d=t.videoTransceiver)||void 0===d?void 0:d.sender.replaceTrack(u);case 8:this.updateVideoDescriptions(t),e.next=13;break;case 11:return e.next=13,null===(l=t.videoTransceiver)||void 0===l?void 0:l.sender.replaceTrack(null);case 13:if(null==s||s.updateMaxBitrate(t),!o||!c){e.next=21;break}return p=i.mixType,(v=i.mixedAudioTrack)&&p!==Dh.PLAYOUT&&c.enabled&&(c=v),e.next=19,null===(h=t.audioTransceiver)||void 0===h?void 0:h.sender.replaceTrack(c);case 19:e.next=24;break;case 21:return e.next=23,null===(_=t.audioTransceiver)||void 0===_?void 0:_.sender.replaceTrack(null);case 23:JN(this.id,"MediaClient.updatePubTrack(audio)","null");case 24:this.emit("___onAfterReplaceTrack");try{JN(this.id,"MediaClient.updatePubTrack",Gg({audioStreamTrack:fx(c),videoStreamTrack:fx(u)}))}catch(jZ){}for(m={},g=0,y=NS(f={localaudio:!!i,localvideo:!!n,videostream:a,audiostream:o,extvideo:!!(n instanceof tH),extaudio:!!(i instanceof rH)});g<y.length;g++)S=gy(y[g],2),b=S[0],(k=S[1])!==EU(t.pubAttributes,b)&&PU(m,b,k);if(MS(m).length){e.next=31;break}return e.abrupt("return");case 31:return t.observer&&(E=t.observer,T=m.audiostream,I=m.videostream,R=m.localaudio,A=m.localvideo,w=m.extaudio,C=m.extvideo,void 0!==A?void 0!==C?E.setPushVideo(C):E.setEnableVideo(A):void 0!==I&&E.setUnmuteVideo(I),void 0!==R?void 0!==w?E.setPushAudio(w):E.setEnableAudio(R):void 0!==T&&E.setUnmuteAudio(T)),t.pubAttributes=Ql(Ql({},t.pubAttributes),f),x={roomId:this._roomId,streamId:t.streamId,attributes:m},e.next=36,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateStreamAttributes",x);case 36:if(this.emit("___onAfterUpdateSignaling"),!tL){e.next=40;break}return e.next=40,null==s?void 0:s.setCurrentDescription();case 40:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"updateToken",value:(y=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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:e.next=13;break;case 10:throw e.prev=10,e.t0=e.catch(5),new bC(fC.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 13:case"end":return e.stop()}}),e,this,[[5,10]])}))),function(e){return y.apply(this,arguments)})},{key:"updateVideoDescriptions",value:(g=Ng(Pg().mark((function e(t){var r,n,i,o,a;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1===t.pubAttributes.videoDescriptions.length){e.next=2;break}return e.abrupt("return");case 2:if(null!=(o=null===(r=t.videoTrack)||void 0===r||null===(n=r.preprocessingTrack)||void 0===n?void 0:n.getSettings())&&o.width&&null!=o&&o.height&&null!=o&&o.frameRate){e.next=5;break}return e.abrupt("return");case 5:if(a=t.pubAttributes.videoDescriptions[0],o.width!==a.width||o.height!==a.height||o.frameRate!==a.framerate){e.next=8;break}return e.abrupt("return");case 8:a.width=o.width,a.height=o.height,a.framerate=o.frameRate,a.maxkbps=t.videoEncodeConfig[0].maxKbps||a.maxkbps,null===(i=this._dataChannelSignal)||void 0===i||i.sendSignaling("updateStreamAttributes",{roomId:this._roomId,streamId:t.streamId,attributes:{videoDescriptions:[a]}});case 13:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"unpublish",value:(m=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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:$H.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:"_getVendorSubSdpInfo",value:(f=Ng(Pg().mark((function e(t,r){var n,i,o,a=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new GW(this._context,""),t.vendorHandler=new MW(this._context,n),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),(i=t.vendorHandler).on("ontrack",r),e.next=7,t.vendorHandler.subscribe(t);case 7:return o=e.sent,i.on("ice_state",(function(e){a.emit(TW.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:dh.CONNECTION_STATE_CONNECTING,connected:dh.CONNECTION_STATE_CONNECTED,disconnected:dh.CONNECTION_STATE_RECONNECTING}[e],userId:t.userId})})),i.once("disconnect",Ng(Pg().mark((function e(){var r,n,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==i||i.removeAllListeners(),"connected"===(null===(r=a._handler)||void 0===r||null===(n=r.pc)||void 0===n?void 0:n.iceConnectionState)){e.next=4;break}return a.logger.info("vendor ice failed",t.streamId),e.abrupt("return");case 4:return o=t.subMediaType,e.next=7,a.unsubscribe(t);case 7:return e.next=9,a.subscribe(t,o);case 9:t.vendorHandler&&t.statsReport.setVar(t.vendorHandler),a.emit(xW.RESUBSCRIBE,{stream:t});case 11:case"end":return e.stop()}}),e)})))),e.abrupt("return",[i,o]);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"subscribe",value:(_=Ng(Pg().mark((function e(t,r,n){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._subscribe(t,r,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return _.apply(this,arguments)})},{key:"_subscribe",value:(v=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M,L,U,V,F,B,j,H,G,z,K,W,X,Y,q,J,Q,Z,$,ee,te,re,ne,ie,oe=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("subscribe()","mediaType: %o",r),iX("subscribe()",t,this.logger),t.streamState=YH.SUB_ING,R=!1,A=!1,GM(r)&&(A=!0),zM(r)&&(R=!0),R||!this.multiChatMode()){e.next=9;break}return t.streamState=YH.INIT,e.abrupt("return");case 9:if(w=IM(),C=t.subVideo,x=[],this._subResolves[t.streamId]||(this._subResolves[t.streamId]=[]),x.push(new jI((function(e,r){oe._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new bC(fC.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),rX);t.on("ontrack",(function r(i){"video"===i.mediaType&&(oe.logger.info("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),this.multiChatMode()||x.push(new jI((function(e,r){oe._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new bC(fC.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),rX);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(oe.logger.info("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),O=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",O),this._ontrackCallbackMap.set(t,O),P=this._handler,null!==(o=this._context.serverConfig)&&void 0!==o&&o.forceUniHandler||!t.enableVendorMode){e.next=28;break}return e.next=22,this._getVendorSubSdpInfo(t,O);case 22:N=e.sent,M=gy(N,2),P=M[0],D=M[1],e.next=31;break;case 28:return e.next=30,this._handler.subscribe(t,{multiChatMode:this.multiChatMode()});case 30:D=e.sent;case 31:if(null===(a=t.observer)||void 0===a||a.setHandler(P),U=(L=D).audioMid,V=L.videoMid,t.subVideo=R,F={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},B={audio:!this.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:V,audioMid:U,sdpInfo:{sdp:null===(s=D)||void 0===s?void 0:s.partialSdp,semantics:null===(c=D)||void 0===c?void 0:c.semantics,type:null===(u=D)||void 0===u?void 0:u.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!this.multiChatMode()||A,video:R},qualityLayer:F},extra:{enableSendRTT:!0},peerConnectionMode:null===(d=D)||void 0===d?void 0:d.peerConnectionMode,supportMultiVendor:!0},null!==(l=D)&&void 0!==l&&l.peerConnectionId&&(B.peerConnectionId=D.peerConnectionId),j=this._context||{},H=j.subscribeFallbackOption,G=j.userPriority,"number"==typeof H&&(B.config.fallbackOption=H),G.has(t.userId)&&(B.config.priority=G.get(t.userId)),null!==(h=D)&&void 0!==h&&h.allSsrc&&(B.extra.subscribeSSRC=D.allSsrc),null===(p=D)||void 0===p||!p.signalingAck){e.next=44;break}return e.next=44,new jI((function(e,r){var n,i,o,a;null===(n=P)||void 0===n||n.handleAck({action:$H.subscribe,streamId:t.streamId,audioMid:U,videoMid:V,audioTransceiverInit:null===(i=D)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=D)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:null===(a=D)||void 0===a?void 0:a.signalingAck,stream:t,sdp:D.sdp,onSuccess:function(){oe.logger.info("ssrc","success"),e(0)},onFail:function(e){oe.logger.info("ssrc","fail",e),r(e)}})}));case 44:return e.prev=44,this.emit("_test_sub_body_",B),e.next=48,null===(K=this._dataChannelSignal)||void 0===K?void 0:K.sendSignaling("subscribe",B);case 48:z=e.sent,e.next=78;break;case 51:if(e.prev=51,e.t0=e.catch(44),t.streamState=YH.INIT,e.t0 instanceof Error&&(null===(Y=this._monitor)||void 0===Y||Y.report("rtc_subscribe_stat",{result:"fail",start:w,message:e.t0.message,stream_user_id:t.userId})),!(e.t0.code>=500&&e.t0.code<600)){e.next=70;break}if(this.emit("_test_sub_5xx_"),!((q=this.getPubSubBackOff(t.streamId)).retryDuration<6e4)){e.next=68;break}return this.logger.info("subRetry",t.streamId,q.retryDuration),e.next=62,new jI((function(e){return setTimeout(e,q.interval)}));case 62:return q.retryDuration+=q.interval,q.interval=q.interval>4e3?8e3:2*q.interval,this.emit(xW.SUB_RETRY,{screen:t.isScreen,userId:t.userId}),e.abrupt("return",this._subscribe(t,r,n));case 68:this.logger.info("subRetry","end",t.streamId),delete this._pubSubBackOff[t.streamId];case 70:return t.subVideo=C,e.next=73,null===(W=P)||void 0===W?void 0:W.rollback({msid:t.streamId,stream:t});case 73:return J={roomId:this._roomId,streamId:t.streamId,userId:t.userId},e.next=76,null===(X=this._dataChannelSignal)||void 0===X?void 0:X.sendSignaling("unsubscribe",J).catch((function(){}));case 76:throw t.streamState=YH.INIT,e.t0;case 78:if(z.relayMessage){e.next=81;break}throw null===(Q=this._monitor)||void 0===Q||Q.report("rtc_error",{error_code:-1009,message:"relayMessage is null"}),new bC(fC.UNEXPECTED_ERROR,"unable to subscribe");case 81:if(Z=null!==(v=null===(_=z)||void 0===_?void 0:_.relayMessage)&&void 0!==v?v:{},$=Z.audioMid,ee=Z.videoMid,ql(f={},U,$),ql(f,V,ee),te=f,this.logger.info("sub midmap",t.userId,te),t.videoMid=V,t.audioMid=U,t.subMediaType=r,t.streamState=YH.SUB_ED,t.subLayer=F,null===(m=this._monitor)||void 0===m||m.report("rtc_recv_answer",{error_code:0,answer_type:null===(g=z)||void 0===g||null===(y=g.relayMessage)||void 0===y?void 0:y.type,sequence_id:(null===(S=z)||void 0===S||null===(b=S.relayMessage)||void 0===b?void 0:b.sequenceId)||0,message:null===(k=z)||void 0===k||null===(E=k.relayMessage)||void 0===E?void 0:E.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:(null===(T=P)||void 0===T?void 0:T.peerConnectionId)||""}),e.prev=90,null!==(re=D)&&void 0!==re&&re.signalingAck){e.next=94;break}return e.next=94,new jI((function(e,r){var n,i,o,a,s,c,u;null===(n=P)||void 0===n||n.handleAck({action:$H.subscribe,streamId:t.streamId,audioMid:U,videoMid:V,audioTransceiverInit:null===(i=D)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=D)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:{sdp:null===(a=z)||void 0===a||null===(s=a.relayMessage)||void 0===s?void 0:s.sdp,sequenceId:null===(c=z)||void 0===c||null===(u=c.relayMessage)||void 0===u?void 0:u.sequenceId},stream:t,sdp:D.sdp,onSuccess:function(){oe.logger.info("sub ack","success"),e(0)},onFail:function(e){oe.logger.info("sub ack","fail",e),r(e)}})}));case 94:return e.next=96,jI.all(x);case 96:e.next=106;break;case 98:return e.prev=98,e.t1=e.catch(90),e.t1 instanceof Error&&(null===(ie=this._monitor)||void 0===ie||ie.report("rtc_subscribe_stat",{result:"fail",start:w,message:e.t1.message,stream_user_id:t.userId})),J={roomId:this._roomId,streamId:t.streamId,userId:t.userId},e.next=104,null===(ne=this._dataChannelSignal)||void 0===ne?void 0:ne.sendSignaling("unsubscribe",J).catch((function(){}));case 104:throw t.streamState=YH.INIT,e.t1;case 106:this.multiChatMode()||(t.subAudio=A),null===(I=this._monitor)||void 0===I||I.report("rtc_subscribe_stat",{result:"success",start:w,message:"unknown",stream_user_id:t.userId}),this._context&&t.startReport((function(e){return oe.emit("onRemoteStreamStats",e)}),P);case 109:case"end":return e.stop()}}),e,this,[[44,51],[90,98]])}))),function(e,t,r){return v.apply(this,arguments)})},{key:"controlMessage",value:(p=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"updateUserAttributes",value:(h=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 h.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(l=Ng(Pg().mark((function e(t,r){var n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return this.logger.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:return this.emit("___afterUpdateSubscribeSend"),t.subLayer=r,e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"updateSubPriority",value:(d=Ng(Pg().mark((function e(t,r){var n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return this.logger.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:return t.priority=r,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"updateSubMediaType",value:(u=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=!1,a=!1,GM(r)&&(a=!0),zM(r)&&(o=!0),s={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:o,audio:!!this.multiChatMode()||a}}},e.next=6,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",s);case 6:return this.multiChatMode()||(null===(c=t.observer)||void 0===c||c.setUnmuteAudio(a),t.subAudio=a),null===(i=t.observer)||void 0===i||i.setUnmuteVideo(o),t.subVideo=o,t.subMediaType=r,e.abrupt("return",t);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(c=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("subscribe4pushTrack()","streamInfo: %o",r),iX("subscribe4pushTrack()",t,this.logger),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 bC(fC.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 8:return s=a.audioMid,c=a.videoMid,(u=[]).push(new jI((function(e,r){var n=setTimeout((function(){return r(new bC(fC.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),rX);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(l.logger.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:$H.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,jI.all(u);case 19:this._context&&t.startReport((function(e){return l.emit("onRemoteStreamStats",e)}),this._handler);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(s=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(iX("unsubscribe4removeTrack()",t,this.logger),this.logger.info("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId,"trackType: ",n),!(r.sequenceId<t.sequenceId)){e.next=5;break}return this.logger.warn("unsubscribe4removeTrack()","sequenceId return"),e.abrupt("return");case 5:return u=!!((c=n+1)&ch.AUDIO),d=!!(c&ch.VIDEO),e.next=10,null===(i=this._handler)||void 0===i?void 0:i.handleAck({action:$H.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 s.apply(this,arguments)})},{key:"unsubscribe",value:(a=Ng(Pg().mark((function e(t){var r,n,i,o,a,s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return iX("unsubscribe()",t,this.logger),o={roomId:this._roomId,streamId:t.streamId,userId:t.userId},a=t.vendorHandler||this.handler,null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unsubscribe",o).catch((function(){})),t.streamState=YH.INIT,t.subVideo=!1,null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(i=t.observer)||void 0===i||i.setSubscribeAudio(!1)),e.next=10,null==a?void 0:a.handleAck({action:$H.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:s=e.sent,this._subResolves[s]&&this._subResolves[s].forEach((function(e){return e(0)})),this.logger.info("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),t.subMediaType=xH.NONE,this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this)}))),function(e){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=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(iX("handleRemoveStream()",t,this.logger),t.subVideo=!1,t.streamState!==YH.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"leave",value:(i=Ng(Pg().mark((function e(){var t,r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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",jI.reject(new bC(fC.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=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g=this;return Pg().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 bC(fC.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=IM(),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,CB();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=GL.VERSION,e.t8=LL.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 jI((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new bC(fC.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),rX);t.on("ontrack",(function r(i){"video"===i.mediaType&&(g.logger.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p.push(new jI((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new bC(fC.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),rX);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(g.logger.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),_=null==h?void 0:h.relayMessage,f=_.sequenceId,m=_.sdp,t.videoMid=d,t.audioMid=u,t.sequenceId=f,t.streamState=YH.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:$H.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:m,sequenceId:f},stream:t});case 44:return e.next=46,jI.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.startReport((function(e){return g.emit("onRemoteStreamStats",e)}),this._handler);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(r=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return iX("unsubscribePublicStream()",t,this.logger),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=YH.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:$H.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),t.subMediaType=xH.NONE,this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;this.logger.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._pubSubBackOff={},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 jI((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 VW,a.code>=500&&a.code<600&&IM()-r.initTs<6e4){var s,c=r.getRetryDelay();return n.logger.warn("_joinRoomWithRetry",Fg(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;e.logger.info("connectStateChange","connected"),null===(r=e._dataChannelSignal)||void 0===r||r.destroy(),null===(n=e._handler)||void 0===n||n.destroy(),e._handler=yW(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.publicStream?e.emit("connectSuccess",{reconnect:!0}):(e._reportJoinRoomStart(),e._callJoinRoom(!0)))})),this._connectionManager.on("disconnected",(function(t){e.connectionState="disconnected",e.logger.error("connectStateChange","disconnected. %o",t),e.isReconnecting&&e.safeEmit(xW.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",e.logger.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",e.logger.warn("connectStateChange","reconnecting"),e.safeEmit("reconnecting")})),this._connectionManager.on("connectWidthTcp",(function(){e.safeEmit(xW.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=IM(),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:"getPubSubBackOff",value:function(e){return this._pubSubBackOff[e]||(this._pubSubBackOff[e]={interval:1e3,retryDuration:0}),this._pubSubBackOff[e]}},{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:IM()-this._joinRoomStartTs}),delete this._joinRoomStartTs)}},{key:"_joinRoomFailed",value:function(e,t){var r;(this._joinReject&&this._joinResolve&&(this._joinReject(new bC(t||fC.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=Ng(Pg().mark((function e(t,r,n){var i,o,a=this;return Pg().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:qg(n).call(n,(function(e){return{dstRoomId:e.roomId,dstToken:wM.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}}]),A}(kU);function aX(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var r,i,o,a=arguments;return Pg().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 bC(fC.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function sX(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var t,r,i,o,a=arguments;return Pg().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}tX([function(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var t,r,i,o,a=this,s=arguments;return Pg().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 jI(function(){var e=Ng(Pg().mark((function e(t,i){var s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new bC(fC.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}],oX.prototype,"join",1),tX([sX,aX],oX.prototype,"publish",1),tX([sX,aX],oX.prototype,"updatePubTrack",1),tX([aX],oX.prototype,"updateVideoDescriptions",1),tX([sX,aX],oX.prototype,"unpublish",1),tX([sX,aX],oX.prototype,"subscribe",1),tX([aX],oX.prototype,"controlMessage",1),tX([aX],oX.prototype,"updateUserAttributes",1),tX([aX],oX.prototype,"updateSubTrackLayer",1),tX([aX],oX.prototype,"updateSubPriority",1),tX([sX,aX],oX.prototype,"subscribe4pushTrack",1),tX([sX,aX],oX.prototype,"unsubscribe4removeTrack",1),tX([sX,aX],oX.prototype,"unsubscribe",1),tX([aX],oX.prototype,"handleRemoveStream",1),tX([sX],oX.prototype,"subscribePublicStream",1),tX([sX],oX.prototype,"unsubscribePublicStream",1);var cX,uX=function(){var e=Ng(Pg().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,_,f,m,g;return Pg().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.originTrack:null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.originTrack,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,JB(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,_=aI(p=v||[]).call(p,(function(e){return"inbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(f=e.sent,m=[],null==f||f.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==(null==v?void 0:v.length)||0===m.length){e.next=22;break}return e.next=21,JB(r.pc);case 21:g=e.sent;case 22:u=Gg({type:t,reports:qg(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==_?void 0:_.bytesReceived,framesReceived:null==_?void 0:_.framesReceived,packetsReceived:null==_?void 0:_.packetsReceived,allReports:g}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Gg(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)}}(),dX=function(){var e=Ng(Pg().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,_,f,m,g;return Pg().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.preprocessingTrack:null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.preprocessingTrack,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,JB(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,_=aI(p=v||[]).call(p,(function(e){return"outbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(f=e.sent,m=[],null==f||f.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==v.length||0===m.length){e.next=22;break}return e.next=21,JB(r.pc);case 21:g=e.sent;case 22:u=Gg({type:t,reports:qg(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==_?void 0:_.bytesSent,framesSent:null==_?void 0:_.framesSent,packetsSent:null==_?void 0:_.packetsSent,allReports:g}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Gg(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)}}(),lX=function(e){UA(a,e);var t,r,n,i,o=ew(a);function a(e,t){var r;return Fh(this,a),ql(aA(r=o.call(this)),"_audioEventSessionId",xM()),ql(aA(r),"_videoEventSessionId",xM()),ql(aA(r),"_handler",void 0),ql(aA(r),"_stream",void 0),ql(aA(r),"_firstAudioFrameTimer",void 0),ql(aA(r),"_firstVideoFrameTimer",void 0),ql(aA(r),"_transportDelayInterval",void 0),ql(aA(r),"_transportDelay",void 0),ql(aA(r),"_firstVideoFrameInterval",void 0),ql(aA(r),"_firstAudioFrameInterval",void 0),ql(aA(r),"_isScreen",!1),ql(aA(r),"_audioFirstFrameState",0),ql(aA(r),"_videoFirstFrameState",0),ql(aA(r),"_timeout",1e4),ql(aA(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),ql(aA(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),ql(aA(r),"_login",!1),ql(aA(r),"_unMuteAudio",!1),ql(aA(r),"_enableAudio",!1),ql(aA(r),"_unMuteVideo",!1),ql(aA(r),"_enableVideo",!1),ql(aA(r),"_remoteUnmuteAudio",!1),ql(aA(r),"_remoteUnmuteVideo",!1),ql(aA(r),"_audioExternal",!1),ql(aA(r),"_pushAudio",!1),ql(aA(r),"_videoExternal",!1),ql(aA(r),"_pushVideo",!1),ql(aA(r),"_autoSubscribeVideo",!1),ql(aA(r),"_autoSubscribeAudio",!1),ql(aA(r),"_autoSubscribe",!1),ql(aA(r),"_publishVideo",!1),ql(aA(r),"_publishAudio",!1),ql(aA(r),"_subscribeAudio",!1),ql(aA(r),"_subscribeVideo",!1),ql(aA(r),"_subscribe",!1),ql(aA(r),"_pushTrack",!1),ql(aA(r),"_multiChatMode",!1),ql(aA(r),"_monitor",void 0),ql(aA(r),"logger",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=KN(e.engineId),r.logger=new pM("RecvFrameObserver",0,e.engineId),r}return Vh(a,[{key:"beginRecvFrame",value:(i=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,yI(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(){uX("audio",k._handler,k._stream,k._monitor),k.stopRecvFrame("audio","timeout"),k._firstAudioFrameInterval&&window.clearInterval(k._firstAudioFrameInterval)}),this._timeout),this.logger.info("rtcFirstFrameRecv",Gg(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===(_=this._currentVideoRecv)||void 0===_?void 0:_.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,transport_delay:i,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(g=this._stream)||void 0===g?void 0:g.pcSessionId)||(null===(y=this._handler)||void 0===y?void 0:y.peerConnectionId)},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){uX("video",k._handler,k._stream,k._monitor),k.stopRecvFrame("video","timeout"),k._firstVideoFrameInterval&&window.clearInterval(k._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),this.logger.info("rtcFirstFrameRecv",Gg(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,this.logger.info("rtcFirstFrameRecv",Gg(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,g;if(1!==this._videoFirstFrameState)return;var y={event_type:"recv_end",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),start:null===(h=this._currentVideoRecv)||void 0===h?void 0:h.startTime,reason:t,result:!1,stream_user_id:null===(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===(_=this._stream)||void 0===_?void 0:_.vendorCode)||0,pc_session_id:(null===(f=this._stream)||void 0===f?void 0:f.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,this.logger.info("rtcFirstFrameRecv",Gg(y)),null===(g=this._monitor)||void 0===g||g.report("rtc_first_frame",y),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T;return Pg().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,yI(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),this.logger.info("rtcFirstFrameRecv",Gg(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,k=b.type,E=b.startTime,yI(v=["login","unmute","subscribe","push_track"]).call(v,k)>=0&&(r=0),T={event_type:"recv_end",media_type:t,is_screen:!(null===(_=this._stream)||void 0===_||!_.isScreen),start:E,result:!0,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,event_session_id:this._videoEventSessionId,type:k,transport_delay:r,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(g=this._stream)||void 0===g?void 0:g.pcSessionId)||(null===(y=this._handler)||void 0===y?void 0:y.peerConnectionId)},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this.logger.info("rtcFirstFrameRecv",Gg(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.stopRecvFrame("audio","stop_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.stopRecvFrame("video","stop_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&&(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(Ng(Pg().mark((function n(){var i,o,a,s,c,u,d,l;return Pg().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.preprocessingTrack){n.next=12;break}return n.next=3,JB(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.preprocessingTrack);case 3:if(d=n.sent,!(l=aI(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(Ng(Pg().mark((function n(){var i,o,a,s,c,u,d,l;return Pg().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.originTrack){n.next=12;break}return n.next=3,JB(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.originTrack);case 3:if(d=n.sent,!(l=aI(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=Ng(Pg().mark((function e(){var t=this;return Pg().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(Ng(Pg().mark((function e(){return Pg().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=Ng(Pg().mark((function e(){var t,r,n,i,o;return Pg().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,JB(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=aI(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=aI(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}(yU.EventEmitter),hX=function(){function e(t,r){Fh(this,e),ql(this,"_audioEventSessionId",xM()),ql(this,"_videoEventSessionId",xM()),ql(this,"_pcSessionId",void 0),ql(this,"_handler",void 0),ql(this,"_firstAudioFrameTimer",void 0),ql(this,"_firstVideoFrameTimer",void 0),ql(this,"_stream",void 0),ql(this,"_firstVideoFrameInterval",void 0),ql(this,"_firstAudioFrameInterval",void 0),ql(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),ql(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),ql(this,"_login",!1),ql(this,"_publisher",!1),ql(this,"_unMuteAudio",!1),ql(this,"_enableAudio",!1),ql(this,"_unMuteVideo",!1),ql(this,"_enableVideo",!1),ql(this,"_audioExternal",!1),ql(this,"_pushAudio",!1),ql(this,"_videoExternal",!1),ql(this,"_pushVideo",!1),ql(this,"_autoPublish",!1),ql(this,"_publish",!1),ql(this,"_timeout",1e4),ql(this,"_audioFirstFrameState",0),ql(this,"_videoFirstFrameState",0),ql(this,"_monitor",void 0),ql(this,"logger",void 0),this._stream=t,this._handler=r,this._monitor=KN(t.engineId),this.logger=new pM("SendFrameObserver",0,t.engineId)}var t,r;return Vh(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(){dX("audio",r._handler,r._stream,r._monitor),r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),this.logger.info("rtcFirstFrameSend",Gg(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 g={event_type:"begin_send",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),type:t,start:this._currentVideoSend.startTime,event_session_id:this._videoEventSessionId,vendor_mode:(null===(h=this._stream)||void 0===h?void 0:h.vendorCode)||0,pc_session_id:(null===(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===(_=this._stream)||void 0===_||null===(f=_.videoTrack)||void 0===f?void 0:f.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){dX("video",r._handler,r._stream,r._monitor),r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),this.logger.info("rtcFirstFrameSend",Gg(g)),null===(m=this._monitor)||void 0===m||m.report("rtc_first_frame",g),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u,d;if(1!==this._audioFirstFrameState)return;var l={event_type:"sent_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioSend)||void 0===i?void 0:i.type,vendor_mode:(null===(o=this._stream)||void 0===o?void 0:o.vendorCode)||0,pc_session_id:(null===(a=this._stream)||void 0===a?void 0:a.pcSessionId)||(null===(s=this._handler)||void 0===s?void 0:s.peerConnectionId),capture_session_id:null===(c=this._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,this.logger.info("rtcFirstFrameSend",Gg(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,g,y,S;if(1!==this._videoFirstFrameState)return;var b={event_type:"sent_end",media_type:e,start:null===(h=this._currentVideoSend)||void 0===h?void 0:h.startTime,is_screen:!(null===(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===(_=this._stream)||void 0===_?void 0:_.vendorCode)||0,pc_session_id:(null===(f=this._stream)||void 0===f?void 0:f.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId),capture_session_id:null===(g=this._stream)||void 0===g||null===(y=g.videoTrack)||void 0===y?void 0:y.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,this.logger.info("rtcFirstFrameSend",Gg(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),this.logger.info("rtcFirstFrameSend",Gg(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,g;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var y=this._currentVideoSend,S=y.type,b=y.startTime,k={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===(_=this._handler)||void 0===_?void 0:_.peerConnectionId),capture_session_id:null===(f=this._stream)||void 0===f||null===(m=f.videoTrack)||void 0===m?void 0:m.captureSessionId};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this.logger.info("rtcFirstFrameSend",Gg(k)),null===(g=this._monitor)||void 0===g||g.report("rtc_first_frame",k),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._stream.pubVideo&&this.beginSendFrame("video","login"),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this._stream.pubAudio&&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=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s;return Pg().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.preprocessingTrack){e.next=6;break}return e.next=3,JB(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o?void 0:o.videoTrack.preprocessingTrack);case 3:return a=e.sent,s=Ty(a).call(a,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",s);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=Ng(Pg().mark((function e(){var t,r,n,i,o,a;return Pg().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.preprocessingTrack){e.next=5;break}return e.next=3,JB(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o?void 0:o.audioTrack.preprocessingTrack);case 3:return a=e.sent,e.abrupt("return",aI(a).call(a,(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(Ng(Pg().mark((function n(){var i,o,a;return Pg().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||qg(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(Ng(Pg().mark((function r(){var n;return Pg().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}(),pX=(ql(cX={},"audio",{delay:1200,stallRadio:.3}),ql(cX,"video",{delay:1200,stallRadio:.6}),ql(cX,"screen_audio",{delay:1600,stallRadio:.8}),ql(cX,"screen_video",{delay:1600,stallRadio:.8}),cX),vX=function(){function e(){Fh(this,e),ql(this,"_preUplinkStats",new cT),ql(this,"_preDownlinkStats",new cT),ql(this,"_timer",void 0),ql(this,"_delayTimer",void 0),ql(this,"_msc",void 0),ql(this,"reportor",void 0)}return Vh(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,sI(i=Fg(o=[]).call(o,tR(l),[d])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var h,p,v=n?"screen_video":"video",_=r._fractionLost,f=r.rtt,m=r._sendBandWidth,g=r._retransmittedRate;0===m&&(_=Math.max(.65,_));var y=this._getQosLevel(f,_||0,g||0),S=this._preUplinkStats.get(v)||[y];this._preUplinkStats.set(v,sI(h=Fg(p=[]).call(p,tR(S),[y])).call(h,-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){var r;if(t){var n,i,o=this._getStreamActiveState(t),a=o.audioActive,s=o.videoActive,c=e.audioStats,u=e.videoStats,d=e.isScreen,l=e.userId,h=!0,p=!0;if(a)if(0===c.receivedKBitrate)h=!1;else{var v=c.rtt,_=c.audioLossRate,f=c.stallDuration,m=c.statsInterval,g=c.e2eDelay,y=f/m,S=d?"screen_audio":"audio",b=this._getQosLevel(v,_||0,u._retransmittedRate||0),k=this._getDownlinkQoE(S,y,g);n=this._getNetworkQuality(b,k)}if(s)if(0===u.receivedKBitrate||0===u.rtt)p=!1;else{var E=u.rtt,T=u.videoLossRate,I=u.stallDuration,R=u.statsInterval,A=u.e2eDelay,w=u._retransmittedRate,C=I/R,x=d?"screen_video":"video",O=this._getQosLevel(E,T||0,w||0),P=this._getDownlinkQoE(x,C,A);i=this._getNetworkQuality(O,P)}var D=Fg(r="".concat(l)).call(r,d?"_screen":"");if(h||p){var N=n&&i?Math.ceil((n+i)/2):n||i;if(N){var M,L,U=this._preDownlinkStats.get(D)||[N];this._preDownlinkStats.set(D,sI(M=Fg(L=[]).call(L,tR(U),[N])).call(M,-2)),this._startNetworkQualityReport()}}else this._preDownlinkStats.delete(D)}}},{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(Xy(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")||Sh.EXCELLENT;var l=Ty(a=qg(s=KC(ix(c=this._preDownlinkStats).call(c))).call(s,(function(e){return o._getBetterQualityAndRemoveOldest(e,"down")}))).call(a,(function(e){return e}));i=Math.ceil(oS(l).call(l,(function(e,t){return t+e}),0)/l.length)||Sh.UNKNOWN}else n=i=Sh.DOWN;navigator.onLine||(n=Sh.DOWN,i=Sh.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=pX[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=Sh.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=Ty(i).call(i,(function(e){return e}));o.length>0&&(r=Math.min.apply(Math,tR(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&&GM(t)&&r.localaudio&&r.audiostream,videoActive:n&&zM(t)&&r.localvideo&&r.videostream}}}]),e}(),_X=function(){function e(t){Fh(this,e),ql(this,"_timer",void 0),ql(this,"_remoteVideoSizeCache",{}),ql(this,"_remoteScreenSizeCache",{}),ql(this,"onchange",void 0),this._room=t,this._start()}return Vh(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.preprocessingTrack;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=0,v=0;if(tL){var _,f,m=null==n||null===(_=n.videoTrack)||void 0===_||null===(f=_.videoPlayer)||void 0===f?void 0:f.domElement;m&&(p=m.videoWidth,v=m.videoHeight)}else{var g=a.getSettings();p=g.width||0,v=g.height||0}h===v&&d===p||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,p,v),delete s[i],(n.isScreen?r:t)[i]={width:p,height:v}}}))})),MS(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),MS(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),fX=KC((new TextEncoder).encode("subt")),mX={1:fC.SUBTITLE_ERR_POSTPROCESS,2:fC.SUBTITLE_ERR_CONNECTION_ERROR,3:fC.SUBTITLE_ERR_PROCESS_ERROR},gX=new pM("SubtitleTool",1),yX=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&yI(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))||"";yI(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=Gg({source_language:o}))}},SX=function(){function e(t){var r,n,i;Fh(this,e),ql(this,"_taskId",void 0),ql(this,"_appId",void 0),ql(this,"_roomId",void 0),ql(this,"_userId",void 0),ql(this,"onEvent",void 0),ql(this,"onMessage",void 0),ql(this,"_preConfig",void 0),ql(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 Vh(e,[{key:"start",value:(n=Ng(Pg().mark((function e(t){var r=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(gX.info("start","Invoke config: %o",t),eU(t.mode,"mode",[Ah.ASR_ONLY,Ah.ASR_AND_TRANSLATION]),t.mode!==Ah.ASR_AND_TRANSLATION||-1!==yI(kX).call(kX,t.targetLanguage||"")){e.next=4;break}throw new bC(fC.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new bC(fC.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:wh.ERROR,errorCode:fC.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=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(eU(t.mode,"mode",[Ah.ASR_ONLY,Ah.ASR_AND_TRANSLATION]),t.mode!==Ah.ASR_AND_TRANSLATION||-1!==yI(kX).call(kX,t.targetLanguage||"")){e.next=3;break}throw new bC(fC.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new bC(fC.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new bC(fC.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;gX.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:wh.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(t=Ng(Pg().mark((function e(){return Pg().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(){gX.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 bC(mX[r]||fC.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:wh.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:wh.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(this._taskId&&this._preConfig){var t=bX(e);if(t&&t.length>0){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){i===Ah.ASR_ONLY?e.mode===i&&a.push(e):i===Ah.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==Ah.ASR_ONLY||a.push(e),e.mode===Ah.ASR_ONLY&&e.language===o&&a.push(Ql(Ql({},e),{},{mode:Ah.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}(),bX=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(fX.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=wM.ab2str(sI(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(c){}return!1},kX=["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"],EX=uT,TX=HI,IX=function(e,t,r,n){for(var i,o=n>1?void 0:n?TX(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&&EX(t,r,o),o},RX=function(){function e(t){Fh(this,e),ql(this,"_forwardDstRooms",new cT),ql(this,"forwardStreamState","stopped"),ql(this,"_monitor",void 0),this._room=t,this._monitor=KN(this._room.id)}var t,r,n,i,o,a;return Vh(e,[{key:"startForwardStream2Rooms",value:(a=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!==this.forwardStreamState&&"paused"!==this.forwardStreamState){e.next=2;break}throw new bC(fC.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=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new bC(fC.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=Ng(Pg().mark((function e(){var t,r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new bC(fC.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),!(tR(ix(t=this._forwardDstRooms).call(t)).length>0)){e.next=10;break}throw new bC(fC.UNEXPECTED_ERROR,"stopforwardstream failed: ".concat(Gg(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=Ng(Pg().mark((function e(){var t,r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("paused"!==this.forwardStreamState&&"stopped"!==this.forwardStreamState){e.next=2;break}throw new bC(fC.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=Ng(Pg().mark((function e(){var t,r,n,i,o=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o.length>0&&void 0!==o[0]&&o[0]||!Xy(t=["running","stopped"]).call(t,this.forwardStreamState)){e.next=3;break}throw new bC(fC.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===Ch.FORWARD_STREAM_STATE_FAILURE&&e._room.safeEmit(xW.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(xW.ON_FORWARD_STREAM_ERROR,{roomId:e.dstRoomId,state:Ch.FORWARD_STREAM_STATE_FAILURE,error:xh.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=eC(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=my(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=i.dstRoomId,a=i.code,s={roomId:o,state:Ch.FORWARD_STREAM_STATE_SUCCESS,error:xh.FORWARD_STREAM_ERROR_OK};200===a||(400===a?(s.state=Ch.FORWARD_STREAM_STATE_FAILURE,s.error=xh.FORWARD_STREAM_ERROR_REMOTE_KICKED):a>=700&&a<800?(s.state=Ch.FORWARD_STREAM_STATE_FAILURE,s.error=xh.FORWARD_STREAM_ERROR_INVALID_TOKEN):(s.state=Ch.FORWARD_STREAM_STATE_FAILURE,s.error=xh.FORWARD_STREAM_ERROR_RESPONSE)),r.push(s)}}catch(HZ){n.e(HZ)}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=aI(e).call(e,(function(e){return e.roomId===n}));if(!s&&!t._forwardDstRooms.has(n))throw new bC(fC.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=TT(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=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="".concat(xM()),"stop"!==t&&(a=qg(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(qg(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:Gg(c),event_session_id:i})),new bC(fC.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=aI(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:Gg(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 AX(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var r,i,o,a,s=arguments;return Pg().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 bC(fC.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 8:case"end":return e.stop()}}),e,this)}))),r}IX([AX],RX.prototype,"startForwardStream2Rooms",1),IX([AX],RX.prototype,"updateForwardStream2Rooms",1),IX([AX],RX.prototype,"stopForwardStream2Rooms",1),IX([AX],RX.prototype,"pauseForwardStream2AllRooms",1),IX([AX],RX.prototype,"resumeForwardStream2AllRooms",1);var wX={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},CX=function(e){UA(x,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C=ew(x);function x(e,t){var r;return Fh(this,x),ql(aA(r=C.call(this)),"id",void 0),ql(aA(r),"_mediaServerClient",void 0),ql(aA(r),"_localStream",void 0),ql(aA(r),"_localScreenStream",void 0),ql(aA(r),"_remoteUsers",new cT),ql(aA(r),"_remoteStreams",new cT),ql(aA(r),"_remoteStreamStreamIdUserIdMap",{}),ql(aA(r),"_virtualStreams",[]),ql(aA(r),"_context",void 0),ql(aA(r),"_sessionId",void 0),ql(aA(r),"_connectionLostTimer",void 0),ql(aA(r),"_serverConfig",void 0),ql(aA(r),"_roomConfig",void 0),ql(aA(r),"_roomInfo",void 0),ql(aA(r),"_userDuplicateLoginTimerMap",new cT),ql(aA(r),"_networkQualityManager",void 0),ql(aA(r),"_videoSizeObserver",void 0),ql(aA(r),"_hasPublished",!1),ql(aA(r),"_subtitleTool",void 0),ql(aA(r),"_csrcUserIdMap",void 0),ql(aA(r),"_publishOnDemandItem",void 0),ql(aA(r),"_onceTriggerBySignal",!1),ql(aA(r),"_pubTransceiverReady",!1),ql(aA(r),"_publishOnDemandBusy",!1),ql(aA(r),"_monitor",void 0),ql(aA(r),"logger",void 0),ql(aA(r),"_forwardStreamManager",void 0),r.id=t.id,r.logger=new pM("Room",1,t.id),r.logger.info("constructor","invoke"),r._roomConfig=e,r._mediaServerClient=new oX(t),r._networkQualityManager=new vX,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(aA(r)),r._videoSizeObserver=new _X(aA(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(aA(r)),r._context=t,r._csrcUserIdMap={},r._monitor=KN(r.id),r._forwardStreamManager=new RX(aA(r)),r._addHandlerEventHandler(),r}return Vh(x,[{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,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M=this;null===(e=this._mediaServerClient)||void 0===e||e.on(kW.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(kW.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return M._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(kW.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(kW.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return M._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(kW.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(kW.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return M._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(kW.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(kW.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return M._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(kW.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(kW.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(kW.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(kW.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(kW.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(kW.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(kW.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(kW.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(kW.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(kW.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(kW.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(kW.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(EW.RSCP,(function(e,t){!!aI(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:Xy(t).call(t,null===(r=M._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(t?M._pubTransceiverReady=!0:M._onceTriggerBySignal=!0,t&&M._onceTriggerBySignal||(M._publishOnDemandItem=e),M._pubTransceiverReady&&M._onPublishOnDemand())})),null===(b=this._mediaServerClient)||void 0===b||b.on(EW.RTT,this._onRTT.bind(this)),null===(k=this._mediaServerClient)||void 0===k||k.on(EW.SSC,this._onSSC.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(TW.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(TW.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return M.emit(TW.ON_VENDOR_CONNECTION_STATE_CHANGE,e)})),null===(I=this._mediaServerClient)||void 0===I||I.on(kW.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){M._networkQualityManager.updateDownlinkStats(e,M._findRemoteStreamByScreen(e.userId,e.isScreen)),M.emit(xW.ON_REMOTE_STREAM_STATS,KM(e))})),null===(A=this._mediaServerClient)||void 0===A||A.on(xW.RESUBSCRIBE,(function(e){M.emit(xW.RESUBSCRIBE,e)})),null===(w=this._mediaServerClient)||void 0===w||w.on(xW.RECONNECT_FAILED,(function(){M.emit(xW.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(kW.ON_FORWARD_DST_ROOM_USER_KICK,this._forwardStreamManager.onForwardDstRoomUserKick.bind(this._forwardStreamManager)),null===(O=this._mediaServerClient)||void 0===O||O.on(xW.ON_REJOIN_WITH_TCP,(function(){M.emit(xW.ON_REJOIN_WITH_TCP)})),null===(P=this._mediaServerClient)||void 0===P||P.on(xW.ON_ICE_CONNECT_WITH_TCP,(function(){M.emit(xW.ON_ICE_CONNECT_WITH_TCP)})),null===(D=this._mediaServerClient)||void 0===D||D.on(xW.PUB_RETRY,(function(e){M.emit(xW.PUB_RETRY,e)})),null===(N=this._mediaServerClient)||void 0===N||N.on(xW.SUB_RETRY,(function(e){M.emit(xW.SUB_RETRY,e)}))}},{key:"_onLocalStreamStats",value:function(e){this._networkQualityManager.updateUplinkStats(e),this.emit(xW.ON_LOCAL_STREAM_STATS,KM(e))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(w=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setSessionId(),e.next=3,this._mediaServerClient.connect();case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"join",value:(A=Ng(Pg().mark((function e(t,r,n,i,o){var a,s,c;return Pg().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}),this.logger.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===fC.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 A.apply(this,arguments)})},{key:"publishScreen",value:(R=Ng(Pg().mark((function e(t,r,n,i,o){var a,s,c,u,d,l,h,p,v,_,f,m;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishScreen()"),this._localScreenStream||(this._localScreenStream=new qH(this._context),null!==(a=this._mediaServerClient)&&void 0!==a&&null!==(s=a.vendorConfig)&&void 0!==s&&s.enableMultiVendor&&(this._localScreenStream.pcSessionId=px()),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new hX(this._localScreenStream,this._mediaServerClient.handler))),c=!1,u=!1,d=!1,l=!1,!this._localScreenStream.videoTrack&&r?(r instanceof tH&&(u=!0),c=!0):this._localScreenStream.videoTrack&&!r&&(c=!1),!this._localScreenStream.audioTrack&&n?(n instanceof rH&&(l=!0),d=!0):this._localScreenStream.audioTrack&&!n&&(d=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(GM(i)&&(this._localScreenStream.pubAudio=o===PW.PUB),zM(i)&&(this._localScreenStream.pubVideo=o===PW.PUB),this.logger.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===(_=this._localScreenStream.observer)||void 0===_||_.setEnableVideo(c),l?null===(f=this._localScreenStream.observer)||void 0===f||f.setPushAudio(d):null===(m=this._localScreenStream.observer)||void 0===m||m.setEnableAudio(d),e.next=28,this.updatePubScreenTrack();case 28:this._localScreenStream.pubAudio||this._localScreenStream.pubVideo?this._mediaServerClient.handler&&this._localScreenStream.startReport(this._onLocalStreamStats.bind(this),this._localScreenStream.vendorHandler||this._mediaServerClient.handler):this._localScreenStream.stopReport("unpublish screen");case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return R.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(I=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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 I.apply(this,arguments)})},{key:"unpublishScreen",value:(T=Ng(Pg().mark((function e(){var t;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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 T.apply(this,arguments)})},{key:"liveControlMessage",value:(E=Ng(Pg().mark((function e(t){var r,n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 E.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(k=Ng(Pg().mark((function e(t){return Pg().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:(b=Ng(Pg().mark((function e(t){return Pg().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 b.apply(this,arguments)})},{key:"updateUserAttributes",value:(S=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 S.apply(this,arguments)})},{key:"publish",value:(y=Ng(Pg().mark((function e(t,r,n,i,o,a){var s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=I.length>6&&void 0!==I[6]&&I[6],this.logger.info("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new qH(this._context),null!==(u=this._mediaServerClient)&&void 0!==u&&null!==(d=u.vendorConfig)&&void 0!==d&&d.enableMultiVendor&&(this._localStream.pcSessionId=px()),this._mediaServerClient.handler&&(this._localStream.observer=new hX(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,h=this._localStream,p=h.pubAudio,v=h.pubVideo,o&&(GM(o)&&(this._localStream.pubAudio=a===PW.PUB),zM(o)&&(this._localStream.pubVideo=a===PW.PUB),this.logger.info("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=29;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=13;break}return e.abrupt("return");case 13:return e.prev=13,s?null===(_=this._localStream.observer)||void 0===_||_.setLogin(!0):c&&(f=!!this._localStream.videoTrack,m=!!this._localStream.audioTrack,g=this._localStream.videoTrack instanceof tH,y=this._localStream.audioTrack instanceof rH,this._roomConfig.isAutoPublish&&!this._hasPublished?(f&&(g?null===(S=this._localStream.observer)||void 0===S||S.setPushVideo(!0):null===(b=this._localStream.observer)||void 0===b||b.setEnableVideo(!0)),m&&(y?null===(k=this._localStream.observer)||void 0===k||k.setPushAudio(!0):null===(E=this._localStream.observer)||void 0===E||E.setEnableAudio(!0))):null===(T=this._localStream.observer)||void 0===T||T.setPublish(!0)),this.emit("___onMediaServerClientPublish"),e.next=18,this._mediaServerClient.publish(this._localStream);case 18:this._hasPublished=!0,this.emit(xW.ON_PUBLISH_RESULT,{isScreen:!1,state:ih.PUBLISH_SUCC}),e.next=27;break;case 22:throw e.prev=22,e.t0=e.catch(13),this.emit(xW.ON_PUBLISH_RESULT,{isScreen:!1,state:ih.PUBLISH_FAIL}),delete this._localStream,e.t0;case 27:e.next=40;break;case 29:return e.prev=29,this.emit("___onMediaServerClientPublish"),e.next=33,this.updatePubTrack();case 33:e.next=40;break;case 35:throw e.prev=35,e.t1=e.catch(29),this._localStream.pubAudio=p,this._localStream.pubVideo=v,e.t1;case 40:this._localStream.pubAudio||this._localStream.pubVideo?this._mediaServerClient.handler&&this._localStream.startReport(this._onLocalStreamStats.bind(this),this._localStream.vendorHandler||this._mediaServerClient.handler):this._localStream.stopReport("unpublish");case 41:case"end":return e.stop()}}),e,this,[[13,22],[29,35]])}))),function(e,t,r,n,i,o){return y.apply(this,arguments)})},{key:"updatePubTrack",value:(g=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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:(m=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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 m.apply(this,arguments)})},{key:"subscribe",value:(f=Ng(Pg().mark((function e(t,r,n){var i,o,a;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("subscribe","remoteStream %o",t),!t.hasSubscribed){e.next=8;break}if((i=t.subMediaType|r)===t.subMediaType){e.next=7;break}return e.next=6,null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubMediaType(t,i);case 6:return e.abrupt("return",e.sent);case 7:return e.abrupt("return");case 8:return a=void 0,n&&(a=this._getSubLayer(n,t)),e.next=12,this._mediaServerClient.subscribe(t,r,a);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return f.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(_=Ng(Pg().mark((function e(t,r){var n,i,o,a,s;return Pg().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 _.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,_;if(h>=(null===(v=d[p])||void 0===v?void 0:v.width)*(null===(_=d[p])||void 0===_?void 0:_.height)){l=p;break}}var f=d[0];if(-1===l)f=d[l=d.length-1];else if(0!==l){var m=d[l-1].width*d[l-1].height,g=(m-h)/(m-d[l].width*d[l].height);f=g<.1?d[l-1]:d[l],l=g<.1?l-1:l}return a=null!==(r=null===(n=f)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=f)||void 0===o?void 0:o.video_index)&&void 0!==i?i:l,spatialSubLayer:a}}},{key:"unsubscribe",value:(v=Ng(Pg().mark((function e(t,r){var n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("unsubscribe","Invoke unsubscribe"),t.hasSubscribed){e.next=3;break}return e.abrupt("return");case 3:if(o=t.subMediaType-(t.subMediaType&r),null!==(n=this._context.serverConfig)&&void 0!==n&&n.muteReplaceUnsub||!(o===xH.NONE||this.multiChatMode&&o===ch.AUDIO)){e.next=8;break}return e.next=7,this._mediaServerClient.unsubscribe(t);case 7:return e.abrupt("return",e.sent);case 8:return e.next=10,null===(i=this._mediaServerClient)||void 0===i?void 0:i.updateSubMediaType(t,o);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"startSubtitle",value:(p=Ng(Pg().mark((function e(t){return Pg().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 bC(fC.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=Ng(Pg().mark((function e(){var t;return Pg().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=Ng(Pg().mark((function e(t){return Pg().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=Ng(Pg().mark((function e(t){return Pg().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=Ng(Pg().mark((function e(){return Pg().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=Ng(Pg().mark((function e(){return Pg().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=Ng(Pg().mark((function e(){return Pg().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=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=h.length>0&&void 0!==h[0]&&h[0],this.logger.info("leave","Invoke leave"),n=IM(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,delete this._sessionId,e.prev=6,s=my(cw(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(HZ){s.e(HZ)}finally{s.f()}return this._localStream&&(null===(d=this._localStream.observer)||void 0===d||d.setLogin(!1)),e.next=12,this._mediaServerClient.leave().catch((function(){}));case 12:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:IM()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=25;break;case 17:if(e.prev=17,e.t0=e.catch(6),!r){e.next=23;break}throw e.t0;case 23:this.destroy();case 24:e.t0 instanceof Error&&(null===(l=this._monitor)||void 0===l||l.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:IM()-n}));case 25:case"end":return e.stop()}}),e,this,[[6,17]])}))),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;this.logger.info("destroy","Invoke destroy"),JN(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 cT;var t,r,n,i=my(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=gy(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.destroy()}))}}catch(HZ){i.e(HZ)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new cT,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=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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(xW.ON_ROOM_ERROR,{errorCode:fC.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||(this._sessionId=bM(),this._mediaServerClient._sessionId=this._sessionId,null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId}))}},{key:"sendRoomMessage",value:(i=Ng(Pg().mark((function e(t){var r,n,i,o,a,s=arguments;return Pg().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,wM.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;this.logger.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(xW.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&i.safeEmit(xW.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=my(cw(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(HZ){p.e(HZ)}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=my(cw(n=this._remoteStreams).call(n));try{for(f.s();!(_=f.n()).done;){var m=_.value;Array.isArray(m)&&m.forEach((function(e){e.stillExist?delete e.stillExist:u.push({clientId:e.userId,streamId:e.streamId,message:SW.clientDisconnected})}))}}catch(HZ){f.e(HZ)}finally{f.f()}c.forEach((function(e){return i._onUserDisconnection(e)})),s.forEach((function(e){return i._onUserConnection(e)})),u.forEach((function(e){return i._onRemoveStream(e)})),d.forEach((function(e){return i._onAddStream(e,{fromSignal:!1})})),l.forEach((function(e){return i._onUpdateStreamAttributes(e)})),a&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r,n,i,o=this;this._localStream&&(this._localStream.clean(),this._localStream.vendorCode=(null===(r=this._mediaServerClient.vendorConfig)||void 0===r?void 0:r.vendorCode)||0,null===(n=this._localStream.observer)||void 0===n||n.setLogin(!0),this._mediaServerClient.publish(this._localStream).then((function(){var e;o._mediaServerClient.handler&&(null===(e=o._localStream)||void 0===e||e.startReport(o._onLocalStreamStats.bind(o),o._localStream.vendorHandler||o._mediaServerClient.handler)),o.emit(xW.ON_PUBLISH_RESULT,{isScreen:!1,state:ih.PUBLISH_SUCC,retry:!0})})).catch((function(e){o.logger.error("failed repub error:".concat(e)),o.emit(xW.ON_PUBLISH_RESULT,{isScreen:!1,state:ih.PUBLISH_FAIL,errorCode:e.code,retry:!0})})));this._localScreenStream&&(this._localScreenStream.clean(),null===(i=this._localScreenStream.observer)||void 0===i||i.setLogin(!0),this._mediaServerClient.publish(this._localScreenStream).then((function(){var e;o._mediaServerClient.handler&&(null===(e=o._localScreenStream)||void 0===e||e.startReport(o._onLocalStreamStats.bind(o),o._localScreenStream.vendorHandler||o._mediaServerClient.handler)),o.emit(xW.ON_PUBLISH_RESULT,{isScreen:!0,state:ih.PUBLISH_SUCC,retry:!0})})).catch((function(e){o.logger.error("failed repub screen stream error:".concat(e)),o.emit(xW.ON_PUBLISH_RESULT,{isScreen:!0,state:ih.PUBLISH_FAIL,errorCode:e.code,retry:!0})})));var a,s=my(cw(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=Ng(Pg().mark((function e(t){var r,n,i,a,s,c;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=22;break}return t.resetHasSubscribed(),e.prev=2,o.logger.info(Fg(r="start resubscribe ".concat(t.userId," with ")).call(r,t.subMediaType)),zM(t.subMediaType)&&(null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!0)),GM(t.subMediaType)&&(null===(i=t.observer)||void 0===i||i.setSubscribeAudio(!0)),e.next=8,o._mediaServerClient.subscribe(t,t.subMediaType);case 8:o.logger.info(Fg(a="success resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType)),o.safeEmit(xW.RESUBSCRIBE,{stream:t}),o.emit(xW.ON_SUBSCRIBE_RESULT,{userId:t.userId,isScreen:t.isScreen,retry:!0}),e.next=22;break;case 13:if(e.prev=13,e.t0=e.catch(2),o.emit(xW.ON_SUBSCRIBE_RESULT,{userId:t.userId,isScreen:t.isScreen,errorCode:e.t0.code,retry:!0}),o.logger.error(Fg(s=Fg(c="failed resubscribe ".concat(t.userId," with ")).call(c,t.subMediaType,", error:")).call(s,e.t0)),e.t0.code!==fC.NOT_CONNECTED_YET){e.next=20;break}return t.streamState=YH.SUB_ED,e.abrupt("return");case 20:t.clean(),null==t||t.resetHasSubscribed();case 22:case"end":return e.stop()}}),e,null,[[2,13]])})));return function(t){return e.apply(this,arguments)}}())}}catch(HZ){s.e(HZ)}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=aI(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 JH(this._context,"ff-stream","ff-stream",!1,!1,wX);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=yH(i),this._virtualStreams.push(s),this.safeEmit(xW.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?aI(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)?aI(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:Ty(p).call(p,(function(e){return e.streamId!==h.streamId}));h.clean(),this._remoteStreams.set(e.clientId,v||[])}var _=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,_)_.attributes=e.attributes;else if((_=new JH(this._context,e.clientId,e.streamId,e.screen,!1,e.attributes)).virtual=c,this._initStreamListeners(_),!c){var f=this._remoteStreams.get(e.clientId);f?f.push(_):this._remoteStreams.set(e.clientId,[_])}if(this._mediaServerClient.handler&&(_.observer=new lX(_,this._mediaServerClient.handler)),!_.isScreen&&l){var m,g,y,S,b,k,E,T;if(a&&_.hasVideo)if(_.attributes.extvideo)null===(m=_.observer)||void 0===m||m.setExternalVideoSource(!0),null===(g=_.observer)||void 0===g||g.setPushVideo(!0);else null===(y=_.observer)||void 0===y||y.setExternalVideoSource(!1),null===(S=_.observer)||void 0===S||S.setPublishVideo(!0);if(a&&_.hasAudio&&d&&!this._mediaServerClient.roomAttributes.multiChatMode)if(_.attributes.extaudio)null===(b=_.observer)||void 0===b||b.setExternalAudioSource(!0),null===(k=_.observer)||void 0===k||k.setPushAudio(!0);else null===(E=_.observer)||void 0===E||E.setExternalAudioSource(!1),null===(T=_.observer)||void 0===T||T.setPublishAudio(!0);if(i&&!a){var I,R=this._roomConfig,A=R.isAutoSubscribeAudio,w=R.isAutoSubscribeVideo;null===(I=_.observer)||void 0===I||I.setLogin(!0,{audio:!!A&&!this.multiChatMode,video:!!w})}}return i&&this.safeEmit(kW.ON_ADD_STREAM,{stream:_}),_}}},{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,Ql({},n)),this.safeEmit(kW.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(xW.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(xW.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code,a=e.forbiddenTime;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var s=null;i===IW.kickedByAdmin?s=fC.KICKED_OUT:i===IW.onUserTokenDidExpire?s=fC.TOKEN_EXPIRED:i===IW.userDuplicateLogin&&(s=fC.DUPLICATE_LOGIN),o===RW.roomDismissByAdmin&&(s=fC.ROOM_DISMISS),s&&this.safeEmit(xW.ON_ROOM_ERROR,{errorCode:s,forbiddenTime:a})}else{var c=eh.DROPPED;i===IW.userLeave?c=eh.QUIT:i===IW.kickedByAdmin?c=eh.KICKED_BY_ADMIN:i===IW.roleChanged&&(c=eh.SWITCH_TO_INVISIBLE);var u=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:SW.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(xW.ON_USER_LEAVE,{userInfo:{userId:n},reason:c})};if(i===IW.userDuplicateLogin){var d=this._userDuplicateLoginTimerMap.get(n);d&&self.clearTimeout(d);var l=self.setTimeout(u,5e3);this._userDuplicateLoginTimerMap.set(n,l)}else u()}}},{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=aI(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).then((function(){var t=r._remoteStreams.get(e.clientId);t&&(t=Ty(t).call(t,(function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),r._remoteStreams.set(e.clientId,t))})).finally((function(){r.safeEmit(kW.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(xW.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(xW.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=Ql(Ql({},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=Ql(Ql({},d),a),h=!1,p=l.localaudio!==d.localaudio,v=!1,_=!1,f=l.localvideo!==d.localvideo,m=!1,g=xH.NONE,y=xH.NONE;if(l.audiostream!==d.audiostream&&(h=l.localaudio,v=!!l.audiostream,l.audiostream?g|=ch.AUDIO:y|=ch.AUDIO),l.videostream!==d.videostream&&(_=l.localvideo,m=!!l.videostream,l.videostream?g|=ch.VIDEO:y|=ch.VIDEO),g&&this.safeEmit(xW.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:PW.PUB,remoteStream:s}),y&&this.safeEmit(xW.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:PW.UNPUB,remoteStream:s}),s.attributes=l,l.localaudio!==d.localaudio)if(l.localaudio){var S,b,k,E;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===(k=s.observer)||void 0===k||k.setExternalAudioSource(!1),null===(E=s.observer)||void 0===E||E.setEnableAudio(!0);this.safeEmit(xW.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(xW.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(xW.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var P,D,N,M;if(l.extvideo)null===(P=s.observer)||void 0===P||P.setExternalVideoSource(!0),null===(D=s.observer)||void 0===D||D.setPushVideo(!1);else null===(N=s.observer)||void 0===N||N.setExternalVideoSource(!1),null===(M=s.observer)||void 0===M||M.setEnableVideo(!1);!s.isScreen&&this.safeEmit(xW.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!p&&r)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(v);if(_&&!f&&n)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&&_C(t).call(t,"audio_mux")){var n=this._onAddStream(Ql(Ql({},e),{},{attributes:wX}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(xW.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){r.logger.error("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:Fg(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:LW.TRACK_ERROR})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message,o=e.trackType;this.logger.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(xW.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&&Xy(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=gy(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&&Kw(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=my(cw(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(HZ){u.e(HZ)}finally{u.f()}this._virtualStreams.forEach((function(e){var t;s.emit(xW.REMOVE_PUSH_TRACK,{stream:e,mediaType:ch.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===nX.DISCONNECTED)t=dh.CONNECTION_STATE_DISCONNECTED;else if(e.next===nX.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._mediaServerClient.isReconnecting?dh.CONNECTION_STATE_RECONNECTED:dh.CONNECTION_STATE_CONNECTED;else{if(e.next!==nX.CONNECTING)return;this._mediaServerClient.isReconnecting?(t=dh.CONNECTION_STATE_RECONNECTING,this._onReconnecting()):t=dh.CONNECTION_STATE_CONNECTING}e.prev===nX.CONNECTED&&e.next===nX.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(TW.ON_CONNECTION_STATE_CHANGE,{state:dh.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setMSC(this._mediaServerClient),this.safeEmit(TW.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(xW.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?sh.STREAM_INDEX_SCREEN:sh.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(kW.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(kW.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(kW.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new SX(this),this._subtitleTool.onEvent=function(t){e.emit(xW.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(xW.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=OW.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=OW.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?OW.START_FAILED:OW.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?OW.STOP_FAILED:OW.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?OW.UPDATE_FAILED:OW.UPDATE_SUCCESS}this.safeEmit(kW.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(kW.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(kW.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(n=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p;return Pg().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=22;break;case 11:if("subscribe"!==t.type){e.next=22;break}if(c=this._remoteStreamStreamIdUserIdMap[t.streamId],!(u=this._findRemoteStream(c,t.streamId))){e.next=22;break}return h=u.subMediaType,p=u.subLayer,e.next=19,null===(d=this._mediaServerClient)||void 0===d?void 0:d.unsubscribe(u);case 19:return e.next=21,null===(l=this._mediaServerClient)||void 0===l?void 0:l.subscribe(u,h,p);case 21:this.safeEmit(xW.RESUBSCRIBE,{stream:u});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===bW.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=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_;return Pg().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)&&(_={},this.logger.info("_onPublishOnDemand exec","usedDescriptions: %o",u),u.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&Xy(t).call(t,l)){var r=null==e?void 0:e.Metadata.VideoIndex;_[r]=!0}})),p.encodings=qg(v=p.encodings).call(v,(function(e){if(e.rid){_[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(xW.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(xW.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(xW.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?sh.STREAM_INDEX_SCREEN:sh.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=Ng(Pg().mark((function e(t,r){var n,i,o,a;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(n=t===sh.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)})}]),x}(kU),xX=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&&TT(r.style,t.style),t.attributes&&NS(t.attributes).forEach((function(e){var t=gy(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},OX=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],PX={playsinline:"","webkit-playsinline":""},DX={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},NX=function(e){UA(n,e);var t,r=ew(n);function n(e,t){var i;Fh(this,n),ql(aA(i=r.call(this)),"_containerDom",void 0),ql(aA(i),"_videoDom",void 0),ql(aA(i),"userId",void 0),ql(aA(i),"renderMode",void 0),ql(aA(i),"mirrorType",lh.MIRROR_TYPE_NONE),ql(aA(i),"isScreen",void 0),ql(aA(i),"isLocal",void 0),ql(aA(i),"played",!1),ql(aA(i),"_needLoad",!1),ql(aA(i),"_emitPlayFailed",!1),ql(aA(i),"_videoContainer",void 0),ql(aA(i),"_safari15VideoTimer",void 0),ql(aA(i),"_monitor",void 0),ql(aA(i),"logger",void 0),ql(aA(i),"_onLocalTrackMute",void 0),ql(aA(i),"_onInterruptionEnd",void 0),ql(aA(i),"_needResume",!1),ql(aA(i),"_rotate",0),ql(aA(i),"_rotateDom",void 0),ql(aA(i),"_resizeObserver",void 0),ql(aA(i),"_hasManuallyPaused",!1),ql(aA(i),"_stream",void 0),ql(aA(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":i.refreshRenderSize("the video started playing."),i._internalPlay();break;case"loadeddata":i._internalPlay();break;case"playing":i.logger.info("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"));break;case"pause":i.logger.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element pause")),i._needResume&&(i.logger.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element resume")),i._internalPlay(),i._needResume=!1)}})),ql(aA(i),"_internalPlay",(function(){var e,t;if(JN(i.engineId,"video _internalPlay",{paused:null===(e=i._videoDom)||void 0===e?void 0:e.paused,hasManuallyPaused:i._hasManuallyPaused}),!i._hasManuallyPaused&&null!==(t=i._videoDom)&&void 0!==t&&t.paused){var r=i._videoDom.play();null!=r&&r.then&&r.then((function(){var e;i.isLocal&&iL&&!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:Fg(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:LW.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:Fg(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:LW.AUTOPLAY_FAILED}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=KN(e),i.logger=new pM("Player",0,e);var a=t.userId,s=t.isScreen?ah.RENDER_MODE_FIT:ah.RENDER_MODE_HIDDEN;i.renderMode=void 0!==t.renderMode?t.renderMode:s,i._rotate=Number(t.rotation||0);var c="string"==typeof o?document.getElementById(o):o;if(!c)throw new bC(fC.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.isLocal||15!==(null==TL?void 0:TL[0])&&15!==bL||(i._safari15VideoTimer=window.setTimeout((function(){try{i._videoContainer.style.display="block",setTimeout((function(){i._videoContainer.style.display="flex"}),500)}catch(jZ){}}),1e3)),i}return Vh(n,[{key:"_initVideo",value:function(){var e,t,r=this;this._videoDom||(this._videoDom=xX("video",{style:{width:"100%",height:"100%"},attributes:DX}),this._videoDom.id=Fg(t="".concat(this.userId,"_")).call(t,TM()),this.setRenderMode(this.renderMode),this.mirror(this.mirrorType===lh.MIRROR_TYPE_RENDER));this._containerDom.appendChild(this._videoContainer),yI(e=[90,270]).call(e,this._rotate)>-1?(this._rotateDom=this._createRotationDiv(),this._rotateDom.appendChild(this._videoDom),this._videoContainer.appendChild(this._rotateDom)):(180===this._rotate&&(this._videoContainer.style.transform="rotate(180deg)"),this._videoContainer.appendChild(this._videoDom)),this._initListeners(),this._onLocalTrackMute=function(){r._needResume=!0},this._onInterruptionEnd=function(){r.logger.warn("resume player after iOS interruption"),r._internalPlay()},Lj.on(Nj.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),Lj.on(Nj.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),Lj.on(Nj.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd)}},{key:"_createRotationDiv",value:function(){var e=this,t=document.createElement("div");return t.style.transform="rotate(".concat(this._rotate,"deg)"),180!==this._rotate&&(t.style.position="absolute",this.refreshRenderSize("init"),window.ResizeObserver&&(this._resizeObserver=new ResizeObserver((function(){e.refreshRenderSize("the container size has changed.")})),this._resizeObserver.observe(this._containerDom))),t}},{key:"refreshRenderSize",value:function(e){if(this._rotateDom){var t,r;this.logger.print("refreshRenderSize","Because ".concat(e));var n=Number(window.getComputedStyle(this._containerDom).width.replace("px","")),i=Number(window.getComputedStyle(this._containerDom).height.replace("px","")),o=null===(t=this._videoDom)||void 0===t?void 0:t.videoWidth,a=null===(r=this._videoDom)||void 0===r?void 0:r.videoHeight;if(n&&i&&a&&o){var s,c;if(this.renderMode===ah.RENDER_MODE_FILL)s=i,c=n;else{var u=this.renderMode===ah.RENDER_MODE_HIDDEN?Math.max(n/a,i/o):Math.min(n/a,i/o);s=o*u,c=a*u}this._rotateDom.style.width="".concat(s,"px"),this._rotateDom.style.height="".concat(c,"px"),this._rotateDom.style.left="".concat((n-s)/2,"px"),this._rotateDom.style.top="".concat((i-c)/2,"px")}}}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&OX.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&&OX.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.removeEventListener(t,e.emitVideoEvent)}))}},{key:"setRenderMode",value:function(e){this.renderMode=e,this._videoDom&&(this.renderMode===ah.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this.renderMode===ah.RENDER_MODE_FILL?this._videoDom.style.objectFit="fill":this._videoDom.style.objectFit="cover")}},{key:"playVideo",value:(t=Ng(Pg().mark((function e(t,r){var n,i,o,a,s=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,this._stream=r,this.logger.info("playVideo","play video track: ".concat(this.userId)),!(o&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(n=t.preprocessingTrack)||void 0===n?void 0:n.id))){e.next=6;break}try{JN(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(jZ){}return e.abrupt("return");case 6:o||(this._initVideo(),o=this._videoDom),this.logger.info("playVideo","play video by dom: ".concat(null===(i=o)||void 0===i?void 0:i.id)),a=new MediaStream,t.videoPlayer=this,a.addTrack(t.preprocessingTrack),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&&GL.VIDEO_STALL&&r.startVideoStallObserve(this),this.played=!0;case 17:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"updateSrcObject",value:function(e){var t=e.preprocessingTrack;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(this.logger.info("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,this._hasManuallyPaused=!1,!this._videoDom)throw new bC(fC.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||hL?this._videoDom.play():jI.resolve()}},{key:"manuallyPause",value:function(){if(this.logger.print("Invoke VideoPlayer.manuallyPause",this.userId,this.isScreen),this.played){if(this._hasManuallyPaused=!0,!this._videoDom)throw new bC(fC.INVALID_PARAMS,"Player not found");return this._videoDom.pause()}}},{key:"mirror",value:function(e){var t;this.logger.info("mirror",Fg(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?lh.MIRROR_TYPE_RENDER:lh.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e,t,r,n=this,i=arguments.length>0&&void 0!==arguments[0]&&arguments[0],o=this._containerDom;(this.logger.info("stop","stop video track: ".concat(this.userId)),null===(e=this._stream)||void 0===e||e.stopVideoStallObserve(),this._videoDom)&&(i||(this._videoDom.srcObject=null),null!=o&&o.contains(this._videoContainer)&&o.removeChild(this._videoContainer),null===(t=this._videoContainer)||void 0===t||t.childNodes.forEach((function(e){e!==n._videoDom&&e!==n._rotateDom||n._videoContainer.removeChild(e)})),null!==(r=this._rotateDom)&&void 0!==r&&r.contains(this._videoDom)&&this._rotateDom.removeChild(this._videoDom));this._hasManuallyPaused=!1,this.played=!1}},{key:"destroy",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.logger.info("destroy","video player: ".concat(this.userId)),this.stop(t),null===(e=this._resizeObserver)||void 0===e||e.disconnect(),MA(NA(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),Lj.off(Nj.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),Lj.off(Nj.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),Lj.off(Nj.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}(yU.EventEmitter),MX=function(e){UA(i,e);var t,r,n=ew(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(Fh(this,i),ql(aA(r=n.call(this)),"_containerDom",void 0),ql(aA(r),"_audioDom",void 0),ql(aA(r),"_fakeAudioDom",void 0),ql(aA(r),"userId",void 0),ql(aA(r),"muted",!1),ql(aA(r),"_emitPlayFailed",!1),ql(aA(r),"played",!1),ql(aA(r),"isScreen",void 0),ql(aA(r),"_wechatTimer",void 0),ql(aA(r),"_edgeTimer",void 0),ql(aA(r),"_monitor",void 0),ql(aA(r),"logger",void 0),ql(aA(r),"_pasued",!0),ql(aA(r),"emitAudioEvent",(function(e){var t,n,i,o,a={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&&r.logger.info("AudioPlayerPlaying","[userId-".concat(r.userId,"] audio element playing")),"pause"===e.type)&&(r.logger.info("AudioPlayerPause","[userId-".concat(r.userId,"] audio element pause")),!r._pasued&&null!==(i=r._audioDom)&&void 0!==i&&null!==(o=i.srcObject)&&void 0!==o&&o.active&&r._internalPlay());_L&&hL&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),pL&&cL&&"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",a)})),ql(aA(r),"_internalPlay",(function(){var e,t;if(JN(r.engineId,"audio _internalPlay",{paused:null===(e=r._audioDom)||void 0===e?void 0:e.paused,userId:r.userId,screen:r.isScreen}),null!==(t=r._audioDom)&&void 0!==t&&t.paused)try{var n,i=r._audioDom.play(),o=Bj.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:Fg(n=Fg(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&&(_L&&pL&&(i=i.then((function(){return new jI((function(e){setTimeout(Ng(Pg().mark((function t(){var n;return Pg().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(){JN(r.engineId,"_internalPlay successfully",{userId:r.userId,screen:r.isScreen}),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:Fg(n=Fg(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:LW.AUTOPLAY_FAILED})})))}catch(l){var c,u,d;r._autoPlayError(l),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:Fg(u=Fg(d="audio autoplay failed, userId: ".concat(r.userId,": ")).call(d,l.message," ")).call(u,l.name),error_code:LW.AUTOPLAY_FAILED})}})),r.engineId=e,a){var u=document.getElementById(a);if(!u)throw new bC(fC.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=KN(e),r.logger=new pM("Player",0,e),r._initAudio(),r}return Vh(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=xX("audio",{style:{display:"none"},attributes:PX}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Fg(e="".concat(this.userId,"_")).call(e,TM()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&OX.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&&(OX.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=Ng(Pg().mark((function e(t){var r,n,i,o,a,s=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("playAudio","play audio track: ".concat(this.userId)),!((o=this._audioDom)&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(r=t.preprocessingTrack)||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 CH?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.originTrack]),a.addTrack(t.preprocessingTrack)):a.addTrack(t.preprocessingTrack),_L&&pL&&(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 bC(fC.INVALID_PARAMS,"Player not found");this._pasued=!0,this._audioDom.pause()}},{key:"manuallyPause",value:function(){return this.pause()}},{key:"manuallyPlay",value:function(){var e,t=this;if(this.logger.info("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new bC(fC.INVALID_PARAMS,"Player not found");if(!this.played)return jI.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=Bj.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?jI.all(r):jI.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,Pj.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=qg(r).call(r,(function(e){return e.deviceId})),Xy(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;this.logger.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(){this.logger.info("destroy","audio player: ".concat(this.userId)),this.stop(),MA(NA(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom),this._edgeTimer&&clearTimeout(this._edgeTimer)}}]),i}(yU.EventEmitter);function LX(e,t,r,n){var i=function(){var e=Ng(Pg().mark((function e(t,i){var o,a;return Pg().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:aI(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 NX&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof MX&&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))})),jI.all(o)}var UX=o,VX=ht("iterator"),FX=!UX((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r=new URLSearchParams("a=1&a=2&b=3"),n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),r.delete("a",2),r.delete("b",void 0),!e.toJSON||!r.has("a",1)||r.has("a",2)||!r.has("a",void 0)||r.has("b")||!t.size&&true||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[VX]||"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"!==n||"x"!==new URL("http://x",void 0).host})),BX=wr,jX=i,HX=P,GX=f,zX=C,KX=FX,WX=vi,XX=fi,YX=ok,qX=Bi,JX=uu,QX=ro,ZX=kv,$X=A,eY=Ze,tY=Jt,rY=mn,nY=rr,iY=ee,oY=Sn,aY=Wn,sY=F,cY=Ap,uY=Sp,dY=Dv,lY=vw,hY=ht("iterator"),pY="URLSearchParams",vY=pY+"Iterator",_Y=QX.set,fY=QX.getterFor(pY),mY=QX.getterFor(vY),gY=Object.getOwnPropertyDescriptor,yY=function(e){if(!zX)return jX[e];var t=gY(jX,e);return t&&t.value},SY=yY("fetch"),bY=yY("Request"),kY=yY("Headers"),EY=bY&&bY.prototype,TY=kY&&kY.prototype,IY=jX.RegExp,RY=jX.TypeError,AY=jX.decodeURIComponent,wY=jX.encodeURIComponent,CY=GX("".charAt),xY=GX([].join),OY=GX([].push),PY=GX("".replace),DY=GX([].shift),NY=GX([].splice),MY=GX("".split),LY=GX("".slice),UY=/\+/g,VY=Array(4),FY=function(e){return VY[e-1]||(VY[e-1]=IY("((?:%[\\da-f]{2}){"+e+"})","gi"))},BY=function(e){try{return AY(e)}catch(jZ){return e}},jY=function(e){var t=PY(e,UY," "),r=4;try{return AY(t)}catch(jZ){for(;r;)t=PY(t,FY(r--),BY);return t}},HY=/[!'()~]|%20/g,GY={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},zY=function(e){return GY[e]},KY=function(e){return PY(wY(e),HY,zY)},WY=JX((function(e,t){_Y(this,{type:vY,iterator:cY(fY(e).entries),kind:t})}),"Iterator",(function(){var e=mY(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),XY=function(e){this.entries=[],this.url=null,void 0!==e&&(iY(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===CY(e,0)?LY(e,1):e:oY(e)))};XY.prototype={type:pY,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=uY(e);if(c)for(r=(t=cY(e,c)).next;!(n=HX(r,t)).done;){if(o=(i=cY(nY(n.value))).next,(a=HX(o,i)).done||(s=HX(o,i)).done||!HX(o,i).done)throw RY("Expected sequence with length 2");OY(this.entries,{key:oY(a.value),value:oY(s.value)})}else for(var u in e)eY(e,u)&&OY(this.entries,{key:u,value:oY(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=MY(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=MY(t,"="),OY(this.entries,{key:jY(DY(r)),value:jY(xY(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],OY(r,KY(e.key)+"="+KY(e.value));return xY(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var YY=function(){ZX(this,qY);var e=_Y(this,new XY(arguments.length>0?arguments[0]:void 0));zX||(this.size=e.entries.length)},qY=YY.prototype;if(YX(qY,{append:function(e,t){var r=fY(this);dY(arguments.length,2),OY(r.entries,{key:oY(e),value:oY(t)}),zX||this.length++,r.updateURL()},delete:function(e){for(var t=fY(this),r=dY(arguments.length,1),n=t.entries,i=oY(e),o=r<2?void 0:arguments[1],a=void 0===o?o:oY(o),s=0;s<n.length;){var c=n[s];if(c.key!==i||void 0!==a&&c.value!==a)s++;else if(NY(n,s,1),void 0!==a)break}zX||(this.size=n.length),t.updateURL()},get:function(e){var t=fY(this).entries;dY(arguments.length,1);for(var r=oY(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){var t=fY(this).entries;dY(arguments.length,1);for(var r=oY(e),n=[],i=0;i<t.length;i++)t[i].key===r&&OY(n,t[i].value);return n},has:function(e){for(var t=fY(this).entries,r=dY(arguments.length,1),n=oY(e),i=r<2?void 0:arguments[1],o=void 0===i?i:oY(i),a=0;a<t.length;){var s=t[a++];if(s.key===n&&(void 0===o||s.value===o))return!0}return!1},set:function(e,t){var r=fY(this);dY(arguments.length,1);for(var n,i=r.entries,o=!1,a=oY(e),s=oY(t),c=0;c<i.length;c++)(n=i[c]).key===a&&(o?NY(i,c--,1):(o=!0,n.value=s));o||OY(i,{key:a,value:s}),zX||(this.size=i.length),r.updateURL()},sort:function(){var e=fY(this);lY(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=fY(this).entries,n=tY(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 WY(this,"keys")},values:function(){return new WY(this,"values")},entries:function(){return new WY(this,"entries")}},{enumerable:!0}),WX(qY,hY,qY.entries,{name:"entries"}),WX(qY,"toString",(function(){return fY(this).serialize()}),{enumerable:!0}),zX&&XX(qY,"size",{get:function(){return fY(this).entries.length},configurable:!0,enumerable:!0}),qX(YY,pY),BX({global:!0,constructor:!0,forced:!KX},{URLSearchParams:YY}),!KX&&$X(kY)){var JY=GX(TY.has),QY=GX(TY.set),ZY=function(e){if(iY(e)){var t,r=e.body;if(rY(r)===pY)return t=e.headers?new kY(e.headers):new kY,JY(t,"content-type")||QY(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),aY(e,{body:sY(0,oY(r)),headers:sY(0,t)})}return e};if($X(SY)&&BX({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return SY(e,arguments.length>1?ZY(arguments[1]):{})}}),$X(bY)){var $Y=function(e){return ZX(this,EY),new bY(e,arguments.length>1?ZY(arguments[1]):{})};EY.constructor=$Y,$Y.prototype=EY,BX({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:$Y})}}var eq,tq={URLSearchParams:YY,getState:fY},rq=f,nq=2147483647,iq=/[^\0-\u007E]/,oq=/[.\u3002\uFF0E\uFF61]/g,aq="Overflow: input needs wider integers to process",sq=RangeError,cq=rq(oq.exec),uq=Math.floor,dq=String.fromCharCode,lq=rq("".charCodeAt),hq=rq([].join),pq=rq([].push),vq=rq("".replace),_q=rq("".split),fq=rq("".toLowerCase),mq=function(e){return e+22+75*(e<26)},gq=function(e,t,r){var n=0;for(e=r?uq(e/700):e>>1,e+=uq(e/t);e>455;)e=uq(e/35),n+=36;return uq(n+36*e/(e+38))},yq=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=lq(e,r++);if(i>=55296&&i<=56319&&r<n){var o=lq(e,r++);56320==(64512&o)?pq(t,((1023&i)<<10)+(1023&o)+65536):(pq(t,i),r--)}else pq(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&&pq(t,dq(n));var c=t.length,u=c;for(c&&pq(t,"-");u<i;){var d=nq;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=u+1;if(d-o>uq((nq-a)/l))throw sq(aq);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>nq)throw sq(aq);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 _=h-v,f=36-v;pq(t,dq(mq(v+_%f))),h=uq(_/f),p+=36}pq(t,dq(mq(h))),s=gq(a,l,u===c),a=0,u++}}a++,o++}return hq(t,"")},Sq=wr,bq=C,kq=FX,Eq=i,Tq=Jt,Iq=f,Rq=vi,Aq=fi,wq=kv,Cq=Ze,xq=kT,Oq=ly,Pq=ai,Dq=Ll.codeAt,Nq=function(e){var t,r,n=[],i=_q(vq(fq(e),oq,"."),".");for(t=0;t<i.length;t++)r=i[t],pq(n,cq(iq,r)?"xn--"+yq(r):r);return hq(n,".")},Mq=Sn,Lq=Bi,Uq=Dv,Vq=tq,Fq=ro,Bq=Fq.set,jq=Fq.getterFor("URL"),Hq=Vq.URLSearchParams,Gq=Vq.getState,zq=Eq.URL,Kq=Eq.TypeError,Wq=Eq.parseInt,Xq=Math.floor,Yq=Math.pow,qq=Iq("".charAt),Jq=Iq(/./.exec),Qq=Iq([].join),Zq=Iq(1..toString),$q=Iq([].pop),eJ=Iq([].push),tJ=Iq("".replace),rJ=Iq([].shift),nJ=Iq("".split),iJ=Iq("".slice),oJ=Iq("".toLowerCase),aJ=Iq([].unshift),sJ="Invalid scheme",cJ="Invalid host",uJ="Invalid port",dJ=/[a-z]/i,lJ=/[\d+-.a-z]/i,hJ=/\d/,pJ=/^0x/i,vJ=/^[0-7]+$/,_J=/^\d+$/,fJ=/^[\da-f]+$/i,mJ=/[\0\t\n\r #%/:<>?@[\\\]^|]/,gJ=/[\0\t\n\r #/:<>?@[\\\]^|]/,yJ=/^[\u0000-\u0020]+/,SJ=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,bJ=/[\t\n\r]/g,kJ=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)aJ(t,e%256),e=Xq(e/256);return Qq(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+=Zq(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},EJ={},TJ=xq({},EJ,{" ":1,'"':1,"<":1,">":1,"`":1}),IJ=xq({},TJ,{"#":1,"?":1,"{":1,"}":1}),RJ=xq({},IJ,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),AJ=function(e,t){var r=Dq(e,0);return r>32&&r<127&&!Cq(t,e)?e:encodeURIComponent(e)},wJ={ftp:21,file:null,http:80,https:443,ws:80,wss:443},CJ=function(e,t){var r;return 2===e.length&&Jq(dJ,qq(e,0))&&(":"===(r=qq(e,1))||!t&&"|"===r)},xJ=function(e){var t;return e.length>1&&CJ(iJ(e,0,2))&&(2===e.length||"/"===(t=qq(e,2))||"\\"===t||"?"===t||"#"===t)},OJ=function(e){return"."===e||"%2e"===oJ(e)},PJ={},DJ={},NJ={},MJ={},LJ={},UJ={},VJ={},FJ={},BJ={},jJ={},HJ={},GJ={},zJ={},KJ={},WJ={},XJ={},YJ={},qJ={},JJ={},QJ={},ZJ={},$J=function(e,t,r){var n,i,o,a=Mq(e);if(t){if(i=this.parse(a))throw Kq(i);this.searchParams=null}else{if(void 0!==r&&(n=new $J(r,!0)),i=this.parse(a,null,n))throw Kq(i);(o=Gq(new Hq)).bindURL(this),this.searchParams=o}};$J.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||PJ,d=0,l="",h=!1,p=!1,v=!1;for(e=Mq(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=tJ(e,yJ,""),e=tJ(e,SJ,"$1")),e=tJ(e,bJ,""),n=Oq(e);d<=n.length;){switch(i=n[d],u){case PJ:if(!i||!Jq(dJ,i)){if(t)return sJ;u=NJ;continue}l+=oJ(i),u=DJ;break;case DJ:if(i&&(Jq(lJ,i)||"+"===i||"-"===i||"."===i))l+=oJ(i);else{if(":"!==i){if(t)return sJ;l="",u=NJ,d=0;continue}if(t&&(c.isSpecial()!==Cq(wJ,l)||"file"===l&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=l,t)return void(c.isSpecial()&&wJ[c.scheme]===c.port&&(c.port=null));l="","file"===c.scheme?u=KJ:c.isSpecial()&&r&&r.scheme===c.scheme?u=MJ:c.isSpecial()?u=FJ:"/"===n[d+1]?(u=LJ,d++):(c.cannotBeABaseURL=!0,eJ(c.path,""),u=JJ)}break;case NJ:if(!r||r.cannotBeABaseURL&&"#"!==i)return sJ;if(r.cannotBeABaseURL&&"#"===i){c.scheme=r.scheme,c.path=Pq(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=ZJ;break}u="file"===r.scheme?KJ:UJ;continue;case MJ:if("/"!==i||"/"!==n[d+1]){u=UJ;continue}u=BJ,d++;break;case LJ:if("/"===i){u=jJ;break}u=qJ;continue;case UJ:if(c.scheme=r.scheme,i===eq)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=Pq(r.path),c.query=r.query;else if("/"===i||"\\"===i&&c.isSpecial())u=VJ;else if("?"===i)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=Pq(r.path),c.query="",u=QJ;else{if("#"!==i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=Pq(r.path),c.path.length--,u=qJ;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=Pq(r.path),c.query=r.query,c.fragment="",u=ZJ}break;case VJ:if(!c.isSpecial()||"/"!==i&&"\\"!==i){if("/"!==i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=qJ;continue}u=jJ}else u=BJ;break;case FJ:if(u=BJ,"/"!==i||"/"!==qq(l,d+1))continue;d++;break;case BJ:if("/"!==i&&"\\"!==i){u=jJ;continue}break;case jJ:if("@"===i){h&&(l="%40"+l),h=!0,o=Oq(l);for(var _=0;_<o.length;_++){var f=o[_];if(":"!==f||v){var m=AJ(f,RJ);v?c.password+=m:c.username+=m}else v=!0}l=""}else if(i===eq||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(h&&""===l)return"Invalid authority";d-=Oq(l).length+1,l="",u=HJ}else l+=i;break;case HJ:case GJ:if(t&&"file"===c.scheme){u=XJ;continue}if(":"!==i||p){if(i===eq||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(c.isSpecial()&&""===l)return cJ;if(t&&""===l&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(l))return a;if(l="",u=YJ,t)return;continue}"["===i?p=!0:"]"===i&&(p=!1),l+=i}else{if(""===l)return cJ;if(a=c.parseHost(l))return a;if(l="",u=zJ,t===GJ)return}break;case zJ:if(!Jq(hJ,i)){if(i===eq||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()||t){if(""!==l){var g=Wq(l,10);if(g>65535)return uJ;c.port=c.isSpecial()&&g===wJ[c.scheme]?null:g,l=""}if(t)return;u=YJ;continue}return uJ}l+=i;break;case KJ:if(c.scheme="file","/"===i||"\\"===i)u=WJ;else{if(!r||"file"!==r.scheme){u=qJ;continue}switch(i){case eq:c.host=r.host,c.path=Pq(r.path),c.query=r.query;break;case"?":c.host=r.host,c.path=Pq(r.path),c.query="",u=QJ;break;case"#":c.host=r.host,c.path=Pq(r.path),c.query=r.query,c.fragment="",u=ZJ;break;default:xJ(Qq(Pq(n,d),""))||(c.host=r.host,c.path=Pq(r.path),c.shortenPath()),u=qJ;continue}}break;case WJ:if("/"===i||"\\"===i){u=XJ;break}r&&"file"===r.scheme&&!xJ(Qq(Pq(n,d),""))&&(CJ(r.path[0],!0)?eJ(c.path,r.path[0]):c.host=r.host),u=qJ;continue;case XJ:if(i===eq||"/"===i||"\\"===i||"?"===i||"#"===i){if(!t&&CJ(l))u=qJ;else if(""===l){if(c.host="",t)return;u=YJ}else{if(a=c.parseHost(l))return a;if("localhost"===c.host&&(c.host=""),t)return;l="",u=YJ}continue}l+=i;break;case YJ:if(c.isSpecial()){if(u=qJ,"/"!==i&&"\\"!==i)continue}else if(t||"?"!==i)if(t||"#"!==i){if(i!==eq&&(u=qJ,"/"!==i))continue}else c.fragment="",u=ZJ;else c.query="",u=QJ;break;case qJ:if(i===eq||"/"===i||"\\"===i&&c.isSpecial()||!t&&("?"===i||"#"===i)){if(".."===(s=oJ(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"===i||"\\"===i&&c.isSpecial()||eJ(c.path,"")):OJ(l)?"/"===i||"\\"===i&&c.isSpecial()||eJ(c.path,""):("file"===c.scheme&&!c.path.length&&CJ(l)&&(c.host&&(c.host=""),l=qq(l,0)+":"),eJ(c.path,l)),l="","file"===c.scheme&&(i===eq||"?"===i||"#"===i))for(;c.path.length>1&&""===c.path[0];)rJ(c.path);"?"===i?(c.query="",u=QJ):"#"===i&&(c.fragment="",u=ZJ)}else l+=AJ(i,IJ);break;case JJ:"?"===i?(c.query="",u=QJ):"#"===i?(c.fragment="",u=ZJ):i!==eq&&(c.path[0]+=AJ(i,EJ));break;case QJ:t||"#"!==i?i!==eq&&("'"===i&&c.isSpecial()?c.query+="%27":c.query+="#"===i?"%23":AJ(i,EJ)):(c.fragment="",u=ZJ);break;case ZJ:i!==eq&&(c.fragment+=AJ(i,TJ))}d++}},parseHost:function(e){var t,r,n;if("["===qq(e,0)){if("]"!==qq(e,e.length-1))return cJ;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 qq(e,l)};if(":"===h()){if(":"!==qq(e,1))return;l+=2,d=++u}for(;h();){if(8===u)return;if(":"!==h()){for(t=r=0;r<4&&Jq(fJ,h());)t=16*t+Wq(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(!Jq(hJ,h()))return;for(;Jq(hJ,h());){if(o=Wq(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}(iJ(e,1,-1)),!t)return cJ;this.host=t}else if(this.isSpecial()){if(e=Nq(e),Jq(mJ,e))return cJ;if(t=function(e){var t,r,n,i,o,a,s,c=nJ(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"===qq(i,0)&&(o=Jq(pJ,i)?16:8,i=iJ(i,8===o?1:2)),""===i)a=0;else{if(!Jq(10===o?_J:8===o?vJ:fJ,i))return e;a=Wq(i,o)}eJ(r,a)}for(n=0;n<t;n++)if(a=r[n],n===t-1){if(a>=Yq(256,5-t))return null}else if(a>255)return null;for(s=$q(r),n=0;n<r.length;n++)s+=r[n]*Yq(256,3-n);return s}(e),null===t)return cJ;this.host=t}else{if(Jq(gJ,e))return cJ;for(t="",r=Oq(e),n=0;n<r.length;n++)t+=AJ(r[n],EJ);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return Cq(wJ,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&CJ(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+=kJ(i),null!==o&&(u+=":"+o)):"file"===t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+Qq(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw Kq(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new eQ(e.path[0]).origin}catch(jZ){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+kJ(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Mq(e)+":",PJ)},getUsername:function(){return this.username},setUsername:function(e){var t=Oq(Mq(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=AJ(t[r],RJ)}},getPassword:function(){return this.password},setPassword:function(e){var t=Oq(Mq(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=AJ(t[r],RJ)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?kJ(e):kJ(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,HJ)},getHostname:function(){var e=this.host;return null===e?"":kJ(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,GJ)},getPort:function(){var e=this.port;return null===e?"":Mq(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=Mq(e))?this.port=null:this.parse(e,zJ))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+Qq(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,YJ))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=Mq(e))?this.query=null:("?"===qq(e,0)&&(e=iJ(e,1)),this.query="",this.parse(e,QJ)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=Mq(e))?("#"===qq(e,0)&&(e=iJ(e,1)),this.fragment="",this.parse(e,ZJ)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var eQ=function(e){var t=wq(this,tQ),r=Uq(arguments.length,1)>1?arguments[1]:void 0,n=Bq(t,new $J(e,!1,r));bq||(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())},tQ=eQ.prototype,rQ=function(e,t){return{get:function(){return jq(this)[e]()},set:t&&function(e){return jq(this)[t](e)},configurable:!0,enumerable:!0}};if(bq&&(Aq(tQ,"href",rQ("serialize","setHref")),Aq(tQ,"origin",rQ("getOrigin")),Aq(tQ,"protocol",rQ("getProtocol","setProtocol")),Aq(tQ,"username",rQ("getUsername","setUsername")),Aq(tQ,"password",rQ("getPassword","setPassword")),Aq(tQ,"host",rQ("getHost","setHost")),Aq(tQ,"hostname",rQ("getHostname","setHostname")),Aq(tQ,"port",rQ("getPort","setPort")),Aq(tQ,"pathname",rQ("getPathname","setPathname")),Aq(tQ,"search",rQ("getSearch","setSearch")),Aq(tQ,"searchParams",rQ("getSearchParams")),Aq(tQ,"hash",rQ("getHash","setHash"))),Rq(tQ,"toJSON",(function(){return jq(this).serialize()}),{enumerable:!0}),Rq(tQ,"toString",(function(){return jq(this).serialize()}),{enumerable:!0}),zq){var nQ=zq.createObjectURL,iQ=zq.revokeObjectURL;nQ&&Rq(eQ,"createObjectURL",Tq(nQ,zq)),iQ&&Rq(eQ,"revokeObjectURL",Tq(iQ,zq))}Lq(eQ,"URL"),Sq({global:!0,constructor:!0,forced:!kq,sham:!bq},{URL:eQ});var oQ=wr,aQ=o,sQ=Dv,cQ=Sn,uQ=FX,dQ=ae("URL");oQ({target:"URL",stat:!0,forced:!(uQ&&aQ((function(){dQ.canParse()})))},{canParse:function(e){var t=sQ(arguments.length,1),r=cQ(e),n=t<2||void 0===arguments[1]?void 0:cQ(arguments[1]);try{return!!new dQ(r,n)}catch(jZ){return!1}}});var lQ=r(te.URL),hQ=function(){var e=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(lQ.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)}}(),pQ=uT,vQ=HI,_Q=function(e,t,r,n){for(var i,o=n>1?void 0:n?vQ(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&&pQ(t,r,o),o},fQ=function(){function e(t,r){Fh(this,e),ql(this,"_sharedAudioContext",new AudioContext),ql(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),ql(this,"_localGainNode",this._sharedAudioContext.createGain()),ql(this,"_bufferGainNode",this._sharedAudioContext.createGain()),ql(this,"_audioBufferSource",void 0),ql(this,"_localSource",void 0),ql(this,"_context",void 0),ql(this,"_failedAudioList",[]),ql(this,"_startingIds",new cT),ql(this,"_revokeURLs",new AB),ql(this,"mixingMap",new cT),ql(this,"resourcesCache",new cT),ql(this,"volumeConfig",new cT),ql(this,"cachedBuffer",[]),ql(this,"id","AudioMixingManager"),this.engineId=r,this._context=t,this._localGainNode.gain.value=1}var t,r,n;return Vh(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=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m=this;return Pg().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,eU(o=n.type,"mixingType",pW(Dh)),a=this._context.getLocalAudioTrack()){e.next=9;break}return e.abrupt("return");case 9:if((s=a.preprocessingTrack)&&this.mixMediaStream(new MediaStream([s])),a.once("needReplaceTrack",(function(){m.mixMediaStream(new MediaStream([a.preprocessingTrack]))})),null!=(c=this.mixingMap.get(t))&&c.audioNode){c.audioNode.pause(),this._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_STOPPED,error:mC.AUDIO_MIXING_ERROR_OK});try{c.gainNode.disconnect(this._audioDestination),c.audioSource.disconnect(c.gainNode)}catch(g){}}if(!(d=this.resourcesCache.get(t))||d.filePath!==r){e.next=19;break}u=d.getAudioNode(),e.next=32;break;case 19:return e.next=21,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw m._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_FAILED,error:mC.AUDIO_MIXING_ERROR_START_FAILED}),new bC(fC.LOAD_RESOURCES_FAILED,e.statusText)}));case 21:return l=e.sent,FT(r).call(r,"mp3")?h={type:"audio/mpeg"}:FT(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=25,hQ(l,h);case 25:if(e.sent){e.next=29;break}throw this._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_FAILED,error:mC.AUDIO_MIXING_ERROR_START_FAILED}),new bC(fC.LOAD_RESOURCES_FAILED,"invalid audio resource");case 29:(u=new Audio).crossOrigin="anonymous",u.src=lQ.createObjectURL(new Blob([l],h));case 32: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:Nh.AUDIO_MIXING_STATE_FINISHED,error:mC.AUDIO_MIXING_ERROR_OK}))}),e.prev=33,e.next=36,u.play();case 36:e.next=43;break;case 38:e.prev=38,e.t0=e.catch(33),console.error(e.t0),this._failedAudioList.push(u),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:sh.STREAM_INDEX_MAIN,mediaType:ch.AUDIO});case 43:if(this._startingIds.delete(t),v=this._sharedAudioContext.createMediaElementSource(u),_=this._sharedAudioContext.createGain(),f=this.volumeConfig.get(t),_.gain.value=f?f/100:1,v.connect(_).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:v,audioNode:u,gainNode:_,type:"file"}),o===Dh.PUBLISH)try{_.disconnect(this._sharedAudioContext.destination)}catch(g){}else _.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_PLAYING,error:mC.AUDIO_MIXING_ERROR_OK});case 53:case"end":return e.stop()}}),e,this,[[33,38]])}))),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:Nh.AUDIO_MIXING_STATE_STOPPED,error:mC.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Nh.AUDIO_MIXING_STATE_PAUSED,error:mC.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:Nh.AUDIO_MIXING_STATE_PLAYING,error:mC.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=Ng(Pg().mark((function e(t,r){var n,i,o=this;return Pg().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 bC(fC.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_FAILED,error:mC.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof bC)throw e;throw new bC(fC.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,FT(r).call(r,"mp3")?i={type:"audio/mpeg"}:FT(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,hQ(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_FAILED,error:mC.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new bC(fC.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Nh.AUDIO_MIXING_STATE_PRELOADED,error:mC.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=lQ.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new jI((function(e){var r=lQ.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)),lQ.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){eU(e,"type",pW(Dh));var t=this._context.getLocalAudioTrack();if(t){var r=t.preprocessingTrack;if(r&&this.mixMediaStream(new MediaStream([r])),e===Dh.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:Nh.AUDIO_MIXING_STATE_PCM_ENABLED,error:mC.AUDIO_MIXING_ERROR_OK})}}},{key:"disableAudioMixingBuffer",value:function(){if(this.cachedBuffer=[],this._audioBufferSource){try{this._audioBufferSource.onended=null,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:Nh.AUDIO_MIXING_STATE_PCM_DISABLED,error:mC.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=Ng(Pg().mark((function e(){var t,r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=my(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:sh.STREAM_INDEX_MAIN,mediaType:ch.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 cT,this._revokeURLs.forEach((function(e){lQ.revokeObjectURL(e)}))}}]),e}();_Q([XN("id","filePath","options")],fQ.prototype,"startAudioMixing",1),_Q([XN("id")],fQ.prototype,"stopAudioMixing",1),_Q([XN("id")],fQ.prototype,"pauseAudioMixing",1),_Q([XN("id")],fQ.prototype,"resumeAudioMixing",1),_Q([XN("id")],fQ.prototype,"preloadAudioMixing",1),_Q([XN("id")],fQ.prototype,"unloadAudioMixing",1),_Q([XN("id")],fQ.prototype,"getAudioMixingVolume",1),_Q([XN("id","volume")],fQ.prototype,"setAudioMixingVolume",1),_Q([XN("id")],fQ.prototype,"getAudioMixingDuration",1),_Q([XN("id")],fQ.prototype,"getAudioMixingCurrentPosition",1),_Q([XN("id","position")],fQ.prototype,"setAudioMixingPosition",1),_Q([XN("type")],fQ.prototype,"enableAudioMixingBuffer",1),_Q([XN()],fQ.prototype,"disableAudioMixingBuffer",1),_Q([XN("buffer")],fQ.prototype,"pushAudioMixingBuffer",1);var mQ=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(mQ||{}),gQ=function(e){UA(c,e);var t,r,n,i,o,a,s=ew(c);function c(e){var t;return Fh(this,c),ql(aA(t=s.call(this)),"_dataChannelSignal",void 0),ql(aA(t),"_handler",void 0),ql(aA(t),"_dataChannelSignalState",nX.DISCONNECTED),ql(aA(t),"_loginSessionId",null),ql(aA(t),"_userId",null),ql(aA(t),"_token",null),ql(aA(t),"_loginResolveCallback",void 0),ql(aA(t),"_loginRejectCallback",void 0),ql(aA(t),"_wait_login_token",!1),ql(aA(t),"_serverParamsCache",void 0),ql(aA(t),"id",void 0),ql(aA(t),"_connectionManager",void 0),ql(aA(t),"isReconnecting",!1),ql(aA(t),"logger",void 0),t._ctx=e,t.id=e.id,t.logger=new pM("RTMClient",1,e.id),t._connectionManager=new ZW(e),t._addConnectHandler(),t}return Vh(c,[{key:"login",value:function(e,t){var r=this;return new jI((function(n,i){var o;if(r.logger.info("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new bC(fC.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new bC(fC.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=KN(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=Ng(Pg().mark((function e(){var t;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new bC(fC.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:JW.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=Ng(Pg().mark((function e(t){var r=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new jI((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=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new bC(fC.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:JW.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=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new bC(fC.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=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,$L(t,"signature"),$L(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new bC(fC.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:JW.C2RTM}).catch((function(e){throw new bC(fC.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=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new bC(fC.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:KW.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;this.logger.info("destroy","invoke."),MA(NA(c.prototype),"removeAllListeners",this).call(this),this._loginResolveCallback&&this._loginRejectCallback&&(this._loginRejectCallback(new bC(fC.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=TM();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:wM.token2auth(this._ctx.appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:GL.VERSION,deviceId:LL.getDeviceId(),appId:this._ctx.appId,userId:this._userId}},{functionType:JW.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,MN.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=fC.INVALID_PARAMS,n="Invalid userId"):(r=fC.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=fC.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new bC(r,a||n))})).finally((function(){delete e._loginResolveCallback,delete e._loginRejectCallback}))}}},{key:"connect",value:function(){var e=this;return new jI((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!==nX.CONNECTED)throw new bC(fC.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n;e._dataChannelSignalState=nX.CONNECTED,e.logger.info("connectStateChange","connected"),null===(r=e._handler)||void 0===r||r.destroy(),null===(n=e._dataChannelSignal)||void 0===n||n.destroy(),e._handler=yW(e._ctx,t.pc),e._dataChannelSignal=t.signaling,e._addSignalEventHandler(),e.isReconnecting&&e._login()})),this._connectionManager.on("disconnected",(function(t){e._dataChannelSignalState=nX.DISCONNECTED,e.logger.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=nX.CONNECTING,e.logger.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=nX.CONNECTING,e.logger.warn("connectStateChange","reconnecting")}))}},{key:"_addSignalEventHandler",value:function(){var e,t,r,n=this;null===(e=this._dataChannelSignal)||void 0===e||e.on(kW.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(kW.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(kW.USER_DISCONNECTION,(function(){n.emit("onUserDisconnection"),n._clearState()}))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,MN.setRtsSessionId(this.id,"")}}]),c}(yU.EventEmitter),yQ=function(){function e(t){Fh(this,e),ql(this,"_roomId",void 0),ql(this,"_constraints",{}),ql(this,"_profile",void 0),ql(this,"_customMaxBitrate",0),this._appId=t}return Vh(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=LL.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=LL.getEngineWebConfig(this._appId,this._roomId||"").audio_encode,n=this.getConstraints(),i=n.sampleRate,o=n.channelCount,a="number"==typeof i?i:null==i?void 0:i.exact,s="number"==typeof o?o:null==o?void 0:o.exact,c={};t.split(";").forEach((function(e){var t=gy(e.split("="),2),r=t[0],n=t[1];r&&n&&(c[r]=n)}));var u=(null==r?void 0:r.bitrate)||this._customMaxBitrate||this._getConfigByAudioProfile().bitrate;u&&(c.maxaveragebitrate=u);var d=(null==r?void 0:r.enc_sample_rate)||a;d&&(c["sprop-maxcapturerate"]=d);var l=(null==r?void 0:r.playback_rate)||a;return l&&(c.maxplaybackrate=l),(s&&s>1||null!=r&&r.stereo)&&(c["sprop-stereo"]=1,c.stereo=1),null!=r&&r.dtx&&(c.usedtx=1),qg(e=MS(c)).call(e,(function(e){var t;return Fg(t="".concat(e,"=")).call(t,c[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=Ql(Ql({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=Ql({},this._constraints),t=LL.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;XM(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),XM(null==t?void 0:t.channel)||(e.channelCount=t.channel),XM(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),XM(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),XM(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return XM(e.sampleRate)&&!XM(n)&&(e.sampleRate=n),XM(e.channelCount)&&!XM(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case Eh.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case Eh.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case Eh.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case Eh.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case Eh.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),SQ=function(e){UA(o,e);var t,r,n,i=ew(o);function o(e,t,r){var n,a=r.businessId;return Fh(this,o),ql(aA(n=i.call(this)),"_mediaServerClient",void 0),ql(aA(n),"_appId",void 0),ql(aA(n),"remoteStreams",void 0),ql(aA(n),"_businessId",void 0),ql(aA(n),"_ctx",void 0),n.id=e,n._appId=t,n.remoteStreams=new cT,n._businessId=a,n._ctx={id:n.id,appId:n._appId,avSync:!0,audioProfileManager:new yQ(n._appId),useCloudProxy:!1,userPriority:new cT,joinRoomConfig:new VL(n.id)},n}return Vh(o,[{key:"connect",value:(n=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new oX(this._ctx),this._mediaServerClient.publicStream=!0,this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=6,this._mediaServerClient.connect();case 6:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=Ng(Pg().mark((function e(t){var r,n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new bC(fC.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new JH(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=WM(e),i=0;i<t.seiCount;i++)n.emit(xW.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 cT,null===(e=this._mediaServerClient)||void 0===e||e.destroy(),this.removeAllListeners()}},{key:"_handleReconnected",value:(t=Ng(Pg().mark((function e(){var t,r,n,i=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=my(this.remoteStreams);try{for(n=function(){var e=gy(r.value,2),t=e[0],n=e[1];n.clean(),n.statsReport.unsubscribe(),i.remoteStreams.delete(t),i.startPlayPublicStream(t).then((function(){var e=i.remoteStreams.get(t);i.safeEmit(xW.RESUBSCRIBE,{stream:e})}))},t.s();!(r=t.n()).done;)n()}catch(HZ){t.e(HZ)}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("connectSuccess",(function(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).reconnect&&r._handleReconnected()})),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}(kU),bQ=new pM("AudioDeviceManager",1),kQ=function(e){UA(c,e);var t,r,n,i,o,a,s=ew(c);function c(e,t){var r;return Fh(this,c),ql(aA(r=s.call(this)),"_audioLevelFetcher",void 0),ql(aA(r),"_playbackDeviceTestTimer",void 0),ql(aA(r),"_audioElement",void 0),ql(aA(r),"_audioTrack",void 0),ql(aA(r),"_mediaRecorder",void 0),ql(aA(r),"_recoderTimer",void 0),ql(aA(r),"_isAudioPlaybackDeviceTesting",!1),ql(aA(r),"_isAudioDeviceRecordTesting",!1),ql(aA(r),"_audioCaptureAndRecoderResolve",void 0),ql(aA(r),"_onAutoplayFailed",void 0),ql(aA(r),"_audioPlaybackDeviceId",void 0),r._ctx=e,r._extensionManager=t,r}return Vh(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new bC(fC.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,bQ.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),bQ.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&&(bQ.info("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=Ng(Pg().mark((function e(t,r,n){var i,o=this,a=arguments;return Pg().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 bC(fC.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 3:if(!this._isAudioDeviceRecordTesting&&!this._isAudioPlaybackDeviceTesting){e.next=5;break}throw new bC(fC.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 5:return this._isAudioDeviceRecordTesting=!0,bQ.info("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){bQ.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(){bQ.info("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(bQ.info("stopAudioDevicePlayTest()","Invoke"),this._isAudioDeviceRecordTesting=!1,this._mediaRecorder&&(this._mediaRecorder.ondataavailable=null),this.stopAudioDeviceRecordAndPlayTest(),this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement()),delete this._onAutoplayFailed}},{key:"getRecordTrack",value:function(){return this._audioTrack}},{key:"setSinkId",value:(i=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(bQ.info("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new bC(fC.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,Pj.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new bC(fC.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(){bQ.info("destroy()","Invoke"),MA(NA(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=Ng(Pg().mark((function e(t,r){var n,i=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return bQ.info("_playAudioFile()",Fg(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new jI((function(e,n){var o=xX("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new Fj(o),o.onplaying=function(){o.onplaying=null,bQ.info("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=Ng(Pg().mark((function e(t){var r,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:bQ.error("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new bC(fC.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;bQ.warn("_playAudioFile()","autoplay error",e);var r=Fg(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return jI.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new bC(fC.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&&(bQ.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&&(bQ.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&&(bQ.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=Ng(Pg().mark((function e(t,r){var n,i=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,pH(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r+.01),n=new MediaStream([this._audioTrack.preprocessingTrack]),bQ.info("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new jI((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=aI(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),bQ.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=Ng(Pg().mark((function n(o){var a,c;return Pg().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return bQ.info("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(lQ.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 bC(fC.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=Ng(Pg().mark((function e(){var t,r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=Bj.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),bQ.info("setSinkId","ctx.sinkId=".concat(t))}catch(o){bQ.error("setSinkId",Fg(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}(yU.EventEmitter),EQ=new pM("VideoSnapshot",1),TQ=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},IQ=function(){var e=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return Pg().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=TQ(n))){e.next=16;break}return EQ.info("takeSnapshot","VideoPlayer already set."),e.next=11,a(c,c.videoWidth,c.videoHeight);case 11:return u=e.sent,EQ.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 EQ.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,EQ.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 29:return EQ.info("takeSnapshot","use temp video"),e.abrupt("return",new jI((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);EQ.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)}}(),RQ=function(){return{url:"",video:{codec:Rh.H264,width:640,height:360,fps:15,gop:2,kBitRate:AQ(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:Ih.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function AQ(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 wQ(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new bC(fC.INVALID_PARAMS,"Invalid rtmp address")}function CQ(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new bC(fC.INVALID_PARAMS,"regions should not be empty.");var t,r=my(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new bC(fC.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new bC(fC.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(HZ){r.e(HZ)}finally{r.f()}}function xQ(e,t){var r,n,i,o=function(e,r){var n=oS(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=oS(e).call(e,(function(e,t){return null==e?void 0:e[t]}),RQ());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!!aI(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 Xy(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return Xy(t=[Ih.LC,Ih.HEv1,Ih.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return Xy(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:AQ(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:qg(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&&Xy(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&Xy(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 OQ,PQ={getDefaultValue:RQ,checkStartParams:function(e){var t;wQ(e.url),CQ(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&wQ(e.url),CQ(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return xQ("started",e)},getUpdateParams:function(e){return xQ("layoutChanged",e)}},DQ=Kp,NQ=ei;wr({target:"Object",stat:!0},{fromEntries:function(e){var t={};return DQ(e,(function(e,r){NQ(t,e,r)}),{AS_ENTRIES:!0}),t}});var MQ,LQ=r(te.Object.fromEntries),UQ=["ele","fakeEle"],VQ=["orgTrack","mediaTrack","preprocessingTrack"],FQ=["orgTrack","mediaTrack","preprocessingTrack"],BQ=["currentTime","duration","ended","error","muted","networkState","paused","readyState","seekable","sinkId","src","volume"],jQ=["currentTime","sampleRate","state","baseLatency","outputLatency","sinkId"],HQ=["contentHint","enabled","id","kind","label","muted","readyState"],GQ=["currentDirection","direction","mid","stopped"];function zQ(e){return KQ.apply(this,arguments)}function KQ(){return(KQ=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Date.now(),n=[],!(t&&t._room&&t._room._mediaServerClient&&t._room._mediaServerClient._handler&&t._room._mediaServerClient._handler._peerConnection)){e.next=6;break}return e.next=5,t._room._mediaServerClient._handler._peerConnection.getStats();case 5:n=e.sent;case 6:return i=[],n.forEach((function(e){i.push(e)})),e.abrupt("return",{timestamp:r,stats:i});case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function WQ(e){var t={};if(e instanceof MediaStream){t.id=e.id,t.active=e.active;var r=e.getTracks();t.tracks=qg(r).call(r,(function(e){return LQ(qg(HQ).call(HQ,(function(t){return[t,e[t]]})))}))}return t}function XQ(e){return YQ.apply(this,arguments)}function YQ(){return(YQ=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Date.now(),n=[],t._videoPlayer&&n.push({userId:"__local__",mediaType:"video",isScreen:!1,isPublic:!1,ele:t._videoPlayer._videoDom}),t._screenPlayer&&n.push({userId:"__local__",mediaType:"video",isScreen:!0,isPublic:!1,ele:t._screenPlayer._videoDom}),t._remoteVideoPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"video",isScreen:!1,isPublic:!1,ele:e?e._videoDom:void 0})})),t._remoteScreenPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"video",isScreen:!0,isPublic:!1,ele:e?e._videoDom:void 0})})),t._remoteAudioPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"audio",isScreen:!1,isPublic:!1,ele:e?e._audioDom:void 0,fakeEle:e?e._fakeAudioDom:void 0})})),t._remoteScreenAudioPlayer&&t._remoteScreenAudioPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"audio",isScreen:!0,isPublic:!1,ele:e?e._audioDom:void 0,fakeEle:e?e._fakeAudioDom:void 0})})),t._publicStreamVideoPlayer&&t._publicStreamVideoPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"video",isScreen:!1,isPublic:!0,ele:e?e._videoDom:void 0})})),t._publicStreamAudioPlayer&&t._publicStreamAudioPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"audio",isScreen:!1,isPublic:!0,ele:e?e._audioDom:void 0,fakeEle:e?e._fakeAudioDom:void 0})})),i=qg(n).call(n,(function(e){var t=e.ele,r=e.fakeEle,n=yN(e,UQ),i=Ql({ele:Ql({srcObject:t?WQ(t.srcObject):void 0},LQ(qg(BQ).call(BQ,(function(e){return[e,t[e]]}))))},n);return r&&(i.fakeEle=Ql({srcObject:WQ(r.srcObject)},LQ(qg(BQ).call(BQ,(function(e){return[e,r[e]]}))))),i})),e.abrupt("return",{timestamp:r,elementStats:i});case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function qQ(e){var t,r=[],n=[];e&&e._room&&e._room._remoteStreams&&(n=cw(t=e._room._remoteStreams).call(t));var i,o=my(n);try{for(o.s();!(i=o.n()).done;){i.value.forEach((function(e){e.audioTrack&&r.push(e.audioTrack)}))}}catch(HZ){o.e(HZ)}finally{o.f()}e._localAudioTrack&&r.push(e._localAudioTrack),e._localScreenAudioTrack&&r.push(e._localScreenAudioTrack);for(var a=0,s=r;a<s.length;a++){var c,u,d=s[a];if(d._audioLevelFetcher&&d._audioLevelFetcher._ctx)return d._audioLevelFetcher._ctx;if(d._ac)return d._ac;if(d._audioFetchMap)if(KC(cw(c=d._audioFetchMap).call(c)).length)return KC(cw(u=d._audioFetchMap).call(u))[0]._ctx;if(d._ap&&d._ap._ac)return d._ap._ac}return null}function JQ(e){return QQ.apply(this,arguments)}function QQ(){return(QQ=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Date.now(),n=qQ(t),i={},n){e.next=5;break}return e.abrupt("return",{timestamp:r,acState:void 0});case 5:return jQ.forEach((function(e){i[e]=n[e]})),e.abrupt("return",{timestamp:r,acState:i});case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ZQ(e){var t=[];e._localAudioTrack&&t.push({userId:"__local__",mediaType:"audio",isScreen:!1,isPublic:!1,isVirtual:!1,orgTrack:e._localAudioTrack._originTrack,mediaTrack:e._localAudioTrack._mediaTrack,preprocessingTrack:e._localAudioTrack._preProcessingTrack}),e._localScreenAudioTrack&&t.push({userId:"__local__",mediaType:"audio",isScreen:!0,isPublic:!1,isVirtual:!1,orgTrack:e._localScreenAudioTrack._originTrack,mediaTrack:e._localScreenAudioTrack._mediaTrack,preprocessingTrack:e._localScreenAudioTrack._preProcessingTrack}),e._localVideoTrack&&t.push({userId:"__local__",mediaType:"video",isScreen:!1,isPublic:!1,isVirtual:!1,orgTrack:e._localVideoTrack._originTrack,mediaTrack:e._localVideoTrack._mediaTrack,preprocessingTrack:e._localVideoTrack._preProcessingTrack}),e._localScreenVideoTrack&&t.push({userId:"__local__",mediaType:"video",isScreen:!0,isPublic:!1,isVirtual:!1,orgTrack:e._localScreenVideoTrack._originTrack,mediaTrack:e._localScreenVideoTrack._mediaTrack,preprocessingTrack:e._localScreenVideoTrack._preProcessingTrack}),e._room&&e._room._remoteStreams&&e._room._remoteStreams.forEach((function(e,r){e.forEach((function(e){e.audioTrack&&t.push({userId:r,mediaType:"audio",isScreen:e.isScreen,isPublic:!1,isVirtual:!1,orgTrack:e.audioTrack._originTrack,mediaTrack:e.audioTrack._mediaTrack}),e.videoTrack&&t.push({userId:r,mediaType:"video",isScreen:e.isScreen,isPublic:!1,isVirtual:!1,orgTrack:e.videoTrack._originTrack,mediaTrack:e.videoTrack._mediaTrack})}))}));var r=e._publicStreamManager;return r||(r=e._outsideRoom),r&&r.remoteStreams.forEach((function(e,r){e.audioTrack&&t.push({userId:r,mediaType:"audio",isScreen:e.isScreen,isPublic:!0,isVirtual:!1,orgTrack:e.audioTrack._originTrack,mediaTrack:e.audioTrack._mediaTrack}),e.videoTrack&&t.push({userId:r,mediaType:"video",isScreen:e.isScreen,isPublic:!0,isVirtual:!1,orgTrack:e.videoTrack._originTrack,mediaTrack:e.videoTrack._mediaTrack})})),e&&e._room&&e._room._virtualStreams&&e._room._virtualStreams.forEach((function(e,r){e.audioTrack&&t.push({userId:"virtualStream-".concat(r),mediaType:"audio",isScreen:!1,isPublic:!1,isVirtual:!0,orgTrack:e.audioTrack._originTrack,mediaTrack:e.audioTrack._mediaTrack}),e.videoTrack&&t.push({userId:"virtualStream-".concat(r),mediaType:"video",isScreen:!1,isPublic:!1,isVirtual:!0,orgTrack:e.videoTrack._originTrack,mediaTrack:e.videoTrack._mediaTrack})})),t}function $Q(e,t){return eZ.apply(this,arguments)}function eZ(){return(eZ=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=2048,i=50,o=128,a=256,s=2,t){e.next=7;break}return e.abrupt("return",void 0);case 7:return(c=new MediaStream).addTrack(t),u=r.createMediaStreamSource(c),d=r.createAnalyser(),u.connect(d),"suspended"===r.state&&(console.warn(r.state),r.resume()),l=new Uint8Array(n),d.getByteTimeDomainData(l),e.next=17,new jI((function(e){setTimeout(e,i)}));case 17:return d.getByteTimeDomainData(l),e.next=20,new jI((function(e){setTimeout(e,i)}));case 20:return h=0,l.forEach((function(e){return h=Math.max(h,Math.abs(e-o))})),v=(p=h/o*a)>s?p:0,u.disconnect(),d.disconnect(),e.abrupt("return",v);case 27:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function tZ(e){return rZ.apply(this,arguments)}function rZ(){return rZ=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1e3,n=Date.now(),MQ||(MQ=new AudioContext),"suspended"!==MQ.state){e.next=6;break}return e.next=6,new jI((function(e){var r=setTimeout((function(){console.warn("[RTC_AMBULANCE] AudioContext resume failed, try to find one in RTCEngine"),(MQ=qQ(t))&&console.warn("[RTC_AMBULANCE] find AudioContext in RTCEngine success"),e()}),1e3);MQ.resume().then((function(){clearTimeout(r),e()}),(function(){clearTimeout(r),MQ=null,e()}))}));case 6:if(MQ){e.next=9;break}return console.error("[RTC_AMBULANCE] get volume is not supported"),e.abrupt("return");case 9:return i=ZQ(t),o=[],e.next=13,jI.all(qg(r=Ty(i).call(i,(function(e){return"audio"===e.mediaType}))).call(r,function(){var e=Ng(Pg().mark((function e(t){var r,n,i,a,s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.orgTrack,n=t.mediaTrack,i=t.preprocessingTrack,a=yN(t,VQ),s=Ql({},a),e.next=4,jI.all([$Q(r,MQ).then((function(e){s.orgTrackVolume=e})),$Q(n,MQ).then((function(e){s.mediaTrackVolume=e})),$Q(i,MQ).then((function(e){s.preprocessingTrackVolume=e}))]);case 4:o.push(s);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 13:return e.abrupt("return",{timestamp:n,trackVolumes:o});case 14:case"end":return e.stop()}}),e)}))),rZ.apply(this,arguments)}function nZ(e){return iZ.apply(this,arguments)}function iZ(){return(iZ=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Date.now(),n=ZQ(t),i=qg(n).call(n,(function(e){var t=e.orgTrack,r=e.mediaTrack,n=e.preprocessingTrack,i=yN(e,FQ);return Ql({orgTrack:t?LQ(qg(HQ).call(HQ,(function(e){return[e,t[e]]}))):void 0,mediaTrack:r?LQ(qg(HQ).call(HQ,(function(e){return[e,r[e]]}))):void 0,preprocessingTrack:n?LQ(qg(HQ).call(HQ,(function(e){return[e,n[e]]}))):void 0},i)})),e.abrupt("return",{timestamp:r,trackStates:i});case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function oZ(e){if(e){var t={track:e.track?e.track.id:void 0,transport:{state:e.transport?e.transport.state:void 0}};return e.transport&&e.transport.iceTransport&&(t.iceTransport={state:e.transport.iceTransport.state,role:e.transport.iceTransport.role,gatheringState:e.transport.iceTransport.gatheringState,component:e.transport.iceTransport.component}),t}}function aZ(e){return sZ.apply(this,arguments)}function sZ(){return(sZ=Ng(Pg().mark((function e(t){var r,n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Date.now(),n=[],t._room&&t._room._mediaServerClient&&t._room._mediaServerClient._handler&&t._room._mediaServerClient._handler._peerConnection&&(n=t._room._mediaServerClient._handler._peerConnection.getTransceivers()),i=[],n.forEach((function(e){var t=Ql({sender:oZ(e.sender),receiver:oZ(e.receiver)},LQ(qg(GQ).call(GQ,(function(t){return[t,e[t]]}))));i.push(t)})),e.abrupt("return",{timestamp:r,tranceiverStates:i});case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function cZ(e){return uZ.apply(this,arguments)}function uZ(){return(uZ=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={stats:[],mediaElementStates:[],audioContextStates:[],volumes:[],trackStates:[],tranceiverStates:[]},n=[],e.next=4,new jI((function(e){var i,o=0;i=setTimeout((function a(){n.push(zQ(t).then((function(e){r.stats.push(e)})),XQ(t).then((function(e){r.mediaElementStates.push(e)})),JQ(t).then((function(e){r.audioContextStates.push(e)})),tZ(t).then((function(e){r.volumes.push(e)})),nZ(t).then((function(e){r.trackStates.push(e)})),aZ(t).then((function(e){r.tranceiverStates.push(e)}))),++o>=10?jI.all(n).then((function(){e()})):(clearTimeout(i),i=setTimeout(a,500))}),500)}));case 4:return console.log("RTC_AMBULANCE",r),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var dZ=uT,lZ=HI,hZ=function(e,t,r,n){for(var i,o=n>1?void 0:n?lZ(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&dZ(t,r,o),o},pZ=function(e){UA(Re,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M,L,U,V,F,B,j,H,G,z,K,W,X,Y,q,J,Q,Z,$,ee,te,re,ne,ie,oe,ae,se,ce,ue,de,le,he,pe,ve,_e,fe,me,ge,ye,Se,be,ke,Ee,Te,Ie=ew(Re);function Re(e,t,r){var n;return Fh(this,Re),ql(aA(n=Ie.call(this)),"monitor",void 0),ql(aA(n),"logger",void 0),ql(aA(n),"_room",void 0),ql(aA(n),"_publicStreamManager",void 0),ql(aA(n),"_appId",void 0),ql(aA(n),"_businessId",void 0),ql(aA(n),"_visibility",!0),ql(aA(n),"_localVideoTrack",void 0),ql(aA(n),"_localAudioTrack",void 0),ql(aA(n),"_localImgVideoTrack",void 0),ql(aA(n),"_localImgScreenTrack",void 0),ql(aA(n),"_localScreenVideoTrack",void 0),ql(aA(n),"_localScreenAudioTrack",void 0),ql(aA(n),"_tempMixingAudioTrack",void 0),ql(aA(n),"_localAudioVolume",100),ql(aA(n),"_localScreenAudioVolume",100),ql(aA(n),"_remoteAudioVolume",new cT),ql(aA(n),"_remoteScreenAudioVolume",new cT),ql(aA(n),"_publicAudioVolume",new cT),ql(aA(n),"_videoPlayer",void 0),ql(aA(n),"_screenPlayer",void 0),ql(aA(n),"_remoteVideoPlayer",new cT),ql(aA(n),"_remoteScreenPlayer",new cT),ql(aA(n),"_remoteAudioPlayer",new cT),ql(aA(n),"_remoteScreenAudioPlayer",new cT),ql(aA(n),"_publicStreamAudioPlayer",new cT),ql(aA(n),"_publicStreamVideoPlayer",new cT),ql(aA(n),"_publicStreamIds",new cT),ql(aA(n),"_roomConfig",void 0),ql(aA(n),"_videoStreamConstraints",Ql({},qL)),ql(aA(n),"_audioStreamConstraints",{}),ql(aA(n),"_enableSimulcast",!1),ql(aA(n),"_videoStreamEncodeConfig",[Ql({},qL)]),ql(aA(n),"_screenStreamEncodeConfig",[Ql({},JL)]),ql(aA(n),"_dummyMainImage",void 0),ql(aA(n),"_dummyScreenImage",void 0),ql(aA(n),"_trackSourceType",void 0),ql(aA(n),"_liveTranscodeConfig",void 0),ql(aA(n),"_startCloudProxyTimestamp",void 0),ql(aA(n),"_localVideoDeviceId",void 0),ql(aA(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),ql(aA(n),"_audioVolumeIndicationTimer",void 0),ql(aA(n),"_dummyMainTimer",void 0),ql(aA(n),"_dummyScreenTimer",void 0),ql(aA(n),"_audioPropertiesReportTimer",null),ql(aA(n),"_mirrorType",lh.MIRROR_TYPE_RENDER),ql(aA(n),"_audioMixingManager",void 0),ql(aA(n),"_pubLock",void 0),ql(aA(n),"_subLocks",void 0),ql(aA(n),"_audioCaptureLock",void 0),ql(aA(n),"_videoCaptureLock",void 0),ql(aA(n),"_screenCaptureLock",void 0),ql(aA(n),"_subScreenLocks",void 0),ql(aA(n),"_rtmClient",void 0),ql(aA(n),"_messageStatisticsObserver",void 0),ql(aA(n),"_tempRoomInfo",void 0),ql(aA(n),"_originIceConfigRequestUrls",void 0),ql(aA(n),"_originConfigServerUrls",void 0),ql(aA(n),"_originLogServerUrl",void 0),ql(aA(n),"_extensionManager",void 0),ql(aA(n),"_audioDeviceManager",void 0),ql(aA(n),"_remoteVideoConfig",new cT),ql(aA(n),"_config",void 0),ql(aA(n),"_needClosePreTrack",!1),ql(aA(n),"_ctx",void 0),ql(aA(n),"_updateMixAudioTrack",function(){var e=Ng(Pg().mark((function e(t){var r,i,o=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:Dh.PLAYOUT_AND_PUBLISH,n.logger.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)}}()),ql(aA(n),"_onAudioMixingMessage",(function(e){n.safeEmit(Lh.onAudioMixingStateChanged,e)})),ql(aA(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(Lh.onAutoplayFailed,e)})),n.id=t,n._appId=e,n.monitor=KN(t),n._ctx={id:t,appId:e,avSync:!0,streamRTT:{},useCloudProxy:!1,audioProfileManager:new yQ(e),userPriority:new cT,expectedIDC:null==r?void 0:r.expectedIDC,joinRoomConfig:new VL(t)},n._pubLock=new CW("pubLock"),n._subLocks=new cT,n._subScreenLocks=new cT,n._audioCaptureLock=new CW("audioCap"),n._videoCaptureLock=new CW("videoCap"),n._screenCaptureLock=new CW("screenCap"),n._addDeviceEventHandler(),n._extensionManager=new Hj(t),n._audioDeviceManager=new kQ(n._ctx,n._extensionManager),n._audioMixingManager=new fQ({getLocalAudioTrack:function(){return n._localAudioTrack},updateLocalAudioTrack:n._updateMixAudioTrack,emitMessage:n._onAudioMixingMessage,onAutoPlayFailed:n._onAudioMixingAutoplayFailed},t),window.__rtc_engine__=aA(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=aA(n),n._trackSourceType={video:Zl.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:Zl.VIDEO_SOURCE_TYPE_INTERNAL,audio:$l.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:$l.AUDIO_SOURCE_TYPE_INTERNAL},n._config=r,n._rtmClient=new gQ(n._ctx),n._handleRTMClient(n._rtmClient),n._handleAudioDeviceManager(),n._messageStatisticsObserver=new LN(t),n.logger=new pM("Engine",0,t),MN.createRTSMsgReportor(n.id),n._getServerConfig(),n.monitor.reportLongString("NativeDetector",Gg(LS)),n}return Vh(Re,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(Te=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateToken()","token: %s",t),$L(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return r=this._tempRoomInfo,n=r.config,i=r.userInfo,o=r.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,o,i,n);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new bC(fC.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,this._room.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return Te.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(Ee=Ng(Pg().mark((function e(t){var r,n,i,o,a,s=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setVideoCaptureDevice()","deviceId: %s",t),$L(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:if(!hL||!_L){e.next=9;break}if(this._localVideoTrack.originTrack.getSettings().deviceId!==t){e.next=9;break}return e.abrupt("return");case 9:return n=Fz({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete n.deviceId,n.facingMode=t):!uL||vL?n.deviceId={exact:t}:delete n.deviceId,_L&&nL&&AL>=85&&AL<=91&&(null===(i=this._videoPlayer)||void 0===i||i.removeTrack()),this._needClosePreTrack=this._needClosePreTrack||KB,this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),this.logger.info("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=17,lH(n,this._extensionManager).catch((function(e){if(s._localVideoTrack&&!s._localVideoTrack.dummy)return s.logger.warn("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),s._removeLocalTrackEvents(s._localVideoTrack),s._localVideoTrack.close(),delete s._localVideoTrack,lH(n,s._extensionManager).then((function(e){return s._needClosePreTrack=!0,e})).catch(Ng(Pg().mark((function t(){var r;return Pg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.logger.error("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,lH(s._videoStreamConstraints,s._extensionManager);case 3:throw r=t.sent,s._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 17:return o=e.sent,this.logger.success("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=n,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null!==(r=this._videoStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&o.setContentHint(null===(a=this._videoStreamEncodeConfig[0])||void 0===a?void 0:a.contentHint),e.next=24,this._switchTrack(o);case 24:case"end":return e.stop()}}),e,this)}))),function(e){return Ee.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(ke=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setAudioCaptureDevice()","deviceId: %s",t),$L(t,"deviceId"),this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.next=9,pH(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 9:if(n=e.sent,this._initLocalTrackEvents(n),this._localAudioTrack=n,this._localAudioTrack.setVolume(this._localAudioVolume),this._room){e.next=15;break}return e.abrupt("return");case 15:if(null===(r=this._room.localStream)||void 0===r||!r.pubAudio){e.next=18;break}return e.next=18,this._updatePublish();case 18:case"end":return e.stop()}}),e,this)}))),function(e){return ke.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){Pj.on(Lh.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),Pj.on(Lh.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,g,y,S,b,k,E,T,I,R,A,w,C,x,O,P,D,N,M,L,U,V=this;null===(e=this._room)||void 0===e||e.on(kW.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(kW.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(kW.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(xW.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(xW.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(xW.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(kW.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(kW.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(kW.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(kW.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(kW.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?V._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?V._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&V._onLiveTranscodingResult(e)})),null===(l=this._room)||void 0===l||l.on(TW.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(TW.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return V.safeEmit(Lh.onVendorConnectionStateChanged,e)})),null===(p=this._room)||void 0===p||p.on(xW.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(v=this._room)||void 0===v||v.on(xW.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(_=this._room)||void 0===_||_.on(xW.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(xW.ON_PUBLISH_RESULT,(function(e){var t,r=!(e.retry||null===(t=V._room)||void 0===t||!t._roomConfig.isAutoPublish);r&&V.safeEmit(Lh.onAutoPublishResult,e),V.safeEmit(Lh.onPublishResult,{isScreen:e.isScreen,isAutoPublish:r,errorCode:e.errorCode})})),null===(m=this._room)||void 0===m||m.on(xW.ON_SUBSCRIBE_RESULT,(function(e){V.safeEmit(Lh.onSubscribeResult,{userId:e.userId,isScreen:e.isScreen,isAutoSubscribe:!1,errorCode:e.errorCode})})),null===(g=this._room)||void 0===g||g.on(xW.ON_REMOTE_STREAM_STATS,(function(e){V.safeEmit(Lh.onRemoteStreamStats,e)})),null===(y=this._room)||void 0===y||y.on(xW.ON_LOCAL_STREAM_STATS,(function(e){V.safeEmit(Lh.onLocalStreamStats,e)})),null===(S=this._room)||void 0===S||S.on(xW.ON_SUBTITLE_STATE_CHANGED,(function(e){V.safeEmit(Lh.onSubtitleStateChanged,e)})),null===(b=this._room)||void 0===b||b.on(xW.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){V.safeEmit(Lh.onSubtitleMessageReceived,e)})),null===(k=this._room)||void 0===k||k.on(xW.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(E=this._room)||void 0===E||E.on(xW.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;V._updateAudioPlayerState(t),V.safeEmit(Lh.onUserStartAudioCapture,{userId:r})})),null===(T=this._room)||void 0===T||T.on(xW.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;V.safeEmit(Lh.onUserStopAudioCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(xW.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;V.safeEmit(Lh.onUserStartVideoCapture,{userId:t})})),null===(R=this._room)||void 0===R||R.on(xW.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;V.safeEmit(Lh.onUserStopVideoCapture,{userId:t})})),null===(A=this._room)||void 0===A||A.on(xW.ON_SEI_MESSAGED_RECEIVED,(function(e){V.safeEmit(Lh.onSEIMessageReceived,e)})),null===(w=this._room)||void 0===w||w.on(xW.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){V.safeEmit(Lh.onRemoteVideoSizeChanged,e,t)})),null===(C=this._room)||void 0===C||C.on(xW.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return V.safeEmit(Lh.onSimulcastSubscribeFallback,e)})),null===(x=this._room)||void 0===x||x.on(xW.RECONNECT_FAILED,(function(){V.safeEmit(Lh.onError,{errorCode:fC.RECONNECT_FAILED})})),null===(O=this._room)||void 0===O||O.on(xW.ON_VIDEO_STREAM_BANNED,(function(e){V.safeEmit(Lh.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(P=this._room)||void 0===P||P.on(xW.ON_AUDIO_STREAM_BANNED,(function(e){V.safeEmit(Lh.onAudioStreamBanned,{uid:e.uid,banned:e.banned})})),null===(D=this._room)||void 0===D||D.on(xW.ON_FORWARD_STREAM_ERROR,(function(e){V.safeEmit(Lh.onForwardStreamError,e)})),null===(N=this._room)||void 0===N||N.on(xW.ON_REJOIN_WITH_TCP,(function(){V.safeEmit(Lh.onRejoinWithTcp)})),null===(M=this._room)||void 0===M||M.on(xW.ON_ICE_CONNECT_WITH_TCP,(function(){V.safeEmit(Lh.onIceConnectWithTcp)})),null===(L=this._room)||void 0===L||L.on(xW.PUB_RETRY,(function(e){V.safeEmit(Lh.onPublishRetry,e)})),null===(U=this._room)||void 0===U||U.on(xW.SUB_RETRY,(function(e){V.safeEmit(Lh.onSubscribeRetry,e)}))}},{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 function(e){var t,r=KL("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!Xy(r).call(r,e))||!Xy(t=[Lh.onRemoteStreamStats,Lh.onLocalStreamStats,Lh.onAudioVolumeIndication,Lh.onLocalAudioPropertiesReport,Lh.onRemoteAudioPropertiesReport]).call(t,e)}(e)&&qN(this.id,e,i),(t=MA(NA(Re.prototype),"safeEmit",this)).call.apply(t,Fg(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(be=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._room){e.next=2;break}return e.abrupt("return");case 2:return this._room=new CX({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:kh.communication},this._ctx),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return be.apply(this,arguments)})},{key:"joinRoom",value:(Se=Ng(Pg().mark((function e(t,r,n,i){var o,a,s,c,u;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,i),oU(t)||$L(t,"token"),aU(r),uU(n),dU(i=Fz({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:kh.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==nX.CONNECTED){e.next=8;break}throw new bC(fC.REPEAT_JOIN,"Already joined");case 8:return this._room||(this._room=new CX(i,this._ctx),this._addHandlerEventHandler()),this._room.roomConfig=i,a=this._liveTranscodeConfig&&PQ.getStartParams(this._liveTranscodeConfig),s=Ql(Ql({},n),{},{businessId:this._businessId,role:this._visibility?mQ.NORMAL_USER:mQ.SILENT_USER}),e.prev=12,this._ctx.useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),yX(s),e.next=17,this._room.join(this._appId,r,t,s,a);case 17:return c=e.sent,this._roomConfig=i,this._ctx.audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,i.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:ch.AUDIO_AND_VIDEO}):(this.safeEmit(Lh.onAutoPublishResult,{isScreen:!1,state:ih.PUBLISH_FAIL}),this.safeEmit(Lh.onPublishResult,{isScreen:!1,isAutoPublish:!0,errorCode:fC.NO_PUBLISH_PERMISSION}))),MN.setRoomId(this.id,r),MN.setUserId(this.id,n.userId),e.abrupt("return",c);case 27:throw e.prev=27,e.t0=e.catch(12),e.t0.code===fC.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:s}),null===(u=this._room)||void 0===u||u.destroy(),delete this._room,e.t0;case 33:case"end":return e.stop()}}),e,this,[[12,27]])}))),function(e,t,r,n){return Se.apply(this,arguments)})},{key:"leaveRoom",value:(ye=Ng(Pg().mark((function e(){var t,r,n,i=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],this.logger.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._subLocks=new cT,this._subScreenLocks=new cT,this._ctx.audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new cT,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new cT,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new cT,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new cT,this._roomConfig=void 0,this._publicStreamIds=new cT,MN.setRoomId(this.id,""),MN.setUserId(this.id,"");case 26:case"end":return e.stop()}}),e,this)}))),function(){return ye.apply(this,arguments)})},{key:"_destroyLocalTrack",value:function(){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)}},{key:"destroy",value:function(){var e,t,r;this.logger.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._subLocks=new cT,this._subScreenLocks=new cT,this._audioCaptureLock=new CW("audioCap"),this._videoCaptureLock=new CW("videoCap"),this._screenCaptureLock=new CW("screenCap"),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._videoStreamEncodeConfig=[qL],this._screenStreamEncodeConfig=[JL],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),MN.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._destroyLocalTrack(),Lj.on("".concat(this.id,"capture-end"),this._destroyLocalTrack.bind(this)),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new cT,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new cT,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new cT,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new cT,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new cT,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new cT,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new cT,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new cT,this._ctx.userPriority.clear(),this._extensionManager.destroy(),this._ctx.avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(ge=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!zM(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,sH(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 ge.apply(this,arguments)})},{key:"unpublishStream",value:(me=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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:PW.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return me.apply(this,arguments)})},{key:"publishScreen",value:(fe=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!zM(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,uH(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:PW.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof bC)){e.next=18;break}throw e.t0;case 18:throw new bC(fC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return fe.apply(this,arguments)})},{key:"unpublishScreen",value:(_e=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:PW.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return _e.apply(this,arguments)})},{key:"subscribeStream",value:(ve=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 ve.apply(this,arguments)})},{key:"_subscribe",value:(pe=Ng(Pg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n!==ch.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=3;break}return this.logger.warn("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 3:if(s=this._room.remoteStreams.get(r),c=null==s?void 0:aI(s).call(s,(function(e){return e.isScreen===t}))){e.next=7;break}throw new bC(fC.STREAM_NOT_EXIST,"stream not exist");case 7:return u=this._pauseAllSubscribeState.audio,d=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&ch.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&ch.VIDEO),this.logger.warn("subscribeStream()","due to pauseAll mediaType: %o",n),l=c.hasSubscribed,h=this._remoteVideoConfig.get(r)||(null===(o=this._roomConfig)||void 0===o?void 0:o.remoteVideoConfig),c.originalMediaType=n,e.next=17,this._room.subscribe(c,n,h);case 17:GM(n)&&this._updateAudioPlayerState(c),zM(n)&&this._updateVideoPlayerState(c),p=0,v=0,u!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?p|=ch.AUDIO:v|=ch.AUDIO),d!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?p|=ch.VIDEO:v|=ch.VIDEO),p&&this.pauseAllSubscribedStream(p),v&&this.resumeAllSubscribedStream(v),this._pauseAllSubscribeState.resumeStreamIds[c.streamId]=c.streamId,(c.audioTrack||c.videoTrack)&&(m=!(t||!(null!==(_=this._roomConfig)&&void 0!==_&&_.isAutoSubscribeAudio||null!==(f=this._roomConfig)&&void 0!==f&&f.isAutoSubscribeVideo)),g={userId:r,isScreen:!1,state:nh.SUBSCRIBE_SUCC},m&&this.safeEmit(Lh.onAutoSubscribeResult,g),this.safeEmit(Lh.onSubscribeResult,{userId:r,isScreen:t,isAutoSubscribe:m})),null!==(a=this._room)&&void 0!==a&&a.multiChatMode||l||!GM(n)||!c.hasAudio||null===(y=c.observer)||void 0===y||y.setSubscribeAudio(!0),!l&&zM(n)&&c.hasVideo&&(null===(S=c.observer)||void 0===S||S.setSubscribeVideo(!0));case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return pe.apply(this,arguments)})},{key:"unsubscribeStream",value:(he=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("unsubscribeStream()","userId: %o, mediaType: %o",t,r),e.abrupt("return",this._unsubscribe(!1,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return he.apply(this,arguments)})},{key:"subscribeScreen",value:(le=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 le.apply(this,arguments)})},{key:"unsubscribeScreen",value:(de=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("unsubscribeScreen() userId: %o, mediaType: %o",t,r),e.abrupt("return",this._unsubscribe(!0,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return de.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(r!==ch.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a,s=this._room.remoteStreams.get(t),c=null==s?void 0:aI(s).call(s,(function(t){return t.isScreen===e}));if(!c)throw new bC(fC.STREAM_NOT_EXIST,"stream not exist");if(_L&&AL&&AL>=85&&AL<=91&&r!==ch.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]}))}this.logger.warn("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(ue=Ng(Pg().mark((function e(t,r){var n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),sU(t),pU(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 ue.apply(this,arguments)})},{key:"startVideoCapture",value:(ce=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startVideoCapture()","deviceId: %s",t),oU(t)||$L(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==Zl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!this._localVideoTrack||this._localVideoTrack.dummy){e.next=8;break}throw new bC(fC.REPEAT_CAPTURE,"Has already capture");case 8:return s=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?(s.facingMode=t,delete s.deviceId):!uL||vL?s.deviceId={exact:t}:delete s.deviceId,this._videoStreamConstraints=s),c={},e.next=13,lH(s,this._extensionManager);case 13:if(u=e.sent,null!==(r=this._videoStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&u.setContentHint(null===(d=this._videoStreamEncodeConfig[0])||void 0===d?void 0:d.contentHint),this._initLocalTrackEvents(u),this._localVideoTrack=u,null===(n=this._videoPlayer)||void 0===n||n.playVideo(u),(l=u.originTrack)&&(c=l.getSettings(),h={width:c.width,height:c.height},this._localVideoTrack.resolution=h,this.autoResetVideoEncoderConfig(c),setTimeout((function(){return v.safeEmit(Lh.onLocalVideoSizeChanged,{streamIndex:sh.STREAM_INDEX_MAIN,info:h})}))),Lj.emit("".concat(this.id,"capture-end")),this._room){e.next=23;break}return e.abrupt("return",c);case 23:return p=this._room._roomConfig.isAutoPublish,(null!==(i=this._room.localStream)&&void 0!==i&&i.pubVideo||p)&&this._visibility&&this._updatePublish(),null===(o=this._room.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setEnableVideo(!0),e.abrupt("return",c);case 27:case"end":return e.stop()}}),e,this)}))),function(e){return ce.apply(this,arguments)})},{key:"stopVideoCapture",value:(se=Ng(Pg().mark((function e(){var t,r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopVideoCapture()"),this._trackSourceType.video!==Zl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=3;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 3:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),this._localVideoTrack&&(this._localVideoTrack.dummy||((o=this._extensionManager.getPluginByName(jj.PRE_PROCESSING,"RTCBeautyExtension"))&&o.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(this._localVideoTrack.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=7;break}return e.abrupt("return");case 7:if(null===(r=this._room.localStream)||void 0===r||!r.pubVideo){e.next=10;break}return e.next=10,this._updatePublish();case 10:null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableVideo(!1);case 11:case"end":return e.stop()}}),e,this)}))),function(){return se.apply(this,arguments)})},{key:"startAudioCapture",value:(ae=Ng(Pg().mark((function e(t){var r,n,i,o,a,s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startAudioCapture()","deviceId: $o",t),oU(t)||$L(t,"deviceId"),t&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._trackSourceType.audio!==$l.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 5:if(!this._localAudioTrack){e.next=7;break}throw new bC(fC.REPEAT_CAPTURE,"Has already capture");case 7:return o={},e.next=10,pH(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 10:if((a=e.sent).originTrack&&(o=a.originTrack.getSettings()),this._initLocalTrackEvents(a),this._localAudioTrack=a,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),Lj.emit("".concat(this.id,"capture-end")),this._room){e.next=19;break}return e.abrupt("return",o);case 19:return s=this._room._roomConfig.isAutoPublish,(null!==(r=this._room.localStream)&&void 0!==r&&r.pubAudio||s)&&this._visibility&&this._updatePublish(),null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableAudio(!0),e.abrupt("return",o);case 23:case"end":return e.stop()}}),e,this)}))),function(e){return ae.apply(this,arguments)})},{key:"stopAudioCapture",value:(oe=Ng(Pg().mark((function e(){var t,r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopAudioCapture()"),this._trackSourceType.audio!==$l.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=3;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 3:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._room){e.next=8;break}return e.abrupt("return");case 8:if(null===(t=this._room.localStream)||void 0===t||!t.pubAudio){e.next=11;break}return e.next=11,this._updatePublish();case 11:null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableAudio(!1);case 12:case"end":return e.stop()}}),e,this)}))),function(){return oe.apply(this,arguments)})},{key:"checkAudioAndVideoDeviceId",value:function(e,t){var r;return this.logger.print("startAudioAndVideoCapture","optionsOrAudioDeviceId: $o",e,"videoDeviceId: $o",t),oU(t)||$L(t,"videoDeviceId"),oU(e)||("string"==typeof e?($L(e,"audioDeviceId"),r=e):(r=null==e?void 0:e.audioDeviceId,t=null==e?void 0:e.videoDeviceId,$L(r,"audioDeviceId"),$L(t,"videoDeviceId"))),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,{audioDeviceId:r,videoDeviceId:t}}},{key:"startAudioAndVideoCapture",value:(ie=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("startAudioAndVideoCapture","optionsOrAudioDeviceId: $o",t,"videoDeviceId: $o",r),l=this.checkAudioAndVideoDeviceId(t,r),h=l.audioDeviceId,p=l.videoDeviceId,r=p,h&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:h}}),this._trackSourceType.video!==Zl.VIDEO_SOURCE_TYPE_EXTERNAL&&this._trackSourceType.audio!==$l.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,this._trackSourceType.video===Zl.VIDEO_SOURCE_TYPE_EXTERNAL?"setVideoSourceType as internal first":"setAudioSourceType as internal first");case 6:if(!this._localVideoTrack||this._localVideoTrack.dummy){e.next=8;break}throw new bC(fC.REPEAT_CAPTURE,"video has already capture");case 8:if(!this._localAudioTrack){e.next=10;break}throw new bC(fC.REPEAT_CAPTURE,"audio has already capture");case 10:return v=this._videoStreamConstraints,r&&("user"===r||"environment"===r||"left"===r||"right"===r?(v.facingMode=r,delete v.deviceId):!uL||vL?v.deviceId={exact:r}:delete v.deviceId,this._videoStreamConstraints=v),_={},f={},e.next=16,_H(this._ctx.audioProfileManager.getConstraints(),v,this._extensionManager);case 16:if(m=e.sent,g=m.audioTrack,y=m.videoTrack,null!==(n=this._videoStreamEncodeConfig[0])&&void 0!==n&&n.contentHint&&y.setContentHint(null===(S=this._videoStreamEncodeConfig[0])||void 0===S?void 0:S.contentHint),this._initLocalTrackEvents(y),this._localVideoTrack=y,null===(i=this._videoPlayer)||void 0===i||i.playVideo(y),this._initLocalTrackEvents(g),this._localAudioTrack=g,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),b=y.originTrack,_=b.getSettings(),k={width:_.width||0,height:_.height||0},this._localVideoTrack.resolution=k,this.autoResetVideoEncoderConfig(_),setTimeout((function(){return T.safeEmit(Lh.onLocalVideoSizeChanged,{streamIndex:sh.STREAM_INDEX_MAIN,info:k})})),b=g.originTrack,f=b.getSettings(),Lj.emit("".concat(this.id,"capture-end")),this._room){e.next=38;break}return e.abrupt("return",{audioTrackSettings:f,videoTrackSettings:_});case 38:return E=this._room._roomConfig.isAutoPublish,(null!==(o=this._room.localStream)&&void 0!==o&&o.pubVideo||null!==(a=this._room.localStream)&&void 0!==a&&a.pubAudio||E)&&this._visibility&&this._updatePublish(),null===(s=this._room.localStream)||void 0===s||null===(c=s.observer)||void 0===c||c.setEnableVideo(!0),null===(u=this._room.localStream)||void 0===u||null===(d=u.observer)||void 0===d||d.setEnableAudio(!0),e.abrupt("return",{audioTrackSettings:f,videoTrackSettings:_});case 43:case"end":return e.stop()}}),e,this)}))),function(e,t){return ie.apply(this,arguments)})},{key:"startVideoAndAudioCapture",value:(ne=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.startAudioAndVideoCapture(r,t));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return ne.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return this.logger.info("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(re=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m=this,g=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=g.length>0&&void 0!==g[0]?g[0]:{},this.logger.info("startScreenCapture()","config: %o",c),u=c.enableAudio,d=void 0!==u&&u,this._trackSourceType.screenVideo!==Zl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==$l.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,mH(d,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(l=e.sent,h=gy(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===(_=this._screenStreamEncodeConfig[0])||void 0===_?void 0:_.contentHint),(f=p.originTrack)&&setTimeout((function(){var e=f.getSettings(),t={width:e.width,height:e.height};p.resolution=t,m.safeEmit(Lh.onLocalVideoSizeChanged,{streamIndex:sh.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 re.apply(this,arguments)})},{key:"stopScreenCapture",value:(te=Ng(Pg().mark((function e(){var t,r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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&&(this._localScreenVideoTrack.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 te.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(this.logger.info("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),eU(e,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),null!=t&&t.renderDom){var r,n,i=Ql(Ql({userId:this._getUserId()},t),{},{isLocal:!0});if(delete i.rotation,lU(i),e===sh.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new NX(this.id,i),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)!==Th.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),this._videoPlayer.domElement;if(e===sh.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new NX(this.id,Ql(Ql({},i),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==Th.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),this._screenPlayer.domElement;if(void 0!==t.renderMode){var o=e===sh.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer;null==o||o.setRenderMode(t.renderMode)}}else{var a,s;e===sh.STREAM_INDEX_MAIN?(null===(a=this._videoPlayer)||void 0===a||a.destroy(!0),delete this._videoPlayer):(null===(s=this._screenPlayer)||void 0===s||s.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:(ee=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startLiveTranscoding()","transcode: %o",t),PQ.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 bC(fC.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(Lh.onStreamMixingEvent,{event:OW.START,error:0,message:""}),!this._room||this._room.connectionState!==nX.CONNECTED){e.next=11;break}return e.next=11,this._room.liveControlMessage(PQ.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof bC)){e.next=19;break}throw e.t0;case 19:throw new bC(fC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return ee.apply(this,arguments)})},{key:"updateLiveTranscoding",value:($=Ng(Pg().mark((function e(t){var r,n,i,o;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=Fz({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,PQ.checckUpdateParams(i),this._liveTranscodeConfig=Fz(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(Lh.onStreamMixingEvent,{event:OW.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(PQ.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof bC)){e.next=21;break}throw e.t0;case 21:throw new bC(fC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return $.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(Z=Ng(Pg().mark((function e(){var t;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(Lh.onStreamMixingEvent,{event:OW.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 bC)){e.next=16;break}throw e.t0;case 16:throw new bC(fC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return Z.apply(this,arguments)})},{key:"startSubtitle",value:(Q=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 Q.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;this.logger.info("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return this.logger.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:(J=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.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:return this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),t||(this._room.unpublish(),this._room.unpublishScreen()),e.next=12,this._room.updateUserAttributes({role:t?mQ.NORMAL_USER:mQ.SILENT_USER});case 12:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:ch.AUDIO_AND_VIDEO});case 14:case"end":return e.stop()}}),e,this)}))),function(e){return J.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]:sh.STREAM_INDEX_MAIN)===sh.STREAM_INDEX_SCREEN;e.on("playback_event",(function(i){switch(i.eventName){case"timeupdate":return;case"loadeddata":if("audio"===i.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:aI(a).call(a,(function(e){return e.isScreen===n})),u=function(){r?t.safeEmit(Lh.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(Lh.onAudioFirstFrameDecoded,{userId:s,isScreen:n}),t.safeEmit(Lh.onRemoteAudioFirstFrame,{userId:s,isScreen:n})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:n})};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:n};r?(h.publicStreamId=h.userId,delete h.userId,delete h.isScreen,t.safeEmit(Lh.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(Lh.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(Lh.onVideoFirstFrameRendered,h),t.safeEmit(Lh.onVideoFirstFrameDecoded,h),t.safeEmit(Lh.onRemoteVideoFirstFrame,h)),t.monitor.report("first_remote_video_render",{stream_id:"",stream_user_id:i.userId||""},{isScreen:n})}break;case"autoplay-error":return r&&(i.publicStreamId=i.userId),JN(t.id,"autoplay-error",e instanceof NX?"video":"audio",0,i.userId||""),void t.safeEmit(Lh.onAutoplayFailed,{userId:i.userId,kind:e instanceof NX?"video":"audio",mediaType:e instanceof NX?ch.VIDEO:ch.AUDIO,streamIndex:e.isScreen?sh.STREAM_INDEX_SCREEN:sh.STREAM_INDEX_MAIN})}t.safeEmit(Lh.onPlayerEvent,i)}))}},{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=Ng(Pg().mark((function e(n){var i,o,a;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.monitor.report("rtc_error",{message:Fg(i="track-".concat(r," mediaType: ")).call(i,n.originTrack.kind),error_code:LW.TRACK_ERROR,capture_session_id:n.captureSessionId,media_type:r,reason:r}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),a=n.originTrack.kind,t.safeEmit({"track-ended":Lh.onTrackEnded,"track-mute":Lh.onTrackMute,"track-unmute":Lh.onTrackUnmute}[r],{kind:a,isScreen:o}),!vL&&!dL){e.next=13;break}if("track-mute"!==r){e.next=12;break}if(Lj.emit(Nj.ON_IOS_LOCAL_TRACK_MUTE,a),"audio"!==a){e.next=12;break}return e.next=11,t.stopAudioCapture();case 11:t.startAudioCapture();case 12:"track-unmute"===r&&Lj.emit(Nj.ON_IOS_LOCAL_TRACK_UNMUTE,a);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(jj.PRE_PROCESSING).forEach((function(t){var n;null==t||null===(n=t.applyConstraints)||void 0===n||n.call(t,r?sh.STREAM_INDEX_SCREEN:sh.STREAM_INDEX_MAIN,e)})),t.safeEmit(Lh.onLocalVideoSizeChanged,{streamIndex:r?sh.STREAM_INDEX_SCREEN:sh.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){this.logger.info("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),eU(e,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),lU(t);var r,n,i,o=t.userId;if(e===sh.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 NX(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:aI(c).call(c,(function(e){return!e.isScreen}));return d&&this._updateVideoPlayerState(d),u.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var l=new NX(this.id,Ql(Ql({},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:aI(i).call(i,(function(e){return e.isScreen}));return h&&this._updateVideoPlayerState(h),l.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){this.logger.info("setLocalVideoMirrorType()","mirrorType: %o",e),eU(e,"mirrorType",[lh.MIRROR_TYPE_NONE,lh.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(q=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setAudioPlaybackDevice()","deviceId: %s",t),$L(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(Lh.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:Gg(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return q.apply(this,arguments)})},{key:"play",value:(Y=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=m.length>1&&void 0!==m[1]?m[1]:ch.AUDIO_AND_VIDEO,o=m.length>2?m[2]:void 0,this.logger.info("play()","userId: %s, mediaType: %s, streamIndex: %s",t,i,o),a=!t||t===this._getUserId()||"local_user"===t,s=void 0===o||o===sh.STREAM_INDEX_MAIN,c=void 0===o||o===sh.STREAM_INDEX_SCREEN,u=i!==ch.VIDEO,d=i!==ch.AUDIO,l=[],a&&d&&(s&&this._localVideoTrack&&(null===(h=this._videoPlayer)||void 0===h||h.mirror(!!this._mirrorType),l.push(null===(p=this._videoPlayer)||void 0===p?void 0:p.manuallyPlay())),c&&this._localScreenVideoTrack&&l.push(null===(v=this._screenPlayer)||void 0===v?void 0:v.manuallyPlay())),t===this._audioMixingManager.id&&l.push(this._audioMixingManager.resumeLocalPlay()),_=null===(r=this._room)||void 0===r?void 0:r.remoteStreams,d&&s&&l.push(LX(this._remoteVideoPlayer,t,!1,_)),d&&c&&l.push(LX(this._remoteScreenPlayer,t,!0,_)),u&&s&&l.push(LX(this._remoteAudioPlayer,t,!1,_)),d&&c&&l.push(LX(this._remoteScreenAudioPlayer,t,!0,_)),f=null===(n=this._publicStreamManager)||void 0===n?void 0:n.remoteStreams,u&&l.push(LX(this._publicStreamVideoPlayer,t,!1,f)),d&&l.push(LX(this._publicStreamAudioPlayer,t,!1,f)),e.abrupt("return",jI.all(l).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return Y.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(X=Ng(Pg().mark((function e(t){var r,n,i,o,a,s=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),GM(t)&&(s._pauseAllSubscribeState.audio=!0),zM(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",jI.resolve());case 6:n=[],i=my(cw(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(HZ){i.e(HZ)}finally{i.f()}return e.abrupt("return",jI.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return X.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(W=Ng(Pg().mark((function e(t){var r,n,i,o,a,s=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),GM(t)&&(s._pauseAllSubscribeState.audio=!1),zM(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",jI.resolve());case 6:n=[],i=my(cw(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(HZ){i.e(HZ)}finally{i.f()}return e.abrupt("return",jI.all(n).then((function(){var e;null===(e=s._room)||void 0===e||e.remoteStreams.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 W.apply(this,arguments)})},{key:"sendUserMessage",value:(K=Ng(Pg().mark((function e(t,r){var n,i,o,a=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sU(t),hU(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 K.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(z=Ng(Pg().mark((function e(t,r){var n,i,o,a=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sU(t),nU(r,"message"),hU(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 z.apply(this,arguments)})},{key:"sendRoomMessage",value:(G=Ng(Pg().mark((function e(t){var r,n,i,o=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return hU(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return G.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(H=Ng(Pg().mark((function e(t){var r,n,i,o=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return hU(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 H.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(j=Ng(Pg().mark((function e(){var t,r=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.length>0&&void 0!==r[0]?r[0]:{},this.logger.info("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,iU(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._ctx.audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return j.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(B=Ng(Pg().mark((function e(){var t,r=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},this.logger.info("setVideoCaptureConfig()","config: %o",t),e.abrupt("return",this._setVideoCaptureConfig(t));case 3:case"end":return e.stop()}}),e,this)}))),function(){return B.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(F=Ng(Pg().mark((function e(){var t,r,n,i=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,iU(r),n=Ql(Ql({},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.originTrack.getSettings())||{});case 9:case"end":return e.stop()}}),e,this)}))),function(){return F.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return this.logger.info("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==TL[0]&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&qM("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(V=Ng(Pg().mark((function e(t){var r,n,i,o,a;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(this.logger.info("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),_U(t=Ty(t).call(t,(function(e){return!!e}))),t.length>3&&(qM("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=sI(t).call(t,0,3)),n=1;n<t.length;n++)i=JM(t[0].width)/JM(t[n].width)||1,Math.floor(i)!==i&&qM("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");return Kw(t).call(t,(function(e,t){return t.maxKbps-e.maxKbps})),this._localVideoTrack&&null!==(o=t[0])&&void 0!==o&&o.contentHint&&this._localVideoTrack.setContentHint(null===(a=t[0])||void 0===a?void 0:a.contentHint),e.next=10,this._setVideoCaptureConfig(Ql({},t[0]));case 10:this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(sh.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 13:case"end":return e.stop()}}),e,this)}))),function(e){return V.apply(this,arguments)})},{key:"setVideoEncoderAutoConfigList",value:function(e){if(Array.isArray(e))return Kw(e).call(e,(function(e,t){return e.maxKbps-t.maxKbps})),YL(e)}},{key:"autoResetVideoEncoderConfig",value:function(e){var t,r=XL;if(r.length){this._videoStreamEncodeConfig.length||(this._videoStreamEncodeConfig=[qL]);var n=this._videoStreamEncodeConfig[0],i=e.width||JM(n.width),o=e.height||JM(n.height),a=i*o;if(!(JM(n.width)*JM(n.height)<=a)){var s,c,u=r[0];r.forEach((function(e){var t=JM(e.width)*JM(e.height);s||(a<t?s=e:u=e)})),c=s&&JM(s.width)*JM(s.height)-a<a-JM(u.width)*JM(u.height)?TT({},s):TT({},u),this._videoStreamEncodeConfig=Ty(t=this._videoStreamEncodeConfig).call(t,(function(e){return!(c&&JM(e.width)*JM(e.height)>=a)||(c.maxKbps=Math.min(e.maxKbps,c.maxKbps),!1)})),this._videoStreamEncodeConfig.unshift({width:i,height:o,frameRate:e.frameRate?Math.round(e.frameRate):this._videoStreamEncodeConfig[0].frameRate,maxKbps:c.maxKbps}),this.logger.print("autoResetVideoEncoderConfig() result",Gg(this._videoStreamEncodeConfig)),JN(this.id,"autoResetVideoEncoderConfig",Gg(this._videoStreamEncodeConfig))}}}},{key:"setScreenEncoderConfig",value:(U=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],!this._localScreenVideoTrack){e.next=7;break}if("16.1"===EL){e.next=6;break}return e.next=6,this._localScreenVideoTrack.updateVideoCaptureConfig(t);case 6:t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint);case 7:this._updateDummyCaptureImage(sh.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 9:case"end":return e.stop()}}),e,this)}))),function(e){return U.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(this.logger.info("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!BB())throw new bC(fC.NOT_SUPPORTED,"Browser does not support sending SEI");eU(e,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),ZL(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(wM.str2ab(t)):t;if(t.length){var i;if(e===sh.STREAM_INDEX_MAIN){var o,a;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=this._room.localStream}else{var s,c;if(null===(s=this._room)||void 0===s||null===(c=s.localScreenStream)||void 0===c||!c.hasPublished)return;i=this._room.localScreenStream}if(n.byteLength>4096)this.logger.warn("sei size must not bigger than 4KB");else{var u=TM();i.seiList.push({content:n,uuid:u,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=eC(e=i.seiList).call(e,(function(e){return e.uuid===u}));if(r>=0)BI(t=i.seiList).call(t,r,1)}}),2e3)}}else this.logger.warn("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;this.logger.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=aI(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(Lh.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=oS(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(Lh.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger.info("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.localMainReportMode,o=void 0===i?hh.NORMAL:i,a=t.audioReportMode,s=void 0===a?ph.MICROPHONE:a,c=t.interval,u=void 0===c?100:c;this._stopAudioPropertiesReport(),u<=0||(u=Math.max(100,u),this._audioPropertiesReportTimer=self.setInterval((function(){if(n||"hidden"!==document.visibilityState){var t=[],r=e._audioDeviceManager.getRecordTrack()||e._localAudioTrack;if(r){var i,a,c=null===(i=e._room)||void 0===i||null===(a=i.localStream)||void 0===a?void 0:a.audioHasPublish,u=!!e._audioDeviceManager.getRecordTrack(),d=r.getAudioLevel(s),l=HM(d),h={streamIndex:sh.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:d,nonlinearVolume:l}};if(c||u)t.push(h);else switch(o){case hh.DISCONNECT:break;case hh.RESET:h.audioPropertiesInfo.linearVolume=0,h.audioPropertiesInfo.nonlinearVolume=-127,t.push(h);break;case hh.NORMAL:t.push(h);break;default:throw new bC(fC.INVALID_PARAMS,"invalid localMainReportMode: ".concat(o," in config"))}}if(e._localScreenAudioTrack){var p=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:sh.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:p,nonlinearVolume:HM(p)}})}if(e.safeEmit(Lh.onLocalAudioPropertiesReport,t),e._room){var v=[];if(e._room.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i,o=255*t.audioLevel;v.push({streamKey:{userId:t.userId,streamIndex:sh.STREAM_INDEX_MAIN,roomId:null!==(r=null===(n=e._room)||void 0===n||null===(i=n._roomInfo)||void 0===i?void 0:i.roomId)&&void 0!==r?r:""},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:HM(o)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o,a=t.audioTrack.getAudioLevel();v.push({streamKey:{userId:r,streamIndex:t.isScreen?sh.STREAM_INDEX_SCREEN:sh.STREAM_INDEX_MAIN,roomId:null!==(n=null===(i=e._room)||void 0===i||null===(o=i.roomInfo)||void 0===o?void 0:o.roomId)&&void 0!==n?n:""},audioPropertiesInfo:{linearVolume:a,nonlinearVolume:HM(a)}})}}))}));e.safeEmit(Lh.onRemoteAudioPropertiesReport,v),e._sendActiveSpeaker(t,Ty(v).call(v,(function(e){return e.streamKey.streamIndex!==sh.STREAM_INDEX_SCREEN})))}}}),u))}},{key:"setVideoSourceType",value:(L=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T,I,R,A;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),eU(t,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),eU(r,"VideoSourceType",[Zl.VIDEO_SOURCE_TYPE_EXTERNAL,Zl.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===sh.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,this.logger.print("setVideoSourceType",Fg(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==sh.STREAM_INDEX_MAIN){e.next=17;break}if(u=!1,r===Zl.VIDEO_SOURCE_TYPE_EXTERNAL&&(u=!0,(d=this._extensionManager.getPluginByName(jj.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===(_=this._room)||void 0===_||null===(f=_.localStream)||void 0===f||null===(m=f.observer)||void 0===m||m.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubVideo||l)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==sh.STREAM_INDEX_SCREEN){e.next=26;break}if(b=!1,r===Zl.VIDEO_SOURCE_TYPE_EXTERNAL&&(b=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(g=this._screenPlayer)||void 0===g||g.stop(),this._localScreenVideoTrack=void 0,b?null===(k=this._room)||void 0===k||null===(E=k.localScreenStream)||void 0===E||null===(T=E.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===(y=this._room)||void 0===y||null===(S=y.localScreenStream)||void 0===S||!S.pubVideo){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return L.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(M=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setExternalVideoTrack()","index: %o, track: %o",t,r),eU(t,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),tU(r),t!==sh.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.video===Zl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,SH(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,!r.contentHint&&null!==(n=this._videoStreamEncodeConfig[0])&&void 0!==n&&n.contentHint&&this._localVideoTrack.setContentHint(null===(c=this._videoStreamEncodeConfig[0])||void 0===c?void 0:c.contentHint),this._initLocalTrackEvents(this._localVideoTrack),null===(i=this._videoPlayer)||void 0===i||i.playVideo(this._localVideoTrack),u=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubVideo||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==sh.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenVideo===Zl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 19:return e.next=21,TH(r,this._extensionManager);case 21:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(d=this._screenPlayer)||void 0===d||d.playVideo(this._localScreenVideoTrack),null===(l=this._room)||void 0===l||null===(h=l.localScreenStream)||void 0===h||null===(p=h.observer)||void 0===p||p.setPushVideo(!0),null===(v=this._room)||void 0===v||null===(_=v.localScreenStream)||void 0===_||!_.pubVideo){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:"setAudioSourceType",value:(N=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,g,y,S,b,k,E,T;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),eU(t,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),eU(r,"audioSourceType",[$l.AUDIO_SOURCE_TYPE_EXTERNAL,$l.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===sh.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,this.logger.print("setVideoSourceType",Fg(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==sh.STREAM_INDEX_MAIN){e.next=16;break}if(c=!1,this._trackSourceType.audio===$l.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===(_=v.observer)||void 0===_||_.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!==sh.STREAM_INDEX_SCREEN){e.next=24;break}if(g=!1,this._trackSourceType.audio===$l.AUDIO_SOURCE_TYPE_EXTERNAL&&(g=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,g?null===(y=this._room)||void 0===y||null===(S=y.localScreenStream)||void 0===S||null===(b=S.observer)||void 0===b||b.setEnableAudio(!1):null===(k=this._room)||void 0===k||null===(E=k.localScreenStream)||void 0===E||null===(T=E.observer)||void 0===T||T.setPushAudio(!1),null===(f=this._room)||void 0===f||null===(m=f.localScreenStream)||void 0===m||!m.pubAudio){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return N.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(D=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setExternalAudioTrack()","index: %o, track: %o",t,r),eU(t,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),tU(r),t!==sh.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===$l.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,kH(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!==sh.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===$l.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new bC(fC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,RH(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(d=this._room)||void 0===d||null===(l=d.localScreenStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setPushAudio(!0),null===(p=this._room)||void 0===p||null===(v=p.localScreenStream)||void 0===v||!v.pubAudio){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return D.apply(this,arguments)})},{key:"login",value:(P=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("login()","token: %o, userInfo: %o",t,r),oU(t)||$L(t,"token"),sU(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return P.apply(this,arguments)})},{key:"logout",value:(O=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return O.apply(this,arguments)})},{key:"updateLoginToken",value:(x=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateLoginToken()","token: %o",t),oU(t)||$L(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return x.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(C=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("getPeerOnlineStatus()","userId: %o",t),sU(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(w=Ng(Pg().mark((function e(t,r){var n,i=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sU(t),hU(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 w.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(A=Ng(Pg().mark((function e(t,r){var n,i=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sU(t),nU(r,"message"),hU(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 A.apply(this,arguments)})},{key:"setServerParams",value:(R=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.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 R.apply(this,arguments)})},{key:"sendServerMessage",value:(I=Ng(Pg().mark((function e(t){var r,n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $L(t,"message"),hU(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 I.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(T=Ng(Pg().mark((function e(t){var r,n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nU(t,"message"),hU(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!0,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new bC(fC.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");this.logger.info("startCloudProxy()",e),$L(e.logProxy,"logProxy"),$L(e.accessProxy,"accessProxy"),$L(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=KL("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=KL("LOG_SERVER_URL"),this._originConfigServerUrls=KL("CONFIG_REQUEST_DOMAINS"),zL("ICE_CONFIG_REQUEST_URLS",e.accessProxy),zL("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)),zL("CONFIG_REQUEST_DOMAINS",[e.configProxy]),LL.clearAccessNode(this._appId),LL.clearAccessUrls(),this._ctx.useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){var e,t,r;if(this._room)throw new bC(fC.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");this.logger.info("stopCloudProxy()");var n=null===(e=this._originIceConfigRequestUrls)||void 0===e?void 0:qg(e).call(e,(function(e){return e.replace("https://","").replace("/dispatch/v1/AccessInfo?Action=GetAccessInfo","")}));zL("ICE_CONFIG_REQUEST_URLS",null!=n?n:[]),zL("LOG_SERVER_URL",null!==(t=this._originLogServerUrl)&&void 0!==t?t:""),zL("CONFIG_REQUEST_DOMAINS",null!==(r=this._originConfigServerUrls)&&void 0!==r?r:[]),LL.clearAccessNode(this._appId),LL.clearAccessUrls(),this._ctx.useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(E=Ng(Pg().mark((function e(t,r){var n,i,o,a=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),cU(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new bC(fC.REPEAT_PUSH,"repeat push public media stream");case 5:return o=WL(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:(k=Ng(Pg().mark((function e(t,r){var n,i;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),cU(t),this._assertNotInRoom(),i=WL(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 k.apply(this,arguments)})},{key:"stopPushPublicStream",value:(b=Ng(Pg().mark((function e(t){var r,n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startPushPublicStream()","publicStreamId: %o",t),cU(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 b.apply(this,arguments)})},{key:"startPlayPublicStream",value:(S=Ng(Pg().mark((function e(t){var r,n,i,o,a=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(cU(t),this._publicStreamManager){e.next=8;break}return this._publicStreamManager=new SQ(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.on(xW.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=a._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=a._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),this._publicStreamManager.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,a.safeEmit(Lh.onPublicStreamStats,e)})),this._publicStreamManager.on(xW.ON_SEI_MESSAGED_RECEIVED,(function(e){a.safeEmit(Lh.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._publicStreamManager.connect();case 8:return e.next=10,this._publicStreamManager.startPlayPublicStream(t);case 10:r=e.sent,(n=this._publicStreamVideoPlayer.get(t))&&r.videoTrack&&n.playVideo(r.videoTrack,r),!(i=this._publicStreamAudioPlayer.get(t))&&r.audioTrack&&(i=new MX(this.id,t,{muted:(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)===Th.VIDEO_ONLY,isScreen:!1}),r.audioTrack.setPlayer(i),this._initPlayerEvents(i,!0),i.playAudio(r.audioTrack),this._publicStreamAudioPlayer.set(t,i));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(y=Ng(Pg().mark((function e(t){var r;return Pg().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:(g=Ng(Pg().mark((function e(t){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.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 g.apply(this,arguments)})},{key:"setAudioEncodeMaxBitrate",value:(m=Ng(Pg().mark((function e(t){var r,n,i,o,a,s;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setAudioEncodeMaxBitrate()",t),ZL(t,"maxBitrate",6,256),this._ctx.audioProfileManager.setCustomMaxBitrate(t),!this._ctx.audioProfileManager.customMaxBitrate){e.next=10;break}if(!tL||!(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 bC(fC.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(sh.STREAM_INDEX_MAIN,t);case 8:return e.next=10,null===(s=this._room)||void 0===s?void 0:s.setAudioEncodeMaxBitrate(sh.STREAM_INDEX_SCREEN,t);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i;this.logger.print("setPublicStreamVideoPlayer()","publicStreamId: %o, videoPlayerOption: %o",e,t);var o=this._publicStreamVideoPlayer.get(e);if(null===(r=o)||void 0===r||r.destroy(),t.renderDom){o=new NX(this.id,Ql(Ql({},t),{},{userId:e})),this._initPlayerEvents(o,!0),this._publicStreamVideoPlayer.set(e,o);var a=null===(n=this._publicStreamManager)||void 0===n?void 0:n.remoteStreams.get(e);null!=a&&a.videoTrack&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==Th.PLAY_MANUALLY&&o.playVideo(a.videoTrack,a)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(f=Ng(Pg().mark((function e(t,r){var n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new jI((function(e,i){$L(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===sh.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new bC(fC.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new bC(fC.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===sh.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=JM(r.width),c=JM(r.height);if(!a)throw new bC(fC.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===sh.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=u):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=u);var d,l,h=o.captureStream(5).getVideoTracks()[0];if(e===sh.STREAM_INDEX_MAIN)this._localImgVideoTrack=h,null!==(d=this._localVideoTrack)&&void 0!==d&&d.dummy&&this._localVideoTrack.setTrack(this._localImgVideoTrack,this._extensionManager);else this._localImgScreenTrack=h,null!==(l=this._localScreenVideoTrack)&&void 0!==l&&l.dummy&&this._localScreenVideoTrack.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=Ng(Pg().mark((function e(r,n){var i,o,a;return Pg().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(Lh.onLocalStreamTrackChangedByExtension,{streamIndex:sh.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:(_=Ng(Pg().mark((function e(t){var r,n;return Pg().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),null===(r=this._localAudioTrack)||void 0===r||r.generatePreProcessingTrack(this._extensionManager),null===(n=this._localVideoTrack)||void 0===n||n.generatePreProcessingTrack(this._extensionManager);case 18:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return _.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(Gg(PQ.getDefaultValue()))}},{key:"_updatePublish",value:(v=Ng(Pg().mark((function e(){var t,r,n,i=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},this.logger.info("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:PW.PUB},t=Ql(Ql({},r),t),this._visibility){e.next=6;break}throw new bC(fC.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===nX.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:e.next=24;break;case 17:if(e.prev=17,e.t0=e.catch(12),!(e.t0 instanceof bC)){e.next=23;break}throw e.t0;case 23:throw new bC(fC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 24:return e.prev=24,n(),e.finish(24);case 27:case"end":return e.stop()}}),e,this,[[12,17,24,27]])}))),function(){return v.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(p=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),$L(t,"filePath"),ZL(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 p.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this.logger.info("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(h=Ng(Pg().mark((function e(t,r){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),ZL(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 h.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){this.logger.info("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){this.logger.info("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;this.logger.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{sU(e),eU(t,"priority",[yh.HIGH,yh.MEDIUM,yh.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:(l=Ng(Pg().mark((function e(t){var r,n;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("takeLocalSnapshot()","streamIndex: %o",t),eU(t,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),r=t===sh.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new bC(fC.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===sh.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",IQ(r.preprocessingTrack,(null==n?void 0:n.mirrorType)===lh.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(d=Ng(Pg().mark((function e(t,r){var n,i,o,a,s,c;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),$L(t,"id"),eU(r,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),c=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=aI(i).call(i,(function(e){return e.isScreen===(r===sh.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 bC(fC.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",IQ(c.preprocessingTrack,!1,r===sh.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){this.logger.info("setSubscribeFallbackOption()","option: %o",e);try{eU(e,"option",[gh.DISABLE,gh.VIDEO_STREAM_LOW,gh.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=this;if(e===sh.STREAM_INDEX_MAIN?(r="video"===t?this.localVideoTrack:this.localAudioTrack,n=function(){var e;return null===(e=i._room)||void 0===e?void 0:e.localStream}):(r="video"===t?this.localScreenVideoTrack:this.localScreenAudioTrack,n=function(){var e;return null===(e=i._room)||void 0===e?void 0:e.localScreenStream}),r){var o=r instanceof wH&&r.mixedAudioTrack?r.mixedAudioTrack:r.preprocessingTrack;if(o){var a=n();return this._reportMsTrackEvent(o,(null==a?void 0:a.stream.id)||"local"),o}}}},{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===sh.STREAM_INDEX_MAIN)a=aI(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=aI(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.preprocessingTrack;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.preprocessingTrack;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:"setJoinRoomParams",value:function(e){e&&(this._ctx.joinRoomParams=e)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i,o,a,s=this;(eU(e,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),t=fU(t,"volume",0,400),e===sh.STREAM_INDEX_SCREEN)?(null===(r=this._localScreenAudioTrack)||void 0===r||r.once("needReplaceTrack",(function(){var e;null===(e=s._room)||void 0===e||e.updatePubScreenTrack()})),null===(n=this._localScreenAudioTrack)||void 0===n||n.setVolume(t),this._localScreenAudioVolume=t):(null===(i=this._localAudioTrack)||void 0===i||i.once("needReplaceTrack",(function(){var e;null===(e=s._room)||void 0===e||e.updatePubTrack()})),null===(o=this._localAudioTrack)||void 0===o||o.setVolume(t),null===(a=this._audioDeviceManager.audioTrack)||void 0===a||a.setVolume(t),this._localAudioVolume=t)}},{key:"setPlaybackVolume",value:function(e,t,r){var n,i,o,a;if(sU(e),eU(t,"streamIndex",[sh.STREAM_INDEX_MAIN,sh.STREAM_INDEX_SCREEN]),r=fU(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)qM("setPlaybackVolume is not supported in Conference mode");else{var s=t===sh.STREAM_INDEX_SCREEN;s?this._remoteScreenAudioVolume.set(e,r):this._remoteAudioVolume.set(e,r);var c=null===(i=this._room)||void 0===i||null===(o=i.remoteStreams.get(e))||void 0===o?void 0:aI(o).call(o,(function(e){return e.isScreen===s}));null==c||null===(a=c.audioTrack)||void 0===a||a.setVolume(r)}}},{key:"setPublicStreamVolume",value:function(e,t){var r,n,i;$L(e,"publicStreamId"),t=fU(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:(u=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){aU(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 u.apply(this,arguments)})},{key:"updateForwardStreamToRooms",value:(c=Ng(Pg().mark((function e(t){var r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){aU(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 c.apply(this,arguments)})},{key:"stopForwardStreamToRooms",value:(s=Ng(Pg().mark((function e(){var t;return Pg().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 s.apply(this,arguments)})},{key:"pauseForwardStreamToAllRooms",value:(a=Ng(Pg().mark((function e(){var t;return Pg().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 a.apply(this,arguments)})},{key:"resumeForwardStreamToAllRooms",value:(o=Ng(Pg().mark((function e(){var t;return Pg().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 o.apply(this,arguments)})},{key:"ambulance",value:(i=Ng(Pg().mark((function e(){var t,r;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,cZ(this);case 2:return t=e.sent,r=Gg(t),this.monitor.reportLongString("ambulance",r),e.abrupt("return",t);case 6: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(){JN(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=Ng(Pg().mark((function e(){var t,r,n,i=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},this.logger.info("_updateScreenPublish()"),r={mediaType:void 0,pubState:PW.PUB},t=Ql(Ql({},r),t),this._visibility){e.next=6;break}throw new bC(fC.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===nX.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 15:e.next=24;break;case 17:if(e.prev=17,e.t0=e.catch(12),!(e.t0 instanceof bC)){e.next=23;break}throw e.t0;case 23:throw new bC(fC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 24:return e.prev=24,n(),e.finish(24);case 27:case"end":return e.stop()}}),e,this,[[12,17,24,27]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){this.logger.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;if(!o){var u;o=new MX(this.id,r,{muted:(null===(u=this._config)||void 0===u?void 0:u.autoPlayPolicy)===Th.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?sh.STREAM_INDEX_SCREEN:sh.STREAM_INDEX_MAIN),i.set(r,o);var d=this._audioDeviceManager.getSinkId();d&&o.setPlaybackDevice(d)}(null===(a=this._config)||void 0===a?void 0:a.autoPlayPolicy)!==Th.PLAY_MANUALLY&&o.playAudio(e.audioTrack),e.audioTrack.setPlayer(o);var l=n?null!==(s=this._remoteScreenAudioVolume.get(r))&&void 0!==s?s:100:null!==(c=this._remoteAudioVolume.get(r))&&void 0!==c?c:100;e.audioTrack.setVolume(l),rL&&dL&&(t=this._remoteAudioPlayer,OQ&&clearTimeout(OQ),OQ=setTimeout((function(){var e,r=my(t);try{for(r.s();!(e=r.n()).done;){var n=gy(e.value,2),i=n[0],o=n[1];null!=i&&_C(i).call(i,"mux")&&o.pause()}}catch(HZ){r.e(HZ)}finally{r.f()}var a,s=my(t);try{for(s.s();!(a=s.n()).done;){var c=gy(a.value,2),u=c[0],d=c[1];null!=u&&_C(u).call(u,"mux")&&d.manuallyPlay()}}catch(HZ){s.e(HZ)}finally{s.f()}}),2e3))}else{var h;null===(h=o)||void 0===h||h.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;this.logger.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)!==Th.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=Ng(Pg().mark((function e(t){var r,n,i,o,a,s,c;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.stream,n=r.attributes,i=n.localaudio,o=n.audiostream,a=n.localvideo,s=n.videostream,c=xH.NONE,o&&(c|=ch.AUDIO),s&&(c|=ch.VIDEO),!c){e.next=11;break}return e.next=8,new jI((function(e){return setTimeout(e)}));case 8:r.isScreen?this.safeEmit(Lh.onUserPublishScreen,{userId:r.userId,mediaType:c}):(this.safeEmit(Lh.onUserPublishStream,{userId:r.userId,mediaType:c,videoStreamDescriptions:r.attributes.videoDescriptions}),this._handleAutoSubscribe(r,!0)),this.safeEmit("onAddStream",{userId:r.userId,mediaType:c,isScreen:!!r.isScreen}),r.isScreen||(i&&this.safeEmit(Lh.onUserStartAudioCapture,{userId:r.userId}),a&&this.safeEmit(Lh.onUserStartVideoCapture,{userId:r.userId}));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=xH.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=ch.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=ch.VIDEO),i){var o,a;if(t&&GM(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&zM(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=vZ[e.reason])&&void 0!==t?t:uh.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?Lh.onUserUnpublishScreen:Lh.onUserUnpublishStream,a=xH.NONE;n.attributes.audiostream&&(a|=ch.AUDIO),n.attributes.videostream&&(a|=ch.VIDEO),a!==xH.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(Lh.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(Lh.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(Lh.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,Fg(e=[Lh.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._ctx.useCloudProxy&&e.state===dh.CONNECTION_STATE_CONNECTED&&this.safeEmit(Lh.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(Lh.onConnectionStateChanged,e),e.state===dh.CONNECTION_STATE_RECONNECTING){var t,r=my(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=gy(t.value,2),i=n[0],o=n[1];_C(i).call(i,"mux")&&o.stop()}}catch(HZ){r.e(HZ)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ch.AUDIO_AND_VIDEO,n=(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),i=(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e),o=[];return r&ch.AUDIO&&o.push(n),r&ch.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&ch.AUDIO&&(r.isScreen?t._remoteScreenAudioPlayer.delete(r.userId):t._remoteAudioPlayer.delete(r.userId)),r.isScreen?e.mediaType&ch.VIDEO&&t._remoteScreenPlayer.delete(r.userId):e.mediaType&ch.VIDEO&&t._remoteVideoPlayer.delete(r.userId),null==n||n.destroy()}))}}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(Lh.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(Lh.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t=this,r=e.userId,n=e.isScreen,i=e.mediaType,o=e.pubState,a=e.remoteStream,s={userId:r,mediaType:i};i&ch.AUDIO&&setTimeout((function(){t._updateAudioPlayerState(a)})),n?o===PW.PUB?this.safeEmit(Lh.onUserPublishScreen,s):this.safeEmit(Lh.onUserUnpublishScreen,Ql(Ql({},s),{},{reason:uh.STREAM_REMOVE_REASON_UNPUBLISH})):o===PW.PUB?(s.videoStreamDescriptions=a.attributes.videoDescriptions,this.safeEmit(Lh.onUserPublishStream,s),this._handleAutoSubscribe(a,!0)):this.safeEmit(Lh.onUserUnpublishStream,Ql(Ql({},s),{},{reason:uh.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(Lh.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(Lh.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Lh.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Lh.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(Lh.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(Lh.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Lh.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(Lh.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Lh.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Lh.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(Lh.onError,{errorCode:fC.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(Lh.onError,{errorCode:fC.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(Lh.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"waitForNewToken",get:function(){return!!this._tempRoomInfo}},{key:"getSubLock",value:function(e,t){var r,n=e?this._subScreenLocks:this._subLocks,i=n.get(t);i||(i=new CW(Fg(r="sub_".concat(e?1:0,"_")).call(r,t)),n.set(t,i));return i}},{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=[];return null!==(e=this._room)&&void 0!==e&&e.remoteStreams&&this._room.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){t.push({userId:e.userId,isScreen:e.isScreen,hasVideo:e.hasVideo,hasAudio:e.hasAudio,videoStreamDescriptions:e.attributes.videoDescriptions})}))})),t}},{key:"iceState",get:function(){var e,t,r;return null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient.handler)||void 0===t||null===(r=t._peerConnection)||void 0===r?void 0:r.iceConnectionState}},{key:"remoteUsers",get:function(){var e,t=[];return null!==(e=this._room)&&void 0!==e&&e.remoteUsers&&this._room.remoteUsers.forEach((function(e){t.push({userId:e.userId})})),t}},{key:"multiChatMode",get:function(){var e;return!(null===(e=this._room)||void 0===e||!e._mediaServerClient.roomAttributes.multiChatMode)}},{key:"checkMediaType",get:function(){return this._checkMediaType}},{key:"assertNotInRoom",get:function(){return this._assertNotInRoom}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(Lh.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==nX.CONNECTED)throw new bC(fC.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){eU(e,"mediaType",[ch.AUDIO,ch.VIDEO,ch.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=Ng(Pg().mark((function e(t){var r,n,i;return Pg().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===Gj.INTERNAL;if(i){var o="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: ".concat(o)),JN(this.id,e,o)}return!i}},{key:"_getServerConfig",value:function(){var e=this,t=LL.getServerConfig(this.appId);t.rts_report&&MN.setConfig(t.rts_report),this._ctx.joinRoomConfig.setServerConfig(t.web_join_room),this._getServerConfigExecutor(t),vM({engineId:this.id,appId:this.appId,sdkVersion:KL("VERSION"),requestDomains:KL("CONFIG_REQUEST_DOMAINS"),keys:["rts_report","web_join_room","web_rtc_config"],deviceId:KL("DEVICE_ID")}).then((function(t){LL.setServerConfig(e.appId,t)}))}},{key:"_getServerConfigExecutor",value:function(e){var t,r,n,i;Nx.setParameter("UPLOAD_CONSOLE_ON",!(null==e||null===(t=e.web_rtc_config)||void 0===t||!t.upload_console_on)),Nx.setParameter("UPLOAD_CONSOLE_LENGTH_CUT",null==e||null===(r=e.web_rtc_config)||void 0===r?void 0:r.upload_console_length_cut),Nx.setParameter("UPLOAD_REPORT_LIMIT",null==e||null===(n=e.web_rtc_config)||void 0===n?void 0:n.upload_report_limit),Nx.setParameter("ENABLE_REPORT_IDB_BUFFER",!(null==e||null===(i=e.web_rtc_config)||void 0===i||!i.enable_report_idb_buffer))}}]),Re}(kU);hZ([XN()],pZ.prototype,"updateToken",1),hZ([XN(),mZ("video")],pZ.prototype,"setVideoCaptureDevice",1),hZ([XN(),mZ("audio")],pZ.prototype,"setAudioCaptureDevice",1),hZ([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=KN(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)}}},XN()],pZ.prototype,"connect",1),hZ([XN()],pZ.prototype,"joinRoom",1),hZ([XN()],pZ.prototype,"leaveRoom",1),hZ([XN()],pZ.prototype,"destroy",1),hZ([XN()],pZ.prototype,"publishStream",1),hZ([XN()],pZ.prototype,"unpublishStream",1),hZ([XN()],pZ.prototype,"publishScreen",1),hZ([XN()],pZ.prototype,"unpublishScreen",1),hZ([XN()],pZ.prototype,"subscribeStream",1),hZ([_Z],pZ.prototype,"_subscribe",1),hZ([XN()],pZ.prototype,"unsubscribeStream",1),hZ([XN()],pZ.prototype,"subscribeScreen",1),hZ([XN()],pZ.prototype,"unsubscribeScreen",1),hZ([_Z],pZ.prototype,"_unsubscribe",1),hZ([XN(),fZ],pZ.prototype,"setRemoteVideoConfig",1),hZ([XN(),mZ("video")],pZ.prototype,"startVideoCapture",1),hZ([XN(),mZ("video")],pZ.prototype,"stopVideoCapture",1),hZ([XN(),mZ("audio")],pZ.prototype,"startAudioCapture",1),hZ([XN(),mZ("audio")],pZ.prototype,"stopAudioCapture",1),hZ([XN(),mZ("all")],pZ.prototype,"startAudioAndVideoCapture",1),hZ([XN()],pZ.prototype,"startVideoAndAudioCapture",1),hZ([XN()],pZ.prototype,"getAudioMixingManager",1),hZ([XN(),gZ],pZ.prototype,"startScreenCapture",1),hZ([XN(),gZ],pZ.prototype,"stopScreenCapture",1),hZ([XN()],pZ.prototype,"setLocalVideoPlayer",1),hZ([XN()],pZ.prototype,"startLiveTranscoding",1),hZ([XN()],pZ.prototype,"updateLiveTranscoding",1),hZ([XN()],pZ.prototype,"stopLiveTranscoding",1),hZ([XN()],pZ.prototype,"startSubtitle",1),hZ([XN()],pZ.prototype,"stopSubtitle",1),hZ([XN()],pZ.prototype,"setBusinessId",1),hZ([XN()],pZ.prototype,"setUserVisibility",1),hZ([XN()],pZ.prototype,"setRemoteVideoPlayer",1),hZ([XN()],pZ.prototype,"setLocalVideoMirrorType",1),hZ([XN()],pZ.prototype,"setAudioPlaybackDevice",1),hZ([XN()],pZ.prototype,"play",1),hZ([XN()],pZ.prototype,"pauseAllSubscribedStream",1),hZ([XN()],pZ.prototype,"resumeAllSubscribedStream",1),hZ([XN()],pZ.prototype,"sendUserMessage",1),hZ([XN()],pZ.prototype,"sendUserBinaryMessage",1),hZ([XN()],pZ.prototype,"sendRoomMessage",1),hZ([XN()],pZ.prototype,"sendRoomBinaryMessage",1),hZ([XN()],pZ.prototype,"setAudioCaptureConfig",1),hZ([YM("4.51"),XN()],pZ.prototype,"setVideoCaptureConfig",1),hZ([XN()],pZ.prototype,"enableSimulcastMode",1),hZ([XN()],pZ.prototype,"setVideoEncoderConfig",1),hZ([XN()],pZ.prototype,"setScreenEncoderConfig",1),hZ([XN()],pZ.prototype,"sendSEIMessage",1),hZ([YM("4.42"),XN()],pZ.prototype,"setAudioVolumeIndicationInterval",1),hZ([XN()],pZ.prototype,"enableAudioPropertiesReport",1),hZ([XN()],pZ.prototype,"setVideoSourceType",1),hZ([XN()],pZ.prototype,"setExternalVideoTrack",1),hZ([XN()],pZ.prototype,"setAudioSourceType",1),hZ([XN()],pZ.prototype,"setExternalAudioTrack",1),hZ([XN()],pZ.prototype,"login",1),hZ([XN()],pZ.prototype,"logout",1),hZ([XN()],pZ.prototype,"updateLoginToken",1),hZ([XN()],pZ.prototype,"getPeerOnlineStatus",1),hZ([XN()],pZ.prototype,"sendUserMessageOutsideRoom",1),hZ([XN()],pZ.prototype,"sendUserBinaryMessageOutsideRoom",1),hZ([XN()],pZ.prototype,"setServerParams",1),hZ([XN()],pZ.prototype,"sendServerMessage",1),hZ([XN()],pZ.prototype,"sendServerBinaryMessage",1),hZ([XN()],pZ.prototype,"startCloudProxy",1),hZ([XN()],pZ.prototype,"stopCloudProxy",1),hZ([XN()],pZ.prototype,"startPushPublicStream",1),hZ([XN()],pZ.prototype,"updatePublicStreamParam",1),hZ([XN()],pZ.prototype,"stopPushPublicStream",1),hZ([XN("streamId")],pZ.prototype,"startPlayPublicStream",1),hZ([XN("streamId")],pZ.prototype,"stopPlayPublicStream",1),hZ([XN()],pZ.prototype,"setAudioProfile",1),hZ([XN()],pZ.prototype,"setAudioEncodeMaxBitrate",1),hZ([XN()],pZ.prototype,"setPublicStreamVideoPlayer",1),hZ([XN()],pZ.prototype,"setDummyCaptureImagePath",1),hZ([XN()],pZ.prototype,"registerExtension",1),hZ([XN()],pZ.prototype,"startAudioPlaybackDeviceTest",1),hZ([XN()],pZ.prototype,"stopAudioPlaybackDeviceTest",1),hZ([XN()],pZ.prototype,"startAudioDeviceRecordTest",1),hZ([XN()],pZ.prototype,"stopAudioDeviceRecordAndPlayTest",1),hZ([XN()],pZ.prototype,"stopAudioDevicePlayTest",1),hZ([XN(),fZ],pZ.prototype,"setRemoteUserPriority",1),hZ([XN()],pZ.prototype,"takeLocalSnapshot",1),hZ([XN()],pZ.prototype,"takeRemoteSnapshot",1),hZ([XN()],pZ.prototype,"setSubscribeFallbackOption",1),hZ([XN()],pZ.prototype,"getLocalStreamTrack",1),hZ([XN()],pZ.prototype,"getRemoteStreamTrack",1),hZ([XN()],pZ.prototype,"getPublicStreamTrack",1),hZ([XN()],pZ.prototype,"setRemoteStreamRenderSync",1),hZ([XN()],pZ.prototype,"setJoinRoomParams",1),hZ([XN()],pZ.prototype,"startForwardStreamToRooms",1),hZ([XN()],pZ.prototype,"updateForwardStreamToRooms",1),hZ([XN()],pZ.prototype,"stopForwardStreamToRooms",1),hZ([XN()],pZ.prototype,"pauseForwardStreamToAllRooms",1),hZ([XN()],pZ.prototype,"resumeForwardStreamToAllRooms",1);var vZ={"client unpublished":uh.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":uh.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":uh.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":uh.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":uh.STREAM_REMOVE_REASON_REPUBLISH};function _Z(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var t,r,i,o,a,s,c,u=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=u.length,r=new Array(t),i=0;i<t;i++)r[i]=u[i];return o=r[0],a=r[1],s=r[2],this.checkMediaType(s),this.assertNotInRoom(),e.next=6,this.getSubLock(o,a).lock();case 6:return c=e.sent,e.prev=7,e.next=10,n.apply(this,r);case 10:return e.abrupt("return",e.sent);case 11:return e.prev=11,c(),e.finish(11);case 14:case"end":return e.stop()}}),e,this,[[7,,11,14]])}))),r}function fZ(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var t,r,i,o,a,s=arguments;return Pg().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=r[0],e.next=4,this.getSubLock(!1,o).lock();case 4:return a=e.sent,e.prev=5,e.next=8,n.apply(this,r);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,a(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[5,,9,12]])}))),r}function mZ(e){return function(t,r,n){var i=n.value;return n.value=Ng(Pg().mark((function t(){var r,n,o,a,s,c=arguments;return Pg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],"video"!==e&&r.push(this._audioCaptureLock.lock()),"audio"!==e&&r.push(this._videoCaptureLock.lock()),t.next=5,jI.all(r);case 5:for(n=t.sent,t.prev=6,o=c.length,a=new Array(o),s=0;s<o;s++)a[s]=c[s];return t.next=10,i.apply(this,a);case 10:return t.abrupt("return",t.sent);case 11:return t.prev=11,n.forEach((function(e){return e()})),t.finish(11);case 14:case"end":return t.stop()}}),t,this,[[6,,11,14]])}))),n}}function gZ(e,t,r){var n=r.value;return r.value=Ng(Pg().mark((function e(){var t,r,i,o,a=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._screenCaptureLock.lock();case 2:for(t=e.sent,e.prev=3,r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=7,n.apply(this,i);case 7:return e.abrupt("return",e.sent);case 8:return e.prev=8,t(),e.finish(8);case 11:case"end":return e.stop()}}),e,this,[[3,,8,11]])}))),r}var yZ,SZ=uT,bZ=HI,kZ=function(e,t,r,n){for(var i,o=n>1?void 0:n?bZ(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&&SZ(t,r,o),o},EZ=function(e){UA(i,e);var t,r,n=ew(i);function i(e,t,r){var o;return Fh(this,i),ql(aA(o=n.call(this,e,t,r)),"singleStreamRenderMode",!1),o.id=t,o.logger=new pM("BLWEngine",0,t),YL([{width:192,height:108,frameRate:15,maxKbps:100},{width:320,height:180,frameRate:15,maxKbps:140},{width:640,height:360,frameRate:15,maxKbps:400},{width:1280,height:720,frameRate:15,maxKbps:1e3},{width:1920,height:1080,frameRate:15,maxKbps:2e3}]),o._handleEngineEvents(),o}return Vh(i,[{key:"subscribeStream",value:(r=Ng(Pg().mark((function e(t,r){var n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("subscribeStream()","userId: %o, mediaType: %o",t,r),this.singleStreamRenderMode&&zM(r)&&MA(NA(i.prototype),"subscribeScreen",this).call(this,t,ch.VIDEO).catch((function(e){n.logger.error("singleStreamRenderMode subscribeScreen()",e)})),e.abrupt("return",MA(NA(i.prototype),"subscribeStream",this).call(this,t,r));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"unsubscribeStream",value:(t=Ng(Pg().mark((function e(t,r){var n=this;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this.singleStreamRenderMode&&zM(r)&&MA(NA(i.prototype),"unsubscribeScreen",this).call(this,t,ch.VIDEO).catch((function(e){n.logger.error("singleStreamRenderMode unsubscribeScreen()",e)})),e.abrupt("return",MA(NA(i.prototype),"unsubscribeStream",this).call(this,t,r));case 3:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"setRemoteScreenVideoStreamIndex",value:function(e){var t;return this.logger.print("setRemoteScreenVideoStreamIndex()","streamIndex: %o",e),(null===(t=this._room)||void 0===t?void 0:t.connectionState)!==nX.CONNECTED&&(this.singleStreamRenderMode=e===sh.STREAM_INDEX_MAIN,!0)}},{key:"setRemoteVideoPlayer",value:function(e,t){if(this.logger.print("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),!this.singleStreamRenderMode||e!==sh.STREAM_INDEX_SCREEN)return MA(NA(i.prototype),"setRemoteVideoPlayer",this).call(this,e,t)}},{key:"destroy",value:function(){this.singleStreamRenderMode=!1,MA(NA(i.prototype),"destroy",this).call(this)}},{key:"_updateVideoPlayerState",value:function(e){var t,r;if(!this.singleStreamRenderMode)return MA(NA(i.prototype),"_updateVideoPlayerState",this).call(this,e);var n,o=e.userId,a=null===(t=this._room)||void 0===t?void 0:t.remoteStreams.get(o);Array.isArray(a)&&a.forEach((function(e){e.isScreen&&(n=e)}));var s=this._remoteVideoPlayer.get(o);if(s){if(!e.isScreen&&null!==(r=n)&&void 0!==r&&r.videoTrack)return this.logger.print("_updateVideoPlayerState","prevent play main stream"),void s.playVideo(n.videoTrack,n);var c;if(e.videoTrack)(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)!==Th.PLAY_MANUALLY&&s.playVideo(e.videoTrack,e);else s.played&&s.stop()}}},{key:"_handleEngineEvents",value:function(){var e=this;this.on(Lh.onUserPublishScreen,(function(t){if(e.singleStreamRenderMode&&zM(t.mediaType)){var r,n,i=null===(r=e._room)||void 0===r?void 0:r.remoteStreams.get(t.userId),o=null==i?void 0:aI(i).call(i,(function(e){return!e.isScreen})),a=null==i?void 0:aI(i).call(i,(function(e){return e.isScreen}));null!=a&&a.hasSubscribed?(e.logger.info("onUserPublishScreen","singleStreamRenderMode screen hasSubscribed"),e._updateVideoPlayerState(a)):(null!==(n=e._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo||null!=o&&o.hasSubscribed&&zM(o.subMediaType))&&(e.logger.info("onUserPublishScreen","singleStreamRenderMode subscribeScreen"),e.subscribeScreen(t.userId,ch.VIDEO))}})),this.on(Lh.onUserUnpublishScreen,(function(t){if(e.singleStreamRenderMode&&zM(t.mediaType)){var r,n=e._remoteVideoPlayer.get(t.userId),i=null===(r=e._room)||void 0===r?void 0:r.remoteStreams.get(t.userId),o=null==i?void 0:aI(i).call(i,(function(e){return!e.isScreen}));if(null==o||!o.videoTrack||!n)return;n.playVideo(o.videoTrack)}}))}}]),i}(pZ);kZ([XN()],EZ.prototype,"subscribeStream",1),kZ([XN()],EZ.prototype,"unsubscribeStream",1),kZ([XN()],EZ.prototype,"setRemoteScreenVideoStreamIndex",1),kZ([XN()],EZ.prototype,"setRemoteVideoPlayer",1),kZ([XN()],EZ.prototype,"destroy",1);var TZ=new pM("VERTC",0);Tx.storeKey=Fg(yZ="".concat(Date.now(),"-")).call(yZ,LL.getDeviceId()),UN({rtc_sdk_version:GL.VERSION,device_id:LL.getDeviceId(),log_cache_key:Tx.storeKey}),VN(GL.LOG_SERVER_URL);var IZ=1,RZ=function(e,t){TZ.info("createEngine","Invoke VERTC.createEngine"),$L(e,"appId");var r=(IZ++).toString();return WN(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new pZ(e,r,t)},AZ=function(e,t){TZ.print("createBLWEngine","Invoke VERTC.createBLWEngine"),$L(e,"appId");var r=(IZ++).toString();return WN(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new EZ(e,r,t)},wZ=function(e){if(TZ.info("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof pZ))throw new bC(fC.INVALID_ENGINE,"Invalid engine object");var t;e.destroy(),(t=e.monitor).report("sdk_init_engine",{start:Date.now(),type:"end"}),zN.delete(t.id)},CZ=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Pj.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),xZ=function(){var e=Ng(Pg().mark((function e(){var t,r,n,i,o,a,s=arguments;return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=(t=s.length>0&&void 0!==s[0]?s[0]:{video:!0,audio:!0}).video,n=t.audio,i={video:!1,audio:!1},!r){e.next=14;break}return e.prev=4,e.next=7,Pj.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,Pj.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)}}(),OZ=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Pj.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),PZ=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Pj.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),DZ=function(){var e=Ng(Pg().mark((function e(){return Pg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Pj.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),NZ=function(){return GL.VERSION},MZ=function(){return wB()},LZ=function(){return xB()},UZ=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(Tx.logLevel=t),r&&(Tx.LogfileSize=r)},VZ=function(e){Tx.download(e)};function FZ(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Gg(qg(t).call(t,(function(e){return e instanceof pZ?"[ENGINE]":e})))}function BZ(e,t){return function(){BN(t,0,FZ.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 jN(t,0,FZ(e)),e})).catch((function(e){throw jN(t,e.code,e.message),e})):(jN(t,0,FZ(r)),r)}}return Ql(Ql(Ql(Ql({},new(Vh((function e(){Fh(this,e),ql(this,"getSdkVersion",BZ(NZ,"getSdkVersion")),ql(this,"createEngine",BZ(RZ,"createEngine")),ql(this,"createBLWEngine",BZ(AZ,"createBLWEngine")),ql(this,"destroyEngine",BZ(wZ,"destroyEngine")),ql(this,"enumerateDevices",BZ(CZ,"enumerateDevices")),ql(this,"enableDevices",BZ(xZ,"enableDevices")),ql(this,"enumerateAudioCaptureDevices",BZ(OZ,"enumerateAudioCaptureDevices")),ql(this,"enumerateVideoCaptureDevices",BZ(PZ,"enumerateVideoCaptureDevices")),ql(this,"enumerateAudioPlaybackDevices",BZ(DZ,"enumerateAudioPlaybackDevices")),ql(this,"getParameter",KL),ql(this,"setParameter",zL),ql(this,"isSupported",BZ(MZ,"isSupported")),ql(this,"getSupportedCodecs",BZ(LZ,"getSupportedCodecs")),ql(this,"events",Lh),ql(this,"ErrorCode",fC),ql(this,"platform","BytePlus"),ql(this,"commitInfo","HEAD<25678df*>"),ql(this,"downloadLog",BZ(VZ,"downloadLog")),ql(this,"setLogConfig",BZ(UZ,"setLogConfig"))})))),Oh),Mh),{},{events:Lh})}));
|
|
7
7
|
//# sourceMappingURL=index.min.js.map
|