@byteplus/rtc 4.61.4 → 4.62.0-beta-oc-1000774380.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.min.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Copyright (c) 2024 The BytePlusRTC project authors. All Rights Reserved.
3
3
  * @brief BytePlusRTC Advance API
4
- * version: 4.61.4
4
+ * version: 4.62.0-beta-oc-1000774380.4
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,f=p.call,_=h&&p.bind.bind(f,f),v=h?_:function(e){return function(){return f.apply(e,arguments)}},m=v,g=m({}.toString),y=m("".slice),S=function(e){return y(g(e),8,-1)},b=S,E=v,k=function(e){if("Function"===b(e))return E(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)},N={},M={}.propertyIsEnumerable,D=Object.getOwnPropertyDescriptor,L=D&&!M.call({1:2},1);N.f=L?function(e){var t=D(this,e);return!!t&&t.enumerable}:M;var U,V,F=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},B=o,j=S,G=Object,H=v("".split),z=B((function(){return!G("z").propertyIsEnumerable(0)}))?function(e){return"String"===j(e)?H(e,""):G(e)}:G,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=v({}.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,fe=pe&&pe.v8;fe&&(V=(U=fe.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,ve=_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&&ve&&ve<41})),Se=ye&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,be=ae,Ee=A,ke=se,Te=Object,Ie=Se?function(e){return"symbol"==typeof e}:function(e){var t=be("Symbol");return Ee(t)&&ke(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,Ne=K,Me=function(e,t){var r=e[t];return Ne(r)?void 0:Pe(r)},De=P,Le=A,Ue=ee,Ve=TypeError,Fe={exports:{}},Be=i,je=Object.defineProperty,Ge=function(e,t){try{je(Be,e,{value:t,configurable:!0,writable:!0})}catch(r){Be[e]=t}return t},He="__core-js_shared__",ze=i[He]||Ge(He,{}),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=v({}.hasOwnProperty),Ze=Object.hasOwn||function(e,t){return Qe(Je(e),t)},$e=v,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,ft=ee,_t=Ie,vt=Me,mt=function(e,t){var r,n;if("string"===t&&Le(r=e.toString)&&!Ue(n=De(r,e)))return n;if(Le(r=e.valueOf)&&!Ue(n=De(r,e)))return n;if("string"!==t&&Le(r=e.toString)&&!Ue(n=De(r,e)))return n;throw Ve("Can't convert object to primitive value")},gt=TypeError,yt=ht("toPrimitive"),St=function(e,t){if(!ft(e)||_t(e))return e;var r,n=vt(e,yt);if(n){if(void 0===t&&(t="default"),r=pt(n,e,t),!ft(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,Et=function(e){var t=St(e,"string");return bt(t)?t:t+""},kt=ee,Tt=i.document,It=kt(Tt)&&kt(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=N,Pt=F,Nt=Q,Mt=Et,Dt=Ze,Lt=wt,Ut=Object.getOwnPropertyDescriptor;w.f=Ct?Ut:function(e,t){if(e=Nt(e),t=Mt(t),Lt)try{return Ut(e,t)}catch(r){}if(Dt(e,t))return Pt(!xt(Ot.f,e,t),e[t])};var Vt=o,Ft=A,Bt=/#|\.prototype\./,jt=function(e,t){var r=Ht[Gt(e)];return r===Kt||r!==zt&&(Ft(t)?Vt(t):!!t)},Gt=jt.normalize=function(e){return String(e).replace(Bt,".").toLowerCase()},Ht=jt.data={},zt=jt.NATIVE="N",Kt=jt.POLYFILL="P",Wt=jt,Xt=Oe,Yt=a,qt=k(k.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=Et,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 fr=Qt,_r=F,vr=C?function(e,t,r){return fr.f(e,t,_r(1,r))}:function(e,t,r){return e[t]=r,e},mr=i,gr=l,yr=k,Sr=A,br=w.f,Er=Wt,kr=te,Tr=Jt,Ir=vr,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,f=e.proto,_=h?mr:p?mr[l]:(mr[l]||{}).prototype,v=h?kr:kr[l]||Ir(kr,l,{})[l],m=v.prototype;for(o in t)n=!(r=Er(h?o:l+(p?".":"#")+o,e.forced))&&_&&Rr(_,o),s=v[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):f&&Sr(a)?yr(a):a,(e.sham||a&&a.sham||s&&s.sham)&&Ir(u,"sham",!0),Ir(v,o,u),f&&(Rr(kr,i=l+"Prototype")||Ir(kr,i,{}),Ir(kr[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)},Nr=Pr,Mr=Math.max,Dr=Math.min,Lr=function(e,t){var r=Nr(e);return r<0?Mr(r+t,0):Dr(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)},Gr=Q,Hr=Lr,zr=jr,Kr=function(e){return function(t,r,n){var i,o=Gr(t),a=zr(o),s=Hr(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},Wr={includes:Kr(!0),indexOf:Kr(!1)},Xr={},Yr=Ze,qr=Q,Jr=Wr.indexOf,Qr=Xr,Zr=v([].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,fn=ht("toStringTag"),_n=Object,vn="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),fn))?r:vn?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={},En=C,kn=Zt,Tn=Qt,In=rr,Rn=Q,An=nn;bn.f=En&&!kn?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))},Nn=rr,Mn=bn,Dn=en,Ln=Xr,Un=Cn,Vn=Rt,Fn="prototype",Bn="script",jn=Pn("IE_PROTO"),Gn=function(){},Hn=function(e){return"<"+Bn+">"+e+"</"+Bn+">"},zn=function(e){e.write(Hn("")),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(Hn("document.F=Object")),e.close(),e.F):zn(wn);for(var n=Dn.length;n--;)delete Kn[Fn][Dn[n]];return Kn()};Ln[jn]=!0;var Wn=Object.create||function(e,t){var r;return null!==e?(Gn[Fn]=Nn(e),r=new Gn,Gn[Fn]=null,r[jn]=e):r=Kn(),void 0===t?r:Mn.f(r,t)},Xn={},Yn=$r,qn=en.concat("length","prototype");Xn.f=Object.getOwnPropertyNames||function(e){return Yn(e,qn)};var Jn={},Qn=Et,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=vr,fi=function(e,t,r,n){return n&&n.enumerable?e[t]=r:pi(e,t,r),e},_i=Qt,vi=function(e,t,r){return _i.f(e,t,r)},mi={},gi=ht;mi.f=gi;var yi,Si,bi,Ei=te,ki=Ze,Ti=mi,Ii=Qt.f,Ri=function(e){var t=Ei.Symbol||(Ei.Symbol={});ki(t,e)||Ii(t,e,{value:Ti.f(e)})},Ai=P,wi=ae,Ci=ht,xi=fi,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,Ni=dn?{}.toString:function(){return"[object "+Pi(this)+"]"},Mi=dn,Di=Qt.f,Li=vr,Ui=Ze,Vi=Ni,Fi=ht("toStringTag"),Bi=function(e,t,r,n){if(e){var i=r?e:e.prototype;Ui(i,Fi)||Di(i,Fi,{configurable:!0,value:t}),n&&!Mi&&Li(i,"toString",Vi)}},ji=A,Gi=i.WeakMap,Hi=ji(Gi)&&/native code/.test(String(Gi)),zi=i,Ki=ee,Wi=vr,Xi=Ze,Yi=ze,qi=Pn,Ji=Xr,Qi="Object already initialized",Zi=zi.TypeError,$i=zi.WeakMap;if(Hi||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=v(Function.toString);oo(ao.inspectSource)||(ao.inspectSource=function(e){return so(e)});var co=ao.inspectSource,uo=v,lo=o,ho=A,po=mn,fo=co,_o=function(){},vo=[],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,vo,e),!0}catch(t){return!1}},Eo=function(e){if(!ho(e))return!1;switch(po(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return So||!!yo(go,fo(e))}catch(t){return!0}};Eo.sham=!0;var ko=!mo||lo((function(){var e;return bo(bo.call)||!bo(Object)||!bo((function(){e=!0}))||e}))?Eo:bo,To=io,Io=ko,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,No=qe,Mo=jr,Do=xo,Lo=v([].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,f=No(c),_=Po(f),v=Oo(u,d),m=Mo(_),g=0,y=l||Do,S=t?y(c,m):r||a?y(c,0):void 0;m>g;g++)if((s||g in _)&&(p=v(h=_[g],g,f),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,Go=v,Ho=C,zo=ye,Ko=o,Wo=Ze,Xo=se,Yo=rr,qo=Q,Jo=Et,Qo=Sn,Zo=F,$o=Wn,ea=nn,ta=Xn,ra=Jn,na=hi,ia=w,oa=Qt,aa=bn,sa=N,ca=fi,ua=vi,da=We,la=Xr,ha=nt,pa=ht,fa=mi,_a=Ri,va=Oi,ma=Bi,ga=ro,ya=Vo.forEach,Sa=Pn("hidden"),ba="Symbol",Ea="prototype",ka=ga.set,Ta=ga.getterFor(ba),Ia=Object[Ea],Ra=Bo.Symbol,Aa=Ra&&Ra[Ea],wa=Bo.TypeError,Ca=Bo.QObject,xa=ia.f,Oa=oa.f,Pa=ra.f,Na=sa.f,Ma=Go([].push),Da=da("symbols"),La=da("op-symbols"),Ua=da("wks"),Va=!Ca||!Ca[Ea]||!Ca[Ea].findChild,Fa=Ho&&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=Da[e]=$o(Aa);return ka(r,{type:ba,tag:e,description:t}),Ho||(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(Da,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)},Ga=function(e,t){Yo(e);var r=qo(t),n=ea(r).concat(Wa(r));return ya(n,(function(t){Ho&&!jo(Ha,r,t)||ja(e,t,r[t])})),e},Ha=function(e){var t=Jo(e),r=jo(Na,this,t);return!(this===Ia&&Wo(Da,t)&&!Wo(La,t))&&(!(r||!Wo(this,t)||!Wo(Da,t)||Wo(this,Sa)&&this[Sa][t])||r)},za=function(e,t){var r=qo(e),n=Jo(t);if(r!==Ia||!Wo(Da,n)||Wo(La,n)){var i=xa(r,n);return!i||!Wo(Da,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(Da,e)||Wo(la,e)||Ma(r,e)})),r},Wa=function(e){var t=e===Ia,r=Pa(t?La:qo(e)),n=[];return ya(r,(function(e){!Wo(Da,e)||t&&!Wo(Ia,e)||Ma(n,Da[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 Ho&&Va&&Fa(Ia,t,{configurable:!0,set:r}),Ba(t,e)},ca(Aa=Ra[Ea],"toString",(function(){return Ta(this).tag})),ca(Ra,"withoutSetter",(function(e){return Ba(ha(e),e)})),sa.f=Ha,oa.f=ja,aa.f=Ga,ia.f=za,ta.f=ra.f=Ka,na.f=Wa,fa.f=function(e){return Ba(pa(e),e)},Ho&&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:!Ho},{create:function(e,t){return void 0===t?$o(e):Ga($o(e),t)},defineProperty:ja,defineProperties:Ga,getOwnPropertyDescriptor:za}),Fo({target:"Object",stat:!0,forced:!zo},{getOwnPropertyNames:Ka}),va(),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=v([].slice),us=io,ds=A,ls=S,hs=Sn,ps=v([].push),fs=wr,_s=ae,vs=l,ms=P,gs=v,ys=o,Ss=A,bs=Ie,Es=cs,ks=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,Ns=/^[\uD800-\uDBFF]$/,Ms=/^[\uDC00-\uDFFF]$/,Ds=!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=Es(arguments),n=ks(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},vs(Rs,null,r)},Vs=function(e,t,r){var n=ws(r,t-1),i=ws(r,t+1);return As(Ns,e)&&!As(Ms,i)||As(Ms,e)&&!As(Ns,n)?"\\u"+Os(Cs(e,0),16):e};Rs&&fs({target:"JSON",stat:!0,arity:3,forced:Ds||Ls},{stringify:function(e,t,r){var n=Es(arguments),i=vs(Ds?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,Gs=r(js),Hs=o,zs=_e,Ks=ht("species"),Ws=function(e){return zs>=51||!Hs((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,fc=TypeError,_c=Object.getOwnPropertyDescriptor,vc=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 fc("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=vc,Ec=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;Ec(r+n);for(var i=0;i<n;i++)t[r]=arguments[i],r++;return bc(t,r),r}});var kc,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,Nc=Ze,Mc=Function.prototype,Dc=Pc&&Object.getOwnPropertyDescriptor,Lc=Nc(Mc,"name"),Uc={EXISTS:Lc,PROPER:Lc&&"something"===function(){}.name,CONFIGURABLE:Lc&&(!Pc||Pc&&Dc(Mc,"name").configurable)},Vc=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Fc=Ze,Bc=A,jc=qe,Gc=Vc,Hc=Pn("IE_PROTO"),zc=Object,Kc=zc.prototype,Wc=Gc?zc.getPrototypeOf:function(e){var t=jc(e);if(Fc(t,Hc))return t[Hc];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=fi,$c=ht("iterator"),eu=!1;[].keys&&("next"in(Ic=[].keys())?(Tc=Qc(Qc(Ic)))!==Object.prototype&&(kc=Tc):eu=!0);var tu=!qc(kc)||Xc((function(){var e={};return kc[$c].call(e)!==e}));Yc((kc=tu?{}:Jc(kc))[$c])||Zc(kc,$c,(function(){return this}));var ru={IteratorPrototype:kc,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=v,lu=Oe,hu=A,pu=String,fu=TypeError,_u=function(e,t,r){try{return du(lu(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(n){}},vu=rr,mu=function(e){if("object"==typeof e||hu(e))return e;throw fu("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 vu(r),mu(n),t?e(r,n):r.__proto__=n,r}}():void 0),yu=wr,Su=P,bu=Uc,Eu=uu,ku=Wc,Tu=Bi,Iu=fi,Ru=Oc,Au=ru,wu=bu.PROPER,Cu=Au.BUGGY_SAFARI_ITERATORS,xu=ht("iterator"),Ou="keys",Pu="values",Nu="entries",Mu=function(){return this},Du=function(e,t,r,n,i,o,a){Eu(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 Nu:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,p=e.prototype,f=p[xu]||p["@@iterator"]||i&&p[i],_=!Cu&&f||d(i),v="Array"===t&&p.entries||f;if(v&&(s=ku(v.call(new e)))!==Object.prototype&&s.next&&(Tu(s,l,!0,!0),Ru[l]=Mu),wu&&i===Pu&&f&&f.name!==Pu&&(h=!0,_=function(){return Su(f,this)}),i)if(c={values:d(Pu),keys:o?_:d(Ou),entries:d(Nu)},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=Du,ju=Lu,Gu="Array Iterator",Hu=Fu.set,zu=Fu.getterFor(Gu);Bu(Array,"Array",(function(e,t){Hu(this,{type:Gu,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=vr,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,fd=hi,_d=rr,vd=v([].concat),md=hd("Reflect","ownKeys")||function(e){var t=pd.f(_d(e)),r=fd.f;return r?vd(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 Ed=r(te.Object.getOwnPropertyDescriptors),kd={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=kd.exports=function(e,t){return Ad.defineProperties(e,t)};Ad.defineProperties.sham&&(wd.sham=!0);var Cd=r(kd.exports),xd={exports:{}},Od=wr,Pd=C,Nd=Qt.f;Od({target:"Object",stat:!0,forced:Object.defineProperty!==Nd,sham:!Pd},{defineProperty:Nd});var Md=te.Object,Dd=xd.exports=function(e,t,r){return Md.defineProperty(e,t,r)};Md.defineProperty.sham&&(Dd.sham=!0);var Ld=xd.exports,Ud=r(Ld),Vd=wr,Fd=o,Bd=io,jd=ee,Gd=qe,Hd=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=Gd(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=Hd(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=v,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,fl=v,_l=Ie,vl=ht,ml=pl("Symbol"),gl=ml.isWellKnownSymbol,yl=pl("Object","getOwnPropertyNames"),Sl=fl(ml.prototype.valueOf),bl=hl("wks"),El=0,kl=yl(ml),Tl=kl.length;El<Tl;El++)try{var Il=kl[El];_l(ml[Il])&&vl(Il)}catch(B0){}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(B0){}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=al,wl=r(Al),Cl=v,xl=Pr,Ol=Sn,Pl=Y,Nl=Cl("".charAt),Ml=Cl("".charCodeAt),Dl=Cl("".slice),Ll=function(e){return function(t,r){var n,i,o=Ol(Pl(t)),a=xl(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Ml(o,a))<55296||n>56319||a+1===s||(i=Ml(o,a+1))<56320||i>57343?e?Nl(o,a):n:e?Dl(o,a,a+2):i-56320+(n-55296<<10)+65536}},Ul={codeAt:Ll(!1),charAt:Ll(!0)},Vl=Ul.charAt,Fl=Sn,Bl=ro,jl=Du,Gl=Lu,Hl="String Iterator",zl=Bl.set,Kl=Bl.getterFor(Hl);jl(String,"String",(function(e){zl(this,{type:Hl,string:Fl(e),index:0})}),(function(){var e,t=Kl(this),r=t.string,n=t.index;return n>=r.length?Gl(void 0,!0):(e=Vl(r,n),t.index+=e.length,Gl(e,!1))}));var Wl=r(mi.f("iterator"));function Xl(e){return(Xl="function"==typeof wl&&"symbol"==typeof Wl?function(e){return typeof e}:function(e){return e&&"function"==typeof wl&&e.constructor===wl&&e!==wl.prototype?"symbol":typeof e})(e)}var Yl=r(mi.f("toPrimitive"));function ql(e){var t=function(e,t){if("object"!==Xl(e)||null===e)return e;var r=e[Yl];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==Xl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Xl(t)?t:String(t)}function Jl(e,t,r){return(t=ql(t))in e?Ud(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ql(e,t){var r=cn(e);if(Gs){var n=Gs(e);t&&(n=tc(n).call(n,(function(t){return lc(e,t).enumerable}))),xc(r).apply(r,n)}return r}function Zl(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?ld(r=Ql(Object(i),!0)).call(r,(function(t){Jl(e,t,i[t])})):Ed?Cd(e,Ed(i)):ld(n=Ql(Object(i))).call(n,(function(t){Ud(e,t,lc(i,t))}))}return e}var $l=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}($l||{}),eh=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}(eh||{}),th=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}(th||{}),rh=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(rh||{}),nh=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(nh||{}),ih=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(ih||{}),oh=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(oh||{}),ah=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(ah||{}),sh=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}(sh||{}),ch=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(ch||{}),uh=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(uh||{}),dh=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[e.STREAM_REMOVE_REASON_TOKEN_PRIVILEGE_EXPIRED=6]="STREAM_REMOVE_REASON_TOKEN_PRIVILEGE_EXPIRED",e}(dh||{}),lh=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}(lh||{}),hh=function(e){return e.ICE_FAILED="iceFailed",e.NODE_CHANGE="nodeChange",e.JOIN_TIMEOUT="joinTimeout",e.NOTIFY_RECONNECT="notifyReconnect",e}(hh||{}),ph=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(ph||{}),fh=function(e){return e[e.NORMAL=0]="NORMAL",e[e.DISCONNECT=1]="DISCONNECT",e[e.RESET=2]="RESET",e}(fh||{}),_h=function(e){return e[e.MICROPHONE=0]="MICROPHONE",e[e.AUDIOMIXING=1]="AUDIOMIXING",e}(_h||{}),vh=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(vh||{}),mh=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(mh||{}),gh=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}(gh||{}),yh=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(yh||{}),Sh=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}(Sh||{}),bh=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(bh||{}),Eh=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}(Eh||{}),kh=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(kh||{}),Th=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}(Th||{}),Ih=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}(Ih||{}),Rh=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}(Rh||{}),Ah=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(Ah||{}),wh=function(e){return e.H264="H264",e.H265="H265",e}(wh||{}),Ch=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(Ch||{}),xh=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e[e.UPDATED=3]="UPDATED",e}(xh||{}),Oh=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}(Oh||{}),Ph=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}(Ph||{}),Nh=function(e){return e[e.DEFAULT=0]="DEFAULT",e[e.HIGH=1]="HIGH",e}(Nh||{}),Mh=Object.freeze({__proto__:null,AAC_PROFILE:Ah,AudioProfileType:Ih,AudioReportMode:_h,AudioSelectionPriority:Nh,AudioSourceType:eh,ChannelProfile:rh,ConnectionState:lh,FallbackOrRecoverReason:kh,ForwardStreamError:Ph,ForwardStreamState:Oh,LocalMainReportMode:fh,LogChannel:vh,MediaType:uh,MirrorMode:ah,MirrorType:ph,NetworkQuality:Eh,PublicInterpolationMode:yh,PublicStreamType:gh,PublishState:oh,RTCAutoPlayPolicy:Rh,ReconnectReason:hh,RemoteUserPriority:bh,RoomProfileType:Th,SUBTITLE_MODE:Ch,StreamIndex:ch,StreamRemoveReason:dh,SubscribeFallbackOption:Sh,SubscribeMode:nh,SubscribeState:ih,SubtitleEventType:xh,TRANSCODING_VIDEO_CODEC:wh,USER_ONLINE_STATUS:mh,UserOfflineReason:th,VideoRenderMode:sh,VideoSourceType:$l}),Dh=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}(Dh||{}),Lh=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(Lh||{}),Uh=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}(Uh||{}),Vh=Object.freeze({__proto__:null,AudioMixingDualMonoMode:Dh,AudioMixingState:Uh,AudioMixingType:Lh}),Fh=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.onTokenPublishPrivilegeWillExpire="onTokenPublishPrivilegeWillExpire",e.onTokenPublishPrivilegeDidExpired="onTokenPublishPrivilegeDidExpired",e.onTokenSubscribePrivilegeWillExpire="onTokenSubscribePrivilegeWillExpire",e.onTokenSubscribePrivilegeDidExpired="onTokenSubscribePrivilegeDidExpired",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.onSEIStreamUpdate="onSEIStreamUpdate",e}(Fh||{});function Bh(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,ql(n.key),n)}}function jh(e,t,r){return t&&Bh(e.prototype,t),r&&Bh(e,r),Ud(e,"prototype",{writable:!1}),e}function Gh(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 Hh=te.Object,zh=r((function(e,t){return Hh.create(e,t)})),Kh=qe,Wh=Wc,Xh=Vc;wr({target:"Object",stat:!0,forced:o((function(){Wh(1)})),sham:!Xh},{getPrototypeOf:function(e){return Wh(Kh(e))}});var Yh=r(te.Object.getPrototypeOf);wr({target:"Object",stat:!0},{setPrototypeOf:gu});var qh=te.Object.setPrototypeOf,Jh=r(qh),Qh=Ze,Zh=md,$h=w,ep=Qt,tp=ee,rp=vr,np=Error,ip=v("".replace),op=String(np("zxcasd").stack),ap=/\n\s*at [^:]*:[^\n]*/,sp=ap.test(op),cp=F,up=!o((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",cp(1,7)),7!==e.stack)})),dp=vr,lp=function(e,t){if(sp&&"string"==typeof e&&!np.prepareStackTrace)for(;t--;)e=ip(e,ap,"");return e},hp=up,pp=Error.captureStackTrace,fp=Oc,_p=ht("iterator"),vp=Array.prototype,mp=function(e){return void 0!==e&&(fp.Array===e||vp[_p]===e)},gp=mn,yp=Me,Sp=K,bp=Oc,Ep=ht("iterator"),kp=function(e){if(!Sp(e))return yp(e,Ep)||yp(e,"@@iterator")||bp[gp(e)]},Tp=P,Ip=Oe,Rp=rr,Ap=Ae,wp=kp,Cp=TypeError,xp=function(e,t){var r=arguments.length<2?wp(e):t;if(Ip(r))return Rp(Tp(r,e));throw Cp(Ap(e)+" is not iterable")},Op=P,Pp=rr,Np=Me,Mp=function(e,t,r){var n,i;Pp(e);try{if(!(n=Np(e,"return"))){if("throw"===t)throw r;return r}n=Op(n,e)}catch(B0){i=!0,n=B0}if("throw"===t)throw r;if(i)throw n;return Pp(n),r},Dp=Jt,Lp=P,Up=rr,Vp=Ae,Fp=mp,Bp=jr,jp=se,Gp=xp,Hp=kp,zp=Mp,Kp=TypeError,Wp=function(e,t){this.stopped=e,this.result=t},Xp=Wp.prototype,Yp=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),f=!(!r||!r.INTERRUPTED),_=Dp(t,d),v=function(e){return n&&zp(n,"normal",e),new Wp(!0,e)},m=function(e){return l?(Up(e),f?_(e[0],e[1],v):_(e[0],e[1])):f?_(e,v):_(e)};if(h)n=e.iterator;else if(p)n=e;else{if(!(i=Hp(e)))throw Kp(Vp(e)+" is not iterable");if(Fp(i)){for(o=0,a=Bp(e);a>o;o++)if((s=m(e[o]))&&jp(Xp,s))return s;return new Wp(!1)}n=Gp(e,i)}for(c=h?e.next:n.next;!(u=Lp(c,n)).done;){try{s=m(u.value)}catch(B0){zp(n,"throw",B0)}if("object"==typeof s&&s&&jp(Xp,s))return s}return new Wp(!1)},qp=Sn,Jp=wr,Qp=se,Zp=Wc,$p=gu,ef=function(e,t,r){for(var n=Zh(t),i=ep.f,o=$h.f,a=0;a<n.length;a++){var s=n[a];Qh(e,s)||r&&Qh(r,s)||i(e,s,o(t,s))}},tf=Wn,rf=vr,nf=F,of=function(e,t){tp(t)&&"cause"in t&&rp(e,"cause",t.cause)},af=function(e,t,r,n){hp&&(pp?pp(e,t):dp(e,"stack",lp(r,n)))},sf=Yp,cf=function(e,t){return void 0===e?arguments.length<2?"":t:qp(e)},uf=ht("toStringTag"),df=Error,lf=[].push,hf=function(e,t){var r,n=Qp(pf,this);$p?r=$p(df(),n?Zp(this):pf):(r=n?this:tf(pf),rf(r,uf,"Error")),void 0!==t&&rf(r,"message",cf(t)),af(r,hf,r.stack,1),arguments.length>2&&of(r,arguments[2]);var i=[];return sf(e,lf,{that:i}),rf(r,"errors",i),r};$p?$p(hf,df):ef(hf,df,{name:!0});var pf=hf.prototype=tf(df.prototype,{constructor:nf(1,hf),message:nf(1,""),name:nf(1,"AggregateError")});Jp({global:!0,constructor:!0,arity:2},{AggregateError:hf});var ff,_f,vf,mf,gf="process"===S(i.process),yf=ae,Sf=vi,bf=C,Ef=ht("species"),kf=function(e){var t=yf(e);bf&&t&&!t[Ef]&&Sf(t,Ef,{configurable:!0,get:function(){return this}})},Tf=se,If=TypeError,Rf=function(e,t){if(Tf(t,e))return e;throw If("Incorrect invocation")},Af=ko,wf=Ae,Cf=TypeError,xf=function(e){if(Af(e))return e;throw Cf(wf(e)+" is not a constructor")},Of=rr,Pf=xf,Nf=K,Mf=ht("species"),Df=function(e,t){var r,n=Of(e).constructor;return void 0===n||Nf(r=Of(n)[Mf])?t:Pf(r)},Lf=TypeError,Uf=function(e,t){if(e<t)throw Lf("Not enough arguments");return e},Vf=/(?:ipad|iphone|ipod).*applewebkit/i.test(ce),Ff=i,Bf=l,jf=Jt,Gf=A,Hf=Ze,zf=o,Kf=Cn,Wf=cs,Xf=Rt,Yf=Uf,qf=Vf,Jf=gf,Qf=Ff.setImmediate,Zf=Ff.clearImmediate,$f=Ff.process,e_=Ff.Dispatch,t_=Ff.Function,r_=Ff.MessageChannel,n_=Ff.String,i_=0,o_={},a_="onreadystatechange";zf((function(){ff=Ff.location}));var s_=function(e){if(Hf(o_,e)){var t=o_[e];delete o_[e],t()}},c_=function(e){return function(){s_(e)}},u_=function(e){s_(e.data)},d_=function(e){Ff.postMessage(n_(e),ff.protocol+"//"+ff.host)};Qf&&Zf||(Qf=function(e){Yf(arguments.length,1);var t=Gf(e)?e:t_(e),r=Wf(arguments,1);return o_[++i_]=function(){Bf(t,void 0,r)},_f(i_),i_},Zf=function(e){delete o_[e]},Jf?_f=function(e){$f.nextTick(c_(e))}:e_&&e_.now?_f=function(e){e_.now(c_(e))}:r_&&!qf?(mf=(vf=new r_).port2,vf.port1.onmessage=u_,_f=jf(mf.postMessage,mf)):Ff.addEventListener&&Gf(Ff.postMessage)&&!Ff.importScripts&&ff&&"file:"!==ff.protocol&&!zf(d_)?(_f=d_,Ff.addEventListener("message",u_,!1)):_f=a_ in Xf("script")?function(e){Kf.appendChild(Xf("script"))[a_]=function(){Kf.removeChild(this),s_(e)}}:function(e){setTimeout(c_(e),0)});var l_={set:Qf,clear:Zf},h_=function(){this.head=null,this.tail=null};h_.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 p_,f_,__,v_,m_,g_=h_,y_=/ipad|iphone|ipod/i.test(ce)&&"undefined"!=typeof Pebble,S_=/web0s(?!.*chrome)/i.test(ce),b_=i,E_=Jt,k_=w.f,T_=l_.set,I_=g_,R_=Vf,A_=y_,w_=S_,C_=gf,x_=b_.MutationObserver||b_.WebKitMutationObserver,O_=b_.document,P_=b_.process,N_=b_.Promise,M_=k_(b_,"queueMicrotask"),D_=M_&&M_.value;if(!D_){var L_=new I_,U_=function(){var e,t;for(C_&&(e=P_.domain)&&e.exit();t=L_.get();)try{t()}catch(B0){throw L_.head&&p_(),B0}e&&e.enter()};R_||C_||w_||!x_||!O_?!A_&&N_&&N_.resolve?((v_=N_.resolve(void 0)).constructor=N_,m_=E_(v_.then,v_),p_=function(){m_(U_)}):C_?p_=function(){P_.nextTick(U_)}:(T_=E_(T_,b_),p_=function(){T_(U_)}):(f_=!0,__=O_.createTextNode(""),new x_(U_).observe(__,{characterData:!0}),p_=function(){__.data=f_=!f_}),D_=function(e){L_.head||p_(),L_.add(e)}}var V_=D_,F_=function(e){try{return{error:!1,value:e()}}catch(B0){return{error:!0,value:B0}}},B_=i.Promise,j_="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,G_=!j_&&!gf&&"object"==typeof window&&"object"==typeof document,H_=i,z_=B_,K_=A,W_=Wt,X_=co,Y_=ht,q_=G_,J_=j_,Q_=_e,Z_=z_&&z_.prototype,$_=Y_("species"),ev=!1,tv=K_(H_.PromiseRejectionEvent),rv={CONSTRUCTOR:W_("Promise",(function(){var e=X_(z_),t=e!==String(z_);if(!t&&66===Q_)return!0;if(!Z_.catch||!Z_.finally)return!0;if(!Q_||Q_<51||!/native code/.test(e)){var r=new z_((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[$_]=n,!(ev=r.then((function(){}))instanceof n))return!0}return!t&&(q_||J_)&&!tv})),REJECTION_EVENT:tv,SUBCLASSING:ev},nv={},iv=Oe,ov=TypeError,av=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw ov("Bad Promise constructor");t=e,r=n})),this.resolve=iv(t),this.reject=iv(r)};nv.f=function(e){return new av(e)};var sv,cv,uv=wr,dv=gf,lv=i,hv=P,pv=fi,fv=Bi,_v=kf,vv=Oe,mv=A,gv=ee,yv=Rf,Sv=Df,bv=l_.set,Ev=V_,kv=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(B0){}},Tv=F_,Iv=g_,Rv=ro,Av=B_,wv=rv,Cv=nv,xv="Promise",Ov=wv.CONSTRUCTOR,Pv=wv.REJECTION_EVENT,Nv=Rv.getterFor(xv),Mv=Rv.set,Dv=Av&&Av.prototype,Lv=Av,Uv=Dv,Vv=lv.TypeError,Fv=lv.document,Bv=lv.process,jv=Cv.f,Gv=jv,Hv=!!(Fv&&Fv.createEvent&&lv.dispatchEvent),zv="unhandledrejection",Kv=function(e){var t;return!(!gv(e)||!mv(t=e.then))&&t},Wv=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&&Qv(t),t.rejection=1),!0===s?r=o:(d&&d.enter(),r=s(o),d&&(d.exit(),i=!0)),r===e.promise?u(Vv("Promise-chain cycle")):(n=Kv(r))?hv(n,r,c,u):c(r)):u(o)}catch(B0){d&&!i&&d.exit(),u(B0)}},Xv=function(e,t){e.notified||(e.notified=!0,Ev((function(){for(var r,n=e.reactions;r=n.get();)Wv(r,e);e.notified=!1,t&&!e.rejection&&qv(e)})))},Yv=function(e,t,r){var n,i;Hv?((n=Fv.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),lv.dispatchEvent(n)):n={promise:t,reason:r},!Pv&&(i=lv["on"+e])?i(n):e===zv&&kv("Unhandled promise rejection",r)},qv=function(e){hv(bv,lv,(function(){var t,r=e.facade,n=e.value;if(Jv(e)&&(t=Tv((function(){dv?Bv.emit("unhandledRejection",n,r):Yv(zv,r,n)})),e.rejection=dv||Jv(e)?2:1,t.error))throw t.value}))},Jv=function(e){return 1!==e.rejection&&!e.parent},Qv=function(e){hv(bv,lv,(function(){var t=e.facade;dv?Bv.emit("rejectionHandled",t):Yv("rejectionhandled",t,e.value)}))},Zv=function(e,t,r){return function(n){e(t,n,r)}},$v=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,Xv(e,!0))},em=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw Vv("Promise can't be resolved itself");var n=Kv(t);n?Ev((function(){var r={done:!1};try{hv(n,t,Zv(em,r,e),Zv($v,r,e))}catch(B0){$v(r,B0,e)}})):(e.value=t,e.state=1,Xv(e,!1))}catch(B0){$v({done:!1},B0,e)}}};Ov&&(Uv=(Lv=function(e){yv(this,Uv),vv(e),hv(sv,this);var t=Nv(this);try{e(Zv(em,t),Zv($v,t))}catch(B0){$v(t,B0)}}).prototype,(sv=function(e){Mv(this,{type:xv,done:!1,notified:!1,parent:!1,reactions:new Iv,rejection:!1,state:0,value:void 0})}).prototype=pv(Uv,"then",(function(e,t){var r=Nv(this),n=jv(Sv(this,Lv));return r.parent=!0,n.ok=!mv(e)||e,n.fail=mv(t)&&t,n.domain=dv?Bv.domain:void 0,0===r.state?r.reactions.add(n):Ev((function(){Wv(n,r)})),n.promise})),cv=function(){var e=new sv,t=Nv(e);this.promise=e,this.resolve=Zv(em,t),this.reject=Zv($v,t)},Cv.f=jv=function(e){return e===Lv||undefined===e?new cv(e):Gv(e)}),uv({global:!0,constructor:!0,wrap:!0,forced:Ov},{Promise:Lv}),fv(Lv,xv,!1,!0),_v(xv);var tm=ht("iterator"),rm=!1;try{var nm=0,im={next:function(){return{done:!!nm++}},return:function(){rm=!0}};im[tm]=function(){return this},Array.from(im,(function(){throw 2}))}catch(B0){}var om=function(e,t){if(!t&&!rm)return!1;var r=!1;try{var n={};n[tm]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(B0){}return r},am=B_,sm=rv.CONSTRUCTOR||!om((function(e){am.all(e).then(void 0,(function(){}))})),cm=P,um=Oe,dm=nv,lm=F_,hm=Yp;wr({target:"Promise",stat:!0,forced:sm},{all:function(e){var t=this,r=dm.f(t),n=r.resolve,i=r.reject,o=lm((function(){var r=um(t.resolve),o=[],a=0,s=1;hm(e,(function(e){var c=a++,u=!1;s++,cm(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 pm=wr,fm=rv.CONSTRUCTOR;B_&&B_.prototype,pm({target:"Promise",proto:!0,forced:fm,real:!0},{catch:function(e){return this.then(void 0,e)}});var _m=P,vm=Oe,mm=nv,gm=F_,ym=Yp;wr({target:"Promise",stat:!0,forced:sm},{race:function(e){var t=this,r=mm.f(t),n=r.reject,i=gm((function(){var i=vm(t.resolve);ym(e,(function(e){_m(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var Sm=P,bm=nv;wr({target:"Promise",stat:!0,forced:rv.CONSTRUCTOR},{reject:function(e){var t=bm.f(this);return Sm(t.reject,void 0,e),t.promise}});var Em=rr,km=ee,Tm=nv,Im=function(e,t){if(Em(e),km(t)&&t.constructor===e)return t;var r=Tm.f(e);return(0,r.resolve)(t),r.promise},Rm=wr,Am=B_,wm=rv.CONSTRUCTOR,Cm=Im,xm=ae("Promise"),Om=!wm;Rm({target:"Promise",stat:!0,forced:true},{resolve:function(e){return Cm(Om&&this===xm?Am:this,e)}});var Pm=P,Nm=Oe,Mm=nv,Dm=F_,Lm=Yp;wr({target:"Promise",stat:!0,forced:sm},{allSettled:function(e){var t=this,r=Mm.f(t),n=r.resolve,i=r.reject,o=Dm((function(){var r=Nm(t.resolve),i=[],o=0,a=1;Lm(e,(function(e){var s=o++,c=!1;a++,Pm(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 Um=P,Vm=Oe,Fm=ae,Bm=nv,jm=F_,Gm=Yp,Hm="No one promise resolved";wr({target:"Promise",stat:!0,forced:sm},{any:function(e){var t=this,r=Fm("AggregateError"),n=Bm.f(t),i=n.resolve,o=n.reject,a=jm((function(){var n=Vm(t.resolve),a=[],s=0,c=1,u=!1;Gm(e,(function(e){var d=s++,l=!1;c++,Um(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,Hm)))}))})),--c||o(new r(a,Hm))}));return a.error&&o(a.value),n.promise}});var zm=wr,Km=B_,Wm=o,Xm=ae,Ym=A,qm=Df,Jm=Im,Qm=Km&&Km.prototype;zm({target:"Promise",proto:!0,real:!0,forced:!!Km&&Wm((function(){Qm.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=qm(this,Xm("Promise")),r=Ym(e);return this.then(r?function(r){return Jm(t,e()).then((function(){return r}))}:e,r?function(r){return Jm(t,e()).then((function(){throw r}))}:e)}});var Zm=te.Promise,$m=nv;wr({target:"Promise",stat:!0},{withResolvers:function(){var e=$m.f(this);return{promise:e.promise,resolve:e.resolve,reject:e.reject}}});var eg=Zm,tg=nv,rg=F_;wr({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=tg.f(this),r=rg(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var ng=eg,ig=r(ng),og=wr,ag=io,sg=v([].reverse),cg=[1,2];og({target:"Array",proto:!0,forced:String(cg)===String(cg.reverse())},{reverse:function(){return ag(this)&&(this.length=this.length),sg(this)}});var ug=qs("Array").reverse,dg=se,lg=ug,hg=Array.prototype,pg=function(e){var t=e.reverse;return e===hg||dg(hg,e)&&t===hg.reverse?lg:t},fg=r(pg),_g=wr,vg=io,mg=ko,gg=ee,yg=Lr,Sg=jr,bg=Q,Eg=ei,kg=ht,Tg=cs,Ig=Ws("slice"),Rg=kg("species"),Ag=Array,wg=Math.max;_g({target:"Array",proto:!0,forced:!Ig},{slice:function(e,t){var r,n,i,o=bg(this),a=Sg(o),s=yg(e,a),c=yg(void 0===t?a:t,a);if(vg(o)&&(r=o.constructor,(mg(r)&&(r===Ag||vg(r.prototype))||gg(r)&&null===(r=r[Rg]))&&(r=void 0),r===Ag||void 0===r))return Tg(o,s,c);for(n=new(void 0===r?Ag:r)(wg(c-s,0)),i=0;s<c;s++,i++)s in o&&Eg(n,i,o[s]);return n.length=i,n}});var Cg=qs("Array").slice,xg=se,Og=Cg,Pg=Array.prototype,Ng=function(e){var t=e.slice;return e===Pg||xg(Pg,e)&&t===Pg.slice?Og:t},Mg=r(Ng);function Dg(){Dg=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 wl?wl:{},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=zh(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",f="executing",_="completed",v={};function m(){}function g(){}function y(){}var S={};u(S,a,(function(){return this}));var b=Yh&&Yh(Yh(x([])));b&&b!==r&&n.call(b,a)&&(S=b);var E=y.prototype=m.prototype=zh(S);function k(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"==Xl(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===f)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===v)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=f;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?_:p,u.arg===v)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")),v;var o=l(i,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;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,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}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(Xl(t)+" is not iterable")}return g.prototype=y,i(E,"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 Jh?Jh(e,y):(e.__proto__=y,u(e,c,"GeneratorFunction")),e.prototype=zh(E),e},t.awrap=function(e){return{__await:e}},k(T.prototype),u(T.prototype,s,(function(){return this})),t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=ig);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()}))},k(E),u(E,c,"Generator"),u(E,a,(function(){return this})),u(E,"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 fg(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(+Mg(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,v):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),v},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),v}},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),v}},t}function Lg(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(B0){return void r(B0)}s.done?t(c):ig.resolve(c).then(n,i)}function Ug(e){return function(){var t=this,r=arguments;return new ig((function(n,i){var o=e.apply(t,r);function a(e){Lg(o,n,i,a,s,"next",e)}function s(e){Lg(o,n,i,a,s,"throw",e)}a(void 0)}))}}var Vg=qs("Array").concat,Fg=se,Bg=Vg,jg=Array.prototype,Gg=r((function(e){var t=e.concat;return e===jg||Fg(jg,e)&&t===jg.concat?Bg:t})),Hg=r(ng),zg=te,Kg=l;zg.JSON||(zg.JSON={stringify:JSON.stringify});var Wg=function(e,t,r){return Kg(zg.JSON.stringify,null,arguments)},Xg=r(Wg),Yg=Vo.map;wr({target:"Array",proto:!0,forced:!Ws("map")},{map:function(e){return Yg(this,e,arguments.length>1?arguments[1]:void 0)}});var qg=qs("Array").map,Jg=se,Qg=qg,Zg=Array.prototype,$g=r((function(e){var t=e.map;return e===Zg||Jg(Zg,e)&&t===Zg.map?Qg:t})),ey=r(kp);wr({target:"Array",stat:!0},{isArray:io});var ty=r(te.Array.isArray),ry=rr,ny=Mp,iy=Jt,oy=P,ay=qe,sy=function(e,t,r,n){try{return n?t(ry(r)[0],r[1]):t(r)}catch(B0){ny(e,"throw",B0)}},cy=mp,uy=ko,dy=jr,ly=ei,hy=xp,py=kp,fy=Array,_y=function(e){var t=ay(e),r=uy(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=iy(i,n>2?arguments[2]:void 0));var a,s,c,u,d,l,h=py(t),p=0;if(!h||this===fy&&cy(h))for(a=dy(t),s=r?new this(a):fy(a);a>p;p++)l=o?i(t[p],p):t[p],ly(s,p,l);else for(d=(u=hy(t,h)).next,s=r?new this:[];!(c=oy(d,u)).done;p++)l=o?sy(u,i,[c.value,p],!0):c.value,ly(s,p,l);return s.length=p,s},vy=_y;wr({target:"Array",stat:!0,forced:!om((function(e){Array.from(e)}))},{from:vy});var my=te.Array.from,gy=r(my);function yy(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 Sy(e,t){var r;if(e){if("string"==typeof e)return yy(e,t);var n=Mg(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?gy(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?yy(e,t):void 0}}function by(e,t){var r=void 0!==wl&&ey(e)||e["@@iterator"];if(!r){if(ty(e)||(r=Sy(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 Ey(e,t){return function(e){if(ty(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==wl&&ey(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)||Sy(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 ky=wr,Ty=o,Iy=Jn.f;ky({target:"Object",stat:!0,forced:Ty((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:Iy});var Ry=te.Object,Ay=r((function(e){return Ry.getOwnPropertyNames(e)})),wy=r(ec),Cy=Wr.includes;wr({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return Cy(this,e,arguments.length>1?arguments[1]:void 0)}});var xy=qs("Array").includes,Oy=ee,Py=S,Ny=ht("match"),My=function(e){var t;return Oy(e)&&(void 0!==(t=e[Ny])?!!t:"RegExp"===Py(e))},Dy=TypeError,Ly=function(e){if(My(e))throw Dy("The method doesn't accept regular expressions");return e},Uy=ht("match"),Vy=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Uy]=!1,"/./"[e](t)}catch(n){}}return!1},Fy=wr,By=Ly,jy=Y,Gy=Sn,Hy=Vy,zy=v("".indexOf);Fy({target:"String",proto:!0,forced:!Hy("includes")},{includes:function(e){return!!~zy(Gy(jy(this)),Gy(By(e)),arguments.length>1?arguments[1]:void 0)}});var Ky=qs("String").includes,Wy=se,Xy=xy,Yy=Ky,qy=Array.prototype,Jy=String.prototype,Qy=r((function(e){var t=e.includes;return e===qy||Wy(qy,e)&&t===qy.includes?Xy:"string"==typeof e||e===Jy||Wy(Jy,e)&&t===Jy.includes?Yy:t})),Zy=Oe,$y=qe,eS=z,tS=jr,rS=TypeError,nS=function(e){return function(t,r,n,i){Zy(r);var o=$y(t),a=eS(o),s=tS(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 rS("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}},iS={left:nS(!1),right:nS(!0)}.left;wr({target:"Array",proto:!0,forced:!gf&&_e>79&&_e<83||!td("reduce")},{reduce:function(e){var t=arguments.length;return iS(this,e,t,t>1?arguments[1]:void 0)}});var oS=qs("Array").reduce,aS=se,sS=oS,cS=Array.prototype,uS=r((function(e){var t=e.reduce;return e===cS||aS(cS,e)&&t===cS.reduce?sS:t})),dS=C,lS=o,hS=v,pS=Wc,fS=nn,_S=Q,vS=hS(N.f),mS=hS([].push),gS=dS&&lS((function(){var e=Object.create(null);return e[2]=2,!vS(e,2)})),yS=function(e){return function(t){for(var r,n=_S(t),i=fS(n),o=gS&&null===pS(n),a=i.length,s=0,c=[];a>s;)r=i[s++],dS&&!(o?r in n:vS(n,r))||mS(c,e?[r,n[r]]:n[r]);return c}},SS={entries:yS(!0),values:yS(!1)}.entries;wr({target:"Object",stat:!0},{entries:function(e){return SS(e)}});var bS,ES,kS,TS,IS,RS,AS,wS,CS,xS,OS,PS,NS,MS,DS,LS,US,VS=r(te.Object.entries),FS=r(sn),BS={};function jS(e,t){try{var r;return Qy(r=e[t].toString()).call(r,"[native code]")?"native":"non-native"}catch(n){return"untouchable"}}var GS=uS(bS="undefined"!=typeof window?[[null===(ES=window.RTCPeerConnection)||void 0===ES?void 0:ES.prototype,"RTCPeerConnection.prototype"],[window.RTCPeerConnection,"RTCPeerConnection"],[null===(kS=window.RTCDataChannel)||void 0===kS?void 0:kS.prototype,"RTCDataChannel.prototype"],[window.RTCDataChannel,"RTCDataChannel"],[null===(TS=window.MediaStreamTrack)||void 0===TS?void 0:TS.prototype,"MediaStreamTrack.prototype"],[window.MediaStreamTrack,"MediaStreamTrack"],[null===(IS=window.MediaStream)||void 0===IS?void 0:IS.prototype,"MediaStream.prototype"],[window.MediaStream,"MediaStream"],[null===(RS=window.HTMLAudioElement)||void 0===RS?void 0:RS.prototype,"HTMLAudioElement.prototype"],[null===(AS=window.HTMLVideoElement)||void 0===AS?void 0:AS.prototype,"HTMLVideoElement.prototype"],[null===(wS=window.HTMLMediaElement)||void 0===wS?void 0:wS.prototype,"HTMLMediaElement.prototype"],[null!==(CS=null===(xS=window.AudioContext)||void 0===xS?void 0:xS.prototype)&&void 0!==CS?CS:null===(OS=window.webkitAudioContext)||void 0===OS?void 0:OS.prototype,"AudioContext.prototype"],[null===(PS=window.BaseAudioContext)||void 0===PS?void 0:PS.prototype,"BaseAudioContext.prototype"],[null===(NS=window.AudioNode)||void 0===NS?void 0:NS.prototype,"AudioNode.prototype"],[window.navigator.mediaDevices,"navigator.mediaDevices"],[window.console,"console"]]:[]).call(bS,(function(e,t){var r=Ey(t,2),n=r[0],i=r[1];return Gg(e).call(e,function(e,t){var r;if(!e)return[];var n=Ay(e);return $g(r=wy(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&&GS.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 HS,zS=by(GS);try{for(zS.s();!(HS=zS.n()).done;){var KS,WS=HS.value,XS=WS.obj,YS=WS.prefix,qS=WS.attr,JS=Gg(KS="".concat(YS,".")).call(KS,qS);BS[JS]=jS(XS,qS)}}catch(j0){zS.e(j0)}finally{zS.f()}"undefined"!=typeof window&&(Qy(MS=window.location.search).call(MS,"_rtc_debug_")||(null===(DS=window.localStorage)||void 0===DS?void 0:DS.getItem("_rtc_debug_")))&&console.log("RTC_AMBULANCE",BS);var QS=$g(LS=wy(US=VS(BS)).call(US,(function(e){var t=Ey(e,2);return t[0],"non-native"===t[1]}))).call(LS,(function(e){var t=Ey(e,2),r=t[0];return t[1],r}));FS(QS).length&&console.warn("RTC_AMBULANCE","have non-native code:\n",QS.join("\n"));var ZS="\t\n\v\f\r                 \u2028\u2029\ufeff",$S=Y,eb=Sn,tb=ZS,rb=v("".replace),nb=RegExp("^["+tb+"]+"),ib=RegExp("(^|[^"+tb+"])["+tb+"]+$"),ob=function(e){return function(t){var r=eb($S(t));return 1&e&&(r=rb(r,nb,"")),2&e&&(r=rb(r,ib,"$1")),r}},ab={start:ob(1),end:ob(2),trim:ob(3)},sb=i,cb=o,ub=v,db=Sn,lb=ab.trim,hb=ZS,pb=sb.parseInt,fb=sb.Symbol,_b=fb&&fb.iterator,vb=/^[+-]?0x/i,mb=ub(vb.exec),gb=8!==pb(hb+"08")||22!==pb(hb+"0x16")||_b&&!cb((function(){pb(Object(_b))}))?function(e,t){var r=lb(db(e));return pb(r,t>>>0||(mb(vb,r)?16:10))}:pb;wr({global:!0,forced:parseInt!==gb},{parseInt:gb});var yb=r(te.parseInt),Sb={exports:{}},bb=o((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),Eb=o,kb=ee,Tb=S,Ib=bb,Rb=Object.isExtensible,Ab=Eb((function(){Rb(1)}))||Ib?function(e){return!!kb(e)&&((!Ib||"ArrayBuffer"!==Tb(e))&&(!Rb||Rb(e)))}:Rb,wb=!o((function(){return Object.isExtensible(Object.preventExtensions({}))})),Cb=wr,xb=v,Ob=Xr,Pb=ee,Nb=Ze,Mb=Qt.f,Db=Xn,Lb=Jn,Ub=Ab,Vb=wb,Fb=!1,Bb=nt("meta"),jb=0,Gb=function(e){Mb(e,Bb,{value:{objectID:"O"+jb++,weakData:{}}})},Hb=Sb.exports={enable:function(){Hb.enable=function(){},Fb=!0;var e=Db.f,t=xb([].splice),r={};r[Bb]=1,e(r).length&&(Db.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===Bb){t(n,i,1);break}return n},Cb({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Lb.f}))},fastKey:function(e,t){if(!Pb(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!Nb(e,Bb)){if(!Ub(e))return"F";if(!t)return"E";Gb(e)}return e[Bb].objectID},getWeakData:function(e,t){if(!Nb(e,Bb)){if(!Ub(e))return!0;if(!t)return!1;Gb(e)}return e[Bb].weakData},onFreeze:function(e){return Vb&&Fb&&Ub(e)&&!Nb(e,Bb)&&Gb(e),e}};Ob[Bb]=!0;var zb=Sb.exports,Kb=wr,Wb=i,Xb=zb,Yb=o,qb=vr,Jb=Yp,Qb=Rf,Zb=A,$b=ee,eE=K,tE=Bi,rE=Qt.f,nE=Vo.forEach,iE=C,oE=ro.set,aE=ro.getterFor,sE=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=Wb[e],c=s&&s.prototype,u={};if(iE&&Zb(s)&&(o||c.forEach&&!Yb((function(){(new s).entries().next()})))){var d=(n=t((function(t,r){oE(Qb(t,d),{type:e,collection:new s}),eE(r)||Jb(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,l=aE(e);nE(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"===e||"set"===e;!(e in c)||o&&"clear"===e||qb(d,e,(function(r,n){var i=l(this).collection;if(!t&&o&&!$b(r))return"get"===e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||rE(d,"size",{configurable:!0,get:function(){return l(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Xb.enable();return tE(n,e,!1,!0),u[e]=n,Kb({global:!0,forced:!0},u),o||r.setStrong(n,e,i),n},cE=fi,uE=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:cE(e,n,t[n],r);return e},dE=Wn,lE=vi,hE=uE,pE=Jt,fE=Rf,_E=K,vE=Yp,mE=Du,gE=Lu,yE=kf,SE=C,bE=zb.fastKey,EE=ro.set,kE=ro.getterFor,TE={getConstructor:function(e,t,r,n){var i=e((function(e,i){fE(e,o),EE(e,{type:t,index:dE(null),first:void 0,last:void 0,size:0}),SE||(e.size=0),_E(i)||vE(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=kE(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=bE(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),SE?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=bE(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key===t)return r};return hE(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,SE?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),SE?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=pE(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)}}),hE(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)}}),SE&&lE(o,"size",{configurable:!0,get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=kE(t),o=kE(n);mE(e,t,(function(e,t){EE(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)?gE("keys"===t?r.key:"values"===t?r.value:[r.key,r.value],!1):(e.target=void 0,gE(void 0,!0))}),r?"entries":"values",!r,!0),yE(t)}};sE("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),TE);var IE=te.Map,RE=function(e,t){return 1===t?function(t,r){return t[e](r)}:function(t,r,n){return t[e](r,n)}},AE=RE,wE=ae("Map"),CE={Map:wE,set:AE("set",2),get:AE("get",1),has:AE("has",1),remove:AE("delete",1),proto:wE.prototype},xE=wr,OE=Oe,PE=Y,NE=Yp,ME=CE.Map,DE=CE.has,LE=CE.get,UE=CE.set,VE=v([].push);xE({target:"Map",stat:!0,forced:true},{groupBy:function(e,t){PE(e),OE(t);var r=new ME,n=0;return NE(e,(function(e){var i=t(e,n++);DE(r,i)?VE(LE(r,i),e):UE(r,i,[e])})),r}});var FE=IE,BE=Jt,jE=P,GE=Oe,HE=xf,zE=K,KE=Yp,WE=[].push,XE=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return HE(this),(t=void 0!==a)&&GE(a),zE(e)?new this:(r=[],t?(n=0,i=BE(a,o>2?arguments[2]:void 0),KE(e,(function(e){jE(WE,r,i(e,n++))}))):KE(e,WE,{that:r}),new this(r))};wr({target:"Map",stat:!0,forced:!0},{from:XE});var YE=cs,qE=function(){return new this(YE(arguments))};wr({target:"Map",stat:!0,forced:!0},{of:qE});var JE=Ae,QE=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(JE(e)+" is not a map")},ZE=QE,$E=CE.remove;wr({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=ZE(this),r=!0,n=0,i=arguments.length;n<i;n++)e=$E(t,arguments[n]),r=r&&e;return!!r}});var ek=QE,tk=CE.get,rk=CE.has,nk=CE.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,t){var r,n,i=ek(this);return rk(i,e)?(r=tk(i,e),"update"in t&&(r=t.update(r,e,i),nk(i,e,r)),r):(n=t.insert(e,i),nk(i,e,n),n)}});var ik=P,ok=function(e,t,r){for(var n,i,o=r?e:e.iterator,a=e.next;!(n=ik(a,o)).done;)if(void 0!==(i=t(n.value)))return i},ak=ok,sk=function(e,t,r){return r?ak(e.entries(),(function(e){return t(e[1],e[0])}),!0):e.forEach(t)},ck=Jt,uk=QE,dk=sk;wr({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=uk(this),r=ck(e,arguments.length>1?arguments[1]:void 0);return!1!==dk(t,(function(e,n){if(!r(e,n,t))return!1}),!0)}});var lk=Jt,hk=QE,pk=sk,fk=CE.Map,_k=CE.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=hk(this),r=lk(e,arguments.length>1?arguments[1]:void 0),n=new fk;return pk(t,(function(e,i){r(e,i,t)&&_k(n,i,e)})),n}});var vk=Jt,mk=QE,gk=sk;wr({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=mk(this),r=vk(e,arguments.length>1?arguments[1]:void 0),n=gk(t,(function(e,n){if(r(e,n,t))return{value:e}}),!0);return n&&n.value}});var yk=Jt,Sk=QE,bk=sk;wr({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=Sk(this),r=yk(e,arguments.length>1?arguments[1]:void 0),n=bk(t,(function(e,n){if(r(e,n,t))return{key:n}}),!0);return n&&n.key}});var Ek=function(e,t){return e===t||e!=e&&t!=t},kk=QE,Tk=sk;wr({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return!0===Tk(kk(this),(function(t){if(Ek(t,e))return!0}),!0)}});var Ik=P,Rk=Yp,Ak=A,wk=Oe,Ck=CE.Map;wr({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new(Ak(this)?this:Ck);wk(t);var n=wk(r.set);return Rk(e,(function(e){Ik(n,r,t(e),e)})),r}});var xk=QE,Ok=sk;wr({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){var t=Ok(xk(this),(function(t,r){if(t===e)return{key:r}}),!0);return t&&t.key}});var Pk=Jt,Nk=QE,Mk=sk,Dk=CE.Map,Lk=CE.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=Nk(this),r=Pk(e,arguments.length>1?arguments[1]:void 0),n=new Dk;return Mk(t,(function(e,i){Lk(n,r(e,i,t),e)})),n}});var Uk=Jt,Vk=QE,Fk=sk,Bk=CE.Map,jk=CE.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=Vk(this),r=Uk(e,arguments.length>1?arguments[1]:void 0),n=new Bk;return Fk(t,(function(e,i){jk(n,i,r(e,i,t))})),n}});var Gk=QE,Hk=Yp,zk=CE.set;wr({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=Gk(this),r=arguments.length,n=0;n<r;)Hk(arguments[n++],(function(e,r){zk(t,e,r)}),{AS_ENTRIES:!0});return t}});var Kk=Oe,Wk=QE,Xk=sk,Yk=TypeError;wr({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=Wk(this),r=arguments.length<2,n=r?void 0:arguments[1];if(Kk(e),Xk(t,(function(i,o){r?(r=!1,n=i):n=e(n,i,o,t)})),r)throw Yk("Reduce of empty map with no initial value");return n}});var qk=Jt,Jk=QE,Qk=sk;wr({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=Jk(this),r=qk(e,arguments.length>1?arguments[1]:void 0);return!0===Qk(t,(function(e,n){if(r(e,n,t))return!0}),!0)}});var Zk=Oe,$k=QE,eT=TypeError,tT=CE.get,rT=CE.has,nT=CE.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=$k(this),n=arguments.length;Zk(t);var i=rT(r,e);if(!i&&n<3)throw eT("Updating absent value");var o=i?tT(r,e):Zk(n>2?arguments[2]:void 0)(e,r);return nT(r,e,t(o,e,r)),r}});var iT=P,oT=Oe,aT=A,sT=rr,cT=TypeError,uT=function(e,t){var r,n=sT(this),i=oT(n.get),o=oT(n.has),a=oT(n.set),s=arguments.length>2?arguments[2]:void 0;if(!aT(t)&&!aT(s))throw cT("At least one callback required");return iT(o,n,e)?(r=iT(i,n,e),aT(t)&&(r=t(r),iT(a,n,e,r))):aT(s)&&(r=s(),iT(a,n,e,r)),r};wr({target:"Map",proto:!0,real:!0,forced:!0},{upsert:uT}),wr({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:uT});var dT=FE,lT=r(dT),hT=r(dT),pT=r(Ld),fT=C,_T=v,vT=P,mT=o,gT=nn,yT=hi,ST=N,bT=qe,ET=z,kT=Object.assign,TT=Object.defineProperty,IT=_T([].concat),RT=!kT||mT((function(){if(fT&&1!==kT({b:1},kT(TT({},"a",{enumerable:!0,get:function(){TT(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!==kT({},e)[r]||gT(kT({},t)).join("")!==n}))?function(e,t){for(var r=bT(e),n=arguments.length,i=1,o=yT.f,a=ST.f;n>i;)for(var s,c=ET(arguments[i++]),u=o?IT(gT(c),o(c)):gT(c),d=u.length,l=0;d>l;)s=u[l++],fT&&!vT(a,c,s)||(r[s]=c[s]);return r}:kT,AT=RT;wr({target:"Object",stat:!0,arity:2,forced:Object.assign!==AT},{assign:AT});var wT=r(te.Object.assign),CT=wr,xT=k;w.f;var OT=Fr,PT=Sn,NT=Ly,MT=Y,DT=Vy,LT=xT("".endsWith),UT=xT("".slice),VT=Math.min;CT({target:"String",proto:!0,forced:!DT("endsWith")},{endsWith:function(e){var t=PT(MT(this));NT(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:VT(OT(r),n),o=PT(e);return LT?LT(t,o,i):UT(t,i-o.length,i)===o}});var FT=qs("String").endsWith,BT=se,jT=FT,GT=String.prototype,HT=r((function(e){var t=e.endsWith;return"string"==typeof e||e===GT||BT(GT,e)&&t===GT.endsWith?jT:t})),zT=!0,KT=!0;function WT(e,t,r){var n=e.match(t);return n&&n.length>=r&&yb(n[r],10)}function XT(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 hT),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===FS(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},pT(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 YT(e){return"boolean"!=typeof e?new Error("Argument type: "+Xl(e)+". Please use a boolean."):(zT=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function qT(e){return"boolean"!=typeof e?new Error("Argument type: "+Xl(e)+". Please use a boolean."):(KT=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function JT(){if("object"===("undefined"==typeof window?"undefined":Xl(window))){if(zT)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function QT(e,t){KT&&console.warn(e+" is deprecated, please use "+t+" instead.")}function ZT(e){return"[object Object]"===Object.prototype.toString.call(e)}function $T(e){var t;return ZT(e)?uS(t=FS(e)).call(t,(function(t,r){var n=ZT(e[r]),i=n?$T(e[r]):e[r],o=n&&!FS(i).length;return void 0===i||o?t:wT(t,Jl({},r,i))}),{}):e}function eI(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),FS(t).forEach((function(n){HT(n).call(n,"Id")?eI(e,e.get(t[n]),r):HT(n).call(n,"Ids")&&t[n].forEach((function(t){eI(e,e.get(t),r)}))})))}function tI(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new hT;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&&eI(e,r,i)}))})),i}var rI=wr,nI=Vo.find,iI="find",oI=!0;iI in[]&&Array(1)[iI]((function(){oI=!1})),rI({target:"Array",proto:!0,forced:oI},{find:function(e){return nI(this,e,arguments.length>1?arguments[1]:void 0)}});var aI=qs("Array").find,sI=se,cI=aI,uI=Array.prototype,dI=r((function(e){var t=e.find;return e===uI||sI(uI,e)&&t===uI.find?cI:t})),lI=r(Ng),hI=wr,pI=Wr.indexOf,fI=td,_I=k([].indexOf),vI=!!_I&&1/_I([1],1,-0)<0;hI({target:"Array",proto:!0,forced:vI||!fI("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return vI?_I(this,e,t)||0:pI(this,e,t)}});var mI=qs("Array").indexOf,gI=se,yI=mI,SI=Array.prototype,bI=function(e){var t=e.indexOf;return e===SI||gI(SI,e)&&t===SI.indexOf?yI:t},EI=r(bI),kI=r(bI),TI=Ae,II=TypeError,RI=function(e,t){if(!delete e[t])throw II("Cannot delete property "+TI(t)+" of "+TI(e))},AI=wr,wI=qe,CI=Lr,xI=Pr,OI=jr,PI=vc,NI=gc,MI=xo,DI=ei,LI=RI,UI=Ws("splice"),VI=Math.max,FI=Math.min;AI({target:"Array",proto:!0,forced:!UI},{splice:function(e,t){var r,n,i,o,a,s,c=wI(this),u=OI(c),d=CI(e,u),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=u-d):(r=l-2,n=FI(VI(xI(t),0),u-d)),NI(u+r-n),i=MI(c,n),o=0;o<n;o++)(a=d+o)in c&&DI(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]:LI(c,s);for(o=u;o>u-n+r;o--)LI(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]:LI(c,s);for(o=0;o<r;o++)c[o+d]=arguments[o+2];return PI(c,u-n+r),i}});var BI=qs("Array").splice,jI=se,GI=BI,HI=Array.prototype,zI=r((function(e){var t=e.splice;return e===HI||jI(HI,e)&&t===HI.splice?GI:t})),KI=r(dc),WI=JT;function XI(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==Xl(e)||e.mandatory||e.optional)return e;var t,r={};(FS(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===Xl(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()+lI(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=Gg(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(Xg(e)))&&"object"===Xl(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(Xg(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===Xl(e.video)){var a=e.video.facingMode;a=a&&("object"===Xl(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=wy(t).call(t,(function(e){return"videoinput"===e.kind}));var r=dI(t).call(t,(function(e){return s.some((function(t){var r;return Qy(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&Qy(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),WI("chrome: "+Xg(e)),i(e)}));e.video=n(e.video)}return WI("chrome: "+Xg(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 Hg.reject(o(e))}))}))}}}}function YI(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function qI(e){if("object"===Xl(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){pT(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=dI(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=dI(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 XT(e,"track",(function(e){return e.transceiver||pT(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function JI(e){if("object"===Xl(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||[],lI(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=kI(t=this._senders).call(t,e);-1!==i&&zI(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=dI(r=t._senders).call(r,(function(t){return t.track===e}));o&&zI(n=t._senders).call(n,kI(i=t._senders).call(i,o),1)}))}}else if("object"===Xl(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},pT(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 QI(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=lI(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 hT($g(t=FS(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 Hg((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function ZI(e){if("object"===Xl(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 tI(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}),XT(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 tI(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?Hg.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Hg.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function $I(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},$g(e=FS(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===kI(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(dI(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=wy(t=this.getSenders()).call(t,(function(e){return-1===kI(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Gg(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&&FS(this._shimmedLocalStreams).forEach((function(r){var n,i,o=kI(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&zI(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function eR(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return $I(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},$g(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(dI(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=lI([]).call(arguments,1);if(1!==s.length||!dI(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(dI(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),Hg.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 dI(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jl({},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,FS(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=KI(e.RTCPeerConnection.prototype,"localDescription");pT(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||{},FS(this._streams).forEach((function(n){var i;dI(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 FS(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 tR(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=Jl({},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 rR(e,t){XT(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 nR=Object.freeze({__proto__:null,fixNegotiationNeeded:rR,shimAddTrackRemoveTrack:eR,shimAddTrackRemoveTrackWithNative:$I,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:JI,shimGetStats:QI,shimGetUserMedia:XI,shimMediaStream:YI,shimOnTrack:qI,shimPeerConnection:tR,shimSenderReceiverGetStats:ZI});function iR(e){return function(e){if(ty(e))return yy(e)}(e)||function(e){if(void 0!==wl&&null!=ey(e)||null!=e["@@iterator"])return gy(e)}(e)||Sy(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 oR=i,aR=o,sR=Sn,cR=ab.trim,uR=ZS,dR=v("".charAt),lR=oR.parseFloat,hR=oR.Symbol,pR=hR&&hR.iterator,fR=1/lR(uR+"-0")!=-1/0||pR&&!aR((function(){lR(Object(pR))}))?function(e){var t=cR(sR(e)),r=lR(t);return 0===r&&"-"===dR(t,0)?-0:r}:lR;wr({global:!0,forced:parseFloat!==fR},{parseFloat:fR});var _R=r(te.parseFloat);function vR(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){QT("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"===Xl(e)&&"object"===Xl(e.audio)&&(e=JSON.parse(Xg(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"===Xl(e)&&(e=JSON.parse(Xg(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function mR(e){"object"===Xl(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&pT(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function gR(e,t){if("object"===Xl(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=Jl({},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=lI(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,wT({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function yR(e){if("object"===Xl(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):Hg.resolve(new hT)}}}function SR(e){if("object"===Xl(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}),XT(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function bR(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;QT("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&Qy(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function ER(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function kR(e){if("object"===Xl(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=iR(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&&!(_R(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(_R(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===FS(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 TR(e){if("object"===Xl(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=Gg(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function IR(e){if("object"===Xl(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?Hg.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function RR(e){if("object"===Xl(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?Hg.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var AR=Object.freeze({__proto__:null,shimAddTransceiver:kR,shimCreateAnswer:RR,shimCreateOffer:IR,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,Hg.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})},shimGetParameters:TR,shimGetUserMedia:vR,shimOnTrack:mR,shimPeerConnection:gR,shimRTCDataChannel:ER,shimReceiverGetStats:SR,shimRemoveStream:bR,shimSenderGetStats:yR});function wR(e){if("object"===Xl(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=[]),Qy(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?Qy(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=kI(t=this._localStreams).call(t,e);if(-1!==i){zI(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){Qy(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function CR(e){if("object"===Xl(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){pT(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=[]),!Qy(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=[]),!(kI(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 xR(e){if("object"===Xl(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),Hg.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),Hg.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),Hg.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Hg.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Hg.resolve()):n},t.addIceCandidate=s}}function OR(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(PR(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function PR(e){return e&&void 0!==e.video?wT({},e,{video:$T(e.video)}):e}function NR(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")?(QT("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(Xg(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&&pT(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function MR(e){"object"===Xl(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&pT(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function DR(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=dI(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=dI(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 LR(e){"object"!==Xl(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var UR=Object.freeze({__proto__:null,shimAudioContext:LR,shimCallbacksAPI:xR,shimConstraints:PR,shimCreateOfferLegacy:DR,shimGetUserMedia:OR,shimLocalStreamsAPI:wR,shimRTCIceServerUrls:NR,shimRemoteStreamsAPI:CR,shimTrackEventTransceiver:MR}),VR=Uc.PROPER,FR=o,BR=ZS,jR=ab.trim;wr({target:"String",proto:!0,forced:function(e){return FR((function(){return!!BR[e]()||"​…᠎"!=="​…᠎"[e]()||VR&&BR[e].name!==e}))}("trim")},{trim:function(){return jR(this)}});var GR,HR,zR=qs("String").trim,KR=se,WR=zR,XR=String.prototype,YR=r((function(e){var t=e.trim;return"string"==typeof e||e===XR||KR(XR,e)&&t===XR.trim?WR:t})),qR={exports:{}};GR=qR,(HR={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=HR.generateIdentifier(),HR.splitLines=function(e){var t;return $g(t=YR(e).call(e).split("\n")).call(t,(function(e){return YR(e).call(e)}))},HR.splitSections=function(e){var t=e.split("\nm=");return $g(t).call(t,(function(e,t){var r;return YR(r=t>0?"m="+e:e).call(r)+"\r\n"}))},HR.getDescription=function(e){var t=HR.splitSections(e);return t&&t[0]},HR.getMediaSections=function(e){var t=HR.splitSections(e);return t.shift(),t},HR.matchPrefix=function(e,t){var r;return wy(r=HR.splitLines(e)).call(r,(function(e){return 0===kI(e).call(e,t)}))},HR.parseCandidate=function(e){for(var t,r={foundation:(t=0===kI(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:yb(t[3],10),ip:t[4],address:t[4],port:yb(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=yb(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},HR.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(" ")},HR.parseIceOptions=function(e){return e.substr(14).split(" ")},HR.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:yb(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=yb(t[1],10),r.channels=3===t.length?yb(t[2],10):1,r.numChannels=r.channels,r},HR.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"},HR.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:yb(r[0],10),direction:kI(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},HR.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},HR.parseFmtp=function(e){for(var t,r={},n=e.substr(kI(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=YR(o=n[i]).call(o).split("="),r[YR(a=t[0]).call(a)]=t[1]}return r},HR.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&FS(e.parameters).length){var n=[];FS(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},HR.parseRtcpFb=function(e){var t=e.substr(kI(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},HR.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},HR.parseSsrcMedia=function(e){var t=kI(e).call(e," "),r={ssrc:yb(e.substr(7,t-7),10)},n=kI(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},HR.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:$g(t).call(t,(function(e){return yb(e,10)}))}},HR.getMid=function(e){var t=HR.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},HR.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},HR.getDtlsParameters=function(e,t){var r=HR.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:$g(r).call(r,HR.parseFingerprint)}},HR.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},HR.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:yb(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:lI(t).call(t,3)}},HR.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===Xl(e.keyParams)?HR.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},HR.parseCryptoKeyParams=function(e){if(0!==kI(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}},HR.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},HR.getCryptoParameters=function(e,t){var r=HR.matchPrefix(e+t,"a=crypto:");return $g(r).call(r,HR.parseCryptoLine)},HR.getIceParameters=function(e,t){var r=HR.matchPrefix(e+t,"a=ice-ufrag:")[0],n=HR.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},HR.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},HR.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=HR.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=HR.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=HR.parseRtpMap(o),c=HR.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=c.length?HR.parseFmtp(c[0]):{},s.rtcpFeedback=$g(a=HR.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,HR.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return HR.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(HR.parseExtmap(e))})),t},HR.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=$g(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+=HR.writeRtpMap(e),n+=HR.writeFmtp(e),n+=HR.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+=HR.writeExtmap(e)})),n},HR.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],c=HR.parseRtpParameters(e),u=-1!==kI(t=c.fecMechanisms).call(t,"RED"),d=-1!==kI(r=c.fecMechanisms).call(r,"ULPFEC"),l=wy(n=$g(i=HR.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return HR.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=l.length>0&&l[0].ssrc,p=$g(o=HR.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return $g(t).call(t,(function(e){return yb(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:yb(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),u&&((t=JSON.parse(Xg(t))).fec={ssrc:h,mechanism:d?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var f,_,v=HR.matchPrefix(e,"b=");return v.length&&(v=0===kI(f=v[0]).call(f,"b=TIAS:")?yb(v[0].substr(7),10):0===kI(_=v[0]).call(_,"b=AS:")?1e3*yb(v[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=v}))),s},HR.parseRtcpParameters=function(e){var t,r,n={},i=wy(t=$g(r=HR.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return HR.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=HR.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=HR.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},HR.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},HR.parseMsid=function(e){var t,r,n,i=HR.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=wy(t=$g(r=HR.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return HR.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},HR.parseSctpDescription=function(e){var t,r=HR.parseMLine(e),n=HR.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=yb(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=HR.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:yb(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=HR.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:yb(a[0],10),protocol:a[1],maxMessageSize:t}}},HR.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("")},HR.generateSessionId=function(){return Math.random().toString().substr(2,21)},HR.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||HR.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},HR.getDirection=function(e,t){for(var r=HR.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?HR.getDirection(t):"sendrecv"},HR.getKind=function(e){return HR.splitLines(e)[0].split(" ")[0].substr(2)},HR.isRejected=function(e){return"0"===e.split(" ",2)[1]},HR.parseMLine=function(e){var t=HR.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:yb(t[1],10),protocol:t[2],fmt:lI(t).call(t,3).join(" ")}},HR.parseOLine=function(e){var t=HR.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:yb(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},HR.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=HR.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},GR.exports=HR;var JR=qR.exports,QR=r(JR),ZR=e({__proto__:null,default:QR},[JR]);function $R(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===Xl(e)&&e.candidate&&0===kI(r=e.candidate).call(r,"a=")&&((e=JSON.parse(Xg(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=QR.parseCandidate(e.candidate),o=wT(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,XT(e,"icecandidate",(function(t){return t.candidate&&pT(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function eA(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||XT(e,"icecandidate",(function(e){if(e.candidate){var t=QR.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function tA(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||pT(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&&pT(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=QR.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=QR.parseMLine(e);return r&&"application"===r.kind&&-1!==kI(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=yb(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=QR.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=yb(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={};pT(c,"maxMessageSize",{get:function(){return i}}),this._sctp=c}return r.apply(this,arguments)}}}function rA(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},XT(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 nA(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;pT(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),pT(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 iA(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!==kI(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=wy(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==YR(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 oA(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?Hg.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Hg.resolve())})}}function aA(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"!==Xl(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 sA=Object.freeze({__proto__:null,removeExtmapAllowMixed:iA,shimAddIceCandidateNullOrEmpty:oA,shimConnectionState:nA,shimMaxMessageSize:tA,shimParameterlessSetLocalDescription:aA,shimRTCIceCandidate:$R,shimRTCIceCandidateRelayProtocol:eA,shimSendThrowTypeError:rA});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=JT,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=WT(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=WT(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=WT(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),i={browserDetails:n,commonShim:sA,extractVersion:WT,disableLog:YT,disableWarnings:qT,sdp:ZR};switch(n.browser){case"chrome":if(!nR||!tR||!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=nR,oA(e,n),aA(e),XI(e,n),YI(e),tR(e,n),qI(e),eR(e,n),JI(e),QI(e),ZI(e),rR(e,n),$R(e),eA(e),nA(e),tA(e,n),rA(e),iA(e,n);break;case"firefox":if(!AR||!gR||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),i;r("adapter.js shimming firefox."),i.browserShim=AR,oA(e,n),aA(e),vR(e,n),gR(e,n),mR(e),bR(e),yR(e),SR(e),ER(e),kR(e),TR(e),IR(e),RR(e),$R(e),nA(e),tA(e,n),rA(e);break;case"safari":if(!UR||!t.shimSafari)return r("Safari shim is not included in this adapter release."),i;r("adapter.js shimming safari."),i.browserShim=UR,oA(e,n),aA(e),NR(e),DR(e),xR(e),wR(e),CR(e),MR(e),OR(e),LR(e),$R(e),eA(e),tA(e,n),rA(e),iA(e,n);break;default:r("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var cA=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=cA.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 uA(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],EI(t).call(t,r)>=0||(i[r]=e[r]);return i}(e,t);if(Gs){var o=Gs(e);for(n=0;n<o.length;n++)r=o[n],EI(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function dA(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var lA=Ze,hA=function(e){return void 0!==e&&(lA(e,"value")||lA(e,"writable"))},pA=P,fA=ee,_A=rr,vA=hA,mA=w,gA=Wc;wr({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return _A(t)===o?t[r]:(n=mA.f(t,r))?vA(n)?n.value:void 0===n.get?void 0:pA(n.get,o):fA(i=gA(t))?e(i,r,o):void 0}});var yA=te.Reflect.get,SA=r(yA),bA=v,EA=Oe,kA=ee,TA=Ze,IA=cs,RA=a,AA=Function,wA=bA([].concat),CA=bA([].join),xA={},OA=RA?AA.bind:function(e){var t=EA(this),r=t.prototype,n=IA(arguments,1),i=function(){var r=wA(n,IA(arguments));return this instanceof i?function(e,t,r){if(!TA(xA,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";xA[t]=AA("C,a","return new C("+CA(n,",")+")")}return xA[t](e,r)}(t,r.length,r):t.apply(e,r)};return kA(r)&&(i.prototype=r),i},PA=OA;wr({target:"Function",proto:!0,forced:Function.bind!==PA},{bind:PA});var NA=qs("Function").bind,MA=se,DA=NA,LA=Function.prototype,UA=r((function(e){var t=e.bind;return e===LA||MA(LA,e)&&t===LA.bind?DA:t}));function VA(e){var t;return(VA=Jh?UA(t=Yh).call(t):function(e){return e.__proto__||Yh(e)})(e)}function FA(){var e;"undefined"!=typeof Reflect&&SA?FA=UA(e=SA).call(e):FA=function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=VA(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 FA.apply(this,arguments)}function BA(e,t){var r;return(BA=Jh?UA(r=Jh).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function jA(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=zh(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Ud(e,"prototype",{writable:!1}),t&&BA(e,t)}var GA=wr,HA=l,zA=OA,KA=xf,WA=rr,XA=ee,YA=Wn,qA=o,JA=ae("Reflect","construct"),QA=Object.prototype,ZA=[].push,$A=qA((function(){function e(){}return!(JA((function(){}),[],e)instanceof e)})),ew=!qA((function(){JA((function(){}))})),tw=$A||ew;GA({target:"Reflect",stat:!0,forced:tw,sham:tw},{construct:function(e,t){KA(e),WA(t);var r=arguments.length<3?e:KA(arguments[2]);if(ew&&!$A)return JA(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 HA(ZA,n,t),new(HA(zA,e,n))}var i=r.prototype,o=YA(XA(i)?i:QA),a=HA(e,o,t);return XA(a)?a:o}});var rw=r(te.Reflect.construct);function nw(){if("undefined"==typeof Reflect||!rw)return!1;if(rw.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(rw(Boolean,[],(function(){}))),!0}catch(e){return!1}}function iw(e){var t=nw();return function(){var r,n=VA(e);if(t){var i=VA(this).constructor;r=rw(n,arguments,i)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===Xl(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return dA(e)}(this,r)}}var ow=ai,aw=Math.floor,sw=function(e,t){var r=e.length,n=aw(r/2);return r<8?cw(e,t):uw(e,sw(ow(e,0,n),t),sw(ow(e,n),t),t)},cw=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},uw=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},dw=sw,lw=ce.match(/firefox\/(\d+)/i),hw=!!lw&&+lw[1],pw=/MSIE|Trident/.test(ce),fw=ce.match(/AppleWebKit\/(\d+)\./),_w=!!fw&&+fw[1],vw=wr,mw=v,gw=Oe,yw=qe,Sw=jr,bw=RI,Ew=Sn,kw=o,Tw=dw,Iw=td,Rw=hw,Aw=pw,ww=_e,Cw=_w,xw=[],Ow=mw(xw.sort),Pw=mw(xw.push),Nw=kw((function(){xw.sort(void 0)})),Mw=kw((function(){xw.sort(null)})),Dw=Iw("sort"),Lw=!kw((function(){if(ww)return ww<70;if(!(Rw&&Rw>3)){if(Aw)return!0;if(Cw)return Cw<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++)xw.push({k:t+n,v:r})}for(xw.sort((function(e,t){return t.v-e.v})),n=0;n<xw.length;n++)t=xw[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));vw({target:"Array",proto:!0,forced:Nw||!Mw||!Dw||!Lw},{sort:function(e){void 0!==e&&gw(e);var t=yw(this);if(Lw)return void 0===e?Ow(t):Ow(t,e);var r,n,i=[],o=Sw(t);for(n=0;n<o;n++)n in t&&Pw(i,t[n]);for(Tw(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:Ew(t)>Ew(r)?1:-1}}(e)),r=Sw(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)bw(t,n++);return t}});var Uw=qs("Array").sort,Vw=se,Fw=Uw,Bw=Array.prototype,jw=r((function(e){var t=e.sort;return e===Bw||Vw(Bw,e)&&t===Bw.sort?Fw:t})),Gw=wr,Hw=Vo.findIndex,zw="findIndex",Kw=!0;zw in[]&&Array(1)[zw]((function(){Kw=!1})),Gw({target:"Array",proto:!0,forced:Kw},{findIndex:function(e){return Hw(this,e,arguments.length>1?arguments[1]:void 0)}});var Ww=qs("Array").findIndex,Xw=se,Yw=Ww,qw=Array.prototype,Jw=r((function(e){var t=e.findIndex;return e===qw||Xw(qw,e)&&t===qw.findIndex?Yw:t})),Qw=wr,Zw=k;w.f;var $w=Fr,eC=Sn,tC=Ly,rC=Y,nC=Vy,iC=Zw("".startsWith),oC=Zw("".slice),aC=Math.min;Qw({target:"String",proto:!0,forced:!nC("startsWith")},{startsWith:function(e){var t=eC(rC(this));tC(e);var r=$w(aC(arguments.length>1?arguments[1]:void 0,t.length)),n=eC(e);return iC?iC(t,n,r):oC(t,r,r+n.length)===n}});var sC=qs("String").startsWith,cC=se,uC=sC,dC=String.prototype,lC=r((function(e){var t=e.startsWith;return"string"==typeof e||e===dC||cC(dC,e)&&t===dC.startsWith?uC:t})),hC=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.TOKEN_NO_PUBLISH_PERMISSION="TOKEN_NO_PUBLISH_PERMISSION",e.TOKEN_NO_SUBSCRIBE_PERMISSION="TOKEN_NO_SUBSCRIBE_PERMISSION",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}(hC||{}),pC=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}(pC||{});function fC(e,t,r){var n;nw()?fC=UA(n=rw).call(n):fC=function(e,t,r){var n=[null];xc(n).apply(n,t);var i=new(UA(Function).apply(e,n));return r&&BA(i,r.prototype),i};return fC.apply(null,arguments)}function _C(e){var t="function"==typeof lT?new lT:void 0;return _C=function(e){if(null===e||(r=e,-1===EI(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 fC(e,arguments,VA(this).constructor)}return i.prototype=zh(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),BA(i,e)},_C(e)}var vC=r(qh),mC=function(e){jA(r,e);var t=iw(r);function r(e,n,i){var o;return Gh(this,r),Jl(dA(o=t.call(this,n)),"code",void 0),Jl(dA(o),"message",void 0),Jl(dA(o),"error",void 0),o.code=e,o.message=n,o.error=i,vC(dA(o),r.prototype),o}return jh(r,[{key:"toString",value:function(){var e;return Gg(e="SDKError: ".concat(this.code," ")).call(e,this.message)}}]),r}(_C(Error)),gC=Pr,yC=Sn,SC=Y,bC=RangeError,EC=v,kC=Fr,TC=Sn,IC=function(e){var t=yC(SC(this)),r="",n=gC(e);if(n<0||n===1/0)throw bC("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},RC=Y,AC=EC(IC),wC=EC("".slice),CC=Math.ceil,xC=function(e){return function(t,r,n){var i,o,a=TC(RC(t)),s=kC(r),c=a.length,u=void 0===n?" ":TC(n);return s<=c||""===u?a:((o=AC(u,CC((i=s-c)/u.length))).length>i&&(o=wC(o,0,i)),e?a+o:o+a)}},OC={start:xC(!1),end:xC(!0)},PC=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(ce),NC=OC.end;wr({target:"String",proto:!0,forced:PC},{padEnd:function(e){return NC(this,e,arguments.length>1?arguments[1]:void 0)}});var MC=qs("String").padEnd,DC=se,LC=MC,UC=String.prototype,VC=r((function(e){var t=e.padEnd;return"string"==typeof e||e===UC||DC(UC,e)&&t===UC.padEnd?LC:t})),FC=gb;wr({target:"Number",stat:!0,forced:Number.parseInt!==FC},{parseInt:FC});var BC=r(te.Number.parseInt),jC=r(my),GC=r(pg),HC=Math.log,zC=Math.LOG10E;wr({target:"Math",stat:!0},{log10:Math.log10||function(e){return HC(e)*zC}});var KC=r(te.Math.log10);wr({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991});var WC,XC=r(9007199254740991),YC=qs("Array").values,qC=mn,JC=Ze,QC=se,ZC=YC,$C=Array.prototype,ex={DOMTokenList:!0,NodeList:!0},tx=r((function(e){var t=e.values;return e===$C||QC($C,e)&&t===$C.values||JC(ex,qC(e))?ZC:t})),rx=qs("Array").keys,nx=mn,ix=Ze,ox=se,ax=rx,sx=Array.prototype,cx={DOMTokenList:!0,NodeList:!0},ux=r((function(e){var t=e.keys;return e===sx||ox(sx,e)&&t===sx.keys||ix(cx,nx(e))?ax:t})),dx=new Uint8Array(16);function lx(){if(!WC&&!(WC="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 WC(dx)}var hx=/^(?:[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 px=[],fx=0;fx<256;++fx)px.push((fx+256).toString(16).substr(1));function _x(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(px[e[t+0]]+px[e[t+1]]+px[e[t+2]]+px[e[t+3]]+"-"+px[e[t+4]]+px[e[t+5]]+"-"+px[e[t+6]]+px[e[t+7]]+"-"+px[e[t+8]]+px[e[t+9]]+"-"+px[e[t+10]]+px[e[t+11]]+px[e[t+12]]+px[e[t+13]]+px[e[t+14]]+px[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&hx.test(e)}(r))throw TypeError("Stringified UUID is invalid");return r}function vx(e,t,r){var n=(e=e||{}).random||(e.rng||lx)();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 _x(n)}var mx=function(){return"undefined"==typeof window},gx=function(){return vx()};var yx=function(e){return"number"==typeof e},Sx=function(e){var t;return Qy(t=Function.prototype.toString.call(e)).call(t,"[native code]")};function bx(e){return null==e?"undefined | null":"string"==typeof e?e:Xg({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function Ex(e){return null==e?"undefined | null":"string"==typeof e?e:Xg({id:e.id,active:e.active})}function kx(e){return null==e?"undefined | null":"string"==typeof e?e:Xg({track:bx(e.track)})}function Tx(e){return null==e?"undefined | null":"string"==typeof e?e:Xg({track:bx(e.track)})}function Ix(e){return null==e?"undefined | null":"string"==typeof e?e:Xg({currentDirection:e.currentDirection,direction:e.direction,mid:e.mid,stopped:e.stopped,receiver:Tx(e.receiver),sender:kx(e.sender)})}var Rx="@byted/ve-rtc",Ax="@byted/ve-rtc-cache-size",wx=function(){function e(){Gh(this,e),Jl(this,"storeKey",void 0),Jl(this,"logLevel",void 0),Jl(this,"LogfileSize",void 0),Jl(this,"db",void 0),Jl(this,"logId",void 0),Jl(this,"cacheLog",void 0),Jl(this,"cachedSize",void 0),Jl(this,"preCacheTime",void 0),Jl(this,"timer",void 0),Jl(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 jh(e,[{key:"_createStore",value:function(){var e=this;if(!mx()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(Rx);try{localStorage.removeItem(Ax)}catch(B0){}},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(Ax);if(t)this.cachedSize=Number(t);else tx(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(B0){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(Ax,"".concat(this.cachedSize))}catch(B0){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(Rx,e).objectStore(Rx)}},{key:"set",value:function(e){var t=this;return new Hg((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Gg(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=Gg(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Gg(s=Gg(c="".concat(l?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(Gg(u="".concat(l)).call(u,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Gg(d="".concat(t.cacheLog)).call(d,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(j0){var p;if(!e)return n(j0);t.cacheLog+=Gg(p="\n\n".concat(t.logId,": ")).call(p,e),t.logId++,n(j0)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Gg(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new Hg((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 Hg((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 ux(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 Hg((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 Hg((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}(),Cx=new wx,xx=OC.start;wr({target:"String",proto:!0,forced:PC},{padStart:function(e){return xx(this,e,arguments.length>1?arguments[1]:void 0)}});var Ox=qs("String").padStart,Px=se,Nx=Ox,Mx=String.prototype,Dx=r((function(e){var t=e.padStart;return"string"==typeof e||e===Mx||Px(Mx,e)&&t===Mx.padStart?Nx:t})),Lx=function(){function e(){Gh(this,e),Jl(this,"_all",{})}return jh(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||zI(r).call(r,kI(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||lI(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,Gg(t=[e]).call(t,n))}catch(B0){console.error(B0)}}},{key:"destroy",value:function(){this._all={}}}]),e}(),Ux=["UPLOAD_CONSOLE_LENGTH_CUT","UPLOAD_REPORT_LIMIT"];var Vx=function(e){jA(r,e);var t=iw(r);function r(){var e,n;Gh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jl(dA(n=t.call.apply(t,Gg(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 jh(r,[{key:"setParameter",value:function(e,t){if(function(e){return Qy(Ux).call(Ux,e)}(e))try{var r=Number(t);if(Number.isNaN(r))return;this.config[e]=r}catch(i){var n;return void console.warn(Gg(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 FS(this.config)}}]),r}(Lx),Fx=new Vx,Bx=io,jx=jr,Gx=gc,Hx=Jt,zx=function(e,t,r,n,i,o,a,s){for(var c,u,d=i,l=0,h=!!a&&Hx(a,s);l<n;)l in r&&(c=h?h(r[l],l,t):r[l],o>0&&Bx(c)?(u=jx(c),d=zx(e,t,c,u,d,o-1)-1):(Gx(d+1),e[d]=c),d++),l++;return d},Kx=zx,Wx=qe,Xx=jr,Yx=Pr,qx=xo;wr({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Wx(this),r=Xx(t),n=qx(t,0);return n.length=Kx(n,t,t,r,0,void 0===e?1:Yx(e)),n}});var Jx=qs("Array").flat,Qx=se,Zx=Jx,$x=Array.prototype,eO=r((function(e){var t=e.flat;return e===$x||Qx($x,e)&&t===$x.flat?Zx:t})),tO={};!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=lI(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==Xl(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 Gg([]).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)}(tO);var rO={},nO={},iO={},oO=tO,aO=0,sO=1;function cO(e){for(var t=e.length;--t>=0;)e[t]=0}var uO=0,dO=29,lO=256,hO=lO+1+dO,pO=30,fO=19,_O=2*hO+1,vO=15,mO=16,gO=7,yO=256,SO=16,bO=17,EO=18,kO=[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],TO=[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],IO=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],RO=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],AO=new Array(2*(hO+2));cO(AO);var wO=new Array(2*pO);cO(wO);var CO=new Array(512);cO(CO);var xO=new Array(256);cO(xO);var OO=new Array(dO);cO(OO);var PO,NO,MO,DO=new Array(pO);function LO(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 UO(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function VO(e){return e<256?CO[e]:CO[256+(e>>>7)]}function FO(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function BO(e,t,r){e.bi_valid>mO-r?(e.bi_buf|=t<<e.bi_valid&65535,FO(e,e.bi_buf),e.bi_buf=t>>mO-e.bi_valid,e.bi_valid+=r-mO):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function jO(e,t,r){BO(e,r[2*t],r[2*t+1])}function GO(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function HO(e,t,r){var n,i,o=new Array(vO+1),a=0;for(n=1;n<=vO;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]=GO(o[s]++,s))}}function zO(e){var t;for(t=0;t<hO;t++)e.dyn_ltree[2*t]=0;for(t=0;t<pO;t++)e.dyn_dtree[2*t]=0;for(t=0;t<fO;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*yO]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function KO(e){e.bi_valid>8?FO(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 WO(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 XO(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&WO(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!WO(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function YO(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?jO(e,i,t):(jO(e,(o=xO[i])+lO+1,t),0!==(a=kO[o])&&BO(e,i-=OO[o],a),jO(e,o=VO(--n),r),0!==(a=TO[o])&&BO(e,n-=DO[o],a))}while(s<e.last_lit);jO(e,yO,t)}function qO(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=_O,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--)XO(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],XO(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++,XO(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,f=t.stat_desc.max_length,_=0;for(o=0;o<=vO;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<_O;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>f&&(o=f,_++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),s=c[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(d[2*n+1]+a)));if(0!==_){do{for(o=f-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[f]--,_-=2}while(_>0);for(o=f;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),HO(o,u,e.bl_count)}function JO(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*SO]++):s<=10?e.bl_tree[2*bO]++:e.bl_tree[2*EO]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function QO(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{jO(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(jO(e,i,e.bl_tree),s--),jO(e,SO,e.bl_tree),BO(e,s-3,2)):s<=10?(jO(e,bO,e.bl_tree),BO(e,s-3,3)):(jO(e,EO,e.bl_tree),BO(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}cO(DO);var ZO=!1;function $O(e,t,r,n){BO(e,(uO<<1)+(n?1:0),3),function(e,t,r,n){KO(e),n&&(FO(e,r),FO(e,~r)),oO.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}iO._tr_init=function(e){ZO||(!function(){var e,t,r,n,i,o=new Array(vO+1);for(r=0,n=0;n<dO-1;n++)for(OO[n]=r,e=0;e<1<<kO[n];e++)xO[r++]=n;for(xO[r-1]=n,i=0,n=0;n<16;n++)for(DO[n]=i,e=0;e<1<<TO[n];e++)CO[i++]=n;for(i>>=7;n<pO;n++)for(DO[n]=i<<7,e=0;e<1<<TO[n]-7;e++)CO[256+i++]=n;for(t=0;t<=vO;t++)o[t]=0;for(e=0;e<=143;)AO[2*e+1]=8,e++,o[8]++;for(;e<=255;)AO[2*e+1]=9,e++,o[9]++;for(;e<=279;)AO[2*e+1]=7,e++,o[7]++;for(;e<=287;)AO[2*e+1]=8,e++,o[8]++;for(HO(AO,hO+1,o),e=0;e<pO;e++)wO[2*e+1]=5,wO[2*e]=GO(e,5);PO=new LO(AO,kO,lO+1,hO,vO),NO=new LO(wO,TO,0,pO,vO),MO=new LO(new Array(0),IO,0,fO,gO)}(),ZO=!0),e.l_desc=new UO(e.dyn_ltree,PO),e.d_desc=new UO(e.dyn_dtree,NO),e.bl_desc=new UO(e.bl_tree,MO),e.bi_buf=0,e.bi_valid=0,zO(e)},iO._tr_stored_block=$O,iO._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 aO;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return sO;for(t=32;t<lO;t++)if(0!==e.dyn_ltree[2*t])return sO;return aO}(e)),qO(e,e.l_desc),qO(e,e.d_desc),a=function(e){var t;for(JO(e,e.dyn_ltree,e.l_desc.max_code),JO(e,e.dyn_dtree,e.d_desc.max_code),qO(e,e.bl_desc),t=fO-1;t>=3&&0===e.bl_tree[2*RO[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?$O(e,t,r,n):4===e.strategy||o===i?(BO(e,2+(n?1:0),3),YO(e,AO,wO)):(BO(e,4+(n?1:0),3),function(e,t,r,n){var i;for(BO(e,t-257,5),BO(e,r-1,5),BO(e,n-4,4),i=0;i<n;i++)BO(e,e.bl_tree[2*RO[i]+1],3);QO(e,e.dyn_ltree,t-1),QO(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),YO(e,e.dyn_ltree,e.dyn_dtree)),zO(e),n&&KO(e)},iO._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*(xO[r]+lO+1)]++,e.dyn_dtree[2*VO(t)]++),e.last_lit===e.lit_bufsize-1},iO._tr_align=function(e){BO(e,2,3),jO(e,yO,AO),function(e){16===e.bi_valid?(FO(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 eP=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 tP=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 rP,nP=function(e,t,r,n){var i=tP,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},iP={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"},oP=tO,aP=iO,sP=eP,cP=nP,uP=iP,dP=0,lP=4,hP=0,pP=-2,fP=-1,_P=4,vP=2,mP=8,gP=9,yP=286,SP=30,bP=19,EP=2*yP+1,kP=15,TP=3,IP=258,RP=IP+TP+1,AP=42,wP=103,CP=113,xP=666,OP=1,PP=2,NP=3,MP=4;function DP(e,t){return e.msg=uP[t],t}function LP(e){return(e<<1)-(e>4?9:0)}function UP(e){for(var t=e.length;--t>=0;)e[t]=0}function VP(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(oP.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 FP(e,t){aP._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,VP(e.strm)}function BP(e,t){e.pending_buf[e.pending++]=t}function jP(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function GP(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-RP?e.strstart-(e.w_size-RP):0,u=e.window,d=e.w_mask,l=e.prev,h=e.strstart+IP,p=u[o+a-1],f=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===f&&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=IP-(h-o),o=h-IP,n>a){if(e.match_start=t,a=n,n>=s)break;p=u[o+a-1],f=u[o+a]}}}while((t=l[t&d])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function HP(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-RP)){oP.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,oP.arraySet(s,a.input,a.next_in,d,c),1===a.state.wrap?a.adler=sP(a.adler,s,d,c):2===a.state.wrap&&(a.adler=cP(a.adler,s,d,c)),a.next_in+=d,a.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=TP)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+TP-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<TP)););}while(e.lookahead<RP&&0!==e.strm.avail_in)}function zP(e,t){for(var r,n;;){if(e.lookahead<RP){if(HP(e),e.lookahead<RP&&t===dP)return OP;if(0===e.lookahead)break}if(r=0,e.lookahead>=TP&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+TP-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-RP&&(e.match_length=GP(e,r)),e.match_length>=TP)if(n=aP._tr_tally(e,e.strstart-e.match_start,e.match_length-TP),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=TP){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+TP-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=aP._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(FP(e,!1),0===e.strm.avail_out))return OP}return e.insert=e.strstart<TP-1?e.strstart:TP-1,t===lP?(FP(e,!0),0===e.strm.avail_out?NP:MP):e.last_lit&&(FP(e,!1),0===e.strm.avail_out)?OP:PP}function KP(e,t){for(var r,n,i;;){if(e.lookahead<RP){if(HP(e),e.lookahead<RP&&t===dP)return OP;if(0===e.lookahead)break}if(r=0,e.lookahead>=TP&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+TP-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=TP-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-RP&&(e.match_length=GP(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===TP&&e.strstart-e.match_start>4096)&&(e.match_length=TP-1)),e.prev_length>=TP&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-TP,n=aP._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-TP),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+TP-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=TP-1,e.strstart++,n&&(FP(e,!1),0===e.strm.avail_out))return OP}else if(e.match_available){if((n=aP._tr_tally(e,0,e.window[e.strstart-1]))&&FP(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return OP}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=aP._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<TP-1?e.strstart:TP-1,t===lP?(FP(e,!0),0===e.strm.avail_out?NP:MP):e.last_lit&&(FP(e,!1),0===e.strm.avail_out)?OP:PP}function WP(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 XP(){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=mP,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 oP.Buf16(2*EP),this.dyn_dtree=new oP.Buf16(2*(2*SP+1)),this.bl_tree=new oP.Buf16(2*(2*bP+1)),UP(this.dyn_ltree),UP(this.dyn_dtree),UP(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new oP.Buf16(kP+1),this.heap=new oP.Buf16(2*yP+1),UP(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new oP.Buf16(2*yP+1),UP(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 YP(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=vP,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?AP:CP,e.adler=2===t.wrap?0:1,t.last_flush=dP,aP._tr_init(t),hP):DP(e,pP)}function qP(e){var t,r=YP(e);return r===hP&&((t=e.state).window_size=2*t.w_size,UP(t.head),t.max_lazy_match=rP[t.level].max_lazy,t.good_match=rP[t.level].good_length,t.nice_match=rP[t.level].nice_length,t.max_chain_length=rP[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=TP-1,t.match_available=0,t.ins_h=0),r}function JP(e,t,r,n,i,o){if(!e)return pP;var a=1;if(t===fP&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>gP||r!==mP||n<8||n>15||t<0||t>9||o<0||o>_P)return DP(e,pP);8===n&&(n=9);var s=new XP;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+TP-1)/TP),s.window=new oP.Buf8(2*s.w_size),s.head=new oP.Buf16(s.hash_size),s.prev=new oP.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new oP.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,qP(e)}rP=[new WP(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(HP(e),0===e.lookahead&&t===dP)return OP;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,FP(e,!1),0===e.strm.avail_out))return OP;if(e.strstart-e.block_start>=e.w_size-RP&&(FP(e,!1),0===e.strm.avail_out))return OP}return e.insert=0,t===lP?(FP(e,!0),0===e.strm.avail_out?NP:MP):(e.strstart>e.block_start&&(FP(e,!1),e.strm.avail_out),OP)})),new WP(4,4,8,4,zP),new WP(4,5,16,8,zP),new WP(4,6,32,32,zP),new WP(4,4,16,16,KP),new WP(8,16,32,32,KP),new WP(8,16,128,128,KP),new WP(8,32,128,256,KP),new WP(32,128,258,1024,KP),new WP(32,258,258,4096,KP)],nO.deflateInit=function(e,t){return JP(e,t,mP,15,8,0)},nO.deflateInit2=JP,nO.deflateReset=qP,nO.deflateResetKeep=YP,nO.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?pP:(e.state.gzhead=t,hP):pP},nO.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?DP(e,pP):pP;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===xP&&t!==lP)return DP(e,0===e.avail_out?-5:pP);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===AP)if(2===n.wrap)e.adler=0,BP(n,31),BP(n,139),BP(n,8),n.gzhead?(BP(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)),BP(n,255&n.gzhead.time),BP(n,n.gzhead.time>>8&255),BP(n,n.gzhead.time>>16&255),BP(n,n.gzhead.time>>24&255),BP(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),BP(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(BP(n,255&n.gzhead.extra.length),BP(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=cP(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(BP(n,0),BP(n,0),BP(n,0),BP(n,0),BP(n,0),BP(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),BP(n,3),n.status=CP);else{var a=mP+(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=CP,jP(n,a),0!==n.strstart&&(jP(n,e.adler>>>16),jP(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=cP(e.adler,n.pending_buf,n.pending-i,i)),VP(e),i=n.pending,n.pending!==n.pending_buf_size));)BP(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=cP(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=cP(e.adler,n.pending_buf,n.pending-i,i)),VP(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,BP(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=cP(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=cP(e.adler,n.pending_buf,n.pending-i,i)),VP(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,BP(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=cP(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=wP)}else n.status=wP;if(n.status===wP&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&VP(e),n.pending+2<=n.pending_buf_size&&(BP(n,255&e.adler),BP(n,e.adler>>8&255),e.adler=0,n.status=CP)):n.status=CP),0!==n.pending){if(VP(e),0===e.avail_out)return n.last_flush=-1,hP}else if(0===e.avail_in&&LP(t)<=LP(r)&&t!==lP)return DP(e,-5);if(n.status===xP&&0!==e.avail_in)return DP(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==dP&&n.status!==xP){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(HP(e),0===e.lookahead)){if(t===dP)return OP;break}if(e.match_length=0,r=aP._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(FP(e,!1),0===e.strm.avail_out))return OP}return e.insert=0,t===lP?(FP(e,!0),0===e.strm.avail_out?NP:MP):e.last_lit&&(FP(e,!1),0===e.strm.avail_out)?OP:PP}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=IP){if(HP(e),e.lookahead<=IP&&t===dP)return OP;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=TP&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+IP;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=IP-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=TP?(r=aP._tr_tally(e,1,e.match_length-TP),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=aP._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(FP(e,!1),0===e.strm.avail_out))return OP}return e.insert=0,t===lP?(FP(e,!0),0===e.strm.avail_out?NP:MP):e.last_lit&&(FP(e,!1),0===e.strm.avail_out)?OP:PP}(n,t):rP[n.level].func(n,t);if(s!==NP&&s!==MP||(n.status=xP),s===OP||s===NP)return 0===e.avail_out&&(n.last_flush=-1),hP;if(s===PP&&(1===t?aP._tr_align(n):5!==t&&(aP._tr_stored_block(n,0,0,!1),3===t&&(UP(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),VP(e),0===e.avail_out))return n.last_flush=-1,hP}return t!==lP?hP:n.wrap<=0?1:(2===n.wrap?(BP(n,255&e.adler),BP(n,e.adler>>8&255),BP(n,e.adler>>16&255),BP(n,e.adler>>24&255),BP(n,255&e.total_in),BP(n,e.total_in>>8&255),BP(n,e.total_in>>16&255),BP(n,e.total_in>>24&255)):(jP(n,e.adler>>>16),jP(n,65535&e.adler)),VP(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?hP:1)},nO.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==AP&&69!==t&&73!==t&&91!==t&&t!==wP&&t!==CP&&t!==xP?DP(e,pP):(e.state=null,t===CP?DP(e,-3):hP):pP},nO.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,d=t.length;if(!e||!e.state)return pP;if(2===(o=(r=e.state).wrap)||1===o&&r.status!==AP||r.lookahead)return pP;for(1===o&&(e.adler=sP(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(UP(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new oP.Buf8(r.w_size),oP.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,HP(r);r.lookahead>=TP;){n=r.strstart,i=r.lookahead-(TP-1);do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+TP-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=TP-1,HP(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=TP-1,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,hP},nO.deflateInfo="pako deflate (from Nodeca project)";var QP={},ZP=tO,$P=!0,eN=!0;try{String.fromCharCode.apply(null,[0])}catch(G0){$P=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(G0){eN=!1}for(var tN=new ZP.Buf8(256),rN=0;rN<256;rN++)tN[rN]=rN>=252?6:rN>=248?5:rN>=240?4:rN>=224?3:rN>=192?2:1;function nN(e,t){if(t<65534&&(e.subarray&&eN||!e.subarray&&$P))return String.fromCharCode.apply(null,ZP.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}tN[254]=tN[254]=1,QP.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 ZP.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},QP.buf2binstring=function(e){return nN(e,e.length)},QP.binstring2buf=function(e){for(var t=new ZP.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},QP.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=tN[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 nN(s,n)},QP.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+tN[e[r]]>t?r:t};var iN=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},oN=nO,aN=tO,sN=QP,cN=iP,uN=iN,dN=Object.prototype.toString,lN=0,hN=-1,pN=0,fN=8;function _N(e){if(!(this instanceof _N))return new _N(e);this.options=aN.assign({level:hN,method:fN,chunkSize:16384,windowBits:15,memLevel:8,strategy:pN,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 uN,this.strm.avail_out=0;var r=oN.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==lN)throw new Error(cN[r]);if(t.header&&oN.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?sN.string2buf(t.dictionary):"[object ArrayBuffer]"===dN.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=oN.deflateSetDictionary(this.strm,n))!==lN)throw new Error(cN[r]);this._dict_set=!0}}function vN(e,t){var r=new _N(t);if(r.push(e,!0),r.err)throw r.msg||cN[r.err];return r.result}_N.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=sN.string2buf(e):"[object ArrayBuffer]"===dN.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 aN.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=oN.deflate(i,n))&&r!==lN)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(sN.buf2binstring(aN.shrinkBuf(i.output,i.next_out))):this.onData(aN.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=oN.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===lN):2!==n||(this.onEnd(lN),i.avail_out=0,!0)},_N.prototype.onData=function(e){this.chunks.push(e)},_N.prototype.onEnd=function(e){e===lN&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=aN.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},rO.Deflate=_N,rO.deflate=vN,rO.deflateRaw=function(e,t){return(t=t||{}).raw=!0,vN(e,t)},rO.gzip=function(e,t){return(t=t||{}).gzip=!0,vN(e,t)};var mN={},gN=rr,yN=P,SN=Ze,bN=se,EN=function(){var e=gN(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},kN=RegExp.prototype,TN=se,IN=function(e){var t=e.flags;return void 0!==t||"flags"in kN||SN(e,"flags")||!bN(kN,e)?t:yN(EN,e)},RN=RegExp.prototype,AN=r((function(e){return e===RN||TN(RN,e)?IN(e):e.flags})),wN={},CN=tO,xN=15,ON=[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],PN=[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],NN=[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],MN=[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],DN=tO,LN=eP,UN=nP,VN=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,R=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,u=r.wsize,d=r.whave,l=r.wnext,h=r.window,p=r.hold,f=r.bits,_=r.lencode,v=r.distcode,m=(1<<r.lenbits)-1,g=(1<<r.distbits)-1;e:do{f<15&&(p+=I[n++]<<f,f+=8,p+=I[n++]<<f,f+=8),y=_[p&m];t:for(;;){if(p>>>=S=y>>>24,f-=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)&&(f<S&&(p+=I[n++]<<f,f+=8),b+=p&(1<<S)-1,p>>>=S,f-=S),f<15&&(p+=I[n++]<<f,f+=8,p+=I[n++]<<f,f+=8),y=v[p&g];r:for(;;){if(p>>>=S=y>>>24,f-=S,!(16&(S=y>>>16&255))){if(0==(64&S)){y=v[(65535&y)+(p&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(E=65535&y,f<(S&=15)&&(p+=I[n++]<<f,(f+=8)<S&&(p+=I[n++]<<f,f+=8)),(E+=p&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(p>>>=S,f-=S,E>(S=o-a)){if((S=E-S)>d&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(k=0,T=h,0===l){if(k+=u-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}else if(l<S){if(k+=u+l-S,(S-=l)<b){b-=S;do{R[o++]=h[k++]}while(--S);if(k=0,l<b){b-=S=l;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}}else if(k+=l-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}for(;b>2;)R[o++]=T[k++],R[o++]=T[k++],R[o++]=T[k++],b-=3;b&&(R[o++]=T[k++],b>1&&(R[o++]=T[k++]))}else{k=o-E;do{R[o++]=R[k++],R[o++]=R[k++],R[o++]=R[k++],b-=3}while(b>2);b&&(R[o++]=R[k++],b>1&&(R[o++]=R[k++]))}break}}break}}while(n<i&&o<s);n-=b=f>>3,p&=(1<<(f-=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=f},FN=function(e,t,r,n,i,o,a,s){var c,u,d,l,h,p,f,_,v,m=s.bits,g=0,y=0,S=0,b=0,E=0,k=0,T=0,I=0,R=0,A=0,w=null,C=0,x=new CN.Buf16(16),O=new CN.Buf16(16),P=null,N=0;for(g=0;g<=xN;g++)x[g]=0;for(y=0;y<n;y++)x[t[r+y]]++;for(E=m,b=xN;b>=1&&0===x[b];b--);if(E>b&&(E=b),0===b)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<b&&0===x[S];S++);for(E<S&&(E=S),I=1,g=1;g<=xN;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<xN;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=ON,C-=257,P=PN,N-=257,p=256):(w=NN,P=MN,p=-1),A=0,y=0,g=S,h=o,k=E,T=0,d=-1,l=(R=1<<E)-1,1===e&&R>852||2===e&&R>592)return 1;for(;;){f=g-T,a[y]<p?(_=0,v=a[y]):a[y]>p?(_=P[N+a[y]],v=w[C+a[y]]):(_=96,v=0),c=1<<g-T,S=u=1<<k;do{i[h+(A>>T)+(u-=c)]=f<<24|_<<16|v|0}while(0!==u);for(c=1<<g-1;A&c;)c>>=1;if(0!==c?(A&=c-1,A+=c):A=0,y++,0==--x[g]){if(g===b)break;g=t[r+a[y]]}if(g>E&&(A&l)!==d){for(0===T&&(T=E),h+=S,I=1<<(k=g-T);k+T<b&&!((I-=x[k+T])<=0);)k++,I<<=1;if(R+=1<<k,1===e&&R>852||2===e&&R>592)return 1;i[d=A&l]=E<<24|k<<16|h-o|0}}return 0!==A&&(i[h+A]=g-T<<24|64<<16|0),s.bits=E,0},BN=1,jN=2,GN=0,HN=-2,zN=1,KN=12,WN=30,XN=852,YN=592;function qN(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function JN(){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 DN.Buf16(320),this.work=new DN.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function QN(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=zN,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new DN.Buf32(XN),t.distcode=t.distdyn=new DN.Buf32(YN),t.sane=1,t.back=-1,GN):HN}function ZN(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,QN(e)):HN}function $N(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)?HN:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,ZN(e))):HN}function eM(e,t){var r,n;return e?(n=new JN,e.state=n,n.window=null,(r=$N(e,t))!==GN&&(e.state=null),r):HN}var tM,rM,nM=!0;function iM(e){if(nM){var t;for(tM=new DN.Buf32(512),rM=new DN.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(FN(BN,e.lens,0,288,tM,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;FN(jN,e.lens,0,32,rM,0,e.work,{bits:5}),nM=!1}e.lencode=tM,e.lenbits=9,e.distcode=rM,e.distbits=5}function oM(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 DN.Buf8(o.wsize)),n>=o.wsize?(DN.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),DN.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(DN.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}wN.inflateReset=ZN,wN.inflateReset2=$N,wN.inflateResetKeep=QN,wN.inflateInit=function(e){return eM(e,15)},wN.inflateInit2=eM,wN.inflate=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R=0,A=new DN.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 HN;(r=e.state).mode===KN&&(r.mode=13),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,l=s,h=c,k=GN;e:for(;;)switch(r.mode){case zN: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=UN(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=WN;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=WN;break}if(d-=4,E=8+(15&(u>>>=4)),0===r.wbits)r.wbits=E;else if(E>r.wbits){e.msg="invalid window size",r.mode=WN;break}r.dmax=1<<E,e.adler=r.check=1,r.mode=512&u?10:KN,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&AN(r))){e.msg="unknown compression method",r.mode=WN;break}if(57344&AN(r)){e.msg="unknown header flags set",r.mode=WN;break}r.head&&(r.head.text=u>>8&1),512&AN(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=UN(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&AN(r)&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=UN(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&AN(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=UN(r.check,A,2,0)),u=0,d=0,r.mode=5;case 5:if(1024&AN(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&AN(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=UN(r.check,A,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&AN(r)&&((p=r.length)>s&&(p=s),p&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),DN.arraySet(r.head.extra,n,o,p,E)),512&AN(r)&&(r.check=UN(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&AN(r)){if(0===s)break e;p=0;do{E=n[o+p++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&p<s);if(512&AN(r)&&(r.check=UN(r.check,n,p,o)),s-=p,o+=p,E)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&AN(r)){if(0===s)break e;p=0;do{E=n[o+p++],r.head&&E&&r.length<65536&&(r.head.comment+=String.fromCharCode(E))}while(E&&p<s);if(512&AN(r)&&(r.check=UN(r.check,n,p,o)),s-=p,o+=p,E)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&AN(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=WN;break}u=0,d=0}r.head&&(r.head.hcrc=AN(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=KN;break;case 10:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}e.adler=r.check=qN(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=KN;case KN: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(iM(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=WN}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=WN;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;DN.arraySet(i,n,o,p,a),s-=p,o+=p,c-=p,a+=p,r.length-=p;break}r.mode=KN;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=WN;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.lens[w[r.have++]]=7&u,u>>>=3,d-=3}for(;r.have<19;)r.lens[w[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,T={bits:r.lenbits},k=FN(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid code lengths set",r.mode=WN;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,!((v=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(g<16)u>>>=v,d-=v,r.lens[r.have++]=g;else{if(16===g){for(I=v+2;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u>>>=v,d-=v,0===r.have){e.msg="invalid bit length repeat",r.mode=WN;break}E=r.lens[r.have-1],p=3+(3&u),u>>>=2,d-=2}else if(17===g){for(I=v+3;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=v,E=0,p=3+(7&(u>>>=v)),u>>>=3,d-=3}else{for(I=v+7;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=v,E=0,p=11+(127&(u>>>=v)),u>>>=7,d-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=WN;break}for(;p--;)r.lens[r.have++]=E}}if(r.mode===WN)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=WN;break}if(r.lenbits=9,T={bits:r.lenbits},k=FN(BN,r.lens,0,r.nlen,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid literal/lengths set",r.mode=WN;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},k=FN(jN,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,T),r.distbits=T.bits,k){e.msg="invalid distances set",r.mode=WN;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,VN(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===KN&&(r.back=-1);break}for(r.back=0;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((v=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(m&&0==(240&m)){for(y=v,S=m,b=g;m=(R=r.lencode[b+((u&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(v=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=y,d-=y,r.back+=y}if(u>>>=v,d-=v,r.back+=v,r.length=g,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=KN;break}if(64&m){e.msg="invalid literal/length code",r.mode=WN;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,!((v=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(0==(240&m)){for(y=v,S=m,b=g;m=(R=r.distcode[b+((u&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(v=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=y,d-=y,r.back+=y}if(u>>>=v,d-=v,r.back+=v,64&m){e.msg="invalid distance code",r.mode=WN;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=WN;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=WN;break}p>r.wnext?(p-=r.wnext,f=r.wsize-p):f=r.wnext-p,p>r.length&&(p=r.length),_=r.window}else _=i,f=a-r.offset,p=r.length;p>c&&(p=c),c-=p,r.length-=p;do{i[a++]=_[f++]}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=AN(r)?UN(r.check,i,h,a-h):LN(r.check,i,h,a-h)),h=c,(AN(r)?u:qN(u))!==r.check){e.msg="incorrect data check",r.mode=WN;break}u=0,d=0}r.mode=28;case 28:if(r.wrap&&AN(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=WN;break}u=0,d=0}r.mode=29;case 29:k=1;break e;case WN:k=-3;break e;case 31:return-4;default:return HN}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<WN&&(r.mode<27||4!==t))&&oM(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=AN(r)?UN(r.check,i,h,e.next_out-h):LN(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===KN?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&k===GN&&(k=-5),k},wN.inflateEnd=function(e){if(!e||!e.state)return HN;var t=e.state;return t.window&&(t.window=null),e.state=null,GN},wN.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?HN:(r.head=t,t.done=!1,GN):HN},wN.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?HN:11===r.mode&&LN(1,t,n,0)!==r.check?-3:oM(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,GN):HN},wN.inflateInfo="pako inflate (from Nodeca project)";var aM={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 sM=wN,cM=tO,uM=QP,dM=aM,lM=iP,hM=iN,pM=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},fM=Object.prototype.toString;function _M(e){if(!(this instanceof _M))return new _M(e);this.options=cM.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 hM,this.strm.avail_out=0;var r=sM.inflateInit2(this.strm,t.windowBits);if(r!==dM.Z_OK)throw new Error(lM[r]);if(this.header=new pM,sM.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=uM.string2buf(t.dictionary):"[object ArrayBuffer]"===fM.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=sM.inflateSetDictionary(this.strm,t.dictionary))!==dM.Z_OK))throw new Error(lM[r])}function vM(e,t){var r=new _M(t);if(r.push(e,!0),r.err)throw r.msg||lM[r.err];return r.result}_M.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?dM.Z_FINISH:dM.Z_NO_FLUSH,"string"==typeof e?s.input=uM.binstring2buf(e):"[object ArrayBuffer]"===fM.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 cM.Buf8(c),s.next_out=0,s.avail_out=c),(r=sM.inflate(s,dM.Z_NO_FLUSH))===dM.Z_NEED_DICT&&u&&(r=sM.inflateSetDictionary(this.strm,u)),r===dM.Z_BUF_ERROR&&!0===d&&(r=dM.Z_OK,d=!1),r!==dM.Z_STREAM_END&&r!==dM.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==dM.Z_STREAM_END&&(0!==s.avail_in||n!==dM.Z_FINISH&&n!==dM.Z_SYNC_FLUSH)||("string"===this.options.to?(i=uM.utf8border(s.output,s.next_out),o=s.next_out-i,a=uM.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&cM.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(cM.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!==dM.Z_STREAM_END);return r===dM.Z_STREAM_END&&(n=dM.Z_FINISH),n===dM.Z_FINISH?(r=sM.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===dM.Z_OK):n!==dM.Z_SYNC_FLUSH||(this.onEnd(dM.Z_OK),s.avail_out=0,!0)},_M.prototype.onData=function(e){this.chunks.push(e)},_M.prototype.onEnd=function(e){e===dM.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=cM.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},mN.Inflate=_M,mN.inflate=vM,mN.inflateRaw=function(e,t){return(t=t||{}).raw=!0,vM(e,t)},mN.ungzip=vM;var mM={};(0,tO.assign)(mM,rO,mN,aM);var gM=r(mM),yM=1,SM=function(){function e(t){Gh(this,e),Jl(this,"lockingPromise",Hg.resolve()),Jl(this,"locks",0),Jl(this,"name",""),Jl(this,"lockId",void 0),this.lockId=yM++,t&&(this.name=t)}return jh(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t=this;this.locks+=1;var r=new Hg((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}(),bM="BytePlusRTC",EM=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},kM=function(){function e(t){Gh(this,e),Jl(this,"storeName",void 0),Jl(this,"pendingList",[]),this.storeName=t,!mx()&&EM()&&this._checkAndCreateStore(t)}var t,r,n,i,o,a,s;return jh(e,[{key:"_checkAndCreateStore",value:(s=Ug(Dg().mark((function t(r,n){var i,o,a=this;return Dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e._promiseLock.lock();case 2:if(i=t.sent,!EM.databases){t.next=6;break}return t.next=6,new Hg((function(e){var t=function(){return EM.databases().finally(e)};o=setInterval(t,100),t()})).finally((function(){return clearInterval(o)}));case 6:return t.abrupt("return",new Hg((function(t){e.db&&(e.db.close(),delete e.db);var o=n?EM().open(bM,n):EM().open(bM);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=Ug(Dg().mark((function e(t){var r,n,i,o;return Dg().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=Ug(Dg().mark((function t(r){var n,i=this;return Dg().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 Hg((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=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{n=Xg(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=Ug(Dg().mark((function e(t){var r,n;return Dg().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=Ug(Dg().mark((function e(t,r){var n;return Dg().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 Hg((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=Ug(Dg().mark((function e(t){var r;return Dg().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 Hg((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=Ug(Dg().mark((function e(t){var r;return Dg().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 Hg((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}();Jl(kM,"db",void 0),Jl(kM,"state","init"),Jl(kM,"_promiseLock",new SM("iDB"));var TM=["message"];var IM,RM,AM,wM=new(function(){function e(){Gh(this,e),Jl(this,"name","LongStringReportor"),Jl(this,"inBuffer",[]),Jl(this,"outBuffer",[])}return jh(e,[{key:"push",value:function(e){var t;e.message&&this.inBuffer.push(Zl(Zl({},e),{},{message:{id:lI(t=gx()).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=Xg(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=Zl(Zl({},uA(i,TM)),{},{message:Zl(Zl({},o),{},{msg:""})}),s=Xg(a).length,c=e-s,u=Zl({},a);if(c>o.msg.length)u.message.msg=o.msg,this.inBuffer.shift();else{if(!(c>=10))break;var d,l,h=lI(d=o.msg).call(d,0,c);u.message.msg=h,u.message.end=!1,this.inBuffer[0].message.msg=lI(l=o.msg).call(l,c),this.inBuffer[0].message.index++}var p=Xg(u.message),f=p.length;e-=f+s,r+=f+s,t.push(Zl(Zl({},u),{},{message:p}))}return{payload:t,payloadSize:r}}},{key:"unshift",value:function(e){this.outBuffer=Gg(e).call(e,this.outBuffer)}},{key:"get",value:function(){var e,t;return Gg(e=[]).call(e,iR(this.outBuffer),iR($g(t=this.inBuffer).call(t,(function(e){return Zl(Zl({},e),{},{message:Xg(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(Zl(Zl({},e),{},{message:JSON.parse(e.message)}))):t.outBuffer.push(e)})),this.outBuffer=Gg(r).call(r,this.outBuffer),this.inBuffer=Gg(n).call(n,this.inBuffer)}},{key:"isEmpty",value:function(){return 0===this.inBuffer.length&&0===this.outBuffer.length}}]),e}()),CM={product_line:"rtc",report_version:"5",os:"web",user_agent:mx()?"":null===(IM=navigator)||void 0===IM?void 0:IM.userAgent,platform:"web",product:"webrtc",app_state:"active"},xM="LogReportor",OM="undefined"!=typeof window&&(Qy(RM=window.location.search).call(RM,"_rtc_debug_")||(null===(AM=window.localStorage)||void 0===AM?void 0:AM.getItem("_rtc_debug_"))),PM=function(){function e(t){Gh(this,e),Jl(this,"_buffer",void 0),this._buffer=new kM(t)}var t,r;return jh(e,[{key:"set",value:(r=Ug(Dg().mark((function e(t,r){return Dg().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=Ug(Dg().mark((function e(t){var r,n;return Dg().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}(),NM=function(){function e(){var t=this;Gh(this,e),Jl(this,"reportCommon",CM),Jl(this,"reportIds",new hT),Jl(this,"dataBuffer",[]),Jl(this,"reportorList",[]),Jl(this,"dbBuffer",void 0),Jl(this,"posting",!1),Jl(this,"sucSendTimer",void 0),Jl(this,"preSucTime",0),Jl(this,"errSendTimer",void 0),Jl(this,"errSendDelay",100),Jl(this,"_logServerUrl",void 0),Jl(this,"_retryCount",0),Jl(this,"_reportLimit",5e5),Jl(this,"_disableTimeout",!1),mx()||(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"})})),OM&&(window.__rtc_debug_reportor__=this)),Fx.on("UPLOAD_REPORT_LIMIT",(function(e){t.setReportLimit(e)})),Fx.on("ENABLE_REPORT_IDB_BUFFER",(function(e){e&&t.enableIndexedDBBuffer()})),setTimeout((function(){t.reportorList.push(uD),t.reportorList.push(wM)}))}var t;return jh(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.reportCommon=wT(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&&(KM("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 PM("ReportorDBBuffer"),this.dbBuffer.get(xM).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(iR(this.dataBuffer),xM),this.reportorList.forEach((function(t){var r;null===(r=e.dbBuffer)||void 0===r||r.set(iR(t.get()),t.name)}))}catch(r){KM("Error when save log into IDB",-1,r)}}},{key:"unshift",value:function(e){var t;this.dataBuffer=Gg(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+=Xg(e[n]).length)>t)return n;return e.length}(this.dataBuffer,this._reportLimit);0===r&&this.dataBuffer.length>0&&(this._reportLimit=Xg(this.dataBuffer[0]).length+10,r=1,KM("update report limit to ".concat(this._reportLimit),0,null));var n=zI(e=this.dataBuffer).call(e,0,r),i=Xg(n).length,o=[n],a=this._reportLimit-i;return this.reportorList.forEach((function(e){var r=zI(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),!mx()&&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=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.backup(),i=uS(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=OM,s={data:t||eO(o).call(o),header:Zl(Zl({},this.reportCommon),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},c={method:"POST",body:a?Xg(s):gM.gzip(Xg(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;KM(Gg(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 MM=new NM,DM=function(){function e(t){Gh(this,e),Jl(this,"modifyIds",{pre_connection:!1}),this.id=t}return jh(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=Zl(Zl(Zl({event_key:e,rtc_timestamp:Date.now()},this.modifyIds),t),{},{common_extra_info:Xg(i),report_id:MM.getReportId(this.modifyIds.engine_session_id)});!mx()&&window.__onRTCReport&&(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.modifyIds.engine_session_id,o,MM.getCommonStats()));MM.push(o)}},{key:"reportLog",value:function(e){var t=Zl(Zl({event_key:"rtc_invoke_status",sdk_api_name:"console_log",rtc_timestamp:Date.now()},this.modifyIds),{},{message:e});uD.push(t)}},{key:"reportLongString",value:function(e,t){var r=Zl(Zl({event_key:"rtc_invoke_status",sdk_api_name:"sdk_long_string_".concat(e),rtc_timestamp:Date.now()},this.modifyIds),{},{message:t});wM.push(r)}},{key:"set",value:function(e){this.modifyIds=wT(this.modifyIds,e)}},{key:"destroy",value:function(){}}]),e}(),LM=function(){function e(t){Gh(this,e),Jl(this,"_preTime",Date.now()),Jl(this,"_one2oneNum",0),Jl(this,"_one2manyNum",0),Jl(this,"_one2oneMsgCache",new hT),Jl(this,"_one2manyMsgCache",new hT),Jl(this,"roomId",""),Jl(this,"userId",""),Jl(this,"rtsSessionId",""),Jl(this,"logger",void 0),Jl(this,"serverUrl","server"),this.id=t,this.logger=new fD("MessageReportor",1)}return jh(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,Zl({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,Zl(Zl({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,Zl({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,Zl(Zl({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(this.logger.info("reportP2PMsg",r.type,Xg(r)),null===(t=YM(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(this.logger.info("reportOne2ManyMsg",r.type,Xg(r)),null===(t=YM(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)||"",this.logger.info("reportMsgRecv",t.type,Xg(t)),null===(n=YM(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}();Jl(LM,"config",void 0);var UM=new hT,VM={_cache:UM,setServerUrl:function(e,t){var r=UM.get(e);r&&(r.serverUrl=t)},setConfig:function(e){new fD("MessageReportor",1).info("setConfig","get config: ".concat(Xg(e))),LM.config=e},setRtsSessionId:function(e,t){var r=UM.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=UM.get(e)||new LM(e);return UM.set(e,t),t},destroyRTSMsgReportor:function(e){var t=UM.get(e);t&&(t.destroy(),UM.delete(e))},setRoomId:function(e,t){var r=UM.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=UM.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=UM.get(e);if(null!=r&&r.needReport("one2one")){var n=t.to?"one2one":"one2server";t.enable_report=!0,t.report_msg_id=t.id,r.cacheP2PMsg({rts_session_id:r.rtsSessionId,msg_id:"".concat(t.id),node_role:"src_sdk",from:t.from,to:t.to||r.serverUrl,msg_type:n,type:n,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;t.enable_report&&yx(t.report_msg_id)&&(null===(n=UM.get(e))||void 0===n||n.updateP2PMsg("".concat(t.report_msg_id),{send_ts:Date.now(),msg_size:r}))},updateP2PMsgAck:function(e,t,r){if(t.enable_report&&yx(t.report_msg_id)){var n=UM.get(e);null==n||n.updateP2PMsg("".concat(t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==n||n.reportP2PMsg("".concat(t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n=UM.get(e);return null!=n&&n.needReport("one2many")&&(r.enable_report=!0,r.report_msg_id=t,n.cacheCustomMsg({rts_session_id:n.rtsSessionId,msg_id:"".concat(t),node_role:"src_sdk",from:r.clientId,to:n.roomId||r.roomId,msg_type:"one2many",type:"one2many",rts_room_id:n.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:""})),r},reportP2PMsgRecv:function(e,t,r){if(t.enable_report&&yx(t.report_msg_id)){var n=UM.get(e),i=t.to?"one2one":"one2many";null==n||n.reportMsgRecv({rts_session_id:n.rtsSessionId,msg_id:"".concat(t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",msg_type:i,type:i,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?"":n.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},updateOne2ManyMsgAck:function(e,t,r){if(t.enable_report&&yx(t.report_msg_id)){var n=UM.get(e);n&&(null==n||n.updateOne2ManyMsg("".concat(t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==n||n.reportOne2ManyMsg("".concat(t.report_msg_id)))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&yx(t.report_msg_id)){var n=UM.get(e);n&&n.updateOne2ManyMsg("".concat(t.report_msg_id),{send_ts:Date.now(),msg_size:r})}},reportOne2ManyMsgRecv:function(e,t,r){if(t.enable_report&&yx(t.report_msg_id)){var n=UM.get(e);null==n||n.reportMsgRecv({rts_session_id:n.rtsSessionId,msg_id:"".concat(t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",msg_type:"one2many",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:n.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}}},FM=function(){function e(t){Gh(this,e),Jl(this,"_timer",void 0),Jl(this,"userMessage",{}),Jl(this,"roomMessage",{}),this.id=t,this._setTimer()}return jh(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(FS(this.userMessage).length||FS(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e,t,r,n=this;null===(e=YM(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:$g(t=FS(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:$g(r=FS(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[Gg(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Gg(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[Gg(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Gg(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Gg(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Gg(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)&&(Qy(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[Gg(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/2<=100?(a.dc_send_ack_100++,a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r/2<=200?(a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r/2<=400?(a.dc_send_ack_400++,a.dc_send_ack_1s++):r/2<=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/2<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t/2<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t/2<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t/2<=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||0,i.s2e_time||0):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}(),BM=function(e){MM.setCommonStats(e)},jM=function(e){MM.setUrl(e)},GM=new DM("global"),HM=function(e,t,r){GM.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},zM=function(e,t,r){GM.report("rtc_sdk_callback",{sdk_callback_name:e,error_code:t,message:r})},KM=function(e,t,r){GM.report("rtc_error",{message:e,error_code:t},r)},WM=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;GM.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)};var XM=new hT,YM=function(e){return XM.get(e)},qM=function(e,t){var r=new DM(e);return r.set(Zl(Zl({},t),{},{engine_session_id:gx()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),XM.set(e,r),r};function JM(){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=function(){for(var e,t,r=Number(VC(e=lI(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=VC(r).call(r,28,"1").split(""),i=[];n.length;)i.push(zI(n).call(n,0,7));return $g(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return BC(r+e.join(""),2)}))}().join("-"),o=n.value;n.value=function(){for(var e,n,a,s=arguments.length,c=new Array(s),u=0;u<s;u++)c[u]=arguments[u];var d,l,h=this.engineId||this.id,p={};(t.forEach((function(e,t){p[e]=c[t]})),"joinRoom"===r)&&(null===(d=YM(h))||void 0===d||d.set({room_id:c[1],user_id:null===(l=c[2])||void 0===l?void 0:l.userId}));var f,_={sdk_api_name:r,message:Xg(tD(c)),error_code:0,event_session_id:i};null===(e=YM(h))||void 0===e||e.report("rtc_sdk_api_call",_,p);try{f=o.apply(this,c)}catch(v){throw ZM(h,r,v.message,v.code||-1,{eventSessionId:i}),v}return"function"==typeof(null===(n=f)||void 0===n?void 0:n.then)?f.then((function(e){return ZM(h,r,[null!=e?e:{}],0,{eventSessionId:i}),e})).catch((function(e){throw ZM(h,r,e.message,e.code,{eventSessionId:i}),e})):(ZM(h,r,[null!==(a=f)&&void 0!==a?a:{}]),f)}}}}var QM,ZM=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:Xg(Array.isArray(r)?tD(r):r)};null!=i&&i.roomId&&(o.room_id=i.roomId),null!=i&&i.eventSessionId&&(o.event_session_id=i.eventSessionId),null===(n=YM(e))||void 0===n||n.report("rtc_sdk_callback",o)},$M=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=YM(e))||void 0===n||n.report("rtc_invoke_status",{sdk_api_name:t,message:r,error_code:i,stream_id:o,elapse:0},a)},eD=10;function tD(e){return $g(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>eD){var c,u,d,l,h,p=new DataView(o),f=$g(c=jC({length:eD/2})).call(c,(function(e,t){return p.getUint8(t)})),_=$g(u=GC(d=$g(l=jC({length:eD/2})).call(l,(function(e,t){return a-1-t}))).call(d)).call(u,(function(e){return p.getUint8(e)}));s=Gg(h=[]).call(h,iR(f),["..."],iR(_))}else s=jC(new Uint8Array(o));return Gg(n=Gg(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return $g(t).call(t,e);if(Qy(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var v={};for(var m in t)v[m]=e(t[m]);return v}return t}))}var rD="undefined"!=typeof window&&Qy(QM=window.location.search).call(QM,"_rtc_upload_console_"),nD=function(){function e(){var t=this;Gh(this,e),Jl(this,"name","ConsoleReportor"),Jl(this,"_uuid","".concat(Math.floor(899*Math.random())+100)),Jl(this,"_consoleReportId",0),Jl(this,"_engineReportIdMap",new hT),Jl(this,"_enabled","NULL"),Jl(this,"_consoleCutLength",Fx.getParameter("UPLOAD_CONSOLE_LENGTH_CUT")),Jl(this,"buffer",[]),rD&&setTimeout((function(){t.switchOn()}),0),Fx.on("UPLOAD_CONSOLE_ON",(function(e){e?t.switchOn():t.turnOff()})),Fx.on("UPLOAD_CONSOLE_LENGTH_CUT",(function(e){t._consoleCutLength=e}))}return jh(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,f,_,v,m,g,y,S=this;if("OFF"!==this._enabled){var b,E=YM(t),k=this._consoleReportId++,T=this.getEngineConsoleId(t),I=iD(c,this._consoleCutLength),R=iR(c),A="".concat(s).replace(/%o|%s/gi,(function(){return iD([R.shift()],S._consoleCutLength)})),w=Gg(u=Gg(d=Gg(l=Gg(h=Gg(p=Gg(f=Gg(_=Gg(v=Gg(m=Gg(g=Gg(y="[".concat(this._uuid,"-")).call(y,k,"][")).call(g,t,"-")).call(m,T,"]-")).call(v,r,"-")).call(_,e,"[")).call(f,n,"]")).call(p,i,"[")).call(h,o,".")).call(l,a,"] ")).call(d,A," ")).call(u,I);E?E.reportLog(w):(b=w,GM.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=Xg(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:zI(t=this.buffer).call(t,0,n),payloadSize:i}}},{key:"unshift",value:function(e){this.buffer=Gg(e).call(e,this.buffer)}},{key:"get",value:function(){return this.buffer}},{key:"set",value:function(e){this.buffer=Gg(e).call(e,this.buffer)}},{key:"isEmpty",value:function(){return"OFF"===this._enabled||0===this.buffer.length}}]),e}();function iD(e,t){return $g(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 bx(e);if(e instanceof MediaStream)return Ex(e);if(e instanceof RTCRtpSender)return kx(e);if(e instanceof RTCRtpReceiver)return Tx(e);if(e instanceof RTCRtpTransceiver)return Ix(e);r=Xg(e)}catch(n){r=e.toString()}return r&&r.length>=t&&(r=lI(r).call(r,0,t)),r})).join(", ")}var oD,aD,sD,cD,uD=new nD,dD="[VERTC]",lD="#0050b3",hD=(Jl(oD={},"DEBUG","rgba(0, 0, 0, 0)"),Jl(oD," INFO","rgba(93, 173, 226, 0)"),Jl(oD," WARN","rgba(255, 119, 0, 0.3)"),Jl(oD,"ERROR","rgba(255, 0, 0, 0.3)"),Jl(oD," SUCC","rgba(0, 119, 0, 0.3)"),oD),pD="undefined"!=typeof window&&(Qy(aD=window.location.search).call(aD,"_rtc_debug_")||(null===(sD=window.localStorage)||void 0===sD?void 0:sD.getItem("_rtc_debug_"))),fD=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"global";Gh(this,e),Jl(this,"indent",void 0),Jl(this,"module",void 0),Jl(this,"_engineId",void 0),this.module=t,this.indent=r,this._engineId=n}return jh(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 f,_,v,m,g=Gg(f=[]).call(f,l),y="".concat(p).replace(/%o/gi,(function(){var e=g.shift();return Xg(e)}));Cx.set(Gg(_=Gg(v=Gg(m="".concat(dD,"[").concat(this.module,".")).call(m,t,"] ")).call(v,y," ")).call(_,$g(g).call(g,(function(e){return Xg(e)})).join(", ")))}catch(B0){}for(var S="",b=0;b<this.indent;b++)S+=" ";var E=_D();uD.report(dD,this._engineId,E,e,S,this.module,t,p,l),pD&&(r=console).log.apply(r,Gg(n=[Gg(i=Gg(o=Gg(a=Gg(s=Gg(c=Gg(u="%c".concat(E,"-")).call(u,dD,"%c[")).call(c,e,"]%c")).call(s,S,"[")).call(a,this.module,".")).call(o,t,"] ")).call(i,p),"color:".concat(lD,";"),"background-color:".concat(hD[e],";"),"color:".concat(lD,";")]).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,Gg(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,Gg(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,Gg(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,Gg(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,Gg(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,Gg(t=[" SUCC",e]).call(t,n))}}]),e}(),_D=function(){var e,t,r=new Date;return Gg(e="".concat(r.toTimeString().split(" ")[0],":")).call(e,Dx(t=r.getMilliseconds().toString()).call(t,3,"0"))},vD=function(e){var t,r=YM(e.engineId),n={keys:ux(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId,deviceId:e.deviceId},i=$g(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:Xg(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=$g(i).call(i,function(){var e=Ug(Dg().mark((function e(t,r){var i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:Xg(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 Hg((function(e){(function(e){return new Hg((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:Xg(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})}))}))},mD=new Uint8Array(16);function gD(){if(!cD&&!(cD="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 cD(mD)}for(var yD=[],SD=0;SD<256;++SD){var bD;yD.push(lI(bD=(SD+256).toString(16)).call(bD,1))}var ED={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function kD(e,t,r){if(ED.randomUUID&&!t&&!e)return ED.randomUUID();var n=(e=e||{}).random||(e.rng||gD)();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(yD[e[t+0]]+yD[e[t+1]]+yD[e[t+2]]+yD[e[t+3]]+"-"+yD[e[t+4]]+yD[e[t+5]]+"-"+yD[e[t+6]]+yD[e[t+7]]+"-"+yD[e[t+8]]+yD[e[t+9]]+"-"+yD[e[t+10]]+yD[e[t+11]]+yD[e[t+12]]+yD[e[t+13]]+yD[e[t+14]]+yD[e[t+15]]).toLowerCase()}(n)}var TD=new TextDecoder,ID=new TextEncoder,RD=function(){return kD()},AD=function(){return Date.now()};function wD(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 CD=function(){function e(){Gh(this,e)}var t,r;return jh(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(wy(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=VS(t);n<i.length;n++){var o=Ey(i[n],2),a=o[0],s=o[1];null!==s&&"object"===Xl(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return TD.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 ID.encode(e).buffer}},{key:"ab2b64str",value:(r=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Hg((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=Ug(Dg().mark((function e(t,r){return Dg().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:Gg(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 xD(){for(var e,t,r=Number(VC(e=lI(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=VC(r).call(r,28,"1").split(""),i=[];n.length;)i.push(zI(n).call(n,0,7));return $g(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return BC(r+e.join(""),2)}))}var OD,PD=function(){return Math.floor(65535*Math.random())};function ND(e){return"string"==typeof e&&kI(e).call(e,"__web__rtc__rtt__")>-1}var MD=function(){var e=Ug(Dg().mark((function e(){var t,r,n,i=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],!OD){e.next=3;break}return e.abrupt("return",OD);case 3:return(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=10,r.createOffer();case 10:return n=e.sent,r.close(),OD=n.sdp,e.abrupt("return",n.sdp);case 14:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),DD=function(e){return new Hg((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 LD(e){return Number(Math.max(-127,10*KC(Math.pow(e/255,2))).toFixed(2))}function UD(e){return(e&uh.AUDIO)===uh.AUDIO}function VD(e){return(e&uh.VIDEO)===uh.VIDEO}function FD(e){var t={};return FS(e).forEach((function(r){"object"===Xl(e[r])?t[r]=FD(e[r]):lC(r).call(r,"_")||(t[r]=e[r])})),t}function BD(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 jD(e){return void 0===e}function GD(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Gg(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 HD(e){console.warn("[RTC WebSDK]: ".concat(e))}function zD(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 KD,WD,XD,YD,qD,JD,QD,ZD,$D=function(){function e(){Gh(this,e),Jl(this,"_id",void 0),this._id=Math.ceil(Math.random()*XC)}return jh(e,[{key:"getMessageId",value:function(){return++this._id>XC&&(this._id=0),this._id}}]),e}(),eL=function(){return"undefined"==typeof window},tL=eL()?"":window.navigator.userAgent;function rL(){var e="none";return eL()||(null!==tL.match("Firefox")?e="mozilla":null!==tL.match("Chrome")?(e="chrome-stable",null!==tL.match("Electron")&&(e="electron")):(null!==tL.match("Safari")||null!==tL.match("AppleWebKit"))&&(e="safari")),e}var nL,iL="mozilla"===rL(),oL="safari"===rL(),aL="chrome-stable"===rL(),sL=!eL()&&/CriOS/i.test(tL),cL=!eL()&&/Edg\//i.test(tL),uL=!eL()&&/EdgA/i.test(tL),dL=!eL()&&/EdgiOS/i.test(tL),lL=cL||uL||dL,hL=!eL()&&/DingTalk/i.test(navigator.userAgent),pL=!eL()&&/OPR\//.test(navigator.userAgent),fL=!eL()&&(!!/(iPad)/i.exec(tL)||/Macintosh/i.test(tL)&&"ontouchend"in document),_L=!eL()&&/Macintosh/i.test(tL),vL=!eL()&&/MicroMessenger/i.test(tL),mL=!eL()&&Qy(KD=tL.toLowerCase()).call(KD,"mobile"),gL=!eL()&&!!/(iPhone|iPad|iPod)/i.exec(tL),yL=!eL()&&/Android/i.test(tL),SL=!eL()&&/Windows/i.test(tL),bL=0,EL="0",kL=!eL()&&(null===(WD=tL.match(/version\/(\d+)/i))||void 0===WD?void 0:WD[1]);oL&&kL&&(bL=Number(kL),EL=null===(nL=navigator.userAgent.match(/version\/(\d+\.\d+)/i))||void 0===nL?void 0:nL[1]);var TL=!eL()&&(null===(XD=tL.match(/Firefox\/(\d+)/i))||void 0===XD?void 0:XD[1]);iL&&TL&&(bL=Number(TL));var IL=bL,RL=bL,AL=EL,wL=null!==(YD=!eL()&&(null===(qD=tL.match(/ ([\d_]+) like Mac OS X/i))||void 0===qD||null===(JD=qD[1])||void 0===JD?void 0:$g(QD=JD.split("_")).call(QD,(function(e){return yb(e)}))))&&void 0!==YD?YD:[],CL=0,xL=!eL()&&(null===(ZD=tL.match(/Chrome\/(\d+)/i))||void 0===ZD?void 0:ZD[1]);xL&&(CL=Number(xL));var OL=CL,PL="BytePlus",NL="RTC_DEVICE_ID",ML="RTC_ACCESS_NODE",DL="RTC_ACCESS_URLS",LL="ENGINE_WEB_CONFIG",UL="SERVER_CONFIG",VL=function(){function e(){Gh(this,e)}return jh(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,Xg(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}(),FL=function(e){jA(r,e);var t=iw(r);function r(){return Gh(this,r),t.apply(this,arguments)}return jh(r,[{key:"getDeviceId",value:function(){if(eL())return"";var e=this.get(NL);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}(16)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return BM({device_id:e}),this.set(NL,e),e}},{key:"getAccessNode",value:function(e){var t;return this.get(Gg(t="".concat(ML,"_").concat(e,"-")).call(t,PL))}},{key:"setAccessNode",value:function(e,t,r){var n;return this.set(Gg(n="".concat(ML,"_").concat(e,"-")).call(n,PL),t,1e3*r)}},{key:"deleteAccessNode",value:function(e,t){var r,n=this.getAccessNode(e),i=this.getTtl(Gg(r="".concat(ML,"_").concat(e,"-")).call(r,PL));Array.isArray(n)&&n.length>0&&((n=wy(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;if(e)this.delete(Gg(t="".concat(ML,"_").concat(e,"-")).call(t,PL));else for(var r in localStorage)lC(r).call(r,ML)&&localStorage.removeItem(r)}},{key:"getAccessUrls",value:function(){return this.get("".concat(DL,"-").concat(PL))}},{key:"setAccessUrls",value:function(e){var t=$g(e).call(e,(function(e){var t,r=e.host,n=e.path;return Gg(t="https://".concat(r)).call(t,n)}));return this.set("".concat(DL,"-").concat(PL),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(DL,"-").concat(PL))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Gg(r=Gg(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(LL);return(null==a||null===(i=dI(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=Gg(n=Gg(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(LL)||[];return(a=wy(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(LL,lI(a).call(a,-5))}}},{key:"getServerConfig",value:function(e){var t,r="".concat(e),n=this.get(UL);return(null==n||null===(t=dI(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(UL)||[];return(n=wy(n).call(n,(function(e){return e.key!==r}))).push({key:r,config:t}),this.set(UL,lI(n).call(n,-5))}}}]),r}(VL),BL=new FL,jL=new fD("JoinRoomConfig",0),GL=function(){function e(t){var r;Gh(this,e),Jl(this,"_useTcpAfterJoinTimeout",e.DEFAULT_CONF.useTcpAfterJoinTimeout),Jl(this,"_joinWithTcpOnly",e.DEFAULT_CONF.joinWithTcpOnly),Jl(this,"_joinWithTcpOnlyDelay",e.DEFAULT_CONF.joinWithTcpOnlyDelay),Jl(this,"_blackBrowserRegexList",[]),this._engineId=t,kI(r=location.search).call(r,"__rtc_tcp_only__")>-1&&(this._joinWithTcpOnly=!0,this._joinWithTcpOnlyDelay=0),this._report()}return jh(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 dI(e=this._blackBrowserRegexList).call(e,(function(e){return new RegExp(e).test(navigator.userAgent)}))}},{key:"setServerConfig",value:function(e){var t,r,n,i=!1;"boolean"==typeof(null==e||null===(t=e.use_tcp_after_join_timeout)||void 0===t?void 0:t.enable)&&(this._useTcpAfterJoinTimeout=e.use_tcp_after_join_timeout.enable,i=!0),"boolean"==typeof(null==e||null===(r=e.join_with_tcp_only)||void 0===r?void 0:r.enable)&&(this._joinWithTcpOnly=e.join_with_tcp_only.enable,i=!0),"number"==typeof(null==e||null===(n=e.join_with_tcp_only)||void 0===n?void 0:n.delay_ms)&&(this._joinWithTcpOnlyDelay=e.join_with_tcp_only.delay_ms,i=!0),e&&Array.isArray(e.black_browser_regex_list)&&(this._blackBrowserRegexList=e.black_browser_regex_list,i=!0),i&&this._report()}},{key:"toString",value:function(){return Xg({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(){jL.print("_report",this.toString()),$M(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}();Jl(GL,"DEFAULT_CONF",{useTcpAfterJoinTimeout:!0,joinWithTcpOnly:!1,joinWithTcpOnlyDelay:5e3});var HL=function(e){return e[e.NONE=0]="NONE",e}(HL||{}),zL="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function KL(){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 WL="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",XL="rtc.rtcplus.com".split(","),YL={VERSION:"4.61.4",ICE_CONFIG_REQUEST_URLS_INTERNAL:$g(zL).call(zL,KL),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:WL,CONFIG_REQUEST_DOMAINS:XL,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:GL.DEFAULT_CONF,SIGNAL_COMPRESSION:!0,SIGNAL_CROP_JOINROOM:!0,VIDEO_STALL_DATA:500,AUDIO_STALL_DATA:200,IOS_SAFARI_ORIENTATION:!1,BLACK_FRAME_LIFETIME:6e4,FALLBACK_ENCODE_CODEC:"",SEI_TIME_OUT:2e3,SEI_COUNT_FPS:1,PRE_ICE:!1,UPLOAD_REMOTE_STATS:HL.NONE,DISABLE_COMPUTE_PRESSURE:!1};function qL(e,t){var r;if(HM("setParameter",0,Gg(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("JOIN_ROOM_CONFIG"===e)return GL.setDefaulConf(t);if("ICE_CONFIG_REQUEST_URLS"===e){var n="string"==typeof t?[t]:t;return YL.ICE_CONFIG_REQUEST_URLS=$g(n).call(n,KL),BL.clearAccessUrls(),void BL.clearAccessNode()}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 i=t===vh.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===vh.domestic?WL:"string"==typeof t?t:void 0;i&&(YL.LOG_SERVER_URL=i,jM(i))}else if("OVERSEA"===e)return BM({extra_is_oversea:t?"1":"0"}),void(YL.OVERSEA=t);if("CONFIG_REQUEST_DOMAINS"===e&&Array.isArray(t)&&t.length>0)YL.CONFIG_REQUEST_DOMAINS=t;else if(!("SEI_TIME_OUT"===e&&"number"!=typeof t||"SEI_COUNT_FPS"===e&&"number"!=typeof t))if("UPLOAD_REMOTE_STATS"!==e||"string"!=typeof t){"DEVICE_ID"===e&&BL.setDeviceId(t);var o=Fx.getKeys();Qy(o).call(o,e)?Fx.setParameter(e,t):YL[e]=t}else{var a,s,c=uS(a=$g(s=t.split(",")).call(s,(function(e){return YR(e).call(e)}))).call(a,(function(e,t){return"video"===t?e|uh.VIDEO:"audio"===t?e|uh.AUDIO:e}),HL.NONE);YL.UPLOAD_REMOTE_STATS=c}}else{var u="string"==typeof t?[t]:t;YL.FORCE_ENABLED_REPORT_CALLBACKS=u}else BM({product:t});else BM({platform:t});else YL.VIDEO_STALL_100MS=nU()&&!!t;else YL.AUDIO_STALL_DATA=Math.max(200,Number(t));else YL.VIDEO_STALL_DATA=Math.max(500,Number(t))}}function JL(e){return"DEVICE_ID"===e?BL.getDeviceId():YL[e]}function QL(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)||yh.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:$g(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 ZL=[];function $L(e){ZL=e}var eU={width:640,height:480,frameRate:15,maxKbps:600},tU={width:1920,height:1080,frameRate:15,maxKbps:3e3};function rU(e,t){if("boolean"!=typeof e)throw new mC(hC.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}var nU=function(){return!mx()&&"function"==typeof HTMLVideoElement.prototype.requestVideoFrameCallback};function iU(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 mC(hC.INVALID_PARAMS,Gg(r=Gg(n="Invalid ".concat(t,": the value range is [")).call(n,i,", ")).call(r,o,"]. integer only"))}function oU(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 mC(hC.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 mC(hC.INVALID_PARAMS,Gg(r=Gg(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function aU(e,t,r){var n;if(!Qy(r).call(r,e))throw new mC(hC.INVALID_PARAMS,Gg(n="Invalid ".concat(t,": The value can only be set as ")).call(n,Xg(r)))}function sU(e){if(!(e instanceof MediaStreamTrack))throw new mC(hC.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function cU(e,t){if(lU(e))throw new mC(hC.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function uU(e,t){if(!(e instanceof ArrayBuffer))throw new mC(hC.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function dU(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=FS(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(o){}}function lU(e){return null==e}function hU(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mC(hC.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function pU(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mC(hC.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function fU(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mC(hC.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function _U(e){cU(e,"userInfo"),pU(e.userId),lU(e.extraInfo)||oU(e.extraInfo,"userInfo.extraInfo",1,200)}function vU(e){cU(e,"roomConfig"),rU(e.isAutoPublish,"roomConfig.isAutoPublish"),rU(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),rU(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),lU(e.roomProfileType)||aU(e.roomProfileType,"roomConfig",[Th.communication,Th.chat,Th.chatRoom,Th.coHost,Th.meeting,Th.classRoom])}function mU(e){cU(e,"videoPlayerOption")}function gU(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 mC(hC.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:CD.str2ab(Xg(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new mC(hC.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function yU(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new mC(hC.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function SU(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 mC(hC.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function bU(e){var t,r=by(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;iU(null==n?void 0:n.maxKbps,"maxKbps"),SU(null==n?void 0:n.width,"width"),SU(null==n?void 0:n.height,"height"),SU(null==n?void 0:n.frameRate,"frameRate")}}catch(j0){r.e(j0)}finally{r.f()}}function EU(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 iU(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var kU=r(js),TU={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?lI(n).call(n,1):n);return kU?Gg(i).call(i,kU(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}(TU);var IU=TU.exports,RU=r(IU),AU=new fD("VERTC",0),wU=function(e){jA(n,e);var t,r=iw(n);function n(){return Gh(this,n),r.apply(this,arguments)}return jh(n,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var r,i,o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return(r=FA(VA(n.prototype),"emit",this)).call.apply(r,Gg(i=[this,e]).call(i,a))}catch(B0){return AU.error("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,B0),console.error(B0),Boolean(t)}}},{key:"asyncEmit",value:(t=Ug(Dg().mark((function e(t){var r,i,o,a=this,s=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=s.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=s[o];return e.next=3,Hg.resolve().then((function(){try{var e,r;(e=FA(VA(n.prototype),"emit",a)).call.apply(e,Gg(r=[a,t]).call(r,i))}catch(B0){AU.error("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",t,B0),console.error(B0)}}));case 3:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),n}(IU.EventEmitter),CU=function(e){return e[e.BLACK=0]="BLACK",e[e.NORMAL=1]="NORMAL",e}(CU||{}),xU=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}(xU||{}),OU=function(e){return e.PushLimitWarn="PushLimitWarn",e.OTHER="OTHER",e}(OU||{}),PU=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.ON_TOKEN_PUBLISH_PRIVILEGE_WILL_EXPIRE="onTokenPublishPrivilegeWillExpire",e.ON_TOKEN_PUBLISH_PRIVILEGE_DID_EXPIRED="onTokenPublishPrivilegeDidExpired",e.ON_TOKEN_SUBSCRIBE_PRIVILEGE_WILL_EXPIRE="onTokenSubscribePrivilegeWillExpire",e.ON_TOKEN_SUBSCRIBE_PRIVILEGE_DID_EXPIRED="onTokenSubscribePrivilegeDidExpired",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}(PU||{}),NU=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(NU||{}),MU=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ON_VENDOR_CONNECTION_STATE_CHANGE="onVendorConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e.ON_RECONNECT_FAILED="onReconnectFailed",e.CONNECT_WITH_TCP="onIceConnectWithTcp",e}(MU||{}),DU=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(DU||{}),LU=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(LU||{}),UU=function(e){return e[e.NORMAL=0]="NORMAL",e[e.BLACK=1]="BLACK",e}(UU||{}),VU=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(VU||{}),FU=function(e){return e.AUDIO="audio",e.VIDEO="video",e}(FU||{}),BU=function(e){return e.MAIN="main",e.SCREEN="screen",e.PUBLIC="public",e.VIRTUAL="virtual",e}(BU||{}),jU=function(e){jA(r,e);var t=iw(r);function r(e,n){var i;return Gh(this,r),Jl(dA(i=t.call(this)),"trackId",RD()),Jl(dA(i),"trackInfo",void 0),Jl(dA(i),"_originTrack",void 0),Jl(dA(i),"_channelCount",void 0),i.trackInfo=n,i._originTrack=e,i._channelCount=e.getSettings().channelCount,i}return jh(r,[{key:"dummy",get:function(){return this.trackInfo.isDummy}},{key:"virtual",get:function(){return"virtual"===this.trackInfo.streamIndex}},{key:"isScreen",get:function(){return"screen"===this.trackInfo.streamIndex}},{key:"isPublic",get:function(){return"public"===this.trackInfo.streamIndex}},{key:"sourceType",get:function(){return this.trackInfo.sourceType}},{key:"mediaType",get:function(){return this.trackInfo.mediaType}},{key:"captureSessionId",get:function(){return this.trackInfo.captureSessionId}},{key:"streamIndex",get:function(){var e=this.trackInfo.streamIndex;return"main"===e?ch.STREAM_INDEX_MAIN:"screen"===e?ch.STREAM_INDEX_SCREEN:void 0}},{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}(wU),GU=function(e){jA(n,e);var t,r=iw(n);function n(e,t,i){var o;return Gh(this,n),Jl(dA(o=r.call(this,e,i)),"_mediaTrack",void 0),Jl(dA(o),"_preProcessingTrack",void 0),Jl(dA(o),"_extensionManager",void 0),Jl(dA(o),"isTrackReady",void 0),Jl(dA(o),"handleTrackEnded",(function(){o.emit("track-ended",dA(o)),o.destroy()})),Jl(dA(o),"handleMute",(function(){o.emit("track-mute",dA(o))})),Jl(dA(o),"handleUnmute",(function(){o.emit("track-unmute",dA(o))})),o._extensionManager=t,o._initListeners(),o.isTrackReady=o.generatePreProcessingTrack(),o}return jh(n,[{key:"mediaTrack",get:function(){var e;return null!==(e=this._mediaTrack)&&void 0!==e?e:this._originTrack},set:function(e){this.mediaTrack.id!==e.id&&(this._mediaTrack=e,this.isTrackReady=this.generatePreProcessingTrack())}},{key:"preprocessingTrack",get:function(){var e;return null!==(e=this._preProcessingTrack)&&void 0!==e?e:this.mediaTrack}},{key:"extensionManager",set:function(e){this._extensionManager=e,this.isTrackReady=this.generatePreProcessingTrack()}},{key:"generatePreProcessingTrack",value:(t=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._preProcessingTrack=void 0,e.prev=1,e.next=4,this._extensionManager.getPreProcessingTrack(this);case 4:(t=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=t),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(){return t.apply(this,arguments)})},{key:"destroy",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(),FA(VA(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}(jU),HU=function(e){jA(r,e);var t=iw(r);function r(e,n){var i;return Gh(this,r),Jl(dA(i=t.call(this,e,n)),"_mediaTrack",void 0),i._originTrack=e,i}return jh(r,[{key:"mediaTrack",get:function(){var e;return null!==(e=this._mediaTrack)&&void 0!==e?e:this._originTrack},set:function(e){this.mediaTrack.id!==e.id&&(this._mediaTrack=e)}},{key:"preprocessingTrack",get:function(){return this.mediaTrack}}]),r}(jU),zU=i;wr({global:!0,forced:zU.globalThis!==zU},{globalThis:zU});var KU=r(i),WU=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!eL()&&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,tV();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,eV();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)}}(),XU=function(){var e=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.next=3,tV();case 3:if(e.t0=e.sent,!e.t0){e.next=8;break}return e.next=7,eV();case 7:e.t0=e.sent;case 8:if(!e.t0){e.next=10;break}t.push("H264");case 10:return e.next=12,nV();case 12:if(e.t1=e.sent,!e.t1){e.next=17;break}return e.next=16,rV();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)}}(),YU=function(){var e=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,XU();case 2:return t=e.sent,e.abrupt("return",$g(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),qU={};function JU(e){var t,r=!1,n=by(e.split("\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value;if(Qy(i).call(i,"level-asymmetry-allowed=1")&&Qy(i).call(i,"packetization-mode=1")&&Qy(i).call(i,"profile-level-id=42e0")){r=!0;break}}}catch(j0){n.e(j0)}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 QU=function(){var e=Ug(Dg().mark((function e(t){var r,n;return Dg().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)}}(),ZU=function(){var e=Ug(Dg().mark((function e(){var t,r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,QU("sendonly");case 2:if(r=e.sent,!Qy(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,QU("sendonly");case 6:r=e.sent;case 7:return qU.h264encode=JU(r),qU.vp8encode=kI(r).call(r,"vp8")>-1,e.abrupt("return",qU);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),$U=function(){var e=Ug(Dg().mark((function e(){var t,r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,QU("recvonly");case 2:if(r=e.sent,!Qy(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,QU("recvonly");case 6:r=e.sent;case 7:return qU.h264decode=JU(r),qU.vp8decode=kI(r).call(r,"vp8")>-1,e.abrupt("return",qU);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),eV=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==qU.h264encode){e.next=9;break}return e.prev=1,e.next=4,ZU();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",qU.h264encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),tV=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==qU.h264decode){e.next=9;break}return e.prev=1,e.next=4,$U();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",qU.h264decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),rV=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==qU.vp8encode){e.next=9;break}return e.prev=1,e.next=4,ZU();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",qU.vp8encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),nV=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==qU.vp8decode){e.next=9;break}return e.prev=1,e.next=4,$U();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",qU.vp8decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),iV=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},oV=function(){return _L?aL&&OL>=70||iL&&RL>=80||oL&&IL>=14:SL?aL&&OL>=70||iL&&RL>=80:gL?wL[0]>=14:!!yL&&(aL&&OL>=86)},aV=aL&&OL<=114,sV=!iL||RL>=96,cV=!(oL&&IL<=14),uV=yL&&aL||gL&&(17===wL[0]||16===wL[0]),dV=void 0!==KU&&"PressureObserver"in KU,lV="undefined"!=typeof window&&window.Worker,hV={getNalunits:function(e){if(e.length-e.position<4)return[];var t=e.position;return 1===e.getInt32(t)||0===e.getInt16(t)&&1===e.getInt8(t+2)?hV.getAnnexbNals(e):hV.getAvccNals(e)},getAnnexbNals:function(e){for(var t=[],r=hV.getHeaderPositionAnnexB(e),n=r.pos,i=n;n<e.length-4;){var o,a,s=new Uint8Array(lI(o=e.buffer).call(o,n,n+r.headerLength));r.pos===e.position&&e.skip(r.headerLength),i=(r=hV.getHeaderPositionAnnexB(e)).pos;var c={header:s,body:new Uint8Array(lI(a=e.buffer).call(a,n+s.byteLength,i)),type:-1};hV.analyseNal(c),c.type<=9&&0!==c.type&&t.push(c),e.skip(i-e.position),n=i}return t},getAvccNals:function(e){for(var t=[];e.position<e.length-4;){var r=e.getInt32(e.position);if(!(e.length-e.position>=r))break;var n,i,o=new Uint8Array(lI(n=e.buffer).call(n,e.position,e.position+4));e.skip(4);var a=new Uint8Array(lI(i=e.buffer).call(i,e.position,e.position+r));e.skip(r);var s={header:o,body:a,type:-1};hV.analyseNal(s),s.type<=9&&0!==s.type&&t.push(s)}return t},analyseNal:function(e){var t=31&e.body[0];switch(e.type=t,t){case 1:e.ndr=!0;break;case 5:e.idr=!0;break;case 6:e.sei=!0;break;case 7:e.sps=!0;break;case 8:e.pps=!0}},getHeaderPositionAnnexB:function(e){for(var t=e.position,r=0,n=e.length;3!==r&&4!==r&&t<n-4;)0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:1===e.getInt8(t+2)?r=3:t++:t++;return t===n-4&&(0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:t=n:(t++,0===e.getInt16(t)&&1===e.getInt8(t)?r=3:t=n)),{pos:t,headerLength:r}}},pV=function(){function e(t){Gh(this,e),Jl(this,"_position",0),Jl(this,"_dataview",void 0),this._dataview=new DataView(t)}return jh(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}(),fV=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(fV||{}),_V=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),vV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]);function mV(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function gV(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 yV=function(){function e(){Gh(this,e)}return jh(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?_V:vV,s=mV(e.byteLength+a.byteLength),c=function(e){var t,r=[],n=0,i=by(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(j0){i.e(j0)}finally{i.f()}return new Uint8Array(r)}(e);return new Uint8Array(Gg(t=[]).call(t,iR(n),iR(i),iR(o),iR(s),iR(a),iR(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=lI(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=Ey(gV(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=vV.byteLength&&i>=vV.byteLength&&lI(t).call(t,r,r+vV.byteLength).toString()===vV.toString()?(r+=vV.byteLength,o=1):t.byteLength>=vV.byteLength&&i>=vV.byteLength&&lI(t).call(t,r,r+_V.byteLength).toString()===_V.toString()&&(r+=_V.byteLength,o=0),{type:o,payload:lI(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new hT,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=Ey(gV(e.payload,r),2),i=n[0];r=n[1];var o,a=Ey(gV(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,lI(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=by(e);try{for(n.s();!(t=n.n()).done;){var i=Ey(t.value,2),o=i[0],a=i[1],s=mV(o),c=mV(a.byteLength);r.push(s,c,a)}}catch(j0){n.e(j0)}finally{n.f()}var u=uS(r).call(r,(function(e,t){return e+t.byteLength}),0),d=new Uint8Array(u);return uS(r).call(r,(function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),SV=o,bV=ht("iterator"),EV=!SV((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[bV]||"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})),kV=wr,TV=i,IV=P,RV=v,AV=C,wV=EV,CV=fi,xV=vi,OV=uE,PV=Bi,NV=uu,MV=ro,DV=Rf,LV=A,UV=Ze,VV=Jt,FV=mn,BV=rr,jV=ee,GV=Sn,HV=Wn,zV=F,KV=xp,WV=kp,XV=Uf,YV=dw,qV=ht("iterator"),JV="URLSearchParams",QV=JV+"Iterator",ZV=MV.set,$V=MV.getterFor(JV),eF=MV.getterFor(QV),tF=Object.getOwnPropertyDescriptor,rF=function(e){if(!AV)return TV[e];var t=tF(TV,e);return t&&t.value},nF=rF("fetch"),iF=rF("Request"),oF=rF("Headers"),aF=iF&&iF.prototype,sF=oF&&oF.prototype,cF=TV.RegExp,uF=TV.TypeError,dF=TV.decodeURIComponent,lF=TV.encodeURIComponent,hF=RV("".charAt),pF=RV([].join),fF=RV([].push),_F=RV("".replace),vF=RV([].shift),mF=RV([].splice),gF=RV("".split),yF=RV("".slice),SF=/\+/g,bF=Array(4),EF=function(e){return bF[e-1]||(bF[e-1]=cF("((?:%[\\da-f]{2}){"+e+"})","gi"))},kF=function(e){try{return dF(e)}catch(B0){return e}},TF=function(e){var t=_F(e,SF," "),r=4;try{return dF(t)}catch(B0){for(;r;)t=_F(t,EF(r--),kF);return t}},IF=/[!'()~]|%20/g,RF={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},AF=function(e){return RF[e]},wF=function(e){return _F(lF(e),IF,AF)},CF=NV((function(e,t){ZV(this,{type:QV,iterator:KV($V(e).entries),kind:t})}),"Iterator",(function(){var e=eF(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),xF=function(e){this.entries=[],this.url=null,void 0!==e&&(jV(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===hF(e,0)?yF(e,1):e:GV(e)))};xF.prototype={type:JV,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=WV(e);if(c)for(r=(t=KV(e,c)).next;!(n=IV(r,t)).done;){if(o=(i=KV(BV(n.value))).next,(a=IV(o,i)).done||(s=IV(o,i)).done||!IV(o,i).done)throw uF("Expected sequence with length 2");fF(this.entries,{key:GV(a.value),value:GV(s.value)})}else for(var u in e)UV(e,u)&&fF(this.entries,{key:u,value:GV(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=gF(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=gF(t,"="),fF(this.entries,{key:TF(vF(r)),value:TF(pF(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],fF(r,wF(e.key)+"="+wF(e.value));return pF(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var OF=function(){DV(this,PF);var e=ZV(this,new xF(arguments.length>0?arguments[0]:void 0));AV||(this.size=e.entries.length)},PF=OF.prototype;if(OV(PF,{append:function(e,t){var r=$V(this);XV(arguments.length,2),fF(r.entries,{key:GV(e),value:GV(t)}),AV||this.length++,r.updateURL()},delete:function(e){for(var t=$V(this),r=XV(arguments.length,1),n=t.entries,i=GV(e),o=r<2?void 0:arguments[1],a=void 0===o?o:GV(o),s=0;s<n.length;){var c=n[s];if(c.key!==i||void 0!==a&&c.value!==a)s++;else if(mF(n,s,1),void 0!==a)break}AV||(this.size=n.length),t.updateURL()},get:function(e){var t=$V(this).entries;XV(arguments.length,1);for(var r=GV(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){var t=$V(this).entries;XV(arguments.length,1);for(var r=GV(e),n=[],i=0;i<t.length;i++)t[i].key===r&&fF(n,t[i].value);return n},has:function(e){for(var t=$V(this).entries,r=XV(arguments.length,1),n=GV(e),i=r<2?void 0:arguments[1],o=void 0===i?i:GV(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=$V(this);XV(arguments.length,1);for(var n,i=r.entries,o=!1,a=GV(e),s=GV(t),c=0;c<i.length;c++)(n=i[c]).key===a&&(o?mF(i,c--,1):(o=!0,n.value=s));o||fF(i,{key:a,value:s}),AV||(this.size=i.length),r.updateURL()},sort:function(){var e=$V(this);YV(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=$V(this).entries,n=VV(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 CF(this,"keys")},values:function(){return new CF(this,"values")},entries:function(){return new CF(this,"entries")}},{enumerable:!0}),CV(PF,qV,PF.entries,{name:"entries"}),CV(PF,"toString",(function(){return $V(this).serialize()}),{enumerable:!0}),AV&&xV(PF,"size",{get:function(){return $V(this).entries.length},configurable:!0,enumerable:!0}),PV(OF,JV),kV({global:!0,constructor:!0,forced:!wV},{URLSearchParams:OF}),!wV&&LV(oF)){var NF=RV(sF.has),MF=RV(sF.set),DF=function(e){if(jV(e)){var t,r=e.body;if(FV(r)===JV)return t=e.headers?new oF(e.headers):new oF,NF(t,"content-type")||MF(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),HV(e,{body:zV(0,GV(r)),headers:zV(0,t)})}return e};if(LV(nF)&&kV({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return nF(e,arguments.length>1?DF(arguments[1]):{})}}),LV(iF)){var LF=function(e){return DV(this,aF),new iF(e,arguments.length>1?DF(arguments[1]):{})};aF.constructor=LF,LF.prototype=aF,kV({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:LF})}}var UF,VF={URLSearchParams:OF,getState:$V},FF=v,BF=2147483647,jF=/[^\0-\u007E]/,GF=/[.\u3002\uFF0E\uFF61]/g,HF="Overflow: input needs wider integers to process",zF=RangeError,KF=FF(GF.exec),WF=Math.floor,XF=String.fromCharCode,YF=FF("".charCodeAt),qF=FF([].join),JF=FF([].push),QF=FF("".replace),ZF=FF("".split),$F=FF("".toLowerCase),eB=function(e){return e+22+75*(e<26)},tB=function(e,t,r){var n=0;for(e=r?WF(e/700):e>>1,e+=WF(e/t);e>455;)e=WF(e/35),n+=36;return WF(n+36*e/(e+38))},rB=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=YF(e,r++);if(i>=55296&&i<=56319&&r<n){var o=YF(e,r++);56320==(64512&o)?JF(t,((1023&i)<<10)+(1023&o)+65536):(JF(t,i),r--)}else JF(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&&JF(t,XF(n));var c=t.length,u=c;for(c&&JF(t,"-");u<i;){var d=BF;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=u+1;if(d-o>WF((BF-a)/l))throw zF(HF);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>BF)throw zF(HF);if(n===o){for(var h=a,p=36;;){var f=p<=s?1:p>=s+26?26:p-s;if(h<f)break;var _=h-f,v=36-f;JF(t,XF(eB(f+_%v))),h=WF(_/v),p+=36}JF(t,XF(eB(h))),s=tB(a,l,u===c),a=0,u++}}a++,o++}return qF(t,"")},nB=wr,iB=C,oB=EV,aB=i,sB=Jt,cB=v,uB=fi,dB=vi,lB=Rf,hB=Ze,pB=RT,fB=_y,_B=ai,vB=Ul.codeAt,mB=function(e){var t,r,n=[],i=ZF(QF($F(e),GF,"."),".");for(t=0;t<i.length;t++)r=i[t],JF(n,KF(jF,r)?"xn--"+rB(r):r);return qF(n,".")},gB=Sn,yB=Bi,SB=Uf,bB=VF,EB=ro,kB=EB.set,TB=EB.getterFor("URL"),IB=bB.URLSearchParams,RB=bB.getState,AB=aB.URL,wB=aB.TypeError,CB=aB.parseInt,xB=Math.floor,OB=Math.pow,PB=cB("".charAt),NB=cB(/./.exec),MB=cB([].join),DB=cB(1..toString),LB=cB([].pop),UB=cB([].push),VB=cB("".replace),FB=cB([].shift),BB=cB("".split),jB=cB("".slice),GB=cB("".toLowerCase),HB=cB([].unshift),zB="Invalid scheme",KB="Invalid host",WB="Invalid port",XB=/[a-z]/i,YB=/[\d+-.a-z]/i,qB=/\d/,JB=/^0x/i,QB=/^[0-7]+$/,ZB=/^\d+$/,$B=/^[\da-f]+$/i,ej=/[\0\t\n\r #%/:<>?@[\\\]^|]/,tj=/[\0\t\n\r #/:<>?@[\\\]^|]/,rj=/^[\u0000-\u0020]+/,nj=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,ij=/[\t\n\r]/g,oj=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)HB(t,e%256),e=xB(e/256);return MB(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+=DB(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},aj={},sj=pB({},aj,{" ":1,'"':1,"<":1,">":1,"`":1}),cj=pB({},sj,{"#":1,"?":1,"{":1,"}":1}),uj=pB({},cj,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),dj=function(e,t){var r=vB(e,0);return r>32&&r<127&&!hB(t,e)?e:encodeURIComponent(e)},lj={ftp:21,file:null,http:80,https:443,ws:80,wss:443},hj=function(e,t){var r;return 2===e.length&&NB(XB,PB(e,0))&&(":"===(r=PB(e,1))||!t&&"|"===r)},pj=function(e){var t;return e.length>1&&hj(jB(e,0,2))&&(2===e.length||"/"===(t=PB(e,2))||"\\"===t||"?"===t||"#"===t)},fj=function(e){return"."===e||"%2e"===GB(e)},_j={},vj={},mj={},gj={},yj={},Sj={},bj={},Ej={},kj={},Tj={},Ij={},Rj={},Aj={},wj={},Cj={},xj={},Oj={},Pj={},Nj={},Mj={},Dj={},Lj=function(e,t,r){var n,i,o,a=gB(e);if(t){if(i=this.parse(a))throw wB(i);this.searchParams=null}else{if(void 0!==r&&(n=new Lj(r,!0)),i=this.parse(a,null,n))throw wB(i);(o=RB(new IB)).bindURL(this),this.searchParams=o}};Lj.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||_j,d=0,l="",h=!1,p=!1,f=!1;for(e=gB(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=VB(e,rj,""),e=VB(e,nj,"$1")),e=VB(e,ij,""),n=fB(e);d<=n.length;){switch(i=n[d],u){case _j:if(!i||!NB(XB,i)){if(t)return zB;u=mj;continue}l+=GB(i),u=vj;break;case vj:if(i&&(NB(YB,i)||"+"===i||"-"===i||"."===i))l+=GB(i);else{if(":"!==i){if(t)return zB;l="",u=mj,d=0;continue}if(t&&(c.isSpecial()!==hB(lj,l)||"file"===l&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=l,t)return void(c.isSpecial()&&lj[c.scheme]===c.port&&(c.port=null));l="","file"===c.scheme?u=wj:c.isSpecial()&&r&&r.scheme===c.scheme?u=gj:c.isSpecial()?u=Ej:"/"===n[d+1]?(u=yj,d++):(c.cannotBeABaseURL=!0,UB(c.path,""),u=Nj)}break;case mj:if(!r||r.cannotBeABaseURL&&"#"!==i)return zB;if(r.cannotBeABaseURL&&"#"===i){c.scheme=r.scheme,c.path=_B(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=Dj;break}u="file"===r.scheme?wj:Sj;continue;case gj:if("/"!==i||"/"!==n[d+1]){u=Sj;continue}u=kj,d++;break;case yj:if("/"===i){u=Tj;break}u=Pj;continue;case Sj:if(c.scheme=r.scheme,i===UF)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=_B(r.path),c.query=r.query;else if("/"===i||"\\"===i&&c.isSpecial())u=bj;else if("?"===i)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=_B(r.path),c.query="",u=Mj;else{if("#"!==i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=_B(r.path),c.path.length--,u=Pj;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=_B(r.path),c.query=r.query,c.fragment="",u=Dj}break;case bj:if(!c.isSpecial()||"/"!==i&&"\\"!==i){if("/"!==i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=Pj;continue}u=Tj}else u=kj;break;case Ej:if(u=kj,"/"!==i||"/"!==PB(l,d+1))continue;d++;break;case kj:if("/"!==i&&"\\"!==i){u=Tj;continue}break;case Tj:if("@"===i){h&&(l="%40"+l),h=!0,o=fB(l);for(var _=0;_<o.length;_++){var v=o[_];if(":"!==v||f){var m=dj(v,uj);f?c.password+=m:c.username+=m}else f=!0}l=""}else if(i===UF||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(h&&""===l)return"Invalid authority";d-=fB(l).length+1,l="",u=Ij}else l+=i;break;case Ij:case Rj:if(t&&"file"===c.scheme){u=xj;continue}if(":"!==i||p){if(i===UF||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(c.isSpecial()&&""===l)return KB;if(t&&""===l&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(l))return a;if(l="",u=Oj,t)return;continue}"["===i?p=!0:"]"===i&&(p=!1),l+=i}else{if(""===l)return KB;if(a=c.parseHost(l))return a;if(l="",u=Aj,t===Rj)return}break;case Aj:if(!NB(qB,i)){if(i===UF||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()||t){if(""!==l){var g=CB(l,10);if(g>65535)return WB;c.port=c.isSpecial()&&g===lj[c.scheme]?null:g,l=""}if(t)return;u=Oj;continue}return WB}l+=i;break;case wj:if(c.scheme="file","/"===i||"\\"===i)u=Cj;else{if(!r||"file"!==r.scheme){u=Pj;continue}switch(i){case UF:c.host=r.host,c.path=_B(r.path),c.query=r.query;break;case"?":c.host=r.host,c.path=_B(r.path),c.query="",u=Mj;break;case"#":c.host=r.host,c.path=_B(r.path),c.query=r.query,c.fragment="",u=Dj;break;default:pj(MB(_B(n,d),""))||(c.host=r.host,c.path=_B(r.path),c.shortenPath()),u=Pj;continue}}break;case Cj:if("/"===i||"\\"===i){u=xj;break}r&&"file"===r.scheme&&!pj(MB(_B(n,d),""))&&(hj(r.path[0],!0)?UB(c.path,r.path[0]):c.host=r.host),u=Pj;continue;case xj:if(i===UF||"/"===i||"\\"===i||"?"===i||"#"===i){if(!t&&hj(l))u=Pj;else if(""===l){if(c.host="",t)return;u=Oj}else{if(a=c.parseHost(l))return a;if("localhost"===c.host&&(c.host=""),t)return;l="",u=Oj}continue}l+=i;break;case Oj:if(c.isSpecial()){if(u=Pj,"/"!==i&&"\\"!==i)continue}else if(t||"?"!==i)if(t||"#"!==i){if(i!==UF&&(u=Pj,"/"!==i))continue}else c.fragment="",u=Dj;else c.query="",u=Mj;break;case Pj:if(i===UF||"/"===i||"\\"===i&&c.isSpecial()||!t&&("?"===i||"#"===i)){if(".."===(s=GB(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"===i||"\\"===i&&c.isSpecial()||UB(c.path,"")):fj(l)?"/"===i||"\\"===i&&c.isSpecial()||UB(c.path,""):("file"===c.scheme&&!c.path.length&&hj(l)&&(c.host&&(c.host=""),l=PB(l,0)+":"),UB(c.path,l)),l="","file"===c.scheme&&(i===UF||"?"===i||"#"===i))for(;c.path.length>1&&""===c.path[0];)FB(c.path);"?"===i?(c.query="",u=Mj):"#"===i&&(c.fragment="",u=Dj)}else l+=dj(i,cj);break;case Nj:"?"===i?(c.query="",u=Mj):"#"===i?(c.fragment="",u=Dj):i!==UF&&(c.path[0]+=dj(i,aj));break;case Mj:t||"#"!==i?i!==UF&&("'"===i&&c.isSpecial()?c.query+="%27":c.query+="#"===i?"%23":dj(i,aj)):(c.fragment="",u=Dj);break;case Dj:i!==UF&&(c.fragment+=dj(i,sj))}d++}},parseHost:function(e){var t,r,n;if("["===PB(e,0)){if("]"!==PB(e,e.length-1))return KB;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 PB(e,l)};if(":"===h()){if(":"!==PB(e,1))return;l+=2,d=++u}for(;h();){if(8===u)return;if(":"!==h()){for(t=r=0;r<4&&NB($B,h());)t=16*t+CB(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(!NB(qB,h()))return;for(;NB(qB,h());){if(o=CB(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}(jB(e,1,-1)),!t)return KB;this.host=t}else if(this.isSpecial()){if(e=mB(e),NB(ej,e))return KB;if(t=function(e){var t,r,n,i,o,a,s,c=BB(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"===PB(i,0)&&(o=NB(JB,i)?16:8,i=jB(i,8===o?1:2)),""===i)a=0;else{if(!NB(10===o?ZB:8===o?QB:$B,i))return e;a=CB(i,o)}UB(r,a)}for(n=0;n<t;n++)if(a=r[n],n===t-1){if(a>=OB(256,5-t))return null}else if(a>255)return null;for(s=LB(r),n=0;n<r.length;n++)s+=r[n]*OB(256,3-n);return s}(e),null===t)return KB;this.host=t}else{if(NB(tj,e))return KB;for(t="",r=fB(e),n=0;n<r.length;n++)t+=dj(r[n],aj);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return hB(lj,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&hj(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+=oj(i),null!==o&&(u+=":"+o)):"file"===t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+MB(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw wB(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new Uj(e.path[0]).origin}catch(B0){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+oj(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(gB(e)+":",_j)},getUsername:function(){return this.username},setUsername:function(e){var t=fB(gB(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=dj(t[r],uj)}},getPassword:function(){return this.password},setPassword:function(e){var t=fB(gB(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=dj(t[r],uj)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?oj(e):oj(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Ij)},getHostname:function(){var e=this.host;return null===e?"":oj(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Rj)},getPort:function(){var e=this.port;return null===e?"":gB(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=gB(e))?this.port=null:this.parse(e,Aj))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+MB(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Oj))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=gB(e))?this.query=null:("?"===PB(e,0)&&(e=jB(e,1)),this.query="",this.parse(e,Mj)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=gB(e))?("#"===PB(e,0)&&(e=jB(e,1)),this.fragment="",this.parse(e,Dj)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Uj=function(e){var t=lB(this,Vj),r=SB(arguments.length,1)>1?arguments[1]:void 0,n=kB(t,new Lj(e,!1,r));iB||(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())},Vj=Uj.prototype,Fj=function(e,t){return{get:function(){return TB(this)[e]()},set:t&&function(e){return TB(this)[t](e)},configurable:!0,enumerable:!0}};if(iB&&(dB(Vj,"href",Fj("serialize","setHref")),dB(Vj,"origin",Fj("getOrigin")),dB(Vj,"protocol",Fj("getProtocol","setProtocol")),dB(Vj,"username",Fj("getUsername","setUsername")),dB(Vj,"password",Fj("getPassword","setPassword")),dB(Vj,"host",Fj("getHost","setHost")),dB(Vj,"hostname",Fj("getHostname","setHostname")),dB(Vj,"port",Fj("getPort","setPort")),dB(Vj,"pathname",Fj("getPathname","setPathname")),dB(Vj,"search",Fj("getSearch","setSearch")),dB(Vj,"searchParams",Fj("getSearchParams")),dB(Vj,"hash",Fj("getHash","setHash"))),uB(Vj,"toJSON",(function(){return TB(this).serialize()}),{enumerable:!0}),uB(Vj,"toString",(function(){return TB(this).serialize()}),{enumerable:!0}),AB){var Bj=AB.createObjectURL,jj=AB.revokeObjectURL;Bj&&uB(Uj,"createObjectURL",sB(Bj,AB)),jj&&uB(Uj,"revokeObjectURL",sB(jj,AB))}yB(Uj,"URL"),nB({global:!0,constructor:!0,forced:!oB,sham:!iB},{URL:Uj});var Gj=wr,Hj=o,zj=Uf,Kj=Sn,Wj=EV,Xj=ae("URL");Gj({target:"URL",stat:!0,forced:!(Wj&&Hj((function(){Xj.canParse()})))},{canParse:function(e){var t=zj(arguments.length,1),r=Kj(e),n=t<2||void 0===arguments[1]?void 0:Kj(arguments[1]);try{return!!new Xj(r,n)}catch(B0){return!1}}});var Yj,qj,Jj=r(te.URL),Qj="undefined"!=typeof window&&(Qy(Yj=window.location.search).call(Yj,"_rtc_debug_")||(null===(qj=window.localStorage)||void 0===qj?void 0:qj.getItem("_rtc_debug_")));function Zj(e){var t=PressureObserver.supportedSources,r="thermal";r=null!=t&&Qy(t).call(t,"thermal")?"thermal":"cpu";var n=new PressureObserver((function(t){t.forEach((function(t){t.source===r&&e(t.state)}))}));return n.observe(r,{sampleInterval:2e3}),n}var $j=new(function(){function e(){Gh(this,e),Jl(this,"_state",void 0),Jl(this,"_handler",!1)}return jh(e,[{key:"init",value:function(){var e=this;if(dV||!JL("DISABLE_COMPUTE_PRESSURE"))try{if(lV){var t=new Blob(["(".concat(Zj.toString(),")(self.postMessage)")],{type:"text/javascript"}),r=new Worker(Jj.createObjectURL(t));r.onmessage=function(t){e._state=t.data},this._handler=r}else this._handler=Zj((function(t){e._state=t}))}catch(n){}}},{key:"state",get:function(){return Qj&&!mx()&&(window.thermal_status=this._state),this._handler||this.init(),this._state}}]),e}()),eG=function(){function e(t){Gh(this,e),Jl(this,"_timer",void 0),Jl(this,"handler",void 0),Jl(this,"_monitor",void 0),Jl(this,"logger",void 0),Jl(this,"_destroyed",!1),this._context=t,this._monitor=YM(t.id),this.logger=new fD("Stats",3,t.id)}return jh(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,$M(this._context.id,"del_media_statistics_timer",Gg(t="reason: ".concat(e,", stack: ")).call(t,(new Error).stack),0,this._stream.streamId||""))}},{key:"filterIllegal",value:function(e){var t={};return FS(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"),$M(this._context.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.stopReport("destroy"),this._destroyed=!0}}]),e}(),tG=function(e){jA(i,e);var t,r,n=iw(i);function i(e,t){var r;return Gh(this,i),(r=n.call(this,e))._stream=t,r}return jh(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=Ug(Dg().mark((function e(){var t,r,n,i,c,u,d;return Dg().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=Ug(Dg().mark((function t(){var r;return Dg().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=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c={},u={timestamp:Date.now()},d=this._stream,l=d.streamId,h=d.audioMid,p=d.isScreen,f=d.pubAttributes,_=d.pubAudio,v=d.audioTrack,m={media_type:"audio",is_screen:!!p,direction:"up",stream_id:l,vid:h,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:f.localaudio?"capture_state_on":"capture_state_off",mute_state:_?"mute_state_off":"mute_state_on",thermal_status:$j.state},v&&(m.playback_volume=v.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",c);case 7:return e.next=9,null===(i=this._context.peerConnection)||void 0===i?void 0:i.getStatsWithLowFrequency(t,!1,null===(o=this._stream.audioTransceiver)||void 0===o?void 0:o.sender);case 9:if((g=e.sent).length){e.next=12;break}return e.abrupt("return",c);case 12:if(g.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,o=e.clockRate,a=e.roundTripTime,s=e.channels,d=e.audioLevel,l=e.mimeType,h=e.availableIncomingBitrate,p=e.availableOutgoingBitrate,f=e.bytesReceived,_=e.nominated,v=e.id,g=e.currentRoundTripTime,y=e.state,S=e.writable,b=e.requestsReceived,E=e.responsesReceived,k=e.requestsSent,T=e.consentRequestsSent,I=e.responsesSent,R=e.jitter,A=e.candidateType,w=e.ip,C=e.address,x=e.networkType,O=e.port,P=e.protocol,N=e.nackCount,M=e.retransmittedBytesSent,D=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(u.packetsSent=r,u.bytesSent=i,m.bytes=i,m.packetsSent=r,m.nackCount=N,m.ssrc=U,m.retransmitted_bytes_sent=M,m.retransmitted_packets_sent=D,u.retransmittedBytesSent=M,u.retransmittedPacketsSent=D):"remote-inbound-rtp"===t?(u.packetsLost=n,m.packetsLost=n,m.net_jitter=1e3*R,c.rtt=1e3*a,m.rtt=c.rtt,c._fractionLost=j||0):"codec"===t?(c.recordSampleRate=o,c.numChannels=s,m.codecName=l):"media-source"===t&&void 0!==d?(m.audio_level=d?-10*KC(Math.pow(d,2)):d,m.volume=255*d,m.total_audio_energy=V,m.totalInputDuration=F):"ssrc"===t&&"audio"===B?m.send_level=L:"candidate-pair"===t?(m.ice_available_incoming_bitrate=h,m.ice_available_outgoing_bitrate=p,m.ice_bytes_received=f,m.ice_bytes_sent=i,m.ice_nominated=Number(_),m.ice_pair_id=v,m.ice_pair_rtt=g,m.ice_pair_state=y,m.ice_pair_writable=S,m.recv_ping_requests=b,m.recv_ping_responses=E,m.sent_ping_requests_before_first_response=k,m.sent_ping_requests_total=k+(T||0),m.sent_ping_responses=I):"local-candidate"===t?(m.local_candidate_type=A,m.local_ip=w||C,m.local_network_type=x,m.local_port=O,m.protocol=P):"remote-candidate"===t&&(m.remote_candidate_type=A,m.remote_ip=w||C,m.remote_port=O);var G=JL("STATS_SCALLBACK_SUPPORT");aV&&G||"media-source"===t&&(m.send_level=d)})),void 0===m.volume&&void 0!==n&&(m.volume=n,m.audio_level=n?-10*KC(Math.pow(n/255,2)):n),(y=r.audio).timestamp){e.next=18;break}return r.audio=u,e.abrupt("return",this.filterIllegal(c));case 18:return void 0!==u.packetsLost&&(c.audioLossRate=Math.max(0,u.packetsLost-y.packetsLost)/(u.packetsSent-y.packetsSent),c.audioLossRate=Number.isNaN(c.audioLossRate)?0:c.audioLossRate,m.fraction_lost=c.audioLossRate),c.statsInterval=u.timestamp-y.timestamp,m.stats_interval=c.statsInterval,c.sendKBitrate=(u.bytesSent-y.bytesSent||0)/c.statsInterval*8,m.mediaBitratebps=Math.round(1e3*c.sendKBitrate),m.bandwidth=Math.round(m.mediaBitratebps/1024),void 0!==u.retransmittedBytesSent&&(m.retransmitBitratebps=(u.retransmittedBytesSent-y.retransmittedBytesSent||0)/c.statsInterval),r.audio=u,m.vendor_mode=this._stream.vendorCode||0,m.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",m),c._retransmittedRate=(u.retransmittedPacketsSent-y.retransmittedPacketsSent)/(u.packetsSent-y.packetsSent),void 0===c.audioLossRate&&(c.audioLossRate=c._retransmittedRate,m.fraction_lost=c.audioLossRate),c._fractionLost=Math.max(c._fractionLost,c.audioLossRate),e.abrupt("return",this.filterIllegal(c));case 33:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s={},c={timestamp:Date.now(),simulcast:{}},u=this._stream,d=u.streamId,l=u.videoMid,h=u.isScreen,p=u.pubAttributes,f=u.enableSimulcast,_=u.pubVideo,v={media_type:"video",is_screen:!!h,direction:"up",stream_id:d,vid:l,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:p.localvideo?"capture_state_on":"capture_state_off",mute_state:_?"mute_state_off":"mute_state_on",thermal_status:$j.state},t&&this.handler){e.next=6;break}return e.abrupt("return",s);case 6:return v.cap_frame_width=t.getSettings().width,v.cap_frame_height=t.getSettings().height,v.frameRateSent=t.getSettings().frameRate,s.isScreen=h,v.is_intersecting=Xg(null===(n=this._stream)||void 0===n||null===(i=n.videoTrack)||void 0===i?void 0:i.intersection),e.next=13,null===(o=this._context.peerConnection)||void 0===o?void 0:o.getStatsWithLowFrequency(t,!1,null===(a=this._stream.videoTransceiver)||void 0===a?void 0:a.sender);case 13:if((m=e.sent).length){e.next=16;break}return e.abrupt("return",s);case 16:if(g=0,m.forEach((function(e){var t=e.type,n=e.framesEncoded,i=e.packetsLost,o=e.bytesSent,a=e.framesSent,u=e.retransmittedBytesSent,d=e.totalPacketSendDelay,l=e.totalEncodeTime,h=e.firCount,p=e.targetBitrate,_=e.roundTripTime,m=e.mimeType,y=e.frameWidth,S=e.frameHeight,b=e.packetsSent,E=e.googActualEncBitrate,k=e.googAvailableReceiveBandwidth,T=e.googAvailableSendBandwidth,I=e.googAvgEncodeMs,R=e.googBucketDelay,A=e.googEncodeUsagePercent,w=e.googFrameRateInput,C=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,O=e.bytesReceived,P=e.nominated,N=e.id,M=e.currentRoundTripTime,D=e.state,L=e.writable,U=e.candidateType,V=e.ip,F=e.address,B=e.networkType,j=e.port,G=e.nackCount,H=e.pliCount,z=e.protocol,K=e.qpSum,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,fe=e.frames;"outbound-rtp"===t?(f&&(ie?c.simulcast[ie]=e:c.simulcast[g]=e,g++),c.framesEncoded=n||c.framesEncoded||0,v.key_frames_encoded=le||0,c.bytesSent=o||c.bytesSent||0,c.framesSent=a||c.framesSent,v.bytes=o||v.bytes||0,c.packetsSent=b||c.packetsSent||0,v.packetsSent=b||v.packetsSent||0,v.nackCount=G||v.nackCount||0,v.pli_count=H||v.pli_count||0,v.qp_sum=K||v.qp_sum||0,v.ssrc=Z||v.ssrc||0,v.retransmitted_packets_sent=te,c.retransmittedPacketsSent=te,c.retransmittedBytesSent=u,v.encoder_implementation=re,v.qualityLimitationReason=se,v.qualityLimitationDurations=ce,v.scalabilityMode=he,void 0!==y&&((!s.encodedFrameWidth||y>s.encodedFrameWidth)&&(s.encodedFrameWidth=y),(!s.encodedFrameHeight||S>s.encodedFrameHeight)&&(s.encodedFrameHeight=S),v.frame_size_height=S,v.frame_size_width=y)):"track"===t?(s.encodedFrameWidth=y,s.encodedFrameHeight=S,v.frame_size_height=S,v.frame_size_width=y):"remote-inbound-rtp"===t?(c.packetsLost=i,s.rtt=1e3*_,v.rtt=s.rtt,v.jitter=1e3*ne,v.packetsLost=i,s._fractionLost=oe||0):"codec"===t?(s.codecType=m,v.codecName=m):"candidate-pair"===t?(v.ice_available_incoming_bitrate=C,v.ice_available_outgoing_bitrate=x,v.ice_bytes_received=O,v.ice_bytes_sent=o,v.ice_nominated=Number(P),v.ice_pair_id=N,v.ice_pair_rtt=M,v.ice_pair_state=D,v.ice_pair_writable=L,v.recv_ping_requests=W,v.recv_ping_responses=X,v.sent_ping_requests_before_first_response=q,v.sent_ping_requests_total=q+J,v.sent_ping_responses=Q):"local-candidate"===t?(v.local_candidate_type=U,v.local_ip=V||F,v.local_network_type=B,v.local_port=j,v.protocol=z):"remote-candidate"===t?(v.remote_candidate_type=U,v.remote_ip=V||F,v.remote_port=j):"VideoBwe"===t?(v.encBitratebps=E,v.available_receive_bandwidth=k,v.available_send_bandwidth=T,v.bucket_delay=R,v.retransmitBitratebps=Y,v.targetEncBitratebps=$,v.transmit_bitrate=ee,s._sendBandWidth=Number(T)):"ssrc"===t&&(v.avg_encode_ms=I,v.encodeUsage=A,v.frame_rate_input=w,v.orignal_input_Framerate=Number(w),v.ddaptationChanges=ae,v.firsReceived=ue,v.frameRateSent=de);var _e=JL("STATS_SCALLBACK_SUPPORT");if(!aV||!_e){var ve=r.video,me=c.timestamp-ve.timestamp;if("outbound-rtp"===t){var ge=o-ve.bytesSent,ye=u-ve.retransmittedBytesSent;v.encBitratebps=Math.round(8e3*(ge-ye)/me),v.bucket_delay=d/b,v.retransmitBitratebps=Math.round(8e3*ye/me),v.targetEncBitratebps=p,v.transmit_bitrate=Math.round(1e3*(o-ve.bytesSent)*8/me),v.avg_encode_ms=1e3*l/n,v.firsReceived=h+H}else"candidate-pair"===t?(v.available_send_bandwidth=x,s._sendBandWidth=x):"media-source"===t&&(v.frame_rate_input=pe,v.orignal_input_Framerate=Number(pe),v.frame_input=fe)}})),(y=r.video).timestamp){e.next=22;break}return r.video=c,e.abrupt("return",this.filterIllegal(s));case 22:return s.statsInterval=c.timestamp-y.timestamp,v.stats_interval=s.statsInterval,S=FS(c.simulcast),f?(v.sim_enc_width=[],v.sim_enc_height=[],v.sim_enc_bps=[],v.sim_enc_framerate=[],v.sim_enc_key_frames=[],v.sim_rids=[],v.sim_enc_bandwidth=[],v.sim_sent_framerate=[],v.sim_fraction_lost=[],v.sim_keyencoded=[],v.active_sim_streams=this._context.activeSimStreams||[],v.sim_retransmittedRate=[],k=!1,jw(S).call(S,(function(e,t){return Number(e)-Number(t)})).forEach((function(e){var t=c.simulcast[e],r=t.frameWidth,n=t.frameHeight,i=t.bytesSent,o=t.framesEncoded,a=t.framesSent,u=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,h=t.qualityLimitationDurations,p=t.qualityLimitationResolutionChanges,f=t.retransmittedPacketsSent,_=t.pliCount,m=t.keyFramesEncoded;void 0!==l&&(v.sim_qualityLimitationReason||(v.sim_qualityLimitationReason=[],v.sim_qualityLimitationDurations=[],v.sim_qualityLimitationResolutionChanges=[]),v.sim_qualityLimitationReason.push(l),v.sim_qualityLimitationDurations.push(h),v.sim_qualityLimitationResolutionChanges.push(p));var g=y.simulcast[e];if(v.sim_enc_width.push(r||0),v.sim_enc_height.push(n||0),v.sim_enc_key_frames.push(m||0),g){var S=(i-g.bytesSent||0)/s.statsInterval;v.sim_enc_bps.push(Math.round(8e3*S)),v.sim_enc_bandwidth.push(Math.round(8e3*S/1024));var b=1e3*(o-g.framesEncoded)/s.statsInterval;v.sim_enc_framerate.push(Math.round(b)),v.sim_rids.push(e);var E=void 0!==a?a-g.framesSent:o-g.framesEncoded,T=1e3*E/s.statsInterval;v.sim_sent_framerate.push(Math.round(T));var I=(u-g.packetsLost)/(d-g.packetsSent);s._retransmittedRate=(f-g.retransmittedPacketsSent)/(d-g.packetsSent),I=Number.isNaN(I)?0:I,v.sim_fraction_lost.push(I),v.sim_keyencoded.push(_-g.pliCount>0),v.sim_retransmittedRate.push(s._retransmittedRate),r>0&&!k&&(s.rid=e,s.sentKBitrate=8*S,s.encoderOutputFrameRate=b,s.encodedFrameCount=E,s.sentFrameRate=T,s.videoLossRate=I,k=!0)}})),v.vendor_mode=this._stream.vendorCode||0,v.pc_session_id=null===(b=this.handler)||void 0===b?void 0:b.peerConnectionId,null===(E=this._monitor)||void 0===E||E.report("rtc_media_statistics",v)):(s.encodedFrameCount=void 0!==c.framesSent?c.framesSent-y.framesSent:c.framesEncoded-y.framesEncoded,s.sentKBitrate=(c.bytesSent-y.bytesSent||0)/s.statsInterval*8,v.bitrate=Math.round(1e3*s.sentKBitrate),v.bandwidth=Math.round(v.bitrate/1024),s.encoderOutputFrameRate=1e3*(c.framesEncoded-y.framesEncoded)/s.statsInterval,v.frame_rate_encoded=Math.round(s.encoderOutputFrameRate),s.sentFrameRate=1e3*s.encodedFrameCount/s.statsInterval,v.frame_rate_sent=Math.round(s.sentFrameRate),s.videoLossRate=Math.max(0,c.packetsLost-y.packetsLost)/(c.packetsSent-y.packetsSent),s.videoLossRate=Number.isNaN(s.videoLossRate)?0:s.videoLossRate,v.fraction_lost=s.videoLossRate,s._retransmittedRate=(c.retransmittedPacketsSent-y.retransmittedPacketsSent)/(c.packetsSent-y.packetsSent),v.vendor_mode=this._stream.vendorCode||0,v.pc_session_id=null===(T=this.handler)||void 0===T?void 0:T.peerConnectionId,null===(I=this._monitor)||void 0===I||I.report("rtc_media_statistics",v)),r.video=c,s._fractionLost=Math.max(s._fractionLost,s.videoLossRate),e.abrupt("return",this.filterIllegal(s));case 29:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(eG),rG=function(e){jA(o,e);var t,r,n,i=iw(o);function o(e,t){var r;return Gh(this,o),(r=i.call(this,e))._stream=t,r}return jh(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Dg().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=Ug(Dg().mark((function e(){var r,n,i,o,c,u,h;return Dg().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"),FA(VA(o.prototype),"stopReport",this).call(this,"unsubscribe"),this._stream.stopAudioStallObserve()}},{key:"getRemoteAudioStats",value:(r=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d={},l={},h=this._stream,p=h.streamId,f=h.userId,_=h.isScreen,v=h.audioMid,m=h.subMediaType,g=h._attributes,y=h.virtual,S=h.audioTrack,b={media_type:"audio",is_screen:!!_,direction:"down",stream_id:p,stream_user_id:f,vid:v,audio_mux:y,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:UD(m)?"mute_state_off":"mute_state_on",remote_user_capture_state:g.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:g.localaudio&&g.audiostream?"mute_state_off":"mute_state_on",thermal_status:$j.state},S&&(b.playback_volume=S.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",d);case 7:return e.next=9,null===(i=this._context.peerConnection)||void 0===i?void 0:i.getStatsWithLowFrequency(t,!1,null===(o=this._stream.audioTransceiver)||void 0===o?void 0:o.receiver);case 9:if((E=e.sent).length){e.next=12;break}return e.abrupt("return",d);case 12:if(E.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,o=e.bytesReceived,a=e.jitterBufferDelay,s=e.jitterBufferEmittedCount,c=e.clockRate,u=e.channels,h=e.totalSamplesReceived,f=e.concealedSamples,_=e.silentConcealedSamples,v=e.concealmentEvents,m=e.totalRoundTripTime,g=e.packetsDiscarded,y=e.state,S=e.currentRoundTripTime,E=e.audioLevel,k=e.totalAudioEnergy,T=e.totalSamplesDuration,R=e.mimeType,A=e.googDecodingNormal,w=e.googDecodingMuted,C=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,O=e.bytesSent,P=e.nominated,N=e.id,M=e.writable,D=e.jitter,L=e.candidateType,U=e.ip,V=e.address,F=e.networkType,B=e.port,j=e.protocol,G=e.audioOutputLevel,H=e.requestsReceived,z=e.responsesReceived,K=e.requestsSent,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)l.packetsLost=r,l.packetsReceived=i,b.packetsLost=r,b.packetsReceived=i,b.packetsDiscarded=g,b.nackCount=q,b.lastPacketReceivedTimestamp=J,b.concealmentevents=Q,l.bytesReceived=o,void 0!==a&&(d.jitterBufferDelay=a/s*1e3,b.average_jitter_buffer_delay_ms=d.jitterBufferDelay),void 0!==h&&(l.totalSamplesReceived=h,d.concealedSamples=f,l.concealedSamples=f,l.silentConcealedSamples=_,b.concealedSamples=f,d.concealmentEvents=v,b.totalSamplesReceived=h),void 0!==Z&&(b.fec_packets_received=Z,l.fecPacketsReceived=Z),b.jitter=1e3*D,b.ssrc=Y,void 0!==E&&0!==E?(b.audio_level=E?-10*KC(Math.pow(E,2)):E,b.volume=255*E):(b.volume=null!=n?n:255*E,b.audio_level=n?-10*KC(Math.pow(n/255,2)):n),void 0!==k&&(b.total_audio_energy=k),void 0!==T&&(b.totalAudioDuration=T);else if("codec"===t)d.recordSampleRate=c,u&&(d.numChannels=u),b.codecName=R;else if("candidate-pair"===t){var $,ee;b.ice_available_incoming_bitrate=C,b.ice_available_outgoing_bitrate=x,b.ice_bytes_received=o,b.ice_bytes_sent=O,b.ice_nominated=Number(P),b.ice_pair_id=N,b.ice_pair_rtt=S,b.rtt=1e3*S,b.rtt&&null!==($=I._context.streamRTT)&&void 0!==$&&null!==(ee=$[p])&&void 0!==ee&&ee.audio&&(b.total_rtt_ms=Math.round(b.rtt+I._context.streamRTT[p].audio)),b.ice_pair_state=y,b.ice_pair_writable=M,b.recv_ping_requests=H,b.recv_ping_responses=z,b.sent_ping_requests_before_first_response=K,b.sent_ping_requests_total=K+(W||0),b.sent_ping_responses=X,"succeeded"===y&&(d.rtt=1e3*S,d.total_rtt=1e3*m)}else"track"===t&&void 0!==E?(0===E&&0!==n?(b.volume=n,b.audio_level=n?-10*KC(Math.pow(n/255,2)):n):(b.audio_level=E?-10*KC(Math.pow(E,2)):E,b.volume=255*E),b.total_audio_energy=k,b.totalAudioDuration=T):"ssrc"===t?(b.decodingNormal=A,b.recvAudioLevel=G,b.decodingMuted=w):"local-candidate"===t?(b.local_candidate_type=L,b.local_ip=U||V,b.local_network_type=F,b.local_port=B,b.protocol=j):"remote-candidate"===t&&(b.remote_candidate_type=L,b.remote_ip=U||V,b.remote_port=B)})),(k=r.audio).timestamp){e.next=18;break}return l.timestamp=Date.now(),r.audio=l,e.abrupt("return",this.filterIllegal(d));case 18:if(void 0===l.concealedSamples){e.next=25;break}return b.interval_concealed_samples=l.concealedSamples-k.concealedSamples,b.interval_samples_received=l.totalSamplesReceived-k.totalSamplesReceived,b.interval_silent_concealed_samples=l.silentConcealedSamples-k.silentConcealedSamples,e.next=24,this._stream.updateAudioStallInfo(b,d,l);case 24:T=e.sent;case 25:return l.timestamp=Date.now(),d.audioLossRate=Math.max(0,l.packetsLost-k.packetsLost)/(l.packetsReceived-k.packetsReceived+(l.packetsLost-k.packetsLost)),d.audioLossRate=Number.isNaN(d.audioLossRate)?0:d.audioLossRate,b.fraction_lost=d.audioLossRate,d.statsInterval=l.timestamp-k.timestamp,b.stats_interval=d.statsInterval,d.receivedKBitrate=(l.bytesReceived-k.bytesReceived||0)/d.statsInterval*8,b.bandwidth=Math.round(1e3*d.receivedKBitrate/1024),void 0!==l.concealedSamples&&(d.receivedSampleRate=1e3*b.interval_samples_received/d.statsInterval),void 0!==l.fecPacketsReceived&&(b.fecBitratebps=(l.fecPacketsReceived-k.fecPacketsReceived||0)/d.statsInterval),b.average_jitter_buffer_delay_ms&&b.total_rtt_ms&&(d.e2eDelay=b.average_jitter_buffer_delay_ms+b.total_rtt_ms),null!==(a=this._context.streamRTT)&&void 0!==a&&null!==(s=a[p])&&void 0!==s&&s.audio&&(d.totalRtt=(b.rtt?b.rtt:0)+this._context.streamRTT[p].audio),r.audio=l,b.vendor_mode=this._stream.vendorCode||0,b.pc_session_id=null===(c=this.handler)||void 0===c?void 0:c.peerConnectionId,null===(u=this._monitor)||void 0===u||u.report("rtc_media_statistics",b,T),e.abrupt("return",this.filterIllegal(d));case 42:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d={},l={timestamp:Date.now()},h=this._stream,p=h.streamId,f=h.userId,_=h.isScreen,v=h.subMediaType,m=h._attributes,g=Zl({media_type:"video",is_screen:!!_,direction:"down",stream_id:p,stream_user_id:f,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:VD(v)?"mute_state_off":"mute_state_on",remote_user_capture_state:m.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:m.localvideo&&m.videostream?"mute_state_off":"mute_state_on",is_intersecting:Xg(null===(n=this._stream.videoTrack)||void 0===n?void 0:n.intersection()),thermal_status:$j.state},this._stream.getVideoRenderInfo()),t&&this.handler){e.next=6;break}return e.abrupt("return",d);case 6:return d.isScreen=_,e.next=9,null===(i=this._context.peerConnection)||void 0===i?void 0:i.getStatsWithLowFrequency(t,!1,null===(o=this._stream.videoTransceiver)||void 0===o?void 0:o.receiver);case 9:if((y=e.sent).length){e.next=12;break}return e.abrupt("return",d);case 12:if(y.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,i=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,s=e.framesDecoded,c=e.jitterBufferDelay,u=e.jitterBufferEmittedCount,h=e.mimeType,f=e.firCount,_=e.availableIncomingBitrate,v=e.availableOutgoingBitrate,m=e.bytesSent,y=e.nominated,S=e.id,b=e.currentRoundTripTime,E=e.state,k=e.writable,T=e.candidateType,R=e.ip,A=e.address,w=e.networkType,C=e.port,x=e.nackCount,O=e.pliCount,P=e.protocol,N=e.requestsReceived,M=e.responsesReceived,D=e.requestsSent,L=e.consentRequestsSent,U=e.responsesSent,V=e.ssrc,F=e.jitter,B=e.framesReceived,j=e.keyFramesDecoded,G=e.totalDecodeTime,H=e.decoderImplementation,z=e.lastPacketReceivedTimestamp,K=e.framesDropped;if("inbound-rtp"===t)l.packetsLost=i,g.packetsLost=i,l.packetsReceived=o,g.packetsReceived=o,l.bytesReceived=a,g.bytes=a,l.framesDecoded=s,l.totalDecodeTime=G,void 0!==c&&(l.jitterBufferDelay=c/u*1e3,g.average_jitter_buffer_delay_ms=l.jitterBufferDelay),g.fir_count=f,g.nackCount=x,l.nackCount=x,g.pli_count=O,g.ssrc=V,g.framesDropped=K,g.jitter=1e3*F,g.framesReceived=B,l.framesReceived=B,g.framesDecoded=s,g.key_frames_decoded=j,g.decoder_name=H,g.last_packet_received_timestamp=z,void 0!==n&&(d.width=n,g.frame_size_width=n,d.height=r,g.frame_size_height=r);else if("track"===t&&void 0!==n)d.width=n,g.frame_size_width=n,d.height=r,g.frame_size_height=r,void 0!==B&&(g.framesReceived=B,l.framesReceived=B);else if("codec"===t)g.codecName=h;else if("candidate-pair"===t){var W,X;g.ice_available_incoming_bitrate=_,g.ice_available_outgoing_bitrate=v,g.ice_bytes_received=a,g.ice_bytes_sent=m,g.ice_nominated=Number(y),g.ice_pair_id=S,g.ice_pair_rtt=b,g.rtt=1e3*b,g.rtt&&null!==(W=I._context.streamRTT)&&void 0!==W&&null!==(X=W[p])&&void 0!==X&&X.video&&(g.total_rtt_ms=Math.round(g.rtt+(I._context.streamRTT[p].video||0))),d.rtt=g.rtt,g.ice_pair_state=E,g.ice_pair_writable=k,g.recv_ping_requests=N,g.recv_ping_responses=M,g.sent_ping_requests_before_first_response=D,g.sent_ping_requests_total=D+(L||0),g.sent_ping_responses=U}else"local-candidate"===t?(g.local_candidate_type=T,g.local_ip=R||A,g.local_network_type=w,g.local_port=C,g.protocol=P):"remote-candidate"===t&&(g.remote_candidate_type=T,g.remote_ip=R||A,g.remote_port=C)})),(S=r.video).timestamp){e.next=17;break}return r.video=l,e.abrupt("return",this.filterIllegal(d));case 17:return b=Math.max(0,l.packetsLost-S.packetsLost),E=l.packetsReceived-S.packetsReceived,d.videoLossRate=b/(E+b),S.totalDecodeTime&&S.framesDecoded&&l.framesDecoded!==S.framesDecoded&&(k=l.totalDecodeTime-S.totalDecodeTime,T=l.framesDecoded-S.framesDecoded,g.decode_elapse_per_frame=Number((k/T*1e3).toFixed(2))),d._retransmittedRate=(l.nackCount-S.nackCount)/(E+b),d.videoLossRate=Number.isNaN(d.videoLossRate)?0:d.videoLossRate,g.fraction_lost=d.videoLossRate,d.statsInterval=l.timestamp-S.timestamp,g.stats_interval=d.statsInterval,d.receivedKBitrate=(l.bytesReceived-S.bytesReceived||0)/d.statsInterval*8,g.bitrate=Math.round(1e3*d.receivedKBitrate),g.bandwidth=Math.round(g.bitrate/1024),d.decoderOutputFrameRate=1e3*(l.framesDecoded-S.framesDecoded)/d.statsInterval,d.receivedFrameRate=1e3*(l.framesReceived-S.framesReceived)/d.statsInterval,g.frame_rate_decoded=Math.round(d.decoderOutputFrameRate),g.frame_rate_received=Math.round(d.receivedFrameRate),g.average_jitter_buffer_delay_ms&&g.total_rtt_ms&&(d.e2eDelay=g.average_jitter_buffer_delay_ms+g.total_rtt_ms),null!==(a=this._context.streamRTT)&&void 0!==a&&null!==(s=a[p])&&void 0!==s&&s.video&&(d.totalRtt=(g.rtt?g.rtt:0)+(this._context.streamRTT[p].video||0)),r.video=l,this._stream.updateVideoStallInfo(g,d),g.vendor_mode=this._stream.vendorCode||0,g.pc_session_id=null===(c=this.handler)||void 0===c?void 0:c.peerConnectionId,null===(u=this._monitor)||void 0===u||u.report("rtc_media_statistics",g),e.abrupt("return",this.filterIllegal(d));case 41:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){FA(VA(o.prototype),"destroy",this).call(this),FA(VA(o.prototype),"stopReport",this).call(this,"destroy"),this._stream.stopAudioStallObserve()}}]),o}(eG),nG=function(){function e(t,r){Gh(this,e),Jl(this,"_removeHandler",void 0),Jl(this,"_remotePauseHandler",void 0),Jl(this,"_prePts",void 0),Jl(this,"_stallList",void 0),Jl(this,"_videoInWaiting",!1),Jl(this,"_videoInWaitingCallback",!1),Jl(this,"_videoInWaiting100ms",!1),Jl(this,"_isPaused",void 0),Jl(this,"_pauseStart",0),Jl(this,"_pauseDuration",0),Jl(this,"_requestVideoFrameCallbackTimer",void 0),Jl(this,"_logger",void 0),Jl(this,"_player",void 0),Jl(this,"_recentVideoInfo",void 0),Jl(this,"_stallTimeThreshold",void 0),Jl(this,"_openVideoStall100ms",YL.VIDEO_STALL_100MS);var n=t?1500:oL||iL?550:500;this._stallTimeThreshold={report:n,callback:Math.max(YL.VIDEO_STALL_DATA,n)},this._logger=new fD("VideoStallObserver",1,r)}return jh(e,[{key:"start",value:function(e){var t=this;if(this._logger.print("start","invoke"),this._player=e,nU())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 r=function(r){return t._onVideoTimeupdate(r,e)};e.on("playback_event",r),this._removeHandler=function(){return e.off("playback_event",r)}}var n=function(e){return t._onVideoPause(e)};e.on("playback_event",n),this._remotePauseHandler=function(){return e.off("playback_event",n)}}},{key:"getRecentRenderInfo4Report",value:function(){var e=this,t={};return this._recentVideoInfo&&FS(this._recentVideoInfo).forEach((function(r){var n,i=r.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return Gg(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&&((oL||iL)&&(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=AD(),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=AD();else if("play"===e.eventName&&this._isPaused){this._isPaused=!1;var t=AD()-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}(),iG=function(){function e(t){Gh(this,e),Jl(this,"_audioStallTimer",void 0),Jl(this,"_preSample",void 0),Jl(this,"_isStallInPreCallbackEnd",!1),Jl(this,"_isStallInPreReportEnd",!1),Jl(this,"_stallList",[]),this._stream=t}var t,r;return jh(e,[{key:"start",value:function(t,r){this.stop(),YL.AUDIO_STALL&&e.interval>0&&"number"==typeof t&&"number"==typeof r&&(this._preSample={ts:AD(),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=Ug(Dg().mark((function t(){var r,n,i,o,a;return Dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={stats_count:wy(r=this._stallList).call(r,(function(e){return!!e.get_stats_cost})).length,stall_list:iR(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=oG(this._stallList,2,this._isStallInPreReportEnd),this._isStallInPreReportEnd=i.isStallInEnd,o=YL.AUDIO_STALL_DATA/e.interval,a=oG(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=Ug(Dg().mark((function n(){return Dg().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=Ug(Dg().mark((function t(){var r,n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R;return Dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._preSample&&!(AD()-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=AD(),this._stallList.push({reason:u?Gg(l="virtual: ".concat(o,", virtualOccupy: ")).call(l,a):Gg(d="hasAudio: ".concat(n,", subAudio: ")).call(d,i)}),t.next=29;break;case 13:return h=AD(),_=0,t.prev=15,t.next=18,null===(v=this._stream.audioTransceiver)||void 0===v?void 0:v.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),f=t.t0.message||Xg(t.t0);case 25:g=AD(),y=AD(),S=y-this._preSample.ts,p?(E=(b=p).concealedSamples,k=b.totalSamplesReceived,T=E-this._preSample.concealedSamples,I=k-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=E,this._preSample.totalSamplesReceived=k,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:_?f||"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}();Jl(iG,"interval",100),Jl(iG,"ratio",.6);var oG=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;lI(e).call(e,s+1,l+1).forEach((function(e){e.is_stall&&(h+=e.diff||0)})),(d=a+h>iG.interval*t*iG.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},aG=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(aG||{}),sG=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}(sG||{}),cG=function(){function e(t){Gh(this,e),Jl(this,"_plugins",new hT),this.id=t}var t;return jh(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(Jw(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 dI(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=Ug(Dg().mark((function e(t){var r,n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.mediaTrack,i=by(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}(),uG=new fD("InternalEventBus",1),dG=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}(dG||{}),lG=function(e){jA(r,e);var t=iw(r);function r(){return Gh(this,r),t.apply(this,arguments)}return jh(r,[{key:"emit",value:function(e){var t,n;uG.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=FA(VA(r.prototype),"emit",this)).call.apply(t,Gg(n=[this,e]).call(n,o))}}]),r}(IU.EventEmitter),hG=new lG,pG=new fD("AudioContext",1),fG=function(){function e(){var t=this;Gh(this,e),Jl(this,"_audioContextInstance",void 0),Jl(this,"_previousState",""),Jl(this,"_currentState",""),Jl(this,"_contextStuckAt",0);var r=0;eL()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,pG.info("currentTime resume"),WM("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,pG.warn("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),WM("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return jh(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;pG.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(),(gL||fL)&&("running"===e._previousState&&"interrupted"===e._currentState&&hG.emit(dG.ON_IOS_INTERRUPTION_START),"interrupted"===e._previousState&&"running"===e._currentState&&hG.emit(dG.ON_IOS_INTERRUPTION_END))}}return this._audioContextInstance}}]),e}(),_G=function(){function e(t){Gh(this,e),Jl(this,"_ctx",void 0),Jl(this,"_analyserNode",void 0),Jl(this,"_audioSource",void 0),Jl(this,"currentTrackId",void 0),this.currentTrackId=t.id;var r=vG.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 jh(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=Ug(Dg().mark((function e(){var t;return Dg().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}(),vG=new fG,mG=new fD("VERTC",0),gG=function(){function e(){Gh(this,e),Jl(this,"_ac",void 0),Jl(this,"_sourceNode",void 0),Jl(this,"_gainNode",void 0),Jl(this,"_destNode",void 0),this._ac=vG.getAudioContextInstance(),this._gainNode=this._ac.createGain(),this._destNode=this._ac.createMediaStreamDestination(),this._gainNode.connect(this._destNode)}return jh(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!==IL&&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}(),yG=function(e){jA(n,e);var t,r=iw(n);function n(e,t,i){var o;return Gh(this,n),Jl(dA(o=r.call(this,e,t,Zl(Zl({},i),{},{mediaType:FU.AUDIO}))),"audioCaptureConfig",void 0),Jl(dA(o),"_ap",void 0),Jl(dA(o),"mixedAudioTrack",void 0),Jl(dA(o),"mixType",Lh.PLAYOUT_AND_PUBLISH),Jl(dA(o),"_audioFetchMap",new hT),Jl(dA(o),"notSupportedWebAudio",!1),o}return jh(n,[{key:"withWebAudio",get:function(){return!!this._ap}},{key:"getAudioLevel",value:function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_h.MICROPHONE,n=r===_h.AUDIOMIXING&&this.mixType!==Lh.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 _G(n),this._audioFetchMap.set(r,i));return i.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=Ug(Dg().mark((function e(){return Dg().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 mG.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:"setVolume",value:function(e){var t=!JL("SKIP_WEB_AUDIO_IN_TRACK")&&oV();t||(this.notSupportedWebAudio=!0);var r,n=!this.withWebAudio&&100!==e;try{t&&n&&(mG.print("Create AudioProcess"),this._ap=new gG,this._ap.updateInputTrack(this.originTrack),this.mediaTrack=this._ap.getOutputTrack())}catch(i){mG.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}},{key:"setUserId",value:function(e){this.trackInfo.streamUserId=e}},{key:"destroy",value:function(){this._audioFetchMap.forEach((function(e){return e.destroy()})),this._audioFetchMap.clear(),this._ap&&this._ap.destroy(),FA(VA(n.prototype),"destroy",this).call(this)}}]),n}(GU),SG=function(e){jA(r,e);var t=iw(r);function r(e,n){var i;return Gh(this,r),Jl(dA(i=t.call(this,e,Zl(Zl({},n),{},{mediaType:FU.AUDIO}))),"_ap",void 0),Jl(dA(i),"_audioPlayer",void 0),Jl(dA(i),"_audioLevelFetcher",void 0),Jl(dA(i),"notSupportedWebAudio",!1),i}return jh(r,[{key:"withWebAudio",get:function(){return!!this._ap}},{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new _G(this.originTrack)),this._audioLevelFetcher.getAudioLevel()}},{key:"setVolume",value:function(e){var t=!JL("SKIP_WEB_AUDIO_IN_TRACK")&&oV();t||(this.notSupportedWebAudio=!0);var r,n,i=!this.withWebAudio&&100!==e;try{t&&i&&(mG.print("Create AudioProcess"),this._ap=new gG,this._ap.updateInputTrack(this.originTrack),this.mediaTrack=this._ap.getOutputTrack())}catch(o){mG.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._audioPlayer)||void 0===n||n.playAudio(this))}},{key:"getVolume",value:function(){return this.notSupportedWebAudio?100:this._ap?this._ap.getVolume():100}},{key:"dangerousGetPlayer",value:function(){return this._audioPlayer}},{key:"setPlaybackDevice",value:function(e){var t;return null===(t=this._audioPlayer)||void 0===t?void 0:t.setPlaybackDevice(e)}},{key:"setPlayer",value:function(e){this._audioPlayer=e}},{key:"pause",value:function(){var e;return null===(e=this._audioPlayer)||void 0===e?void 0:e.pause()}},{key:"play",value:function(){var e,t,r;return null!==(e=this._audioPlayer)&&void 0!==e&&e.played?null===(t=this._audioPlayer)||void 0===t?void 0:t.manuallyPlay():null===(r=this._audioPlayer)||void 0===r?void 0:r.playAudio(this)}},{key:"manuallyPause",value:function(){var e;return null===(e=this._audioPlayer)||void 0===e?void 0:e.manuallyPause()}},{key:"stop",value:function(){var e;return null===(e=this._audioPlayer)||void 0===e?void 0:e.stop()}},{key:"destroy",value:function(){var e,t;null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),this._ap&&this._ap.destroy(),null===(t=this._audioPlayer)||void 0===t||t.destroy(),this._audioPlayer=void 0,FA(VA(r.prototype),"destroy",this).call(this)}}]),r}(HU),bG=r(Al),EG=new fD("VideoSnapshot",1),kG=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},TG=function(){var e=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=document.createElement("canvas"),i=n.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(o=function(e,t,r){return t=t||e.width,r=r||e.height,n.width=t,n.height=r,i.setTransform(1,0,0,1,0,0),i.drawImage(e,0,0,t,r),i.getImageData(0,0,t,r)},a=Date.now(),!(s=kG(r))){e.next=16;break}return EG.info("takeSnapshot","VideoPlayer already set."),e.next=11,o(s,s.videoWidth,s.videoHeight);case 11:return c=e.sent,EG.info("takeSnapshot","success, cost ".concat(Date.now()-a,"ms")),e.abrupt("return",c);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(u=new window.ImageCapture(t)).track.readyState||!u.track.enabled||u.track.muted){e.next=29;break}return EG.info("takeSnapshot","use ImageCapture"),e.t0=o,e.next=23,u.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return d=e.sent,EG.info("takeSnapshot","success, cost ".concat(Date.now()-a,"ms")),e.abrupt("return",d);case 29:return EG.info("takeSnapshot","use temp video"),e.abrupt("return",new Hg((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=o(i,i.videoWidth,i.videoHeight);EG.info("takeSnapshot","success, cost ".concat(Date.now()-a,"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){return e.apply(this,arguments)}}(),IG=new fD("VERTC",0),RG=bG("default"),AG=function(e){return e.START_STALL_OBSERVE="start_stall_observe",e.STOP_STALL_OBSERVE="stop_stall_observe",e}(AG||{}),wG=function(e){jA(n,e);var t,r=iw(n);function n(e,t,i){var o;return Gh(this,n),Jl(dA(o=r.call(this,e,t,Zl(Zl({},i),{},{mediaType:FU.VIDEO}))),"resolution",void 0),Jl(dA(o),"videoPlayers",new hT),o.resolution={width:0,height:0},o}return jh(n,[{key:"intersection",value:function(){var e={};return this.videoPlayers.forEach((function(t,r){e[r.toString()]=t.isIntersecting})),e}},{key:"updateVideoCaptureConfig",value:(t=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IG.info("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=Zl({},t)).contentHint,iL&&this.trackInfo.streamIndex===BU.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:"setContentHint",value:function(e){var t;"contentHint"in this.originTrack&&Qy(t=["text","motion","detail"]).call(t,e)&&(this.originTrack.contentHint=e)}},{key:"setTrack",value:function(e,t,r){this._originTrack=e,this.extensionManager=t,this.trackInfo=Zl(Zl({},this.trackInfo),r),this.isTrackReady=this.generatePreProcessingTrack()}},{key:"setPlayer",value:function(e,t,r,n,i){var o,a=null!==(o=t.playerId)&&void 0!==o?o:RG,s=this.videoPlayers.get(a);return t.player!==s&&(s=t.player,this.videoPlayers.set(a,s),i(s,this.isPublic,this.streamIndex)),this.mirror(!!r),this.dummy||n===Rh.PLAY_MANUALLY||this.play(a),s.domElement}},{key:"setUserId",value:function(e){this.trackInfo.streamUserId=e,this.videoPlayers.forEach((function(t){t.userId=e}))}},{key:"snapshot",value:function(){var e,t,r,n=by(tx(e=this.videoPlayers).call(e));try{for(n.s();!(r=n.n()).done;){var i=r.value;if(i.played){t=i;break}}}catch(j0){n.e(j0)}finally{n.f()}return TG(this.preprocessingTrack,t)}},{key:"setRenderMode",value:function(e,t){var r;return null===(r=this.videoPlayers.get(e))||void 0===r?void 0:r.setRenderMode(t)}},{key:"mirror",value:function(e){this.videoPlayers.forEach((function(t){t.mirror(e)}))}},{key:"removePlayerTrack",value:function(){var e=this;this.videoPlayers.forEach((function(t,r){var n;null===(n=e.videoPlayers.get(r))||void 0===n||n.removeTrack()}))}},{key:"play",value:function(e){var t=this.videoPlayers.get(e);return null!=t&&t.played?t.manuallyPlay():null==t?void 0:t.playVideo(this)}},{key:"playAll",value:function(){var e=this;this.videoPlayers.forEach((function(t,r){e.play(r)}))}},{key:"manuallyPlay",value:function(e){var t;return null===(t=this.videoPlayers.get(e))||void 0===t?void 0:t.manuallyPlay()}},{key:"pause",value:function(e){var t;null===(t=this.videoPlayers.get(e))||void 0===t||t.manuallyPause()}},{key:"stop",value:function(e){var t;return null===(t=this.videoPlayers.get(e))||void 0===t?void 0:t.stop()}},{key:"stopAll",value:function(){var e=this;return this.videoPlayers.forEach((function(t,r){e.stop(r)}))}},{key:"destroy",value:function(){var e=this;this.videoPlayers.forEach((function(t,r){e.stop(r),t.removeAllListeners(),e.videoPlayers.delete(r)})),FA(VA(n.prototype),"destroy",this).call(this)}}]),n}(GU),CG=function(e){jA(r,e);var t=iw(r);function r(e,n,i){var o;return Gh(this,r),Jl(dA(o=t.call(this,e,Zl(Zl({},i),{},{mediaType:FU.VIDEO}))),"videoPlayers",new hT),Jl(dA(o),"_stream",void 0),Jl(dA(o),"_observingPlayer",void 0),o._stream=n,o}return jh(r,[{key:"observingPlayerId",get:function(){var e;return null===(e=this._observingPlayer)||void 0===e?void 0:e.playerId}},{key:"getSizeByPlayer",value:function(){var e=0,t=0;return this.videoPlayers.forEach((function(r){var n;null!==(n=r.domElement)&&void 0!==n&&n.videoWidth&&r.domElement.videoHeight&&(e=r.domElement.videoWidth,t=r.domElement.videoHeight)})),{width:e,height:t}}},{key:"intersection",value:function(){var e={};return this.videoPlayers.forEach((function(t,r){e[r.toString()]=t.isIntersecting})),e}},{key:"setPlayer",value:function(e,t,r,n){var i,o,a=null!==(i=t.playerId)&&void 0!==i?i:RG,s=this.videoPlayers.get(a);return t.player!==s&&(s=t.player,this.videoPlayers.set(a,s),this._handlePlayerStallEvent(s),n(s,this.isPublic,this.streamIndex)),this.dummy||r===Rh.PLAY_MANUALLY||this.play(a),null===(o=s)||void 0===o?void 0:o.domElement}},{key:"dangerousGetPlayer",value:function(e){return this.videoPlayers.get(e)}},{key:"snapshot",value:function(){var e,t,r,n=by(tx(e=this.videoPlayers).call(e));try{for(n.s();!(r=n.n()).done;){var i=r.value;if(i.played){t=i;break}}}catch(j0){n.e(j0)}finally{n.f()}return TG(this.preprocessingTrack,t)}},{key:"stop",value:function(e){var t;null===(t=this.videoPlayers.get(e))||void 0===t||t.stop()}},{key:"stopAll",value:function(){var e=this;this.videoPlayers.forEach((function(t,r){e.stop(r)}))}},{key:"play",value:function(e){var t=this.videoPlayers.get(e);return null!=t&&t.played?t.manuallyPlay():null==t?void 0:t.playVideo(this)}},{key:"pause",value:function(e){var t;return null===(t=this.videoPlayers.get(e))||void 0===t?void 0:t.manuallyPause()}},{key:"_handlePlayerStallEvent",value:function(e){var t=this;e.on("start_stall_observe",(function(){!t._observingPlayer&&e&&(t._observingPlayer=e,t._stream.startVideoStallObserve(t._observingPlayer))})),e.on("stop_stall_observe",(function(){t._observingPlayer===e&&(t._stream.stopVideoStallObserve(),t._observingPlayer=void 0,t.videoPlayers.forEach((function(e){!t._observingPlayer&&e.played&&(t._observingPlayer=e,t._stream.startVideoStallObserve(e))})))}))}},{key:"destroy",value:function(){var e=this;this.videoPlayers.forEach((function(t,r){e.stop(r),t.removeAllListeners(),e.videoPlayers.delete(r)})),FA(VA(r.prototype),"destroy",this).call(this)}}]),r}(HU),xG=function(e){jA(f,e);var t,r,n,i,o,a,s,c,u,d,l,h,p=iw(f);function f(){var e,t,r;return Gh(this,f),Jl(dA(r=p.call(this)),"deviceMap",{audioinput:new hT,audiooutput:new hT,videoinput:new hT}),Jl(dA(r),"checkDeviceChangeTimer",null),Jl(dA(r),"isSupportedPermissionsQuery",!1),Jl(dA(r),"isGrantedMicrophonePermission",!1),Jl(dA(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!eL()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(dA(r)),!eL()&&r.initListener().then((function(){r.updateDeviceListInSilent()})),r}return jh(f,[{key:"refreshDevices",value:(h=Ug(Dg().mark((function e(){var t,r,n,i=this,o=arguments;return Dg().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,!iL){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=Ug(Dg().mark((function e(){var t,r,n,i,o=this;return Dg().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=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c=this;return Dg().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,!iL){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=wy(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=jC(Gg(t=[]).call(t,iR(tx(r=this.deviceMap.audioinput).call(r)),iR(tx(n=this.deviceMap.videoinput).call(n)),iR(tx(i=this.deviceMap.audiooutput).call(i)))),(mL||fL)&&!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||(Qy(t=e.kind).call(t,"video")?c.emit(Fh.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):Qy(r=e.kind).call(r,"audio")&&c.emit(Fh.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;dI(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),Qy(t=e.kind).call(t,"video")?c.emit(Fh.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):Qy(r=e.kind).call(r,"audio")&&c.emit(Fh.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 16:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"getUserMedia",value:(u=Ug(Dg().mark((function e(t){var r;return Dg().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=Ug(Dg().mark((function e(){var t,r;return Dg().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=wy(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=wy(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=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l=arguments;return Dg().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=Ug(Dg().mark((function e(){return Dg().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=Ug(Dg().mark((function e(){var t,r,n,i;return Dg().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",jC(Gg(t=[]).call(t,iR(tx(r=this.deviceMap.audioinput).call(r)),iR(tx(n=this.deviceMap.videoinput).call(n)),iR(tx(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=Ug(Dg().mark((function e(){var t;return Dg().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",jC(tx(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=Ug(Dg().mark((function e(){var t;return Dg().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",jC(tx(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=Ug(Dg().mark((function e(){var t;return Dg().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",jC(tx(t=this.deviceMap.audiooutput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getAudioPlaybackDeviceById",value:(t=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateAudioPlaybackDevices();case 2:return r=e.sent,e.abrupt("return",dI(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)})}]),f}(wU),OG=new xG;!eL()&&(window.__rtc_dd__=OG);var PG=new fD("VERTC",0);function NG(e,t){return MG.apply(this,arguments)}function MG(){return(MG=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new wG(t,r,{streamIndex:BU.MAIN,sourceType:VU.INTERNAL,isDummy:!0}),e.next=3,n.isTrackReady;case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function DG(e,t){return LG.apply(this,arguments)}function LG(){return(LG=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new wG(t,r,{isDummy:!0,streamIndex:BU.SCREEN,sourceType:VU.INTERNAL}),e.next=3,n.isTrackReady;case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function UG(e,t){return VG.apply(this,arguments)}function VG(){return(VG=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return Dg().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=YM(r.id),s=gx(),e.prev=3,PG.info("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o,capture_session_id:s}),u=AD(),iL&&(t.frameRate={ideal:30,max:30}),e.next=10,OG.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:AD()-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 mC(hC.GET_VIDEO_TRACK_FAILED,Gg(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 wG(l,r,{streamIndex:BU.MAIN,sourceType:VU.INTERNAL,captureSessionId:s}),e.next=22,h.isTrackReady;case 22:return e.abrupt("return",h);case 23:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function FG(e,t){return BG.apply(this,arguments)}function BG(){return(BG=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return PG.info("createMicrophoneAudioTrack","constraints:",t),o=(null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=YM(r.id),s=gx(),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=AD(),(d=r.getPluginByName(sG.PRE_PROCESSING,"RTCAIAnsExtension"))&&(d.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=11,OG.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:AD()-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 mC(hC.GET_AUDIO_TRACK_FAILED,Gg(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 yG(h,r,{streamIndex:BU.MAIN,sourceType:VU.INTERNAL,captureSessionId:s}),e.next=23,p.isTrackReady;case 23:return e.abrupt("return",p);case 24:case"end":return e.stop()}}),e,null,[[4,15]])})))).apply(this,arguments)}function jG(e,t,r){return GG.apply(this,arguments)}function GG(){return(GG=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return PG.print("createCameraAndMicrophoneTrack","audioConstraints:",t,"videoConstraints:",r),a=YM(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=gx(),l=gx(),e.prev=6,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}),f=AD(),iL&&(r.frameRate={ideal:30,max:30}),(_=n.getPluginByName(sG.PRE_PROCESSING,"RTCAIAnsExtension"))&&(_.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=15,OG.getUserMedia({audio:t,video:r});case 15: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:AD()-f,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:AD()-f,event_session_id:l}),e.next=25;break;case 20:throw e.prev=20,e.t0=e.catch(6),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 mC(hC.GET_VIDEO_TRACK_FAILED,Gg(v="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(v,e.t0.message||"unknown message","."),e.t0);case 25:return m=s.getVideoTracks()[0],g=new wG(m,n,{streamIndex:BU.MAIN,sourceType:VU.INTERNAL,captureSessionId:d}),y=s.getAudioTracks()[0],S=new yG(y,n,{streamIndex:BU.MAIN,sourceType:VU.INTERNAL,captureSessionId:l}),e.next=31,Hg.all([g.isTrackReady,S.isTrackReady]);case 31:return e.abrupt("return",{videoTrack:g,audioTrack:S});case 32:case"end":return e.stop()}}),e,null,[[6,20]])})))).apply(this,arguments)}function HG(e,t,r){return zG.apply(this,arguments)}function zG(){return(zG=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return PG.info("createScreenTracks","screenConfig: %o, constraints: %o",t,n),u=YM(r.id),d=gx(),l=t.enableAudio,h=void 0!==l&&l,p=t.displaySurface,f=t.systemAudio,_=t.surfaceSwitching,v=t.selfBrowserSurface,m={},Qy(i=["monitor","browser","window"]).call(i,p)&&(n?n.displaySurface=p:n={displaySurface:p}),Qy(o=["include","exclude"]).call(o,f)&&(m.systemAudio=f),Qy(a=["include","exclude"]).call(a,_)&&(m.surfaceSwitching=_),Qy(s=["include","exclude"]).call(s,v)&&(m.selfBrowserSurface=v),e.prev=9,null==u||u.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen",capture_session_id:d}),b=AD(),e.next=14,navigator.mediaDevices.getDisplayMedia(Zl({video:!(n&&(!oL||"16.1"!==AL))||n,audio:!!h&&{channelCount:2,noiseSuppression:!1,echoCancellation:!0,autoGainControl:!1}},m));case 14:c=e.sent,null==u||u.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",media_device_name:Gg(g="".concat((null===(y=c.getVideoTracks()[0])||void 0===y?void 0:y.label)||"",", ")).call(g,(null===(S=c.getAudioTracks()[0])||void 0===S?void 0:S.label)||""),reason:"success",elapse:AD()-b,capture_session_id:d}),e.next=22;break;case 18:throw e.prev=18,e.t0=e.catch(9),null==u||u.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:d}),new mC(hC.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 22:if(E=c.getVideoTracks()[0],k=new wG(E,r,{streamIndex:BU.SCREEN,sourceType:VU.INTERNAL,captureSessionId:d}),T=c.getAudioTracks()[0],!c.getAudioTracks().length){e.next=30;break}return I=new yG(T,r,{streamIndex:BU.SCREEN,sourceType:VU.INTERNAL,captureSessionId:d}),e.next=29,Hg.all([k.isTrackReady,I.isTrackReady]);case 29:return e.abrupt("return",[k,I]);case 30:return e.next=32,k.isTrackReady;case 32:return e.abrupt("return",[k,void 0]);case 33:case"end":return e.stop()}}),e,null,[[9,18]])})))).apply(this,arguments)}function KG(e,t){return new SG(e,Zl({},t))}function WG(e,t){return XG.apply(this,arguments)}function XG(){return(XG=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new wG(t,r,{streamIndex:BU.MAIN,sourceType:VU.EXTERNAL}),e.next=3,n.isTrackReady;case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function YG(e,t){return qG.apply(this,arguments)}function qG(){return(qG=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new yG(t,r,{streamIndex:BU.MAIN,sourceType:VU.EXTERNAL}),e.next=3,n.isTrackReady;case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function JG(e,t){return QG.apply(this,arguments)}function QG(){return(QG=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new wG(t,r,{sourceType:VU.EXTERNAL,streamIndex:BU.SCREEN}),e.next=3,n.isTrackReady;case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ZG(e,t){return $G.apply(this,arguments)}function $G(){return($G=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new yG(t,r,{sourceType:VU.EXTERNAL,streamIndex:BU.SCREEN}),e.next=3,n.isTrackReady;case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var eH,tH=function(e){jA(r,e);var t=iw(r);function r(e){var n;return Gh(this,r),Jl(dA(n=t.call(this)),"isScreen",!1),Jl(dA(n),"audioMid",void 0),Jl(dA(n),"videoMid",void 0),Jl(dA(n),"videoTransceiver",void 0),Jl(dA(n),"audioTransceiver",void 0),Jl(dA(n),"vendorHandler",void 0),Jl(dA(n),"vendorCode",0),Jl(dA(n),"engineId",void 0),Jl(dA(n),"logger",void 0),n._ctx=e,n.engineId=e.id,n.logger=new fD("Stream",0,e.id),n}return jh(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}(wU),rH=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(rH||{}),nH=function(e){jA(r,e);var t=iw(r);function r(e){var n;Gh(this,r),Jl(dA(n=t.call(this,e)),"id",void 0),Jl(dA(n),"stream",void 0),Jl(dA(n),"streamId",void 0),Jl(dA(n),"seiList",[]),Jl(dA(n),"videoTrack",void 0),Jl(dA(n),"audioTrack",void 0),Jl(dA(n),"videoEncodeConfig",[eU]),Jl(dA(n),"subVideoDescriptions",[]),Jl(dA(n),"enableSimulcast",!1),Jl(dA(n),"observer",void 0),Jl(dA(n),"statsReport",void 0),Jl(dA(n),"prevBitrate",0),Jl(dA(n),"pubAudio",!1),Jl(dA(n),"pubVideo",!1),Jl(dA(n),"blackFrameRenderInterval",void 0),Jl(dA(n),"blackFrameLifetimeInterval",void 0),Jl(dA(n),"pubAttributes",void 0),Jl(dA(n),"pcSessionId",void 0),Jl(dA(n),"maxSeiCount",1),Jl(dA(n),"transformer",(function(e,t){var r;if(n.seiList.length){var i,o=[],a=0,s=by(n.seiList);try{for(s.s();!(i=s.n()).done;){var c=i.value;if(o.length>=n.maxSeiCount)break;var u=yV.generateSEI(c.content);a+=u.byteLength,c.repeatCount--,o.push(u)}}catch(j0){s.e(j0)}finally{s.f()}n.seiList=wy(r=n.seiList).call(r,(function(e){return e.repeatCount>0}));var d=new Uint8Array(a+e.data.byteLength);d.set(new Uint8Array(e.data));var l=e.data.byteLength;o.forEach((function(e){d.set(e,l),l+=e.byteLength})),e.data=d.buffer,t.enqueue(e)}else t.enqueue(e)})),n.stream=new MediaStream,n.id=gx(),n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1,videoDescriptions:[],videoType:UU.NORMAL},n.statsReport=new tG(e,dA(n));var i=JL("SEI_COUNT_FPS");return"number"==typeof i&&i<=10&&(n.maxSeiCount=i),n}return jh(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(){if(this.videoTransceiver&&this.videoTransceiver.sender){var e=this.videoTransceiver.sender;if(iV()){var t=e.createEncodedStreams(),r=t.readable,n=t.writable,i=new TransformStream({transform:this.transformer});r.pipeThrough(i).pipeTo(n)}}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(){$M(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),FA(VA(r.prototype),"destroy",this).call(this),this.prevBitrate=0,this.subVideoDescriptions=[],clearTimeout(this.blackFrameLifetimeInterval),clearInterval(this.blackFrameRenderInterval)}},{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}},{key:"genBlackFrame",value:function(){var e,t;this.logger.info("genBlackFrame()");var r=null!==(e=this.videoEncodeConfig[0])&&void 0!==e&&e.frameRate?zD(null===(t=this.videoEncodeConfig[0])||void 0===t?void 0:t.frameRate):15,n=Math.ceil(1e3/r),i=document.createElement("canvas"),o=i.getContext("2d");i.width=16,i.height=16;var a=function(e){e.fillRect(0,0,16,16)};return o&&(o.fillStyle="#000",a(o),this.blackFrameRenderInterval=window.setInterval((function(){a(o)}),n),this.refreshBlackFrameLifetime()),i.captureStream(r).getVideoTracks()[0]}},{key:"stopBlackFrame",value:function(){this.logger.info("stopBlackFrame()"),clearTimeout(this.blackFrameLifetimeInterval),clearInterval(this.blackFrameRenderInterval),delete this.blackFrameRenderInterval}},{key:"refreshBlackFrameLifetime",value:function(){var e=this;this.logger.info("refreshBlackFrameLifetime()"),this.blackFrameRenderInterval&&(clearTimeout(this.blackFrameLifetimeInterval),this.blackFrameLifetimeInterval=setTimeout((function(){clearInterval(e.blackFrameRenderInterval),delete e.blackFrameRenderInterval,e.emit("black-frame-ended")}),YL.BLACK_FRAME_LIFETIME))}}]),r}(tH),iH=function(e){jA(n,e);var t,r=iw(n);function n(e,t,i,o,a,s){var c;return Gh(this,n),Jl(dA(c=r.call(this,e)),"streamId",void 0),Jl(dA(c),"userId",void 0),Jl(dA(c),"isPublic",void 0),Jl(dA(c),"hasVideo",void 0),Jl(dA(c),"hasAudio",void 0),Jl(dA(c),"_attributes",void 0),Jl(dA(c),"streamState",void 0),Jl(dA(c),"removeTrack",!1),Jl(dA(c),"observer",void 0),Jl(dA(c),"statsReport",void 0),Jl(dA(c),"subVideo",void 0),Jl(dA(c),"subAudio",void 0),Jl(dA(c),"subMediaType",void 0),Jl(dA(c),"subLayer",void 0),Jl(dA(c),"_sequenceId",void 0),Jl(dA(c),"stream",void 0),Jl(dA(c),"videoTrack",void 0),Jl(dA(c),"audioTrack",void 0),Jl(dA(c),"recordedVideoFrames",void 0),Jl(dA(c),"stillExist",void 0),Jl(dA(c),"originalMediaType",void 0),Jl(dA(c),"priority",void 0),Jl(dA(c),"remoteSessionId",""),Jl(dA(c),"originalStreamIndex",0),Jl(dA(c),"virtual",void 0),Jl(dA(c),"pcSessionId",void 0),Jl(dA(c),"_virtualOccupy",void 0),Jl(dA(c),"_videoStallObserver",void 0),Jl(dA(c),"_audioStallObserver",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=HL.NONE,c.subLayer={spatialLayer:0,spatialSubLayer:-1},c.streamState=0,c.statsReport=new rG(e,dA(c)),c.enableVendorMode&&(c.pcSessionId=gx()),c}return jh(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)}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){hV.getNalunits(new pV(t.data)).forEach((function(t){if(t.sei){var r=yV.decodeSeiBody(t.body);r&&r.type!==fV.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;$M(this.engineId,"Stream.ontrack",Xg({uid:this.userId,streamId:this.streamId,streams:uS(i=e.streams).call(i,(function(e,t){return e+Ex(t)}),""),transceiver:Ix(e.transceiver),track:bx(e.track)}),0,this.streamId||"")}catch(B0){}if(this.enableVendorMode||null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&Qy(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",e.playerId),this._videoStallObserver||(this._videoStallObserver=new nG(this.isScreen,this.engineId)),this._videoStallObserver.start(e)}},{key:"stopVideoStallObserve",value:function(){var e;this.logger.info("stopVideoStallObserve","invoke"),null===(e=this._videoStallObserver)||void 0===e||e.stop()}},{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,o=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=o:e.stall_duration=o,e.pause_duration=Math.min(o,n.pauseDuration),t.stallCount=n.callback.stallCount,t.stallDuration=n.callback.stallDuration,n.stall100ms){var a=Math.min(n.stall100ms.duration,e.stats_interval||0);e.stall_duration_100ms=a,e.stall_count_100ms=n.stall100ms.count,t.stallDuration100MS=a,t.stallCount100MS=n.stall100ms.count}if(0!==n.report.stallCount||0!==n.report.stallDuration)this.logger.print("video_stall_report",this.userId,null===(i=this.videoTrack)||void 0===i?void 0:i.observingPlayerId,Xg(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=Ug(Dg().mark((function e(t,r,n){var i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._audioStallObserver){e.next=6;break}this._audioStallObserver=new iG(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,Xg(Zl(Zl({},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,r;this.logger.info("clean",Gg(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),$M(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),FA(VA(n.prototype),"destroy",this).call(this),this.subAudio=!1,this.subVideo=!1,this.sequenceId=0,null===(t=this.videoTrack)||void 0===t||t.destroy(),this.videoTrack=void 0,null===(r=this.audioTrack)||void 0===r||r.destroy(),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=KG(e,{streamIndex:this.isPublic?BU.PUBLIC:this.virtual?BU.VIRTUAL:this.isScreen?BU.SCREEN:BU.MAIN,streamUserId:this.userId}),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,t,r){return new CG(e,t,Zl({},r))}(e,this,{streamIndex:this.isPublic?BU.PUBLIC:this.virtual?BU.VIRTUAL:this.isScreen?BU.SCREEN:BU.MAIN,streamUserId:this.userId}),this.emit("ontrack",this.videoTrack))}}]),n}(tH),oH=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.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.PUB_RETRY="PUB_RETRY",e.SUB_RETRY="SUB_RETRY",e.VIDEO_TYPE_CHANGE="VIDEO_TYPE_CHANGE",e.JOIN_SUCCESS="JOIN_SUCCESS",e}(oH||{}),aH=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}(aH||{}),sH=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(sH||{}),cH=function(){var e=Ug(Dg().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,u="",d=-1,l="video"===r?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"===r?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.next=8,null===(p=t.peerConnection)||void 0===p?void 0:p.getStatsWithLowFrequency(l,!0,h);case 8:return v=e.sent,m=dI(f=v||[]).call(f,(function(e){return"inbound-rtp"===e.type})),e.next=12,null==h?void 0:h.getStats();case 12:if(g=e.sent,y=[],null==g||g.forEach((function(e){return y.push(e.type)})),0!==(null==v?void 0:v.length)||0===y.length){e.next=19;break}return e.next=18,null===(b=t.peerConnection)||void 0===b?void 0:b.getStatsWithLowFrequency(void 0,void 0,h);case 18:S=e.sent;case 19:u=Xg({type:r,reports:$g(v).call(v,(function(e){return e.type})),reports2:y,pc:(null===(_=t.peerConnection)||void 0===_?void 0:_.getOriginRTCPeerConnection())||null,track:(null==l?void 0:l.id)||null,bytes:null==m?void 0:m.bytesReceived,framesReceived:null==m?void 0:m.framesReceived,packetsReceived:null==m?void 0:m.packetsReceived,allReports:S}),e.next=26;break;case 22:e.prev=22,e.t0=e.catch(5),d=-999,u=e.t0.mseeage||Xg(e.t0);case 26: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=31;break;case 29:e.prev=29,e.t1=e.catch(0);case 31:case"end":return e.stop()}}),e,null,[[0,29],[5,22]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),uH=function(){var e=Ug(Dg().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,u="",d=-1,l="video"===r?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"===r?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.next=8,null===(p=t.peerConnection)||void 0===p?void 0:p.getStatsWithLowFrequency(l,!0,h);case 8:return v=e.sent,m=dI(f=v||[]).call(f,(function(e){return"outbound-rtp"===e.type})),e.next=12,null==h?void 0:h.getStats();case 12:if(g=e.sent,y=[],null==g||g.forEach((function(e){return y.push(e.type)})),0!==v.length||0===y.length){e.next=19;break}return e.next=18,null===(b=t.peerConnection)||void 0===b?void 0:b.getStatsWithLowFrequency(void 0,void 0,h);case 18:S=e.sent;case 19:u=Xg({type:r,reports:$g(v).call(v,(function(e){return e.type})),reports2:y,pc:(null===(_=t.peerConnection)||void 0===_?void 0:_.getOriginRTCPeerConnection())||null,track:(null==l?void 0:l.id)||null,bytes:null==m?void 0:m.bytesSent,framesSent:null==m?void 0:m.framesSent,packetsSent:null==m?void 0:m.packetsSent,allReports:S}),e.next=26;break;case 22:e.prev=22,e.t0=e.catch(5),d=-999,u=e.t0.mseeage||Xg(e.t0);case 26: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=31;break;case 29:e.prev=29,e.t1=e.catch(0);case 31:case"end":return e.stop()}}),e,null,[[0,29],[5,22]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),dH=function(e){jA(a,e);var t,r,n,i,o=iw(a);function a(e,t){var r;return Gh(this,a),Jl(dA(r=o.call(this)),"_audioEventSessionId",PD()),Jl(dA(r),"_videoEventSessionId",PD()),Jl(dA(r),"_stream",void 0),Jl(dA(r),"_firstAudioFrameTimer",void 0),Jl(dA(r),"_firstVideoFrameTimer",void 0),Jl(dA(r),"_transportDelayInterval",void 0),Jl(dA(r),"_transportDelay",void 0),Jl(dA(r),"_firstVideoFrameInterval",void 0),Jl(dA(r),"_firstAudioFrameInterval",void 0),Jl(dA(r),"_isScreen",!1),Jl(dA(r),"_audioFirstFrameState",0),Jl(dA(r),"_videoFirstFrameState",0),Jl(dA(r),"_timeout",1e4),Jl(dA(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),Jl(dA(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),Jl(dA(r),"_login",!1),Jl(dA(r),"_unMuteAudio",!1),Jl(dA(r),"_enableAudio",!1),Jl(dA(r),"_unMuteVideo",!1),Jl(dA(r),"_enableVideo",!1),Jl(dA(r),"_remoteUnmuteAudio",!1),Jl(dA(r),"_remoteUnmuteVideo",!1),Jl(dA(r),"_audioExternal",!1),Jl(dA(r),"_pushAudio",!1),Jl(dA(r),"_videoExternal",!1),Jl(dA(r),"_pushVideo",!1),Jl(dA(r),"_autoSubscribeVideo",!1),Jl(dA(r),"_autoSubscribeAudio",!1),Jl(dA(r),"_autoSubscribe",!1),Jl(dA(r),"_publishVideo",!1),Jl(dA(r),"_publishAudio",!1),Jl(dA(r),"_subscribeAudio",!1),Jl(dA(r),"_subscribeVideo",!1),Jl(dA(r),"_subscribe",!1),Jl(dA(r),"_pushTrack",!1),Jl(dA(r),"_multiChatMode",!1),Jl(dA(r),"_monitor",void 0),Jl(dA(r),"logger",void 0),r._ctx=e,r._stream=t,r.getTransportDelay(),r._monitor=YM(t.engineId),r.logger=new fD("RecvFrameObserver",0,t.engineId),r}return jh(a,[{key:"beginRecvFrame",value:(i=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,kI(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},f={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._ctx.peerConnection)||void 0===l?void 0:l.getConnectionId()),remote_rtc_session_id:null===(h=this._stream)||void 0===h?void 0:h.remoteSessionId},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){cH(T._ctx,"audio",T._stream,T._monitor),T.stopRecvFrame("audio","timeout"),T._firstAudioFrameInterval&&window.clearInterval(T._firstAudioFrameInterval)}),this._timeout),this.logger.info("rtcFirstFrameRecv",Xg(f)),null===(p=this._monitor)||void 0===p||p.report("rtc_first_frame",f),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},k={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(_=this._stream)||void 0===_||!_.isScreen),start:null===(v=this._currentVideoRecv)||void 0===v?void 0:v.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(m=this._stream)||void 0===m?void 0:m.userId,transport_delay:i,vendor_mode:(null===(g=this._stream)||void 0===g?void 0:g.vendorCode)||0,pc_session_id:(null===(y=this._stream)||void 0===y?void 0:y.pcSessionId)||(null===(S=this._ctx.peerConnection)||void 0===S?void 0:S.getConnectionId()),remote_rtc_session_id:null===(b=this._stream)||void 0===b?void 0:b.remoteSessionId},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){cH(T._ctx,"video",T._stream,T._monitor),T.stopRecvFrame("video","timeout"),T._firstVideoFrameInterval&&window.clearInterval(T._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),this.logger.info("rtcFirstFrameRecv",Xg(k)),null===(E=this._monitor)||void 0===E||E.report("rtc_first_frame",k),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,d;if(1!==this._audioFirstFrameState)return;var l={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._ctx.peerConnection)||void 0===c?void 0:c.getConnectionId()),remote_rtc_session_id:null===(u=this._stream)||void 0===u?void 0:u.remoteSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,this.logger.info("rtcFirstFrameRecv",Xg(l)),null===(d=this._monitor)||void 0===d||d.report("rtc_first_frame",l),this._audioFirstFrameState=2}else if("video"===e){var h,p,f,_,v,m,g,y,S;if(1!==this._videoFirstFrameState)return;var b={event_type:"recv_end",media_type:e,is_screen:!(null===(h=this._stream)||void 0===h||!h.isScreen),start:null===(p=this._currentVideoRecv)||void 0===p?void 0:p.startTime,reason:t,result:!1,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,event_session_id:this._videoEventSessionId,type:null===(_=this._currentVideoRecv)||void 0===_?void 0:_.type,vendor_mode:(null===(v=this._stream)||void 0===v?void 0:v.vendorCode)||0,pc_session_id:(null===(m=this._stream)||void 0===m?void 0:m.pcSessionId)||(null===(g=this._ctx.peerConnection)||void 0===g?void 0:g.getConnectionId()),remote_rtc_session_id:null===(y=this._stream)||void 0===y?void 0:y.remoteSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,this.logger.info("rtcFirstFrameRecv",Xg(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R;return Dg().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:l=this._currentAudioRecv,h=l.type,p=l.startTime,kI(n=["login","unmute","subscribe","push_track"]).call(n,h)>=0&&(r=0),f={event_type:"recv_end",media_type:t,start:p,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:h,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._ctx.peerConnection)||void 0===c?void 0:c.getConnectionId()),remote_rtc_session_id:null===(u=this._stream)||void 0===u?void 0:u.remoteSessionId},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this.logger.info("rtcFirstFrameRecv",Xg(f)),null===(d=this._monitor)||void 0===d||d.report("rtc_first_frame",f),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:k=this._currentVideoRecv,T=k.type,I=k.startTime,kI(_=["login","unmute","subscribe","push_track"]).call(_,T)>=0&&(r=0),R={event_type:"recv_end",media_type:t,is_screen:!(null===(v=this._stream)||void 0===v||!v.isScreen),start:I,result:!0,stream_user_id:null===(m=this._stream)||void 0===m?void 0:m.userId,event_session_id:this._videoEventSessionId,type:T,transport_delay:r,vendor_mode:(null===(g=this._stream)||void 0===g?void 0:g.vendorCode)||0,pc_session_id:(null===(y=this._stream)||void 0===y?void 0:y.pcSessionId)||(null===(S=this._ctx.peerConnection)||void 0===S?void 0:S.getConnectionId()),remote_rtc_session_id:null===(b=this._stream)||void 0===b?void 0:b.remoteSessionId},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this.logger.info("rtcFirstFrameRecv",Xg(R)),null===(E=this._monitor)||void 0===E||E.report("rtc_first_frame",R),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:"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);var n=this._ctx.peerConnection;this._firstVideoFrameInterval=window.setInterval(Ug(Dg().mark((function i(){var o,a,s,c,u,d,l,h;return Dg().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!n||null===(o=e._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a||!a.preprocessingTrack){i.next=13;break}return d=null===(s=e._stream.videoTransceiver)||void 0===s?void 0:s.receiver,i.next=4,n.getStatsWithLowFrequency(null===(c=e._stream)||void 0===c||null===(u=c.videoTrack)||void 0===u?void 0:u.preprocessingTrack,!0,d);case 4:if(l=i.sent,!(h=dI(l).call(l,(function(e){return"inbound-rtp"===e.type})))||!(h.framesReceived>t||h.packetsReceived>r)){i.next=13;break}if(-1!==t||-1!==r){i.next=11;break}return t=h.framesReceived,r=h.packetsReceived,i.abrupt("return");case 11:e.recvFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 13:case"end":return i.stop()}}),i)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval);var n=this._ctx.peerConnection;this._firstAudioFrameInterval=window.setInterval(Ug(Dg().mark((function i(){var o,a,s,c,u,d;return Dg().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!n||null===(o=e._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a||!a.originTrack){i.next=12;break}return i.next=3,n.getStatsWithLowFrequency(null===(s=e._stream)||void 0===s||null===(c=s.audioTrack)||void 0===c?void 0:c.originTrack);case 3:if(u=i.sent,!(d=dI(u).call(u,(function(e){return"inbound-rtp"===e.type})))||!(d.totalSamplesReceived>t||d.packetsReceived>r)){i.next=12;break}if(-1!==t||-1!==r){i.next=10;break}return t=d.totalSamplesReceived,r=d.packetsReceived,i.abrupt("return");case 10:e.recvFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return i.stop()}}),i)}))),200)}},{key:"getTransportDelay",value:(r=Ug(Dg().mark((function e(){var t=this;return Dg().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(Ug(Dg().mark((function e(){return Dg().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=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t=this._ctx.peerConnection)){e.next=9;break}return i=null===(r=this._stream)||void 0===r||null===(n=r.videoTransceiver)||void 0===n?void 0:n.receiver,e.next=5,t.getStatsWithLowFrequency(void 0,!0,i);case 5:o=e.sent,a=dI(o).call(o,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(s=dI(o).call(o,(function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==a?void 0:a.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*s.currentRoundTripTime/2));case 9: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}(IU.EventEmitter),lH=function(){function e(t,r){Gh(this,e),Jl(this,"_audioEventSessionId",PD()),Jl(this,"_videoEventSessionId",PD()),Jl(this,"_pcSessionId",void 0),Jl(this,"_firstAudioFrameTimer",void 0),Jl(this,"_firstVideoFrameTimer",void 0),Jl(this,"_stream",void 0),Jl(this,"_firstVideoFrameInterval",void 0),Jl(this,"_firstAudioFrameInterval",void 0),Jl(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),Jl(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),Jl(this,"_login",!1),Jl(this,"_publisher",!1),Jl(this,"_unMuteAudio",!1),Jl(this,"_enableAudio",!1),Jl(this,"_unMuteVideo",!1),Jl(this,"_enableVideo",!1),Jl(this,"_audioExternal",!1),Jl(this,"_pushAudio",!1),Jl(this,"_videoExternal",!1),Jl(this,"_pushVideo",!1),Jl(this,"_autoPublish",!1),Jl(this,"_publish",!1),Jl(this,"_timeout",1e4),Jl(this,"_audioFirstFrameState",0),Jl(this,"_videoFirstFrameState",0),Jl(this,"_monitor",void 0),Jl(this,"logger",void 0),this._ctx=t,this._stream=r,this._monitor=YM(r.engineId),this.logger=new fD("SendFrameObserver",0,r.engineId)}var t,r;return jh(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._ctx.peerConnection)||void 0===a?void 0:a.getConnectionId()),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(){uH(r._ctx,"audio",r._stream,r._monitor),r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),this.logger.info("rtcFirstFrameSend",Xg(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,f,_,v,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===(f=this._ctx.peerConnection)||void 0===f?void 0:f.getConnectionId()),capture_session_id:null===(_=this._stream)||void 0===_||null===(v=_.videoTrack)||void 0===v?void 0:v.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){uH(r._ctx,"video",r._stream,r._monitor),r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),this.logger.info("rtcFirstFrameSend",Xg(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._ctx.peerConnection)||void 0===s?void 0:s.getConnectionId()),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",Xg(l)),null===(d=this._monitor)||void 0===d||d.report("rtc_first_frame",l),this._audioFirstFrameState=2}else if("video"===e){var h,p,f,_,v,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===(f=this._currentVideoSend)||void 0===f?void 0:f.type,vendor_mode:(null===(_=this._stream)||void 0===_?void 0:_.vendorCode)||0,pc_session_id:(null===(v=this._stream)||void 0===v?void 0:v.pcSessionId)||(null===(m=this._ctx.peerConnection)||void 0===m?void 0:m.getConnectionId()),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",Xg(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._ctx.peerConnection)||void 0===i?void 0:i.getConnectionId()),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",Xg(l)),null===(s=this._monitor)||void 0===s||s.report("rtc_first_frame",l),this._audioFirstFrameState=3}else if("video"===e){var h,p,f,_,v,m,g;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var y=this._currentVideoSend,S=y.type,b=y.startTime,E={event_type:"sent_end",media_type:e,is_screen:!(null===(h=this._stream)||void 0===h||!h.isScreen),start:b,result:!0,event_session_id:this._videoEventSessionId,type:S,vendor_mode:(null===(p=this._stream)||void 0===p?void 0:p.vendorCode)||0,pc_session_id:(null===(f=this._stream)||void 0===f?void 0:f.pcSessionId)||(null===(_=this._ctx.peerConnection)||void 0===_?void 0:_.getConnectionId()),capture_session_id:null===(v=this._stream)||void 0===v||null===(m=v.videoTrack)||void 0===m?void 0:m.captureSessionId};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this.logger.info("rtcFirstFrameSend",Xg(E)),null===(g=this._monitor)||void 0===g||g.report("rtc_first_frame",E),this._videoFirstFrameState=3}}},{key:"setLogin",value:function(e){if(this._login!==e){var t,r;if(this._login=e,e)null!==(t=this._stream)&&void 0!==t&&t.videoTrack&&this._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:"_getFirstVideoFrameStats",value:(r=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null===(t=this._stream)||void 0===t||null===(r=t.videoTrack)||void 0===r?void 0:r.preprocessingTrack,a=null===(n=this._stream)||void 0===n||null===(i=n.videoTransceiver)||void 0===i?void 0:i.sender,!this._ctx.peerConnection||!o){e.next=8;break}return e.next=5,this._ctx.peerConnection.getStatsWithLowFrequency(o,!0,a);case 5:return s=e.sent,c=wy(s).call(s,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null===(t=this._stream)||void 0===t||null===(r=t.audioTrack)||void 0===r?void 0:r.preprocessingTrack,a=null===(n=this._stream)||void 0===n||null===(i=n.audioTransceiver)||void 0===i?void 0:i.sender,!this._ctx.peerConnection||!o){e.next=7;break}return e.next=5,this._ctx.peerConnection.getStatsWithLowFrequency(o,!0,a);case 5:return s=e.sent,e.abrupt("return",dI(s).call(s,(function(e){return"outbound-rtp"===e.type})));case 7: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(Ug(Dg().mark((function n(){var i,o,a;return Dg().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||$g(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(Ug(Dg().mark((function r(){var n;return Dg().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}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),hH=(Jl(eH={},"audio",{delay:1200,stallRadio:.3}),Jl(eH,"video",{delay:1200,stallRadio:.6}),Jl(eH,"screen_audio",{delay:1600,stallRadio:.8}),Jl(eH,"screen_video",{delay:1600,stallRadio:.8}),eH),pH=function(){function e(t){Gh(this,e),Jl(this,"_preUplinkStats",new hT),Jl(this,"_preDownlinkStats",new hT),Jl(this,"_timer",void 0),Jl(this,"_delayTimer",void 0),Jl(this,"reportor",void 0),this._ctx=t}return jh(e,[{key:"updateUplinkStats",value:function(e,t){var r=e.audioStats,n=e.videoStats,i=e.isScreen;if(r.sendKBitrate>0&&r.rtt){var o,a,s=i?"screen_audio":"audio",c=r.rtt,u=r._fractionLost,d=r._retransmittedRate,l=this._getQosLevel(c,u||0,d||0),h=this._preUplinkStats.get(s)||[l];this._preUplinkStats.set(s,lI(o=Gg(a=[]).call(a,iR(h),[l])).call(o,-2))}if(n.sentKBitrate>0&&n.rtt){var p,f,_=i?"screen_video":"video",v=n._fractionLost,m=n.rtt,g=n._sendBandWidth,y=n._retransmittedRate;0===g&&(v=Math.max(.65,v));var S=this._getQosLevel(m,v||0,y||0),b=this._getUplinkVideoQoE(e,t),E=this._getVideoUplinkNetworkQuality(S,b),k=this._preUplinkStats.get(_)||[E];this._preUplinkStats.set(_,lI(p=Gg(f=[]).call(f,iR(k),[E])).call(p,-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 f=c.rtt,_=c.audioLossRate,v=c.stallDuration,m=c.statsInterval,g=c.e2eDelay,y=v/m,S=d?"screen_audio":"audio",b=this._getQosLevel(f,_||0,u._retransmittedRate||0),E=this._getDownlinkQoE(S,y,g);n=this._getNetworkQuality(b,E)}if(s)if(0===u.receivedKBitrate||0===u.rtt)p=!1;else{var k=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(k,T||0,w||0),P=this._getDownlinkQoE(x,C,A);i=this._getNetworkQuality(O,P)}var N=Gg(r="".concat(l)).call(r,d?"_screen":"");if(h||p){var M=n&&i?Math.ceil((n+i)/2):n||i;if(M){var D,L,U=this._preDownlinkStats.get(N)||[M];this._preDownlinkStats.set(N,lI(D=Gg(L=[]).call(L,iR(U),[M])).call(D,-2)),this._startNetworkQualityReport()}}else this._preDownlinkStats.delete(N)}}},{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=this;if(Qy(e=["connected","connecting"]).call(e,null===(t=this._ctx.handler)||void 0===t?void 0:t.getConnectionState())){var o,a,s,c=this._getBetterQualityAndRemoveOldest("audio","up"),u=this._getBetterQualityAndRemoveOldest("video","up");r=c&&u?Math.ceil((c+u)/2):c||u||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||Eh.EXCELLENT;var d=wy(o=$g(a=jC(ux(s=this._preDownlinkStats).call(s))).call(a,(function(e){return i._getBetterQualityAndRemoveOldest(e,"down")}))).call(o,(function(e){return e}));n=Math.ceil(uS(d).call(d,(function(e,t){return t+e}),0)/d.length)||Eh.UNKNOWN}else r=n=Eh.DOWN;navigator.onLine||(r=Eh.DOWN,n=Eh.DOWN),"function"==typeof this.reportor&&this.reportor(r,n)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getVideoUplinkNetworkQuality",value:function(e,t){return 1===t||0===t?e:2===t?Math.min(e+1,5):Math.min(e+2,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:"_getUplinkVideoQoE",value:function(e,t){var r,n=(null==e||null===(r=e.videoStats)||void 0===r?void 0:r.rid)||"0";if(!t)return 0;var i=t.pubAttributes.videoDescriptions[n],o=e.videoStats,a=o.encodedFrameWidth*o.encodedFrameHeight/(i.width*i.height),s=o.sentFrameRate/i.framerate,c=0,u=0;return"number"!=typeof a||Number.isNaN(a)||(c=a>=.9?1:a<.9&&a>=.8?2:3),"number"!=typeof s||Number.isNaN(s)||(u=s>=.8?1:s<.8&&s>=.6?2:3),Math.max(0,c,u)}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=hH[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=Eh.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=wy(i).call(i,(function(e){return e}));o.length>0&&(r=Math.min.apply(Math,iR(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&&UD(t)&&r.localaudio&&r.audiostream,videoActive:n&&VD(t)&&r.localvideo&&r.videostream}}}]),e}(),fH=function(){function e(t){Gh(this,e),Jl(this,"_timer",void 0),Jl(this,"_remoteVideoSizeCache",{}),Jl(this,"_remoteScreenSizeCache",{}),Jl(this,"onchange",void 0),this._room=t,this._start()}return jh(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,f=0;if(iL){var _,v,m=null!==(_=null==n||null===(v=n.videoTrack)||void 0===v?void 0:v.getSizeByPlayer())&&void 0!==_?_:{width:0,height:0};p=m.width,f=m.height}else{var g=a.getSettings();p=g.width||0,f=g.height||0}h===f&&d===p||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,p,f),delete s[i],(n.isScreen?r:t)[i]={width:p,height:f}}}))})),FS(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),FS(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),_H=jC((new TextEncoder).encode("subt")),vH={1:hC.SUBTITLE_ERR_POSTPROCESS,2:hC.SUBTITLE_ERR_CONNECTION_ERROR,3:hC.SUBTITLE_ERR_PROCESS_ERROR},mH=new fD("SubtitleTool",1),gH=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&kI(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))||"";kI(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=Xg({source_language:o}))}},yH=function(){function e(t,r){Gh(this,e),Jl(this,"_taskId",void 0),Jl(this,"_sourceLanguage","zh"),Jl(this,"_updating",!1),Jl(this,"onEvent",void 0),Jl(this,"onMessage",void 0),Jl(this,"_preConfig",void 0),Jl(this,"_timer",void 0),this._ctx=t,this._roomConf=r;var n=r.userInfo.extraInfo;if(n)try{var i=JSON.parse(n);i.source_language&&(this._sourceLanguage=i.source_language)}catch(o){}}var t,r,n,i;return jh(e,[{key:"start",value:(i=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(mH.info("start","Invoke config: %o",t),aU(t.mode,"mode",[Ch.ASR_ONLY,Ch.ASR_AND_TRANSLATION]),r=Array.isArray(t.targetLanguage)?t.targetLanguage:[t.targetLanguage||""],!(t.mode===Ch.ASR_AND_TRANSLATION&&Jw(r).call(r,(function(e){return-1===kI(bH).call(bH,e)}))>-1)){e.next=5;break}throw new mC(hC.INVALID_PARAMS,"Invalid targetLanguage.");case 5:if(!this._taskId){e.next=7;break}throw new mC(hC.SUBTITLE_ALREADY_ON,"Already turned on subtitle");case 7:return this._preConfig={targetLanguage:r,mode:t.mode},this._taskId=(Date.now().toString()+this._roomConf.roomId+this._roomConf.userId).substring(0,20),e.next=11,this._sendSubtitleSignalingWithRetry(t,this._taskId);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"update",value:(n=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(mH.info("update","Invoke config: %o",t),this._taskId){e.next=3;break}throw new mC(hC.SUBTITLE_NOT_TURNED_ON,"Start subtitle first.");case 3:return this._sourceLanguage=t.sourceLanguage,this._updating=!0,e.prev=5,e.next=8,this._ctx.signalingManager.sendSignaling("controlMessage",this._genChangeSubtitleLanguageSignaling(t,this._taskId));case 8:e.next=14;break;case 10:throw e.prev=10,e.t0=e.catch(5),this._updating=!1,e.t0;case 14:case"end":return e.stop()}}),e,this,[[5,10]])}))),function(e){return n.apply(this,arguments)})},{key:"stop",value:function(){var e=this;mH.info("stop","Invoke"),this._taskId&&this._ctx.signalingManager.sendSignaling("controlMessage",{type:"subtitle",action:"stopped",appId:this._ctx.appId,roomId:this._roomConf.roomId,userId:this._roomConf.userId,taskId:this._taskId}).finally((function(){var t;delete e._taskId,null===(t=e.onEvent)||void 0===t||t.call(e,{event:xh.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(r=Ug(Dg().mark((function e(){return Dg().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._ctx.signalingManager.sendSignaling("controlMessage",{type:"subtitle",action:"stopped",appId:this._ctx.appId,roomId:this._roomConf.roomId,userId:this._roomConf.userId,taskId:this._taskId});case 3:delete this._taskId,this.start(this._preConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getConfig",value:function(){return this._preConfig}},{key:"destroy",value:function(){mH.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 mC(vH[r]||hC.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:xh.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:xh.STARTED}),this._clearTimer()}else if(this._updating&&"LanguageChanged"===i){var c;this._updating=!1,null===(c=this.onEvent)||void 0===c||c.call(this,{event:xh.UPDATED})}}},{key:"onMessageRecv",value:function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]||this._taskId&&this._preConfig){var t=SH(e);if(!t||0===t.length)return!1;if(this._taskId&&this._preConfig){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){if(i===Ch.ASR_ONLY)e.mode===i&&a.push(e);else{var t=Qy(o).call(o,e.language);(t||e.mode===Ch.ASR_ONLY)&&a.push(e),e.mode===Ch.ASR_ONLY&&t&&a.push(Zl(Zl({},e),{},{mode:Ch.ASR_AND_TRANSLATION}))}})),a.length>0)null===(r=this.onMessage)||void 0===r||r.call(this,a)}return!0}return!1}},{key:"_sendSubtitleSignalingWithRetry",value:(t=Ug(Dg().mark((function t(r,n){var i,o=this,a=arguments;return Dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=a.length>2&&void 0!==a[2]?a[2]:0,t.next=3,this._ctx.signalingManager.sendSignaling("controlMessage",this._genSubtitleSignaling(r,n));case 3:this._timer=self.setTimeout((function(){var e;2===i?(null===(e=o.onEvent)||void 0===e||e.call(o,{event:xh.ERROR,errorCode:hC.TIME_OUT,errorMessage:"start subtitle timeout."}),delete o._timer,o.stop()):o._sendSubtitleSignalingWithRetry(r,n,i+1)}),e.retryIntervel);case 4:case"end":return t.stop()}}),t,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"_genSubtitleSignaling",value:function(e,t){return{taskId:t,type:"subtitle",action:"started",roomId:this._roomConf.roomId,appId:this._ctx.appId,userId:this._roomConf.userId,subtitleMeta:{subtitleConfig:{mode:e.mode,usersConfig:[{userId:this._roomConf.userId,targetLanguages:Array.isArray(e.targetLanguage)?e.targetLanguage:[e.targetLanguage||""]}]},vendorConfig:{type:0}}}}},{key:"_genChangeSubtitleLanguageSignaling",value:function(e,t){return{taskId:t,type:"subtitle",action:"subtitleUpdated",roomId:this._roomConf.roomId,appId:this._ctx.appId,userId:this._roomConf.userId,subtitleMeta:{protocol:1,languageConfig:{sourceLanguages:[{userId:this._roomConf.userId,languageCode:[e.sourceLanguage]}]}}}}},{key:"_clearTimer",value:function(){this._timer&&(self.clearTimeout(this._timer),delete this._timer)}}]),e}();Jl(yH,"retryIntervel",3e4);var SH=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(_H.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=CD.ab2str(lI(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(c){}return!1},bH=["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"],EH=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[e.DUPLICATE_DOM=-1005]="DUPLICATE_DOM",e}(EH||{}),kH="object"==typeof global&&global&&global.Object===Object&&global,TH="object"==typeof self&&self&&self.Object===Object&&self,IH=kH||TH||Function("return this")(),RH=IH.Symbol,AH=Object.prototype,wH=AH.hasOwnProperty,CH=AH.toString,xH=RH?RH.toStringTag:void 0;var OH=Object.prototype.toString;var PH="[object Null]",NH="[object Undefined]",MH=RH?RH.toStringTag:void 0;function DH(e){return null==e?void 0===e?NH:PH:MH&&MH in Object(e)?function(e){var t=wH.call(e,xH),r=e[xH];try{e[xH]=void 0;var n=!0}catch(o){}var i=CH.call(e);return n&&(t?e[xH]=r:delete e[xH]),i}(e):function(e){return OH.call(e)}(e)}function LH(e){return null!=e&&"object"==typeof e}var UH="[object Symbol]";function VH(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}var FH=Array.isArray,BH=1/0,jH=RH?RH.prototype:void 0,GH=jH?jH.toString:void 0;function HH(e){if("string"==typeof e)return e;if(FH(e))return VH(e,HH)+"";if(function(e){return"symbol"==typeof e||LH(e)&&DH(e)==UH}(e))return GH?GH.call(e):"";var t=e+"";return"0"==t&&1/e==-BH?"-0":t}function zH(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function KH(e){return e}var WH="[object AsyncFunction]",XH="[object Function]",YH="[object GeneratorFunction]",qH="[object Proxy]";function JH(e){if(!zH(e))return!1;var t=DH(e);return t==XH||t==YH||t==WH||t==qH}var QH,ZH=IH["__core-js_shared__"],$H=(QH=/[^.]+$/.exec(ZH&&ZH.keys&&ZH.keys.IE_PROTO||""))?"Symbol(src)_1."+QH:"";var ez=Function.prototype.toString;function tz(e){if(null!=e){try{return ez.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var rz=/^\[object .+?Constructor\]$/,nz=Function.prototype,iz=Object.prototype,oz=nz.toString,az=iz.hasOwnProperty,sz=RegExp("^"+oz.call(az).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function cz(e){return!(!zH(e)||(t=e,$H&&$H in t))&&(JH(e)?sz:rz).test(tz(e));var t}function uz(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return cz(r)?r:void 0}var dz=uz(IH,"WeakMap"),lz=Object.create,hz=function(){function e(){}return function(t){if(!zH(t))return{};if(lz)return lz(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}(),pz=hz;var fz=Date.now;var _z,vz,mz,gz=function(){try{var e=uz(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),yz=gz,Sz=yz?function(e,t){return yz(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:KH,bz=(_z=Sz,vz=0,mz=0,function(){var e=fz(),t=16-(e-mz);if(mz=e,t>0){if(++vz>=800)return arguments[0]}else vz=0;return _z.apply(void 0,arguments)}),Ez=bz;var kz=9007199254740991,Tz=/^(?:0|[1-9]\d*)$/;function Iz(e,t){var r=typeof e;return!!(t=null==t?kz:t)&&("number"==r||"symbol"!=r&&Tz.test(e))&&e>-1&&e%1==0&&e<t}function Rz(e,t,r){"__proto__"==t&&yz?yz(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function Az(e,t){return e===t||e!=e&&t!=t}var wz=Object.prototype.hasOwnProperty;function Cz(e,t,r){var n=e[t];wz.call(e,t)&&Az(n,r)&&(void 0!==r||t in e)||Rz(e,t,r)}function xz(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?Rz(r,s,c):Cz(r,s,c)}return r}var Oz=Math.max;function Pz(e,t){return Ez(function(e,t,r){return t=Oz(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=Oz(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,KH),e+"")}var Nz=9007199254740991;function Mz(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=Nz}function Dz(e){return null!=e&&Mz(e.length)&&!JH(e)}var Lz=Object.prototype;function Uz(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Lz)}function Vz(e){return LH(e)&&"[object Arguments]"==DH(e)}var Fz=Object.prototype,Bz=Fz.hasOwnProperty,jz=Fz.propertyIsEnumerable,Gz=Vz(function(){return arguments}())?Vz:function(e){return LH(e)&&Bz.call(e,"callee")&&!jz.call(e,"callee")},Hz=Gz;var zz="object"==typeof exports&&exports&&!exports.nodeType&&exports,Kz=zz&&"object"==typeof module&&module&&!module.nodeType&&module,Wz=Kz&&Kz.exports===zz?IH.Buffer:void 0,Xz=(Wz?Wz.isBuffer:void 0)||function(){return!1},Yz={};function qz(e){return function(t){return e(t)}}Yz["[object Float32Array]"]=Yz["[object Float64Array]"]=Yz["[object Int8Array]"]=Yz["[object Int16Array]"]=Yz["[object Int32Array]"]=Yz["[object Uint8Array]"]=Yz["[object Uint8ClampedArray]"]=Yz["[object Uint16Array]"]=Yz["[object Uint32Array]"]=!0,Yz["[object Arguments]"]=Yz["[object Array]"]=Yz["[object ArrayBuffer]"]=Yz["[object Boolean]"]=Yz["[object DataView]"]=Yz["[object Date]"]=Yz["[object Error]"]=Yz["[object Function]"]=Yz["[object Map]"]=Yz["[object Number]"]=Yz["[object Object]"]=Yz["[object RegExp]"]=Yz["[object Set]"]=Yz["[object String]"]=Yz["[object WeakMap]"]=!1;var Jz="object"==typeof exports&&exports&&!exports.nodeType&&exports,Qz=Jz&&"object"==typeof module&&module&&!module.nodeType&&module,Zz=Qz&&Qz.exports===Jz&&kH.process,$z=function(){try{var e=Qz&&Qz.require&&Qz.require("util").types;return e||Zz&&Zz.binding&&Zz.binding("util")}catch(t){}}(),eK=$z&&$z.isTypedArray,tK=eK?qz(eK):function(e){return LH(e)&&Mz(e.length)&&!!Yz[DH(e)]},rK=Object.prototype.hasOwnProperty;function nK(e,t){var r=FH(e),n=!r&&Hz(e),i=!r&&!n&&Xz(e),o=!r&&!n&&!i&&tK(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&&!rK.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Iz(u,c))||s.push(u);return s}function iK(e,t){return function(r){return e(t(r))}}var oK=iK(Object.keys,Object),aK=Object.prototype.hasOwnProperty;function sK(e){return Dz(e)?nK(e):function(e){if(!Uz(e))return oK(e);var t=[];for(var r in Object(e))aK.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var cK=Object.prototype.hasOwnProperty;function uK(e){if(!zH(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&&cK.call(e,n))&&r.push(n);return r}function dK(e){return Dz(e)?nK(e,!0):uK(e)}var lK,hK=(lK=function(e,t){xz(t,dK(t),e)},Pz((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=lK.length>3&&"function"==typeof i?(n--,i):void 0,o&&function(e,t,r){if(!zH(r))return!1;var n=typeof t;return!!("number"==n?Dz(r)&&Iz(t,r.length):"string"==n&&t in r)&&Az(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&&lK(e,a,r,i)}return e}))),pK=hK,fK=uz(Object,"create");var _K=Object.prototype.hasOwnProperty;var vK=Object.prototype.hasOwnProperty;function mK(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 gK(e,t){for(var r=e.length;r--;)if(Az(e[r][0],t))return r;return-1}mK.prototype.clear=function(){this.__data__=fK?fK(null):{},this.size=0},mK.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},mK.prototype.get=function(e){var t=this.__data__;if(fK){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return _K.call(t,e)?t[e]:void 0},mK.prototype.has=function(e){var t=this.__data__;return fK?void 0!==t[e]:vK.call(t,e)},mK.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=fK&&void 0===t?"__lodash_hash_undefined__":t,this};var yK=Array.prototype.splice;function SK(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])}}SK.prototype.clear=function(){this.__data__=[],this.size=0},SK.prototype.delete=function(e){var t=this.__data__,r=gK(t,e);return!(r<0)&&(r==t.length-1?t.pop():yK.call(t,r,1),--this.size,!0)},SK.prototype.get=function(e){var t=this.__data__,r=gK(t,e);return r<0?void 0:t[r][1]},SK.prototype.has=function(e){return gK(this.__data__,e)>-1},SK.prototype.set=function(e,t){var r=this.__data__,n=gK(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var bK=uz(IH,"Map");function EK(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 kK(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 TK(e){return null==e?"":HH(e)}function IK(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}kK.prototype.clear=function(){this.size=0,this.__data__={hash:new mK,map:new(bK||SK),string:new mK}},kK.prototype.delete=function(e){var t=EK(this,e).delete(e);return this.size-=t?1:0,t},kK.prototype.get=function(e){return EK(this,e).get(e)},kK.prototype.has=function(e){return EK(this,e).has(e)},kK.prototype.set=function(e,t){var r=EK(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};var RK=iK(Object.getPrototypeOf,Object);var AK,wK=(AK={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"},function(e){return null==AK?void 0:AK[e]}),CK=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,xK=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g");var OK=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;var PK=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;var NK="\\ud800-\\udfff",MK="\\u2700-\\u27bf",DK="a-z\\xdf-\\xf6\\xf8-\\xff",LK="A-Z\\xc0-\\xd6\\xd8-\\xde",UK="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",VK="["+UK+"]",FK="\\d+",BK="["+MK+"]",jK="["+DK+"]",GK="[^"+NK+UK+FK+MK+DK+LK+"]",HK="(?:\\ud83c[\\udde6-\\uddff]){2}",zK="[\\ud800-\\udbff][\\udc00-\\udfff]",KK="["+LK+"]",WK="(?:"+jK+"|"+GK+")",XK="(?:"+KK+"|"+GK+")",YK="(?:['’](?:d|ll|m|re|s|t|ve))?",qK="(?:['’](?:D|LL|M|RE|S|T|VE))?",JK="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",QK="[\\ufe0e\\ufe0f]?",ZK=QK+JK+("(?:\\u200d(?:"+["[^"+NK+"]",HK,zK].join("|")+")"+QK+JK+")*"),$K="(?:"+[BK,HK,zK].join("|")+")"+ZK,eW=RegExp([KK+"?"+jK+"+"+YK+"(?="+[VK,KK,"$"].join("|")+")",XK+"+"+qK+"(?="+[VK,KK+WK,"$"].join("|")+")",KK+"?"+WK+"+"+YK,KK+"+"+qK,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",FK,$K].join("|"),"g");function tW(e,t,r){return e=TK(e),void 0===(t=r?void 0:t)?function(e){return PK.test(e)}(e)?function(e){return e.match(eW)||[]}(e):function(e){return e.match(OK)||[]}(e):e.match(t)||[]}var rW=RegExp("['’]","g");function nW(e){var t=this.__data__=new SK(e);this.size=t.size}nW.prototype.clear=function(){this.__data__=new SK,this.size=0},nW.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},nW.prototype.get=function(e){return this.__data__.get(e)},nW.prototype.has=function(e){return this.__data__.has(e)},nW.prototype.set=function(e,t){var r=this.__data__;if(r instanceof SK){var n=r.__data__;if(!bK||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new kK(n)}return r.set(e,t),this.size=r.size,this};var iW="object"==typeof exports&&exports&&!exports.nodeType&&exports,oW=iW&&"object"==typeof module&&module&&!module.nodeType&&module,aW=oW&&oW.exports===iW?IH.Buffer:void 0,sW=aW?aW.allocUnsafe:void 0;function cW(){return[]}var uW=Object.prototype.propertyIsEnumerable,dW=Object.getOwnPropertySymbols,lW=dW?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}(dW(e),(function(t){return uW.call(e,t)})))}:cW,hW=lW;var pW=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)IK(t,hW(e)),e=RK(e);return t}:cW,fW=pW;function _W(e,t,r){var n=t(e);return FH(e)?n:IK(n,r(e))}function vW(e){return _W(e,sK,hW)}function mW(e){return _W(e,dK,fW)}var gW=uz(IH,"DataView"),yW=uz(IH,"Promise"),SW=uz(IH,"Set"),bW="[object Map]",EW="[object Promise]",kW="[object Set]",TW="[object WeakMap]",IW="[object DataView]",RW=tz(gW),AW=tz(bK),wW=tz(yW),CW=tz(SW),xW=tz(dz),OW=DH;(gW&&OW(new gW(new ArrayBuffer(1)))!=IW||bK&&OW(new bK)!=bW||yW&&OW(yW.resolve())!=EW||SW&&OW(new SW)!=kW||dz&&OW(new dz)!=TW)&&(OW=function(e){var t=DH(e),r="[object Object]"==t?e.constructor:void 0,n=r?tz(r):"";if(n)switch(n){case RW:return IW;case AW:return bW;case wW:return EW;case CW:return kW;case xW:return TW}return t});var PW=OW,NW=Object.prototype.hasOwnProperty;var MW=IH.Uint8Array;function DW(e){var t=new e.constructor(e.byteLength);return new MW(t).set(new MW(e)),t}var LW=/\w*$/;var UW=RH?RH.prototype:void 0,VW=UW?UW.valueOf:void 0;var FW="[object Boolean]",BW="[object Date]",jW="[object Map]",GW="[object Number]",HW="[object RegExp]",zW="[object Set]",KW="[object String]",WW="[object Symbol]",XW="[object ArrayBuffer]",YW="[object DataView]",qW="[object Float32Array]",JW="[object Float64Array]",QW="[object Int8Array]",ZW="[object Int16Array]",$W="[object Int32Array]",eX="[object Uint8Array]",tX="[object Uint8ClampedArray]",rX="[object Uint16Array]",nX="[object Uint32Array]";function iX(e,t,r){var n,i,o,a=e.constructor;switch(t){case XW:return DW(e);case FW:case BW:return new a(+e);case YW:return function(e,t){var r=t?DW(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case qW:case JW:case QW:case ZW:case $W:case eX:case tX:case rX:case nX:return function(e,t){var r=t?DW(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,r);case jW:return new a;case GW:case KW:return new a(e);case HW:return(o=new(i=e).constructor(i.source,LW.exec(i))).lastIndex=i.lastIndex,o;case zW:return new a;case WW:return n=e,VW?Object(VW.call(n)):{}}}var oX=$z&&$z.isMap,aX=oX?qz(oX):function(e){return LH(e)&&"[object Map]"==PW(e)};var sX=$z&&$z.isSet,cX=sX?qz(sX):function(e){return LH(e)&&"[object Set]"==PW(e)},uX=1,dX=2,lX=4,hX="[object Arguments]",pX="[object Function]",fX="[object GeneratorFunction]",_X="[object Object]",vX={};function mX(e,t,r,n,i,o){var a,s=t&uX,c=t&dX,u=t&lX;if(r&&(a=i?r(e,n,i,o):r(e)),void 0!==a)return a;if(!zH(e))return e;var d=FH(e);if(d){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&NW.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=PW(e),h=l==pX||l==fX;if(Xz(e))return function(e,t){if(t)return e.slice();var r=e.length,n=sW?sW(r):new e.constructor(r);return e.copy(n),n}(e,s);if(l==_X||l==hX||h&&!i){if(a=c||h?{}:function(e){return"function"!=typeof e.constructor||Uz(e)?{}:pz(RK(e))}(e),!s)return c?function(e,t){return xz(e,fW(e),t)}(e,function(e,t){return e&&xz(t,dK(t),e)}(a,e)):function(e,t){return xz(e,hW(e),t)}(e,function(e,t){return e&&xz(t,sK(t),e)}(a,e))}else{if(!vX[l])return i?e:{};a=iX(e,l,s)}}o||(o=new nW);var p=o.get(e);if(p)return p;o.set(e,a),cX(e)?e.forEach((function(n){a.add(mX(n,t,r,n,e,o))})):aX(e)&&e.forEach((function(n,i){a.set(i,mX(n,t,r,i,e,o))}));var f=d?void 0:(u?c?mW:vW:c?dK:sK)(e);return function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););}(f||e,(function(n,i){f&&(n=e[i=n]),Cz(a,i,mX(n,t,r,i,e,o))})),a}vX[hX]=vX["[object Array]"]=vX["[object ArrayBuffer]"]=vX["[object DataView]"]=vX["[object Boolean]"]=vX["[object Date]"]=vX["[object Float32Array]"]=vX["[object Float64Array]"]=vX["[object Int8Array]"]=vX["[object Int16Array]"]=vX["[object Int32Array]"]=vX["[object Map]"]=vX["[object Number]"]=vX[_X]=vX["[object RegExp]"]=vX["[object Set]"]=vX["[object String]"]=vX["[object Symbol]"]=vX["[object Uint8Array]"]=vX["[object Uint8ClampedArray]"]=vX["[object Uint16Array]"]=vX["[object Uint32Array]"]=!0,vX["[object Error]"]=vX[pX]=vX["[object WeakMap]"]=!1;function gX(e){return mX(e,5)}function yX(e){return null==e?[]:function(e,t){return VH(t,(function(t){return e[t]}))}(e,sK(e))}var SX,bX=(SX=function(e,t,r){return e+(r?"_":"")+t.toLowerCase()},function(e){return function(e,t,r,n){var i=-1,o=null==e?0:e.length;for(n&&o&&(r=e[++i]);++i<o;)r=t(r,e[i],i,e);return r}(tW(function(e){return(e=TK(e))&&e.replace(CK,wK).replace(xK,"")}(e).replace(rW,"")),SX,"")}),EX=function(){function e(t,r){Gh(this,e),Jl(this,"roomId",void 0),Jl(this,"userInfo",void 0),Jl(this,"userId",void 0),Jl(this,"sessionId",gx()),Jl(this,"token",void 0),Jl(this,"rtcVid",void 0),Jl(this,"joinPromise",void 0),Jl(this,"startJoinTimestamp",void 0),Jl(this,"_liveControlMessage",void 0),Jl(this,"_userStreamMap",new hT),Jl(this,"_roomConfig",{isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:Th.communication}),Jl(this,"_vendorConfig",{enableMultiVendor:!1,vendorCode:0}),Jl(this,"_roomAttr",{multiChatMode:!1,bigRoomMode:!1}),Jl(this,"_tokenPublishPrivilegeExpired",!1),Jl(this,"_tokenSubscribePrivilegeExpired",!1),Jl(this,"_monitor",void 0),this._ctx=r,this.roomId=t.roomId,this.userInfo=t.userInfo,this.userId=t.userInfo.userId,this.token=t.token,this._monitor=YM(r.id)}var t;return jh(e,[{key:"checkJoinRoom",value:(t=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.joinPromise;case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"vendorConfig",get:function(){return this._vendorConfig}},{key:"setVendorConfig",value:function(e){this._vendorConfig=e}},{key:"updateRoomAttributes",value:function(e){this._roomAttr=Zl(Zl({},this._roomAttr),e)}},{key:"setLiveControlMessage",value:function(e){this._liveControlMessage=e}},{key:"getLiveControlMessage",value:function(){return this._liveControlMessage}},{key:"isMultiChatMode",value:function(){return this._roomAttr.multiChatMode}},{key:"updateRoomConfig",value:function(e){return this._roomConfig=pK(this._roomConfig,e),this._roomConfig}},{key:"isAutoPublish",get:function(){return this._roomConfig.isAutoPublish}},{key:"isAutoSubscribeAudio",get:function(){return this._roomConfig.isAutoSubscribeAudio}},{key:"isAutoSubscribeVideo",get:function(){return this._roomConfig.isAutoSubscribeVideo}},{key:"remoteVideoConfig",get:function(){return this._roomConfig.remoteVideoConfig}},{key:"roomProfileType",get:function(){return this._roomConfig.roomProfileType||Th.communication}},{key:"updateUserPubInfo",value:function(e){var t=this._userStreamMap.get(e.clientId)||{};e.screen?(t.screenAudio=e.attributes.audiostream,t.screenVideo=e.attributes.videostream):(t.audio=e.attributes.audiostream,t.video=e.attributes.videostream),this._userStreamMap.set(e.clientId,t)}},{key:"getUserPubInfo",value:function(e){return Zl({audio:!1,video:!1,screenAudio:!1,screenVideo:!1},this._userStreamMap.get(e)||{})}},{key:"resetUserPubInfo",value:function(){this._userStreamMap.clear()}},{key:"tokenPublishPrivilegeExpired",get:function(){return this._tokenPublishPrivilegeExpired}},{key:"tokenSubscribePrivilegeExpired",get:function(){return this._tokenSubscribePrivilegeExpired}},{key:"setTokenPublishPrivilegeExpired",value:function(e){this._tokenPublishPrivilegeExpired=e}},{key:"setTokenSubscribePrivilegeExpired",value:function(e){this._tokenSubscribePrivilegeExpired=e}},{key:"getStayRoomDuration",value:function(){return this.startJoinTimestamp?AD()-this.startJoinTimestamp:0}},{key:"report",value:function(e,t,r){var n;null===(n=this._monitor)||void 0===n||n.report(e,Zl({room_id:this.roomId,user_id:this.userId,rtc_session_id:this.sessionId,rtc_vid:this.rtcVid},t),r)}}]),e}(),kX=6e4,TX=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)};function IX(e,t,r){var n=r.value;return r.value=Ug(Dg().mark((function e(){var r,i,o,a=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._ctx.signalingManager.isConnected()){e.next=2;break}throw new mC(hC.NOT_CONNECTED_YET,"error in ".concat(t,": try again after connect"));case 2:return e.prev=2,e.next=5,(this._roomConf||this.config).checkJoinRoom();case 5:e.next=10;break;case 7:throw e.prev=7,e.t0=e.catch(2),new mC(hC.JOIN_ROOM_FAILED,"error in ".concat(t,": try again after joined"));case 10:for(r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.abrupt("return",n.apply(this,i));case 12:case"end":return e.stop()}}),e,this,[[2,7]])}))),r}var RX=pT,AX=KI,wX=function(e,t,r,n){for(var i,o=n>1?void 0:n?AX(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&&RX(t,r,o),o},CX=function(e){jA(c,e);var t,r,n,i,o,a,s=iw(c);function c(e,t){var r;return Gh(this,c),Jl(dA(r=s.call(this)),"_forwardDstRooms",new hT),Jl(dA(r),"forwardStreamState","stopped"),r._ctx=e,r._roomConf=t,r}return jh(c,[{key:"startForwardStream2Rooms",value:(a=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!==this.forwardStreamState&&"paused"!==this.forwardStreamState){e.next=2;break}throw new mC(hC.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke startForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("start",this._roomConf.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=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new mC(hC.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._roomConf.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=Ug(Dg().mark((function e(){var t,r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new mC(hC.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._roomConf.roomId);case 6:r=e.sent;case 7:if(this._updateDstRooms([],r),!(iR(ux(t=this._forwardDstRooms).call(t)).length>0)){e.next=10;break}throw new mC(hC.UNEXPECTED_ERROR,"stopforwardstream failed: ".concat(Xg(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=Ug(Dg().mark((function e(){var t,r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("paused"!==this.forwardStreamState&&"stopped"!==this.forwardStreamState){e.next=2;break}throw new mC(hC.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke pauseForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("stop",this._roomConf.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=Ug(Dg().mark((function e(){var t,r,n,i,o=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o.length>0&&void 0!==o[0]&&o[0]||!Qy(t=["running","stopped"]).call(t,this.forwardStreamState)){e.next=3;break}throw new mC(hC.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._roomConf.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===Oh.FORWARD_STREAM_STATE_FAILURE&&e.safeEmit(oH.ON_FORWARD_STREAM_ERROR,t)}))}))}},{key:"onForwardDstRoomUserKick",value:function(e){var t=[{dstRoomId:e.dstRoomId,code:200,forwardStreamType:"stop"}];this._updateDstRooms([],t),this.safeEmit(oH.ON_FORWARD_STREAM_ERROR,{roomId:e.dstRoomId,state:Oh.FORWARD_STREAM_STATE_FAILURE,error:Ph.FORWARD_STREAM_ERROR_REMOTE_KICKED})}},{key:"destoy",value:function(){FA(VA(c.prototype),"removeAllListeners",this).call(this),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=Jw(r).call(r,(function(t){return t.dstRoomId===e.roomId}));-1===n?r.push({dstRoomId:e.roomId,forwardStreamType:"start",code:e.roomId===t._roomConf.roomId?400:200}):r[n].forwardStreamType="update"})),r}},{key:"_transformForwardStreamResult",value:function(e){e||(e=[]);var t,r=[],n=by(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=i.dstRoomId,a=i.code,s={roomId:o,state:Oh.FORWARD_STREAM_STATE_SUCCESS,error:Ph.FORWARD_STREAM_ERROR_OK};200===a||(400===a?(s.state=Oh.FORWARD_STREAM_STATE_FAILURE,s.error=Ph.FORWARD_STREAM_ERROR_REMOTE_KICKED):a>=700&&a<800?(s.state=Oh.FORWARD_STREAM_STATE_FAILURE,s.error=Ph.FORWARD_STREAM_ERROR_INVALID_TOKEN):(s.state=Oh.FORWARD_STREAM_STATE_FAILURE,s.error=Ph.FORWARD_STREAM_ERROR_RESPONSE)),r.push(s)}}catch(j0){n.e(j0)}finally{n.f()}return r}},{key:"_updateDstRooms",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];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=dI(e).call(e,(function(e){return e.roomId===n}));if(!s&&!t._forwardDstRooms.has(n))throw new mC(hC.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=wT(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=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="".concat(PD()),"stop"!==t&&(o=$g(n).call(n,(function(e){return e.roomId})),this._roomConf.report("rtc_forward_stream",{type:"begin",dst_rooms:"{ ".concat($g(o).call(o,(function(e){return'"'.concat(e,'"')})).join(",")," }"),event_session_id:i})),a={forwardStreamType:t,roomId:r},("start"===t||"update"===t)&&(a.dstRoomInfos=null==n?void 0:$g(n).call(n,(function(e){return{dstRoomId:e.roomId,dstToken:CD.token2auth(l._ctx.appId,e.roomId,l._roomConf.userId,e.token)}}))),e.next=7,this._ctx.signalingManager.sendSignaling("forwardStream",a);case 7:if(s=e.sent,c=[],200===(null==s?void 0:s.code)){e.next=12;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)})})),this._roomConf.report("rtc_forward_stream",{type:"end",dst_rooms:Xg(c),event_session_id:i})),new mC(hC.UNEXPECTED_ERROR,"server side internal error, error code: ".concat(s));case 12:return"stop"!==t&&(null===(u=s.forwardStreamResults)||void 0===u||u.forEach((function(e){c.push({dst_room_id:e.dstRoomId,result:"dst room lost"})})),null===(d=s.forwardStreamResults)||void 0===d||d.forEach((function(e){var t=dI(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))})),this._roomConf.report("rtc_forward_stream",{type:"end",dst_rooms:Xg(c),event_session_id:i})),e.abrupt("return",s.forwardStreamResults);case 14:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})}]),c}(wU);wX([IX],CX.prototype,"startForwardStream2Rooms",1),wX([IX],CX.prototype,"updateForwardStream2Rooms",1),wX([IX],CX.prototype,"stopForwardStream2Rooms",1),wX([IX],CX.prototype,"pauseForwardStream2AllRooms",1),wX([IX],CX.prototype,"resumeForwardStream2AllRooms",1);var xX=[{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}];function OX(e,t,r){var n,i=e?null===(n=dI(r).call(r,(function(t){return t.rid===e})))||void 0===n?void 0:n.maxkbps:r[0].maxkbps;return Math.min(null!=i?i:Number.POSITIVE_INFINITY,t)}var PX=r(yA),NX=wr,MX=P,DX=rr,LX=ee,UX=hA,VX=Qt,FX=w,BX=Wc,jX=F;var GX=o((function(){var e=function(){},t=VX.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}));NX({target:"Reflect",stat:!0,forced:GX},{set:function e(t,r,n){var i,o,a,s=arguments.length<4?t:arguments[3],c=FX.f(DX(t),r);if(!c){if(LX(o=BX(t)))return e(o,r,n,s);c=jX(0)}if(UX(c)){if(!1===c.writable||!LX(s))return!1;if(i=FX.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,VX.f(s,r,i)}else VX.f(s,r,jX(0,n))}else{if(void 0===(a=c.set))return!1;MX(a,s,n)}return!0}});var HX=r(te.Reflect.set),zX=function(){function e(t){Gh(this,e),Jl(this,"_roomId",void 0),Jl(this,"_constraints",{}),Jl(this,"_profile",void 0),Jl(this,"_customMaxBitrate",0),this._appId=t}return jh(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=BL.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=BL.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=Ey(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),$g(e=FS(c)).call(e,(function(e){var t;return Gg(t="".concat(e,"=")).call(t,c[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=Zl(Zl({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=Zl({},this._constraints),t=BL.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;jD(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),jD(null==t?void 0:t.channel)||(e.channelCount=t.channel),jD(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),jD(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),jD(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return jD(e.sampleRate)&&!jD(n)&&(e.sampleRate=n),jD(e.channelCount)&&!jD(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case Ih.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case Ih.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case Ih.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case Ih.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case Ih.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),KX={start_interval:100,multiplier:2,max_interval:3e4},WX=function(){function e(){Gh(this,e),Jl(this,"_times",0),Jl(this,"_config",KX),Jl(this,"initTs",AD())}return jh(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}(),XX=function(){function e(t){var r=this;Gh(this,e),Jl(this,"_reconnectTimer",void 0),Jl(this,"_retryFunc",void 0),Jl(this,"_abortControllers",[]),Jl(this,"_monitor",void 0),Jl(this,"logger",void 0),Jl(this,"_groupConfigId",RD()),Jl(this,"_retryLimiter",new WX),Jl(this,"_timer",void 0),Jl(this,"_destroyed",!1),Jl(this,"_onlineListener",(function(){r._reconnectTimer&&r._retryFunc&&(clearTimeout(r._reconnectTimer),r._retryFunc())})),this._ctx=t,this._monitor=YM(t.id),this.logger=new fD("ICERequest",4,t.id),window.addEventListener("online",this._onlineListener)}var t,r,n,i,o;return jh(e,[{key:"getICENode",value:(o=Ug(Dg().mark((function e(t){var r;return Dg().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 mC(hC.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 o.apply(this,arguments)})},{key:"_getAccessWithRetry",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 0!==r&&this.logger.info("_getAccessWithRetry()","invoke feedbackInfo: %o, 201count: %o",e,r),new Hg((function(n,i){t._getAccessNode(e).then((function(e){t._retryLimiter.reset(),n(e)})).catch((function(o){if(!t._destroyed){if(Array.isArray(o)&&o.length>0){if(Jw(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._retryFunc=function(){t._getAccessWithRetry(e,r).then(n).catch(i)},t._reconnectTimer=self.setTimeout(t._retryFunc,a)}}))}))}},{key:"_getAccessNode",value:(i=Ug(Dg().mark((function e(t){var r=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Hg((function(e,n){var i=BL.getAccessNode(r._ctx.appId);if(i){var o,a=$g(o=Array.isArray(i)?i:[i]).call(o,(function(e){return e.cache_status=!0,e}));r.logger.info("getAccessNode","use cache node."),e(a),r._timer=window.setTimeout((function(){r._getAccessNodeFromServer(t),r._reportRtcInvokeStatus("es.R.node.cache",i),delete r._timer}),0)}else r._getAccessNodeFromServer(t).then(e).catch(n)})));case 1:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"_getAccessNodeFromServer",value:(n=Ug(Dg().mark((function e(t){var r,n,i,o=this;return Dg().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&&(null==t?void 0:t.length)>0&&BL.setAccessNode(o._ctx.appId,t,e.ttl||11200),e.dispatchDomains&&!o._ctx.useCloudProxy&&BL.setAccessUrls(e.dispatchDomains),t})).catch((function(e){if(i)return o._reportRtcInvokeStatus("es.R.req.fallback",""),BL.clearAccessUrls(),o._getAccessNodeFromServer(t);throw e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_getAccessUrls",value:function(){var e=BL.getAccessUrls()||[],t=!0;return this._reportRtcInvokeStatus("es.R.req.cache.urls",e),0===e.length&&(e=YL.ICE_CONFIG_REQUEST_URLS,t=!1,this._reportRtcInvokeStatus("es.R.req.external.urls",e)),0===e.length&&(e=YL.ICE_CONFIG_REQUEST_URLS_INTERNAL,t=!1,this._reportRtcInvokeStatus("es.R.req.internal.urls",e)),{urls:e,needFallback:t}}},{key:"getICEConfigFromServer",value:(r=Ug(Dg().mark((function e(t,r){var n,i,o,a,s=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={appID:this._ctx.appId,deviceID:BL.getDeviceId(),os:"web",sdkVersion:YL.VERSION,isOversea:YL.OVERSEA,expectedAddr:JL("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC},r&&(n.feedbackInfo=r,"ICE_FAILED"!==(null===(i=r[0])||void 0===i||null===(o=i.feedbackReason)||void 0===o?void 0:o.type)&&delete n.expectedAddr),a=$g(t).call(t,(function(e){return s._httpRequest(e,n)})),e.abrupt("return",DD(a));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_httpRequest",value:(t=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=RD(),r.connectSessionID=i,o=Date.now(),null===(n=this._monitor)||void 0===n||n.report("rtc_get_access",{error_code:0,message:Xg(r),elapse:0,type:"request",host:t,config_id:i,group_config_id:this._groupConfigId}),a=new AbortController,this._abortControllers.push(a),e.prev=6,e.prev=7,e.next=10,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:Xg(r),signal:a.signal});case 10:s=e.sent,e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),Sx(fetch)||null===(d=this._monitor)||void 0===d||d.report("rtc_error",{error_code:EH.Fetch_MODIFY,message:"get access failed, possibly due to modifying the browser's Fetch API."},{origin_error:e.t0}),e.t0;case 17:if(this._abortControllers=wy(c=this._abortControllers).call(c,(function(e){return e!==a})),200===s.status){e.next=20;break}throw{message:s.statusText,code:s.status};case 20:return e.next=22,s.json();case 22:if(200===(l=e.sent).code){e.next=25;break}throw l;case 25:return null===(u=this._monitor)||void 0===u||u.report("rtc_get_access",{error_code:200,message:Xg(l),elapse:Date.now()-o,type:"response",host:t,config_id:i,group_config_id:this._groupConfigId}),e.abrupt("return",l);case 29:throw e.prev=29,e.t1=e.catch(6),null===(h=this._monitor)||void 0===h||h.report("rtc_get_access",{error_code:Number((null===e.t1||void 0===e.t1?void 0:e.t1.code)||(null===e.t1||void 0===e.t1?void 0:e.t1.server_code)),message:null===e.t1||void 0===e.t1?void 0:e.t1.message,elapse:Date.now()-o,type:"response",host:t,config_id:i,group_config_id:this._groupConfigId},{error:Xg(e.t1)}),e.t1;case 33:case"end":return e.stop()}}),e,this,[[6,29],[7,13]])}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._destroyed=!0,window.removeEventListener("online",this._onlineListener),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}(),YX={},qX={},JX={exports:{}},QX=JX.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"]}]};FS(QX).forEach((function(e){QX[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}));var ZX=JX.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=ZX,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t,o={},a=[],s=o;return wy(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=lI(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 uS(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return $g(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=$g(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 $g(t=e.split(" ")).call(t,(function(e){var t;return uS(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return $g(r=e.split(";")).call(r,(function(e){var r;return $g(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}}))}))}}(qX);var $X=ZX,eY=/%[sdv%]/g,tY=function(e){var t=1,r=arguments,n=r.length;return e.replace(eY,(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""}}))},rY=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 tY.apply(null,n)},nY=["v","o","s","i","u","e","p","c","b","t","r","z","a"],iY=["i","c","b","a"],oY=qX,aY=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||nY,n=t.innerOrder||iY,i=[];return r.forEach((function(t){$X[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(rY(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(rY(t,r,e))}))}))})),e.media.forEach((function(e){i.push(rY("m",$X.m[0],e)),n.forEach((function(t){$X[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(rY(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(rY(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};YX.write=aY,YX.parse=oY.parse,YX.parseParams=oY.parseParams,YX.parseFmtpConfig=oY.parseFmtpConfig,YX.parsePayloads=oY.parsePayloads,YX.parseRemoteCandidates=oY.parseRemoteCandidates,YX.parseImageAttributes=oY.parseImageAttributes,YX.parseSimulcastStreamList=oY.parseSimulcastStreamList;var sY=new fD("FirefoxHandler",3),cY=Math.pow(2,32),uY="kp34Za0H+aVf862l";function dY(e){return e>cY-18?(sY.warn("generateAllSsrc","reset start id",e),dY(e=e-cY+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var lY=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:Gg(n=Gg(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Gg(o="".concat(e,"-")).call(o,t)}]},hY=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=uS(s).call(s,(function(t,r){return Gg(t).call(t,lY(e,"video",r,c))}),[]),h=[{semantics:"FID",ssrcs:Gg(r="".concat(i," ")).call(r,o)}];u&&h.push({semantics:"FEC-FR",ssrcs:Gg(d="".concat(i," ")).call(d,a)});return{ssrcs:l,ssrcGroups:h}};function pY(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 fY=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=Zl(Zl({},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,YX.write(i)};function _Y(e){return vY.apply(this,arguments)}function vY(){return(vY=Ug(Dg().mark((function e(t){var r,n,i,o,a;return Dg().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,gY(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=mY(n,a),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function mY(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(Zl(Zl({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(Zl(Zl({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var gY=function(){var e=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c;return Dg().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,CD.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=wD(Uint8Array,n,i,o,a),e.next=15,CD.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)}}(),yY=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=by(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(Qy(o=c.config).call(o,"level-asymmetry-allowed=1")&&Qy(a=c.config).call(a,"packetization-mode=1")&&Qy(s=c.config).call(s,"profile-level-id=42e0")){r=c.payload;break}}}catch(j0){i.e(j0)}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(zI(l=e.rtp).call(l,u,1)[0]);break}}else if(d.codec===t){var h;e.rtp.unshift(zI(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(" ")}},SY=function(e){var t,r=YX.parse(e);return r.media=$g(t=r.media).call(t,(function(e){return"audio"===e.type?kY(e,r):EY(e,["H264","VP8"],r)})),YX.write(r)},bY=function(e){e.media.forEach((function(e){"audio"!==e.type&&"video"!==e.type||e.rtp.forEach((function(t){var r;e.rtcpFb||(e.rtcpFb=[]),dI(r=e.rtcpFb).call(r,(function(e){return e.payload===t.payload&&"rrtr"===e.type}))||e.rtcpFb.push({payload:t.payload,type:"rrtr"})}))}))},EY=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(lC(r).call(r,"apt=")){var n=lI(r).call(r,4);u[t]=n}else Qy(r).call(r,"42e0")&&Qy(r).call(r,"packetization-mode=1")&&(l=t)})),Array.isArray(e.rtp))&&(e.rtp=wy(n=e.rtp).call(n,(function(e){var r,n=e.codec,i=e.payload;switch(n){case"H264":return r=!1,$g(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,$g(t).call(t,(function(e){e===n&&(d[i]=i,h.push(i),r=!0)})),r}})));Array.isArray(e.fmtp)&&(e.fmtp=wy(i=e.fmtp).call(i,(function(e){return d[e.payload]})));Array.isArray(e.rtcpFb)?e.rtcpFb=wy(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"})})),TY(e,r),Array.isArray(e.ext))&&(e.ext=wy(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=wy(s=e.payloads.split(" ")).call(s,(function(e){return d[e]})).join(" "));return e},kY=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{rrtr:!1},i={};Array.isArray(e.rtp)&&(e.rtp=wy(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&&FS(i).forEach((function(t){var r;null===(r=e.rtcpFb)||void 0===r||r.push({payload:Number(t),type:"rrtr"})})),TY(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},TY=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)};sE("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),TE);var IY=te.Set,RY=Ae,AY=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(RY(e)+" is not a set")},wY=RE,CY=ae("Set"),xY=CY.prototype,OY={Set:CY,add:wY("add",1),has:wY("has",1),remove:wY("delete",1),proto:xY},PY=ok,NY=function(e,t,r){return r?PY(e.keys(),t,!0):e.forEach(t)},MY=NY,DY=OY.Set,LY=OY.add,UY=function(e){var t=new DY;return MY(e,(function(e){LY(t,e)})),t},VY=function(e){return e.size},FY=Oe,BY=rr,jY=P,GY=Pr,HY=function(e){return{iterator:e,next:e.next,done:!1}},zY="Invalid size",KY=RangeError,WY=TypeError,XY=Math.max,YY=function(e,t,r,n){this.set=e,this.size=t,this.has=r,this.keys=n};YY.prototype={getIterator:function(){return HY(BY(jY(this.keys,this.set)))},includes:function(e){return jY(this.has,this.set,e)}};var qY=function(e){BY(e);var t=+e.size;if(t!=t)throw WY(zY);var r=GY(t);if(r<0)throw KY(zY);return new YY(e,XY(r,0),FY(e.has),FY(e.keys))},JY=AY,QY=UY,ZY=VY,$Y=qY,eq=NY,tq=ok,rq=OY.has,nq=OY.remove,iq=function(e){var t=JY(this),r=$Y(e),n=QY(t);return ZY(t)<=r.size?eq(t,(function(e){r.includes(e)&&nq(n,e)})):tq(r.getIterator(),(function(e){rq(t,e)&&nq(n,e)})),n},oq=function(){return!1},aq=iq;wr({target:"Set",proto:!0,real:!0,forced:!oq()},{difference:aq});var sq=AY,cq=VY,uq=qY,dq=NY,lq=ok,hq=OY.Set,pq=OY.add,fq=OY.has,_q=function(e){var t=sq(this),r=uq(e),n=new hq;return cq(t)>r.size?lq(r.getIterator(),(function(e){fq(t,e)&&pq(n,e)})):dq(t,(function(e){r.includes(e)&&pq(n,e)})),n},vq=_q;wr({target:"Set",proto:!0,real:!0,forced:!oq()},{intersection:vq});var mq=AY,gq=OY.has,yq=VY,Sq=qY,bq=NY,Eq=ok,kq=Mp,Tq=function(e){var t=mq(this),r=Sq(e);if(yq(t)<=r.size)return!1!==bq(t,(function(e){if(r.includes(e))return!1}),!0);var n=r.getIterator();return!1!==Eq(n,(function(e){if(gq(t,e))return kq(n,"normal",!1)}))},Iq=Tq;wr({target:"Set",proto:!0,real:!0,forced:!oq()},{isDisjointFrom:Iq});var Rq=AY,Aq=VY,wq=NY,Cq=qY,xq=function(e){var t=Rq(this),r=Cq(e);return!(Aq(t)>r.size)&&!1!==wq(t,(function(e){if(!r.includes(e))return!1}),!0)},Oq=xq;wr({target:"Set",proto:!0,real:!0,forced:!oq()},{isSubsetOf:Oq});var Pq=AY,Nq=OY.has,Mq=VY,Dq=qY,Lq=ok,Uq=Mp,Vq=function(e){var t=Pq(this),r=Dq(e);if(Mq(t)<r.size)return!1;var n=r.getIterator();return!1!==Lq(n,(function(e){if(!Nq(t,e))return Uq(n,"normal",!1)}))},Fq=Vq;wr({target:"Set",proto:!0,real:!0,forced:!oq()},{isSupersetOf:Fq});var Bq=AY,jq=UY,Gq=qY,Hq=ok,zq=OY.add,Kq=OY.has,Wq=OY.remove,Xq=function(e){var t=Bq(this),r=Gq(e).getIterator(),n=jq(t);return Hq(r,(function(e){Kq(t,e)?Wq(n,e):zq(n,e)})),n},Yq=Xq;wr({target:"Set",proto:!0,real:!0,forced:!oq()},{symmetricDifference:Yq});var qq=AY,Jq=OY.add,Qq=UY,Zq=qY,$q=ok,eJ=function(e){var t=qq(this),r=Zq(e).getIterator(),n=Qq(t);return $q(r,(function(e){Jq(n,e)})),n},tJ=eJ;wr({target:"Set",proto:!0,real:!0,forced:!oq()},{union:tJ});var rJ=IY;wr({target:"Set",stat:!0,forced:!0},{from:XE}),wr({target:"Set",stat:!0,forced:!0},{of:qE});var nJ=AY,iJ=OY.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=nJ(this),t=0,r=arguments.length;t<r;t++)iJ(e,arguments[t]);return e}});var oJ=AY,aJ=OY.remove;wr({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=oJ(this),r=!0,n=0,i=arguments.length;n<i;n++)e=aJ(t,arguments[n]),r=r&&e;return!!r}});var sJ=Jt,cJ=AY,uJ=NY;wr({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=cJ(this),r=sJ(e,arguments.length>1?arguments[1]:void 0);return!1!==uJ(t,(function(e){if(!r(e,e,t))return!1}),!0)}});var dJ=mn,lJ=Ze,hJ=K,pJ=Oc,fJ=ht("iterator"),_J=Object,vJ=A,mJ=function(e){if(hJ(e))return!1;var t=_J(e);return void 0!==t[fJ]||"@@iterator"in t||lJ(pJ,dJ(t))},gJ=ee,yJ=ae("Set"),SJ=function(e){return function(e){return gJ(e)&&"number"==typeof e.size&&vJ(e.has)&&vJ(e.keys)}(e)?e:mJ(e)?new yJ(e):e},bJ=P,EJ=SJ,kJ=iq;wr({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){return bJ(kJ,this,EJ(e))}});var TJ=Jt,IJ=AY,RJ=NY,AJ=OY.Set,wJ=OY.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=IJ(this),r=TJ(e,arguments.length>1?arguments[1]:void 0),n=new AJ;return RJ(t,(function(e){r(e,e,t)&&wJ(n,e)})),n}});var CJ=Jt,xJ=AY,OJ=NY;wr({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=xJ(this),r=CJ(e,arguments.length>1?arguments[1]:void 0),n=OJ(t,(function(e){if(r(e,e,t))return{value:e}}),!0);return n&&n.value}});var PJ=P,NJ=SJ,MJ=_q;wr({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){return PJ(MJ,this,NJ(e))}});var DJ=P,LJ=SJ,UJ=Tq;wr({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){return DJ(UJ,this,LJ(e))}});var VJ=P,FJ=SJ,BJ=xq;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){return VJ(BJ,this,FJ(e))}});var jJ=P,GJ=SJ,HJ=Vq;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){return jJ(HJ,this,GJ(e))}});var zJ=wr,KJ=v,WJ=AY,XJ=NY,YJ=Sn,qJ=KJ([].join),JJ=KJ([].push);zJ({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=WJ(this),r=void 0===e?",":YJ(e),n=[];return XJ(t,(function(e){JJ(n,e)})),qJ(n,r)}});var QJ=Jt,ZJ=AY,$J=NY,eQ=OY.Set,tQ=OY.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=ZJ(this),r=QJ(e,arguments.length>1?arguments[1]:void 0),n=new eQ;return $J(t,(function(e){tQ(n,r(e,e,t))})),n}});var rQ=Oe,nQ=AY,iQ=NY,oQ=TypeError;wr({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=nQ(this),r=arguments.length<2,n=r?void 0:arguments[1];if(rQ(e),iQ(t,(function(i){r?(r=!1,n=i):n=e(n,i,i,t)})),r)throw oQ("Reduce of empty set with no initial value");return n}});var aQ=Jt,sQ=AY,cQ=NY;wr({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=sQ(this),r=aQ(e,arguments.length>1?arguments[1]:void 0);return!0===cQ(t,(function(e){if(r(e,e,t))return!0}),!0)}});var uQ=P,dQ=SJ,lQ=Xq;wr({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){return uQ(lQ,this,dQ(e))}});var hQ=P,pQ=SJ,fQ=eJ;wr({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){return hQ(fQ,this,pQ(e))}});var _Q,vQ=r(rJ),mQ=["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"],gQ=new hT,yQ=!0,SQ=function(){var e=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Hg((function(e){var r={all:[],getTrackStats:function(){return[]}},n=JL("STATS_SCALLBACK_SUPPORT");if(yQ&&aL&&void 0===window.InstallTrigger&&aV&&n)try{var i,o,a,s;null===(i=t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!Qy(mQ).call(mQ,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(Zl(Zl({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return wy(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(){yQ=!1,e(r)}))}catch(c){yQ=!1,e(r)}else e(r)})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),bQ=function(){var e=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c;return Dg().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 hT,n.forEach((function(e){var t=o.get(e.type)||new hT;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("codec"))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=o.get("transport"))||void 0===n||n.forEach((function(e){e.id===d&&(s=e,t.add(e))})),null===(i=o.get("track"))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(a=o.get("media-playout"))||void 0===a||a.forEach((function(e){e.id===h&&t.add(e)})),s){var p,f,_=s,v=_.localCertificateId,m=_.remoteCertificateId,g=_.selectedCandidatePairId;null===(p=o.get("certificate"))||void 0===p||p.forEach((function(e){(e.id===v||e.id===m)&&t.add(e)})),null===(f=o.get("candidate-pair"))||void 0===f||f.forEach((function(e){e.id===g&&(c=e,t.add(e))}))}if(c){var y,S,b=c,E=b.localCandidateId,k=b.remoteCandidateId;null===(y=o.get("local-candidate"))||void 0===y||y.forEach((function(e){e.id===E&&t.add(e)})),null===(S=o.get("remote-candidate"))||void 0===S||S.forEach((function(e){e.id===k&&t.add(e)}))}}))},o.get("media-source")?null===(s=o.get("media-source"))||void 0===s||s.forEach((function(e){var t,r=new vQ;r.add(e);var n=[];null===(t=o.get("outbound-rtp"))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=o.get("remote-inbound-rtp"))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=jC(r)})):o.get("track")&&(null===(c=o.get("track"))||void 0===c||c.forEach((function(e){var t,r=new vQ;r.add(e);var n=[];null===(t=o.get("outbound-rtp"))||void 0===t||t.forEach((function(t){var i;t.trackId===e.id&&(r.add(t),n.push(t),null===(i=o.get("remote-inbound-rtp"))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=jC(r)}))),null===(r=o.get("inbound-rtp"))||void 0===r||r.forEach((function(e){var t,r=new vQ;r.add(e),null===(t=o.get("remote-outbound-rtp"))||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("track"))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(s=t.trackIdentifier)})));i[s]=jC(r)})),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),EQ=function(){var e=Ug(Dg().mark((function e(t,r,n,i){var o,a,s,c,u,d;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!iL&&!oL){e.next=22;break}if(a=[],e.prev=5,!i){e.next=12;break}return e.next=9,i.getStats();case 9:e.t0=e.sent,e.next=15;break;case 12:return e.next=14,t.getStats(r);case 14:e.t0=e.sent;case 15:e.t0.forEach((function(e){a.push(e)})),e.next=21;break;case 19:e.prev=19,e.t1=e.catch(5);case 21:return e.abrupt("return",a);case 22:return(!(s=gQ.get(t))||Date.now()-s.timestamp>150)&&(s={timestamp:Date.now(),statsPromise:bQ(t),extraStatsPromise:SQ(t)},gQ.set(t,s)),e.next=26,s.statsPromise;case 26:if(c=e.sent,u=(o?c[o]:c.all)||[],n){e.next=33;break}return e.next=31,s.extraStatsPromise;case 31:d=e.sent,u=Gg(u).call(u,(o?d.getTrackStats(o):d.all)||[]);case 33:return e.abrupt("return",u);case 34:case"end":return e.stop()}}),e,null,[[5,19]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),kQ={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!iV()||void 0},TQ=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}(TQ||{}),IQ=0,RQ=function(e){jA(c,e);var t,r,n,i,o,a,s=iw(c);function c(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return Gh(this,c),Jl(dA(r=s.call(this)),"uuid",(IQ++).toString()),Jl(dA(r),"_peerConnectionId",""),Jl(dA(r),"audioTrack4ff",void 0),Jl(dA(r),"_pc",void 0),Jl(dA(r),"_dc",void 0),Jl(dA(r),"_iceNode",void 0),Jl(dA(r),"_initSctpEvents",!1),Jl(dA(r),"_monitor",void 0),Jl(dA(r),"_offerIce",{}),Jl(dA(r),"_answerIce",{}),Jl(dA(r),"_offerSession",void 0),Jl(dA(r),"_answerSession",void 0),Jl(dA(r),"_offerMlines",[]),Jl(dA(r),"_answerMlines",[]),Jl(dA(r),"_connectReject",void 0),Jl(dA(r),"_logger",void 0),Jl(dA(r),"_destroyed",!1),Jl(dA(r),"_reportTimer",void 0),Jl(dA(r),"_clearPeerListeners",void 0),Jl(dA(r),"_iceStartTs",0),Jl(dA(r),"_icePreStepTs",0),r._ctx=e,r._groupConnectionId=t,r._isReconnect=n,r._monitor=YM(e.id),r._logger=new fD("PeerConnection_".concat(r.uuid),4,e.id),r._pc=new RTCPeerConnection(kQ),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",Gg(i=Gg(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",Gg(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",DQ.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 jh(c,[{key:"getOriginRTCPeerConnection",value:function(){return this._pc}},{key:"getConnectionId",value:function(){return this._peerConnectionId}},{key:"getGroupConnectionId",value:function(){return this._groupConnectionId}},{key:"getIceConnectionState",value:function(){return this._pc.iceConnectionState}},{key:"startIceConnect",value:(a=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p=this;return Dg().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||"",this.reportRtcPreIce("ice_start"),iL&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=17,this._pc.createOffer();case 17:if((a=e.sent).sdp){e.next=20;break}throw new mC(hC.NOT_SUPPORTED,"create offer sdp failed.");case 20:if(s=YX.parse(a.sdp),c=Ey(s.media,1),u=c[0],this._offerIce.fingerprint=s.fingerprint||u.fingerprint,!iL){e.next=36;break}return s.media=$g(d=s.media).call(d,(function(e){var t,r,n,i,o=Zl(Zl({},e),p._offerIce);return"video"===o.type&&(sV?(o.ext=null===(t=o.ext)||void 0===t?void 0:wy(t).call(t,(function(e){var t;return-1===kI(t=e.uri).call(t,"abs-send-time")})),o.rtcpFb=null===(r=o.rtcpFb)||void 0===r?void 0:wy(r).call(r,(function(e){return"goog-remb"!==e.type}))):(o.rtcpFb=null===(n=o.rtcpFb)||void 0===n?void 0:wy(n).call(n,(function(e){return"transport-cc"!==e.type})),o.ext=null===(i=o.ext)||void 0===i?void 0:wy(i).call(i,(function(e){var t;return-1===kI(t=e.uri).call(t,"transport")})))),o})),cV&&bY(s),(h=Zl({},s)).fingerprint=this._answerIce.fingerprint,h.media=$g(l=h.media).call(l,(function(e){return delete(e=Zl(Zl({},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})),cV&&bY(h),e.next=32,this.setLocalDescription(YX.write(s));case 32:return e.next=34,this.setRemoteDescription(YX.write(h));case 34:e.next=44;break;case 36:delete s.media,this._offerSession=Zl({},s),this._answerSession=Zl({},s),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),this._offerMlines=[Zl(Zl(Zl({},u),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[Zl(Zl(Zl({},u),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription();case 44:return this._reportTransportStats(),e.next=47,new Hg((function(e,t){p._connectReject=t;var n=setTimeout((function(){var e;p.reportRtcPreIce("timeout"),null===(e=p._connectReject)||void 0===e||e.call(p,{code:4,message:"connect timeout"}),delete p._connectReject}),8e3),i=function(){p._print("connect","dataChannel open"),p._reportRtcInvokeStatus("es.dc.open",""),p.reportRtcPreIce("datachannel_opened"),clearTimeout(n),e(""),delete p._connectReject},o=function(e){var t,r,i,o;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===(i=p._connectReject)||void 0===i||i.call(p,{message:"dc.onerror, ".concat(null===(o=e.error)||void 0===o?void 0:o.errorDetail),code:0}),p.emit("disconnect",DQ.DC_ERROR),delete p._connectReject,clearTimeout(n)},a=function(){var e;p._reportRtcInvokeStatus("es.dc.close",""),null===(e=p._connectReject)||void 0===e||e.call(p,{message:"dc.onclose",code:1}),p.reportRtcPreIce("datachannel_closed"),p.emit("disconnect",DQ.DC_CLOSE),delete p._connectReject,clearTimeout(n)},s=function(){"connected"===p._pc.iceConnectionState?p.reportRtcPreIce("ice_connected"):"failed"!==p._pc.iceConnectionState&&"closed"!==p._pc.iceConnectionState||p.reportRtcPreIce("ice_failed")},c=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:Gg(t="pc.connectionstatechange -> ".concat(p._pc.connectionState,", ice -> ")).call(t,p._pc.iceConnectionState),code:2}),delete p._connectReject,clearTimeout(n))};r.addEventListener("open",i),r.addEventListener("error",o),r.addEventListener("close",a),p._pc.addEventListener("iceconnectionstatechange",s),p._pc.addEventListener("connectionstatechange",c),p._clearPeerListeners=function(){r.removeEventListener("open",i),r.removeEventListener("error",o),r.removeEventListener("close",a),p._pc.removeEventListener("iceconnectionstatechange",s),p._pc.removeEventListener("connectionstatechange",c)}}));case 47:return this._print("connect","dataChannel establish success"),e.abrupt("return",r);case 49:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"setDescription",value:(o=Ug(Dg().mark((function e(t){var r,n;return Dg().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=AD(),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:AD()-n}),e.next=13,this.setLocalDescription(YX.write(this._offerSession),t);case 13:return e.next=15,this.setRemoteDescription(YX.write(this._answerSession),t);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setLocalDescription",value:(i=Ug(Dg().mark((function e(t,r){var n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=AD(),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:AD()-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=13;break;case 8:throw 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:AD()-n},{type:"offer"}),e.t0;case 13:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return i.apply(this,arguments)})},{key:"setRemoteDescription",value:(n=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=AD(),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:AD()-n},{type:"answer"}),e.next=12;break;case 7:throw 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:AD()-n},{type:"answer"}),e.t0;case 12:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return n.apply(this,arguments)})},{key:"closeIceConnect",value:function(){var e,t,r,n;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(),delete this._dc,this._pc.ontrack=null,this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,n=this._pc,gQ.has(n)&&gQ.delete(n),null===(r=this._clearPeerListeners)||void 0===r||r.call(this),delete this._clearPeerListeners}},{key:"reportRtcPreIce",value:function(e){var t,r=AD();"ice_start"===e&&(this._iceStartTs=r,this._icePreStepTs=r),this._report("rtc_pre_ice",{connect_event:e,message:e,elapse:r-this._icePreStepTs,total_elapse:r-this._iceStartTs,cache_status:!(null===(t=this._iceNode)||void 0===t||!t.cache_status),is_reconnect:this._isReconnect}),this._icePreStepTs=r}},{key:"getStatsWithLowFrequency",value:function(e,t,r){return EQ(this._pc,e,t,r)}},{key:"destroy",value:function(){this._print("destroy",this._peerConnectionId),FA(VA(c.prototype),"removeAllListeners",this).call(this),this.closeIceConnect(),this._destroyed=!0,this._reportTimer&&(clearTimeout(this._reportTimer),delete this._reportTimer),delete this._pc}},{key:"_genIceInfo",value:(r=Ug(Dg().mark((function e(t){var r,n,i,o;return Dg().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,_Y(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 r.apply(this,arguments)})},{key:"_reportTransportStats",value:(t=Ug(Dg().mark((function e(){var t,r,n,i,o=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getStatsWithLowFrequency();case 2:t=e.sent,r={},t.forEach((function(e){if("transport"===e.type)r.dtls_state=e.dtlsState,r.bytes_received=e.bytesReceived,r.bytes_sent=e.bytesSent,r.ice_state=e.iceState,r.packets_received=e.packetsReceived,r.packets_sent=e.packetsSent,r.selected_candidate_pair_changes=e.selectedCandidatePairChanges;else if("local-candidate"===e.type||"remote-candidate"===e.type){var t;r.candidates_info=Gg(t=[]).call(t,iR(r.candidates_info||[]),[{id:e.id,is_remote:e.isRemote,port:e.port,protocol:e.protocol,candidate_type:e.candidateType,priority:e.priority,network_type:e.networkType,candidate_ip:e.ip}])}else"candidate-pair"===e.type&&(r.candidatePairsInfo={},r.candidatePairsInfo.candidate_state=e.state,r.candidatePairsInfo.writable_state=e.writable,r.candidatePairsInfo.sent_ping_requests_total=e.requestsSent,r.candidatePairsInfo.recv_ping_requests=e.requestsReceived,r.candidatePairsInfo.sent_ping_responses=e.responsesSent,r.candidatePairsInfo.recv_ping_responses=e.responsesReceived,r.candidatePairsInfo.current_rtt=e.currentRoundTripTime,r.candidatePairsInfo.total_rtt=e.totalRoundTripTime,["localCandidateId","remoteCandidateId","bytesSent","bytesReceived","availableOutgoingBitrate","availableIncomingBitrate","bytesDiscardedOnSend","consentRequestsSent","packetsDiscardedOnSend","lastPacketReceivedTimestamp","lastPacketSentTimestamp"].forEach((function(t){void 0!==e[t]&&(r.candidatePairsInfo[bX(t)]=e[t])})))})),FS(r).length>0&&(null===(n=this._monitor)||void 0===n||n.report("rtc_transport_statistics",r)),this._destroyed||(i="connected"===this._pc.iceConnectionState&&"connected"===this._pc.connectionState,this._reportTimer=setTimeout((function(){o._reportTransportStats()}),i?5e3:1e3));case 7:case"end":return e.stop()}}),e,this)}))),function(){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,Gg(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,Zl(Zl({},t),{},{connection_id:this._peerConnectionId,group_connection_id:this._groupConnectionId}),Zl(Zl({},r),{},{tcp_only:null===(i=this._iceNode)||void 0===i?void 0:i.iceConfig.tcpOnly,ms_addr:Xg((null===(o=this._iceNode)||void 0===o?void 0:$g(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 mC(hC.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 mC(hC.NOT_SUPPORTED,"missing peer.".concat(e," API."))}))}}]),c}(wU),AQ=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(AQ||{}),wQ=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}(wQ||{}),CQ=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}(CQ||{}),xQ=(Jl(_Q={},0,[0,"success"]),Jl(_Q,1,[hC.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),Jl(_Q,2,[hC.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),Jl(_Q,3,[hC.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),Jl(_Q,4,[hC.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),Jl(_Q,5,[hC.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),Jl(_Q,17,[hC.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),Jl(_Q,18,[hC.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),Jl(_Q,100,[hC.USER_MESSAGE_NOT_JOIN,"not join room"]),Jl(_Q,105,[hC.USER_MESSAGE_NOT_LOGIN,"not login."]),Jl(_Q,106,[hC.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),Jl(_Q,1e3,[hC.USER_MESSAGE_UNKNOWN,"unknown."]),_Q),OQ=["msg"],PQ=[],NQ=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}(NQ||{}),MQ=function(e){jA(a,e);var t,r,n,i,o=iw(a);function a(e,t,r){var n;return Gh(this,a),Jl(dA(n=o.call(this)),"_singlingCache",new hT),Jl(dA(n),"_p2pCache",new hT),Jl(dA(n),"_rttIds",{}),Jl(dA(n),"_p2pMessageId",new $D),Jl(dA(n),"_clearDataChannelListener",void 0),Jl(dA(n),"_monitor",void 0),Jl(dA(n),"logger",void 0),n.id=e,n._dataChannel=t,n.connectionIds=r,n._clearDataChannelListener=n._handleHandler(),n._monitor=YM(e),n.logger=new fD("DataChannelSignaling",3,e),n}return jh(a,[{key:"destroy",value:function(){var e=this;this._clearDataChannelListener(),delete this._dataChannel,this._singlingCache.forEach((function(t,r){t.error(new mC(hC.OPERATION_CANCEL,"disconnect")),e._singlingCache.delete(r)})),this._singlingCache.clear(),this._p2pCache.clear(),this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:6e4;return new Hg((function(o,a){var s,c,u=n._genHeader(r);u.id=xD();var d=u.id.join("-"),l=Zl({error_code:0,message:Xg(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up",event_session_id:d},n.connectionIds);null===(s=n._monitor)||void 0===s||s.report("rtc_signaling",l);var h="customMessage"===e;h&&VM.samplingOne2ManyMsg(n.id,Number(u.id.join("")),t);var p=setTimeout((function(){n._singlingCache.delete(d),a(new mC(hC.TIME_OUT,"".concat(e," message time out"))),h&&VM.updateOne2ManyMsgAck(n.id,t,999)}),i);n._singlingCache.set(d,{start:AD(),signalingType:e,success:function(e){clearTimeout(p),o(e),h&&VM.updateOne2ManyMsgAck(n.id,t,0)},error:function(e){clearTimeout(p),a(e),h&&VM.updateOne2ManyMsgAck(n.id,t,e.code)},id:d}),n.logger.info("Signal",Gg(c=">>>>>> [".concat(e,"][")).call(c,d,"]"),t),n._sendMessage(e,u,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=Ug(Dg().mark((function e(t,r){var n,i,o;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=uA(t,OQ),o=n instanceof ArrayBuffer,e.t0=this,e.t1=VM,e.t2=this.id,e.t3=Zl,e.t4=Zl({ver:1,id:this._p2pMessageId.getMessageId(),time:Date.now(),dir:AQ.SEND,type:wQ.P2P,err:CQ.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,CD.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 ND(e.msg)?this._rttIds[e.id]=e.id:e.dir===AQ.SEND&&this.logger.info("_sendP2PMessage [DC Signaling p2p >>]",Xg(e)),new Hg((function(n,i){var o=t._genHeader(Zl(Zl({needAck:!0,functionType:1},r),{},{id:xD()}));if(e.dir===AQ.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new mC(hC.USER_MESSAGE_TIMEOUT,"P2P message timeout")),VM.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),VM.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),VM.updateP2PMsgAck(t.id,e,r.err);var o=Ey(xQ[r.err]||[hC.USER_MESSAGE_UNKNOWN,Gg(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===hC.NOT_CONNECTED_YET&&(s.code=hC.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new mC(hC.NOT_CONNECTED_YET,"DataChannel not open");var i=JL("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=CD.str2ab(Xg([e,r])),c=wD(Uint8Array,Gg(n=[o,a]).call(n,iR(t.id||[])),i||t.zip?gM.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:EH.DC_SEND_ERROR}),d}"p2p"===e?VM.updateP2PMsgReq(this.id,r,c.buffer.byteLength):"customMessage"===e&&VM.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=jC(lI(t).call(t,2,r))}return{header:o,data:lI(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:$g(n=e.split("-")).call(n,(function(e){return Number(e)}))});Qy(PQ).call(PQ,t)||this.logger.info("Signal",Gg(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,d;return Dg().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 gM.Inflate).push(o,!0),o=s.result),c=CD.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",Zl({error_code:-1,message:e.t0.message,reason:"message parse failed"},this.connectionIds))),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=Ug(Dg().mark((function e(t,r,n,i,o){var a,s,c,u,d;return Dg().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],Qy(PQ).call(PQ,u)||this.logger.info("Signal","<<<<<< ".concat(u),r,s),this._feedbackSignaling(s,u,u===PU.ON_CUSTOM_MESSAGE?Zl(Zl({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,CD.b64str2ab(r.message,this._monitor);case 13:r.message=e.sent;case 14:d=Date.now(),this.emit(u,Zl({},r)),u===PU.ON_CUSTOM_MESSAGE&&VM.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",Zl({error_code:0,message:n,signaling_event:"on-".concat(u),signaling_type:"Recv",stream_id:r.streamId,stream_user_id:r.clientId,direction:"down"},this.connectionIds));case 18:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"C2C",value:(t=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,f,_,v;return Dg().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)===AQ.FEEDBACK||ND(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===AQ.SEND?6:e.t0===AQ.FEEDBACK?46:48;break;case 6:if(u=Date.now(),ND(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,f=d.to,_=d.from,v=""===p?l?PU.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:PU.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:l?PU.USER_BINARY_MESSAGE_RECEIVED:PU.USER_MESSAGE_RECEIVED,f){e.next=27;break}if(e.t1=this,e.t2=PU.ON_CUSTOM_MESSAGE,e.t3=_,e.t4=l,!l){e.next=21;break}return e.next=18,CD.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=v,e.t10=Zl,e.t11=Zl({},t),e.t12={},!l){e.next=38;break}return e.next=35,CD.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(Zl(Zl({},t),{},{dir:AQ.FEEDBACK,msg:""})),VM.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=Ey(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",Zl({error_code:0,message:r,signaling_event:"on-".concat(d),signaling_type:"Recv",stream_id:"",stream_user_id:"",direction:"down"},this.connectionIds)),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 f=JSON.parse(l);f.length&&this.emit(d,f[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(){var i=e._dataChannel;null==i||i.removeEventListener("close",t),null==i||i.removeEventListener("error",r),null==i||i.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){return Zl({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",Gg(i="<<<<<< [".concat(o.signalingType,"-ack] ")).call(i,e),t));var a=Zl({error_code:0,message:r,signaling_event:null==o?void 0:o.signalingType,signaling_type:"Ack",stream_id:"",stream_user_id:"",direction:"down",elapse:o?AD()-o.start:0},this.connectionIds);null!=o&&o.id&&(a.event_session_id=o.id),null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",a)}},{key:"_handleP2PMsgFeedback",value:function(e){var t=this._p2pCache.get(e.id);t&&(this._p2pCache.delete(e.id),e.err===CQ.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(IU.EventEmitter),DQ=function(e){return e.ICE_FAILED="ice failed",e.DC_ERROR="datachannel onerror",e.DC_CLOSE="datachannel onclose",e.NODE_CHANGE="recv nodeChange signaling",e.NOTIFY_RECONNECT="recv notifyReconnect signaling",e.JOIN_TIMEOUT="joinRoom timeout, retry with tcp only",e}(DQ||{}),LQ=function(e){jA(o,e);var t,r,n,i=iw(o);function o(e){var t;return Gh(this,o),Jl(dA(t=i.call(this)),"id",void 0),Jl(dA(t),"_monitor",void 0),Jl(dA(t),"logger",void 0),Jl(dA(t),"_getAccessManager",void 0),Jl(dA(t),"_connectionPool",new hT),Jl(dA(t),"_curConnection",void 0),Jl(dA(t),"_hasReportBrowerWarning",!1),Jl(dA(t),"_reconnectTimer",void 0),Jl(dA(t),"_connecting",!1),Jl(dA(t),"_isFirstTimeConnected",!0),Jl(dA(t),"_feedbackNodes",[]),Jl(dA(t),"_preIceStartTime",-1),Jl(dA(t),"_tcpOnlyTimer",void 0),Jl(dA(t),"_destroyed",!1),t._ctx=e,t.id=e.id,t._monitor=YM(t.id),t.logger=new fD("ConnectionManager",3,t.id),t.logger.info("constructor","invoke"),t._getAccessManager=new XX(e),t}return jh(o,[{key:"startup",value:function(){var e=this;this.logger.info("connect","invoke");try{RQ.checkSupported()}catch(t){this.asyncEmit("disconnected",t)}this._connecting||(this._onConnectStart(),Hg.resolve().then((function(){return e.emit("__onGetIceConfigHook")})),this._getAccess())}},{key:"reconnectByNodeChange",value:(n=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.info("reconnectByNodeChange","invoke %o",t),a=t.nodes,s=t.reason,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:Xg(t),reason:Xg(s)}),BL.clearAccessNode(this._ctx.appId),null===(n=this._curConnection)||void 0===n||n.pc.reportRtcPreIce("node_change"),c=(null===(i=this._curConnection)||void 0===i||null===(o=i.node.publicIPs[0])||void 0===o?void 0:o.ip)||"",this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart("recv nodeChange signaling"),Array.isArray(a)&&a.length>0?this._startIceConnect(a):this._getAccess([{feedbackIP:c,feedbackReason:{type:"NODE_CHANGED",reason:s}}]);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"reconnect",value:(r=Ug(Dg().mark((function e(t){var r,n=arguments;return Dg().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:"shotdown",value:function(){var e=this;this.logger.info("destroy","invoke"),this._destroyed=!0,this.asyncEmit("disconnected",new mC(hC.OPERATION_CANCEL,"destroy")).then((function(){FA(VA(o.prototype),"removeAllListeners",e).call(e)})),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.asyncEmit("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=gx();this._preIceStartTime=AD();var i=this._ctx.joinRoomConfig.useTcpJoin,o=this._ctx.joinRoomConfig.useTcpJoinDelay,a=function(){var i=Ug(Dg().mark((function i(o){var a,s,c,u;return Dg().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return r&&((o=gX(o)).iceConfig.tcpOnly=!0),a={node:o},i.prev=2,s=new RQ(t._ctx,n,!t._isFirstTimeConnected),a.pc=s,t._connectionPool.set(s.uuid,a),i.next=8,s.startIceConnect(o);case 8:return c=i.sent,u=new MQ(t.id,c,{connection_id:s.getConnectionId(),group_connection_id:n}),a.signaling=u,s.reportRtcPreIce("datachannel_send_ping"),i.next=14,u.sendPingSignaling();case 14:s.reportRtcPreIce("datachannel_recv_pong"),t._onConnectSuccess({node:o,pc:s,signaling:u,dc:c}),t.safeEmit("__onConnectSuccessHook",e.length),i.next=22;break;case 19:i.prev=19,i.t0=i.catch(2),t._onConnectionFailed(a,i.t0);case 22:case"end":return i.stop()}}),i,null,[[2,19]])})));return function(e){return i.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=gX(e)).iceConfig.tcpOnly=!0,a(e)})),delete t._tcpOnlyTimer}),o))}}},{key:"_onConnectSuccess",value:function(e){var t,r=this;(this.logger.info("connect","peer_%s connect success.",e.pc.uuid),this.emit("__onIceConnectSuccessHook",e),this._curConnection)?(e.pc.destroy(),e.signaling.destroy(),this._connectionPool.delete(e.pc.uuid)):(this._curConnection=e,this._addConnectionHandler(e.pc),null===(t=this._monitor)||void 0===t||t.set({connection_id:e.pc.getConnectionId()}),this._connectionPool.delete(e.pc.uuid),this._feedbackNodes.forEach((function(e){return r._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!==TQ.DESTROY&&t.code!==hC.OPERATION_CANCEL)&&(this._curConnection?this._feedbackBySignaling(e.node):this._feedbackNodes.push(e.node),this.logger.info("connect","remove cache node"),BL.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(),AD()-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=Ug(Dg().mark((function e(t){return Dg().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($g(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:EH.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||"init")),this._connecting=!0,e?this.asyncEmit("reconnecting",e):this.asyncEmit("connecting");var r,n=gx();(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.asyncEmit("connected",e),e.node.iceConfig.tcpOnly&&(this.logger.info("_onConnectEnded","use tcp only"),$M(this._ctx.id,"connected_with_tcp_only",Xg(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.signaling)||void 0===n||n.destroy(),null===(i=t.pc)||void 0===i||i.destroy(),e._connectionPool.delete(r)}))}},{key:"_clearReconnectTimer",value:function(){this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer)}}]),o}(wU),UQ=r(mi.f("asyncIterator"));function VQ(e){var t,r,n,i=2;for(void 0!==wl&&(r=UQ,n=Wl);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new FQ(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function FQ(e){function t(e){if(Object(e)!==e)return ig.reject(new TypeError(e+" is not an object."));var t=e.done;return ig.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(FQ=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?ig.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?ig.reject(e):t(r.apply(this.s,arguments))}},new FQ(e)}var BQ,jQ,GQ,HQ=function(e){jA(n,e);var t,r=iw(n);function n(e,t){var i;return Gh(this,n),Jl(dA(i=r.call(this)),"_context",void 0),Jl(dA(i),"peerConnectionMode",0),Jl(dA(i),"id",void 0),Jl(dA(i),"_monitor",void 0),Jl(dA(i),"logger",void 0),Jl(dA(i),"_nextSsrc",Math.floor(Math.random()*cY+1e4)),Jl(dA(i),"_aSendonlyAnswerTpl",void 0),Jl(dA(i),"_vSendonlyAnswerTpl",void 0),Jl(dA(i),"_enableSubFlexfec",!1),Jl(dA(i),"audioTrack4ff",void 0),Jl(dA(i),"setLocalDescription",void 0),Jl(dA(i),"setRemoteDescription",void 0),i.peer=t,i.id=e.id,i._monitor=YM(i.id),i.logger=new fD("BasicHandler",3,e.id),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 jh(n,[{key:"destroy",value:function(){this.logger.info("destroy",this.peerConnectionId||""),FA(VA(n.prototype),"removeAllListeners",this).call(this)}},{key:"_peerConnection",get:function(){return this.peer.getOriginRTCPeerConnection()}},{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=$g(o=lI(a=lI(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=zD(e.width),i=t.width/n;return{width:n,height:Math.floor(t.height/i),scaleResolutionDownBy:i,frameRate:zD(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,r,n=e.stream,i=e.videoTrack,o=e.audioTrack,a=e.enableSimulcast,s=e.pubAudio,c=e.pubVideo,u={direction:"sendonly",streams:[n]},d={direction:"sendonly",streams:[n]},l=[],h=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var p,f,_=null==i?void 0:i.preprocessingTrack,v=Zl({},eU);if(_){var m=null==_?void 0:_.getSettings();v={width:Math.floor(m.width),height:Math.floor(m.height),frameRate:Math.floor(m.frameRate)}}"number"!=typeof v.frameRate&&(v.frameRate=30);var g=null==e?void 0:e.videoEncodeConfig[0],y={maxBitrate:1e3*g.maxKbps,rid:"0"};if(e.prevBitrate=g.maxKbps,d.sendEncodings=[y],l.push({width:v.width,height:v.height,framerate:v.frameRate,maxkbps:g.maxKbps,rid:"0"}),a&&(!iL||"VP8"===(null===(p=this._context)||void 0===p||null===(f=p.serverConfig)||void 0===f?void 0:f.videoCodec))){var S,b,E=function(e){for(var t=0,r=e.width*e.height,n=0;n<xX.length;n++)if(r>=xX[n].totalPixels){t=n;break}if(0===t)return xX[t].maxLayers;var i=xX[t-1].totalPixels;return(i-r)/(i-xX[t].totalPixels)<.1?xX[t-1].maxLayers:xX[t].maxLayers}(v);if(this.logger.info("simulcast() ","maxLayers: %o",E),E>1)this._simulcast(e,Zl(Zl({},v),{},{maxKbps:g.maxKbps}),d,l,E),null!==(S=this._context)&&void 0!==S&&null!==(b=S.serverConfig)&&void 0!==b&&b.simulcastOnDemand&&(h=$g(l).call(l,(function(e,t){return Zl(Zl({},e),{},{video_index:t,sub_index:t})})))}}null!==(t=this._context)&&void 0!==t&&null!==(r=t.serverConfig)&&void 0!==r&&r.e2eFeedback&&(h=$g(l).call(l,(function(e,t){return Zl(Zl({},e),{},{video_index:t,sub_index:t})}))),this.logger.info("publish videoTransceiverInit videoDescriptions","",d,l);var k=null==o?void 0:o.preprocessingTrack;(null==o?void 0:o.mixType)!==Lh.PLAYOUT&&null!=o&&o.mixedAudioTrack&&(k=null==o?void 0:o.mixedAudioTrack),k=s&&k?k:"audio";var T=null==i?void 0:i.preprocessingTrack;T=c&&T?T:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",Xg({aTrack:bx(k),vTrack:bx(T),audioTransceiverInit:u,videoTransceiverInit:d}))}catch(B0){}return{semantics:"unified-plan",videoDescriptions:l,subVideoDescriptions:h,audioTransceiverInit:{track:k,init:u},videoTransceiverInit:{track:T,init:d}}}},{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:$g(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",Xg(c.encodings))}catch(B0){}}}else this.logger.warn("updateMaxBitrate()","no pub")}},{key:"setCurrentDescription",value:(t=Ug(Dg().mark((function e(){return Dg().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=YX.parse(e);r.media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:dI(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:dI(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&&Qy(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))})),cV&&bY(r)}},{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(Qy(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=dI(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=Gg(s=[]).call(s,iR(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,Zl(Zl({},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}(IU.EventEmitter),zQ=new fD("queue",4),KQ=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(KQ||{}),WQ=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(WQ||{}),XQ=(Jl(BQ={},"publish","unpublish"),Jl(BQ,"subscribe","unsubscribe"),Jl(BQ,"pushtrack","removetrack"),BQ),YQ=(Jl(jQ={},"publish",0),Jl(jQ,"subscribe",0),Jl(jQ,"pushtrack",0),Jl(jQ,"unpublish",1),Jl(jQ,"unsubscribe",1),Jl(jQ,"removetrack",1),jQ),qQ=function(e){jA(r,e);var t=iw(r);function r(){var e;return Gh(this,r),Jl(dA(e=t.call(this)),"_queue",void 0),e._queue=[],e}return jh(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t,r=this._queue.length,n="";return this._queue=wy(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==XQ[t.action]||(n=t.streamId,zQ.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;aL&&OL>=86&&OL<=92&&(t=Math.min(this._queue.length,5));for(var r=YQ[this._queue[0].action],n=1;n<t;n++){var i;if(YQ[this._queue[n].action]!==r)return{sdpStrategy:r,items:zI(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:zI(e=this._queue).call(e,0,t)}}}]),r}(RU),JQ=iV(),QQ=function(e){jA(c,e);var t,r,n,i,o,a,s=iw(c);function c(e,t){var r;return Gh(this,c),Jl(dA(r=s.call(this,e,t)),"name","chrome"),Jl(dA(r),"_queueBusy",!1),Jl(dA(r),"_sdpQueue",void 0),Jl(dA(r),"_aSendonlyOfferTpl",void 0),Jl(dA(r),"_vSendonlyOfferTpl",void 0),Jl(dA(r),"_aRecvonlyOfferTpl",void 0),Jl(dA(r),"_vRecvonlyOfferTpl",void 0),Jl(dA(r),"_mid",10),Jl(dA(r),"_inactiveMlineIndex",[]),Jl(dA(r),"_mlinesCache",{}),Jl(dA(r),"setDescription",void 0),r.logger=new fD("ChromeHandler",3,e.id),r.setDescription=t.setDescription.bind(t),r._sdpQueue=new qQ,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(r.logger.info("dequeue start"),r.dequeue())})),r}return jh(c,[{key:"destroy",value:function(){FA(VA(c.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(a=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,N,M,D,L,U,V,F,B;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d=t.stream,l=t.enableSimulcast,h=FA(VA(c.prototype),"internalPublish",this).call(this,t),p=h.videoDescriptions,f=h.subVideoDescriptions,_=h.audioTransceiverInit,v=h.videoTransceiverInit,m=dY(this._nextSsrc),this._nextSsrc=m.next,g="".concat(this._mid++),y="".concat(this._mid++),S=Zl(Zl(Zl({},this._aSendonlyOfferTpl),this.peer._offerIce),{},{mid:g,msid:Gg(r="".concat(d.id," ")).call(r,d.id,"-audio"),ssrcs:lY(d.id,"audio",m.audio,uY)}),b=Zl(Zl(Zl({},this._vSendonlyOfferTpl),this.peer._offerIce),{},{mid:y,msid:Gg(n="".concat(d.id," ")).call(n,d.id,"-video")}),l?(this.logger.info("subVideoDesc","desc: %o ",f),delete b.ssrcGroups,delete b.ssrcs,E=[],b.rids=$g(p).call(p,(function(e){var t=e.rid;return E.unshift(t),{id:t,direction:"send"}})),b.simulcast={dir1:"send",list1:E.join(";")}):(k=hY(d.id,m,{cname:uY}),T=k.ssrcs,I=k.ssrcGroups,b.ssrcs=T,b.ssrcGroups=I),null!==(i=this._context)&&void 0!==i&&null!==(o=i.serverConfig)&&void 0!==o&&o.audioRed&&Array.isArray(S.rtp)&&(-1!==(A=Jw(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(C=zI(w=S.rtp).call(w,A,1),x=Ey(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&&yY(b,null===(N=this._context)||void 0===N||null===(M=N.serverConfig)||void 0===M?void 0:M.videoCodec),Array.isArray(b.ext)&&(JL("IOS_SAFARI_ORIENTATION")||!oL&&!gL||(b.ext=wy(L=b.ext).call(L,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&Qy(t).call(t,"video-orientation"))}))),b.ext=wy(D=b.ext).call(D,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&Qy(t).call(t,"framemarking"))}))),(U=null==S?void 0:dI(u=S.rtp).call(u,(function(e){return"opus"===e.codec})))&&S.fmtp&&(B=dI(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||oL||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:fY(this.peer._offerSession,S,b),audioMid:g,videoMid:y,type:"incroffer",semantics:"unified-plan",videoDescriptions:p,subVideoDescriptions:f,audioTransceiverInit:_,videoTransceiverInit:v,peerConnectionMode:this.peerConnectionMode});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"subscribe",value:(o=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,N,M,D,L,U;return Dg().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,ZQ();case 6:return c=e.sent,e.next=9,this.createAVMlineOfferTpl(c);case 9:return u="",d="",l=!1,h=!1,p=void 0,f=void 0,this._mlinesCache[t.streamId]=[p,f],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=Zl(Zl({},gX(this._aRecvonlyOfferTpl)),{},{mid:u})),l&&(this._mlinesCache[t.streamId][0]=p,_={track:"audio",init:{direction:"recvonly"}}),d&&(f=Zl(Zl({},gX(this._vRecvonlyOfferTpl)),{},{mid:d})),h&&(this._mlinesCache[t.streamId][1]=f,v={track:"video",init:{direction:"recvonly"}}),m=fY(this.peer._offerSession,p,f),g=void 0,y=void 0,t.enableVendorMode||r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl||(g=dY(this._nextSsrc),this._nextSsrc=g.next,A=Zl(Zl(Zl({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Gg(S=Gg(b="".concat(t.streamId)).call(b,null!==(E=this._context)&&void 0!==E&&E.avSync?"":"-audio"," ")).call(S,t.streamId,"-audio"),ssrcs:lY(t.streamId,"audio",g.audio)}),w=Zl(Zl(Zl({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:d,msid:Gg(k=Gg(T="".concat(t.streamId)).call(T,null!==(I=this._context)&&void 0!==I&&I.avSync?"":"-video"," ")).call(k,t.streamId,"-video")},hY(t.streamId,g,{flexfec:this._enableSubFlexfec})),y={sdp:YX.write(Zl(Zl({},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:dI(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:dI(O=x.fmtp).call(O,(function(e){return e.payload===C.payload})))&&this._context&&(P.config+=";stereo=1;sprop-stereo=1"),t.isPublic&&OL>=86&&null!=(L=null===(N=f)||void 0===N?void 0:wy(M=N.rtp).call(M,(function(e){return"H264"===e.codec})))&&L.length&&null!==(D=f)&&void 0!==D&&D.fmtp&&(null===(U=f)||void 0===U||U.fmtp.forEach((function(e){dI(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:v,allSsrc:g,peerConnectionMode:this.peerConnectionMode,signalingAck:y});case 29:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"handleAck",value:(i=Ug(Dg().mark((function e(t){return Dg().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 i.apply(this,arguments)})},{key:"dequeue",value:(n=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,f,_,v,m=this;return Dg().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!==KQ.ADD){e.next=16;break}return e.delegateYield(Dg().mark((function e(){var t,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=Zl({},m.peer._answerIce)).candidates,c=!1,u=!1,e.prev=4,l=VQ(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 iH;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 f,_={},v={},g=YX.parse(l.sdp);Array.isArray(g.media)&&jw(f=g.media).call(f,(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=Zl(Zl({},r),t)).type?(_=r).mid=e:(v=r).mid=n}));var y,S=h.streamId;if(c===WQ.publish&&(S=null===(y=h.stream)||void 0===y?void 0:y.id),!m._mlinesCache[S])return"break";var b=Ey(m._mlinesCache[S],2),E=b[0],k=b[1];if(u&&E){h.audioTransceiver=m._peerConnection.addTransceiver(u.track,u.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",Xg({audioStreamTrack:bx(u.track)}));var T=m._inactiveMlineIndex.shift();T||(T=m.peer._offerMlines.length),m.peer._offerMlines[T]=Zl({},E),m.peer._answerMlines[T]=_,JQ&&h.initAudioEncodedTransform()}if(d&&k){var I,R;h.videoTransceiver=m._peerConnection.addTransceiver(d.track,d.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",Xg({videoStreamTrack:bx(d.track)}));var A,w,C=m._inactiveMlineIndex.shift();C||(C=m.peer._offerMlines.length),m.peer._offerMlines[C]=Zl({},k),c===WQ.publish&&null!==(I=m._context)&&void 0!==I&&null!==(R=I.serverConfig)&&void 0!==R&&R.videoCodec&&yY(v,null===(A=m._context)||void 0===A||null===(w=A.serverConfig)||void 0===w?void 0:w.videoCodec),m.peer._answerMlines[C]=v,JQ&&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:v={},n.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;v[t]=t,n!==WQ.removetrack&&(v[r]=r),v[t]=t})),this.peer._offerMlines=$g(p=this.peer._offerMlines).call(p,(function(e,t){return v[e.mid]&&(e=pY(e),m._inactiveMlineIndex.push(t)),e})),jw(f=this._inactiveMlineIndex).call(f,(function(e,t){return e-t})),this.peer._answerMlines=$g(_=this.peer._answerMlines).call(_,(function(e){return v[e.mid]&&(e=pY(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(B0){}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 n.apply(this,arguments)})},{key:"getDefaultSdp",value:(r=Ug(Dg().mark((function e(){var t,r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ZQ();case 2:return r=e.sent,this.createAVMlineOfferTpl(r),n=YX.parse(r),i=[],n.media=wy(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=wy(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"}],cV&&bY(n),e.abrupt("return",{sdp:YX.write(n),semantics:"unified-plan",type:"incroffer"});case 10:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"rollback",value:(t=Ug(Dg().mark((function e(t){var r;return Dg().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 t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this,r=YX.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=wy(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=wy(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}})),cV&&bY(r)}}]),c}(HQ),ZQ=function(){var e=Ug(Dg().mark((function e(){var t,r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,MD(!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 mC(hC.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(){return e.apply(this,arguments)}}(),$Q=function(e){jA(d,e);var t,r,n,i,o,a,s,c,u=iw(d);function d(e,t){var r;return Gh(this,d),Jl(dA(r=u.call(this,e,t)),"name","firefox"),Jl(dA(r),"_aRecvonlyOfferTpl",void 0),r.logger=new fD("FirefoxHandler",3,e.id),r}return jh(d,[{key:"publish",value:(c=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,f,_,v,m,g=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=FA(VA(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=$g(u=c.init.sendEncodings).call(u,(function(e){return delete e.rid,e}))),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),l=AD(),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:AD()-l}),(p=YX.parse(h.sdp)).media=null===(r=p.media)||void 0===r?void 0:$g(r).call(r,(function(e){return Zl(Zl({},e),g.peer._offerIce)})),bY(p),e.next=15,this.setLocalDescription(YX.write(p));case 15:return f=t.audioTransceiver.mid,_=t.videoTransceiver.mid,v=null,m=null,p.media=null===(n=p.media)||void 0===n?void 0:$g(n).call(n,(function(e){if("".concat(e.mid)===f){var t,r,n=null===(t=v=e)||void 0===t?void 0:dI(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&v.fmtp){var i,o,a=dI(i=v.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&&yY(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(YX.write(p));case 23:return e.abrupt("return",{partialSdp:fY(p,v,m),audioMid:f,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=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R,A,w=this;return Dg().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"})),f=AD(),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:AD()-f}),(v=YX.parse(_.sdp)).media=null===(n=v.media)||void 0===n?void 0:$g(n).call(n,(function(e){return Zl(Zl({},e),w.peer._offerIce)})),$g(i=v.media).call(i,(function(e){var t,r,n,i;"video"===e.type&&(sV?(e.ext=null===(t=e.ext)||void 0===t?void 0:wy(t).call(t,(function(e){var t;return-1===kI(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:wy(r).call(r,(function(e){return"goog-remb"!==e.type}))):(e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:wy(n).call(n,(function(e){return"transport-cc"!==e.type})),e.ext=null===(i=e.ext)||void 0===i?void 0:wy(i).call(i,(function(e){var t;return-1===kI(t=e.uri).call(t,"transport")}))))})),cV&&bY(v),e.next=22,this.setLocalDescription(YX.write(v),{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=v.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=Zl(Zl({},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=dY(this._nextSsrc),this._nextSsrc=m.next,R=Zl(Zl(Zl({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:c,msid:Gg(y=Gg(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:lY(t.streamId,"audio",m.audio)}),A=Zl(Zl(Zl({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Gg(E=Gg(k="".concat(t.streamId)).call(k,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},hY(t.streamId,m,{flexfec:this._enableSubFlexfec})),g={sdp:YX.write(Zl(Zl({},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:fY(v,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=Ug(Dg().mark((function e(t){var r,n,i,o;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==WQ.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==WQ.unpublish&&i!==WQ.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=YX.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=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=YX.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=Zl(Zl({},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 nH&&RL<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=wy(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=wy(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=wy(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=wy(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=YX.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=$g(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,$g(a=c.media).call(a,(function(e){var t,r,n,i;"video"===e.type&&(sV?(e.ext=null===(t=e.ext)||void 0===t?void 0:wy(t).call(t,(function(e){var t;return-1===kI(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:wy(r).call(r,(function(e){return"goog-remb"!==e.type}))):(e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:wy(n).call(n,(function(e){return"transport-cc"!==e.type})),e.ext=null===(i=e.ext)||void 0===i?void 0:wy(i).call(i,(function(e){var t;return-1===kI(t=e.uri).call(t,"transport")}))))})),cV&&bY(c),e.next=12,this.setRemoteDescription(YX.write(c));case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Ug(Dg().mark((function e(){var t,r,n,i,o;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=YX.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=wy(n=i.media).call(n,(function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,o.push("".concat(e.mid)),!0)})),cV&&bY(i),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:YX.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=Ug(Dg().mark((function e(t){var r,n,i;return Dg().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=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,f,_=this;return Dg().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=YX.parse(null==l?void 0:l.sdp)).media=$g(i=h.media).call(i,(function(e){return u[e.mid]&&(e=pY(e)),"inactive"!==e.direction&&d.push(e.mid),Zl(Zl({},e),_.peer._offerIce)})),p=YX.parse(null===(o=this._peerConnection.remoteDescription)||void 0===o?void 0:o.sdp),f={},p.media.forEach((function(e){void 0!==e.mid&&(f[e.mid]=e)})),p.media=$g(a=h.media).call(a,(function(e){return"inactive"===e.direction?e:f[e.mid]})),h.groups&&p.groups&&(h.groups[0].mids=d.join(" "),p.groups[0].mids=d.join(" ")),e.next=19,this.setLocalDescription(YX.write(h));case 19:return e.next=21,this.setRemoteDescription(YX.write(p));case 21:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Ug(Dg().mark((function e(){return Dg().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=YX.parse(e);r.media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)})),cV&&bY(r)}}]),d}(HQ),eZ=(Jl(GQ={},DQ.ICE_FAILED,hh.ICE_FAILED),Jl(GQ,DQ.DC_ERROR,hh.ICE_FAILED),Jl(GQ,DQ.DC_CLOSE,hh.ICE_FAILED),Jl(GQ,DQ.NODE_CHANGE,hh.NODE_CHANGE),Jl(GQ,DQ.NOTIFY_RECONNECT,hh.NOTIFY_RECONNECT),Jl(GQ,DQ.JOIN_TIMEOUT,hh.JOIN_TIMEOUT),GQ),tZ=function(e){jA(r,e);var t=iw(r);function r(e){var n;return Gh(this,r),Jl(dA(n=t.call(this)),"_connectionManager",void 0),Jl(dA(n),"_dataChannelSignal",void 0),Jl(dA(n),"_state",void 0),Jl(dA(n),"_connectionLostTimer",void 0),Jl(dA(n),"_isReconnecting",!1),Jl(dA(n),"logger",void 0),n._ctx=e,n.logger=new fD("SignalingManager",1,e.id),n.logger.info("constructor","invoke"),n._connectionManager=new LQ(e),n._addConnectorHandler(),n}return jh(r,[{key:"connect",value:function(){var e=this;return this.isConnected()?Hg.resolve():new Hg((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.startup()}))}},{key:"reconnect",value:function(e,t){this._connectionManager.reconnect(e,t)}},{key:"sendSignaling",value:function(e,t,r,n){if(!this._dataChannelSignal)throw new mC(hC.NOT_CONNECTED_YET,"signaling channel is not connected");return this._dataChannelSignal.sendSignaling(e,t,r,n)}},{key:"sendP2PMessage",value:function(e){if(!this._dataChannelSignal)throw new mC(hC.NOT_CONNECTED_YET,"signaling channel is not connected");return this._dataChannelSignal.sendP2PMessage(e)}},{key:"destroy",value:function(){var e;this.logger.info("destroy()"),this._clearConnectionLostTimer(),this._connectionManager.shotdown(),this._ctx.handler=void 0,null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),this._setState(lh.CONNECTION_STATE_DISCONNECTED),this.removeAllListeners()}},{key:"isConnected",value:function(){return this._state===lh.CONNECTION_STATE_CONNECTED||this._state===lh.CONNECTION_STATE_RECONNECTED}},{key:"isReconnecting",value:function(){return this._state===lh.CONNECTION_STATE_CONNECTING||this._state===lh.CONNECTION_STATE_RECONNECTING}},{key:"_setState",value:function(e,t){if(this._state!==e){this._state=e;var r={state:e};t&&(r.reason=eZ[t]||hh.ICE_FAILED),this.safeEmit(MU.ON_CONNECTION_STATE_CHANGE,r)}}},{key:"_addConnectorHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n,i;e.logger.info("connectStateChange","connected"),e._clearConnectionLostTimer(),null===(r=e._dataChannelSignal)||void 0===r||r.destroy(),e._ctx.peerConnection=t.pc,e._ctx.handler=(n=e._ctx,i=t.pc,iL?new $Q(n,i):new QQ(n,i)),e._dataChannelSignal=t.signaling,e._addSignalEventHandler(),e._setState(e._isReconnecting?lh.CONNECTION_STATE_RECONNECTED:lh.CONNECTION_STATE_CONNECTED)})),this._connectionManager.on("disconnected",(function(t){e._clearConnectionLostTimer(),e._setState(lh.CONNECTION_STATE_DISCONNECTED),e.logger.error("connectStateChange","disconnected. %o",t.message),e._isReconnecting&&e.safeEmit(MU.ON_RECONNECT_FAILED)})),this._connectionManager.on("connecting",(function(){e._isReconnecting=!1,e._ctx.handler=void 0,e._setState(lh.CONNECTION_STATE_CONNECTING),e.logger.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(t){e._setState(lh.CONNECTION_STATE_DISCONNECTED,t),e._connectionLostTimer||(e._connectionLostTimer=window.setTimeout((function(){e.safeEmit(MU.ON_CONNECTION_STATE_CHANGE,{state:lh.CONNECTION_STATE_LOST})}),1e4)),e._isReconnecting=!0,e._ctx.handler=void 0,e._setState(lh.CONNECTION_STATE_RECONNECTING,t),e.logger.warn("connectStateChange","reconnecting")})),this._connectionManager.on("connectWidthTcp",(function(){e.safeEmit(MU.CONNECT_WITH_TCP)})),["__onGetIceConfigHook","__onIceConnectSuccessHook","__onConnectSuccessHook"].forEach((function(t){e._connectionManager.on(t,(function(){for(var r,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return e.emit.apply(e,Gg(r=[t]).call(r,i))}))}))}},{key:"_clearConnectionLostTimer",value:function(){this._connectionLostTimer&&(clearTimeout(this._connectionLostTimer),delete this._connectionLostTimer)}},{key:"_addSignalEventHandler",value:function(){var e,t,r=this;[PU.ON_ADD_STREAM,PU.ON_ADD_STREAM_LIST,PU.ON_REMOVE_STREAM,PU.ON_REMOVE_STREAM_LIST,PU.USER_CONNECTION,PU.USER_CONNECTION_LIST,PU.USER_DISCONNECTION,PU.USER_DISCONNECTION_LIST,PU.ON_UPDATE_STREAM_ATTRIBUTES,PU.ON_UPDATE_ROOM_ATTRIBUTES,PU.ON_PUSH_TRACK,PU.ON_REMOVE_TRACK,PU.ON_CUSTOM_MESSAGE,PU.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,PU.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,PU.USER_MESSAGE_RECEIVED,PU.USER_BINARY_MESSAGE_RECEIVED,PU.POST_PROCESSING_MESSAGE,PU.ON_USER_TOKEN_WILL_EXPIRE,PU.ON_TOKEN_PUBLISH_PRIVILEGE_WILL_EXPIRE,PU.ON_TOKEN_PUBLISH_PRIVILEGE_DID_EXPIRED,PU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_WILL_EXPIRE,PU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_DID_EXPIRED,PU.STREAM_CONTROL_MESSAGE,PU.ON_UPDATE_USER_ATTRIBUTES,PU.ON_SPEAKER_CHANGE,PU.ON_STREAM_FAILED,PU.ON_FORWARD_DST_ROOM_USER_KICK,NU.RSCP,NU.RTT,NU.SSC].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(PU.NODE_CHANGE,(function(e){r._connectionManager.reconnectByNodeChange(e)})),null===(t=this._dataChannelSignal)||void 0===t||t.on(PU.ON_NOTIFY_RECONNECT,(function(){r._connectionManager.reconnect(DQ.NOTIFY_RECONNECT)}))}}]),r}(wU),rZ=new fD("Locker",2),nZ=1,iZ=function(){function e(t){var r;Gh(this,e),Jl(this,"lockingPromise",Hg.resolve()),Jl(this,"locks",0),Jl(this,"name",""),Jl(this,"lockId",void 0),Jl(this,"closeReason",void 0),this.lockId=nZ++,t&&(this.name=t),rZ.info(Gg(r="lock-".concat(this.name,"-")).call(r,this.lockId),"is created.")}return jh(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r=this;this.locks+=1,rZ.info(Gg(e="lock-".concat(this.name,"-")).call(e,this.lockId),"locked, current queue ".concat(this.locks,"."));var n=new Hg((function(e){t=function(){var t;r.locks-=1,rZ.info(Gg(t="lock-".concat(r.name,"-")).call(t,r.lockId),"unlocked, current queue ".concat(r.locks,".")),e()}})),i=this.lockingPromise.then((function(){return t}));return this.lockingPromise=this.lockingPromise.then((function(){return n})),i}}]),e}(),oZ=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(oZ||{}),aZ=function(e){return e.RECONNECT="ice-reconnect",e.LEAVE="leave_room",e}(aZ||{}),sZ=function(){function e(t,r,n){Gh(this,e),Jl(this,"avSync",!0),Jl(this,"streamRTT",{}),Jl(this,"useCloudProxy",!1),Jl(this,"audioProfileManager",void 0),Jl(this,"userPriority",new hT),Jl(this,"expectedIDC",void 0),Jl(this,"joinRoomConfig",void 0),Jl(this,"signalingManager",void 0),Jl(this,"peerConnection",void 0),Jl(this,"pubSubLock",new iZ("pubSubLock")),Jl(this,"visibility",!0),Jl(this,"serverConfig",void 0),Jl(this,"mediaParams",void 0),Jl(this,"activeSimStreams",void 0),Jl(this,"subscribeFallbackOption",void 0),Jl(this,"joinRoomParams",void 0),Jl(this,"isPreConnection",!1),Jl(this,"_handler",void 0),Jl(this,"_monitor",void 0),Jl(this,"_businessId",void 0),this.id=t,this.appId=r,this._monitor=YM(t),this.expectedIDC=null==n?void 0:n.expectedIDC,this.audioProfileManager=new zX(r),this.joinRoomConfig=new GL(t),this.signalingManager=new tZ(this)}return jh(e,[{key:"businessId",get:function(){return this._businessId},set:function(e){var t;this._businessId=e,null===(t=this._monitor)||void 0===t||t.set({rtc_business_id:e})}},{key:"handler",get:function(){return this._handler},set:function(e){var t;e&&this.resetPubSubLock("ice-reconnect"),null===(t=this._handler)||void 0===t||t.destroy(),this._handler=e}},{key:"role",get:function(){return this.visibility?oZ.NORMAL_USER:oZ.SILENT_USER}},{key:"resetPubSubLock",value:function(e){this.pubSubLock.closeReason=e,this.pubSubLock=new iZ("pubSubLock")}},{key:"destroy",value:function(){var e;this.signalingManager.destroy(),null===(e=this.handler)||void 0===e||e.destroy(),this.userPriority.clear(),this.avSync=!0}}]),e}();function cZ(e,t,r){var n=r.value;return r.value=Ug(Dg().mark((function e(){var t,r,i,o,a,s,c,u=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ctx.pubSubLock.lock();case 2:if(r=e.sent,"chrome"===(null===(t=this._ctx.handler)||void 0===t?void 0:t.name)&&r(),e.prev=4,!(i=this._ctx.pubSubLock.closeReason)){e.next=8;break}throw new mC(hC.UNEXPECTED_ERROR,i);case 8:for(o=u.length,a=new Array(o),s=0;s<o;s++)a[s]=u[s];return e.next=11,n.apply(this,a);case 11:return e.abrupt("return",e.sent);case 12:return e.prev=12,"chrome"!==(null===(c=this._ctx.handler)||void 0===c?void 0:c.name)&&r(),e.finish(12);case 15:case"end":return e.stop()}}),e,this,[[4,,12,15]])}))),r}var uZ=iV(),dZ=function(e){jA(s,e);var t,r,n,i,o,a=iw(s);function s(e,t){var r;return Gh(this,s),Jl(dA(r=a.call(this,e,t)),"_peerConnectionId",RD()),Jl(dA(r),"peerConnectionMode",1),Jl(dA(r),"name","vendor"),Jl(dA(r),"direction","up"),Jl(dA(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 jh(s,[{key:"publish",value:(o=Ug(Dg().mark((function e(t){var r,n,i,o,a,c,u,d,l,h,p=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.enableSimulcast=!1,this.stream=t,r=FA(VA(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),uZ&&(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=AD(),d=YX.parse(c.sdp),Array.isArray(d.media)&&(d.media=$g(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&&yY(e,null===(i=p._context)||void 0===i||null===(o=i.serverConfig)||void 0===o?void 0:o.videoCodec),(oL||gL)&&Array.isArray(e.ext)&&(e.ext=wy(a=e.ext).call(a,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&Qy(t).call(t,"video-orientation"))}))),oL||p.addBitrateLimit(e,t.videoEncodeConfig[0].maxKbps);else if("audio"===e.type){var s,c=null==e?void 0:dI(s=e.rtp).call(s,(function(e){return"opus"===e.codec}));if(c&&e.fmtp){var u,d,l=dI(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:YX.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:AD()-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:AD()-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=Ug(Dg().mark((function e(t){var r,n,i,o,a,s=this;return Dg().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"}),uZ&&(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=AD(),i=YX.parse(r.sdp),Array.isArray(i.media)&&(i.media=$g(o=i.media).call(o,(function(e){if("audio"===e.type){var t,r=null==e?void 0:dI(t=e.rtp).call(t,(function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n,i=null==e?void 0:dI(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:YX.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:AD()-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:AD()-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=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.action!==WQ.publish&&t.action!==WQ.subscribe){e.next=16;break}return n=new RTCSessionDescription({sdp:null===(r=t.signalingAck)||void 0===r?void 0:r.sdp,type:"answer"}),i=AD(),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:AD()-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:AD()-i},{type:"offer"}),e.t0;case 13:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=17;break;case 16:t.action!==WQ.unpublish&&t.action!==WQ.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(),FA(VA(s.prototype),"destroy",this).call(this)}},{key:"getDefaultSdp",value:(r=Ug(Dg().mark((function e(){return Dg().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=Ug(Dg().mark((function e(){return Dg().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}(HQ),lZ=pT,hZ=KI,pZ=function(e,t,r,n){for(var i,o=n>1?void 0:n?hZ(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&&lZ(t,r,o),o},fZ=function(e){jA(c,e);var t,r,n,i,o,a,s=iw(c);function c(e,t){var r;return Gh(this,c),Jl(dA(r=s.call(this)),"_logger",void 0),Jl(dA(r),"_pubBackOff",new hT),r._ctx=e,r._roomConf=t,r._logger=new fD("RoomPublisher",2,e.id),r}return jh(c,[{key:"publish",value:(a=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._logger.info("publish()","localStream: %o",t),_=t.videoTrack,v=t.audioTrack,m=AD(),g="",y="",S=this._ctx.handler,"H264"!==(null===(r=this._ctx.serverConfig)||void 0===r?void 0:r.videoCodec)){e.next=17;break}return e.next=10,eV();case 10:if(e.sent){e.next=17;break}if("VP8"!==JL("FALLBACK_ENCODE_CODEC")){e.next=16;break}this._ctx.serverConfig.videoCodec="VP8",e.next=17;break;case 16:throw new mC(hC.PUBLISH_FAILED,"h264 is not supported");case 17:if(!this._roomConf.vendorConfig.enableMultiVendor){e.next=26;break}return e.next=20,this._getVendorPubSdpInfo(t);case 20:E=e.sent,k=Ey(E,2),S=k[0],b=k[1],e.next=29;break;case 26:return e.next=28,this._ctx.handler.publish(t);case 28:b=e.sent;case 29:return this.emit("_test_pub_sdpInfo_",b),g=b.audioMid,y=b.videoMid,t.pubAttributes={localaudio:!!v,localvideo:!!_,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:(null==_?void 0:_.sourceType)===aG.EXTERNAL,extaudio:(null==v?void 0:v.sourceType)===aG.EXTERNAL,videoDescriptions:b.videoDescriptions,videoType:UU.NORMAL},T={attributes:Zl({},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:g,videoMid:y,sdpInfo:{msid:t.stream.id,type:b.type,sdp:b.partialSdp,semantics:b.semantics},peerConnectionMode:null===(n=b)||void 0===n?void 0:n.peerConnectionMode,supportMultiVendor:!0},((I=!this._roomConf.vendorConfig.enableMultiVendor&&t.enableSimulcast&&(null===(i=this._ctx.serverConfig)||void 0===i?void 0:i.simulcastOnDemand)&&(null===(o=b.subVideoDescriptions)||void 0===o?void 0:o.length))||null!==(a=this._ctx.serverConfig)&&void 0!==a&&a.e2eFeedback)&&(T.attributes.subVideoDescriptions=b.subVideoDescriptions),null!==(s=b)&&void 0!==s&&s.peerConnectionId&&(T.peerConnectionId=b.peerConnectionId),e.prev=37,this.emit("_test_pub_body_",T),e.next=41,this._ctx.signalingManager.sendSignaling("publish",T);case 41:R=e.sent,e.next=70;break;case 44:return e.prev=44,e.t0=e.catch(37),e.t0 instanceof Error?this._roomConf.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:m,message:Gg(w="".concat(e.t0.name,": ")).call(w,e.t0.message)}):e.t0 instanceof mC&&this._roomConf.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:m,message:Gg(C="".concat(e.t0.code,": ")).call(C,e.t0.message)}),e.next=49,null===(A=S)||void 0===A?void 0:A.rollback({msid:t.stream.id,stream:t,audioMid:g,videoMid:y});case 49:if(!(e.t0.code>=500&&e.t0.code<600)){e.next=67;break}if(this.emit("_test_pub_5xx_"),!((x=this._getPubBackOff(t.id)).retryDuration<6e4)){e.next=63;break}return this._logger.info("pubRetry",t.id,x.retryDuration),e.next=56,new Hg((function(e){return setTimeout(e,x.interval)}));case 56:return x.retryDuration+=x.interval,x.interval=x.interval>4e3?8e3:2*x.interval,t.resetStream(),this.emit(oH.PUB_RETRY,{screen:t.isScreen}),e.abrupt("return",this.publish(t));case 63:this._logger.info("pubRetry","end"),this._pubBackOff.delete(t.id);case 65:e.next=69;break;case 67:if(403!==e.t0.code){e.next=69;break}throw new mC(hC.TOKEN_NO_PUBLISH_PERMISSION,e.t0.message||"token no publish permission");case 69:throw e.t0;case 70:if(this._roomConf.report("rtc_recv_answer",{error_code:0,answer_type:null===(c=R)||void 0===c?void 0:c.relayMessage.type,sequence_id:(null===(u=R)||void 0===u||null===(d=u.relayMessage)||void 0===d?void 0:d.sequenceId)||0,message:null===(l=R)||void 0===l||null===(h=l.relayMessage)||void 0===h?void 0:h.sdp,direction:"up",stream_id:"",stream_user_id:"",pc_session_id:(null===(p=S)||void 0===p?void 0:p.peerConnectionId)||""}),O=new Hg((function(e,r){var n,i,o,a,s,c,u,d;null===(n=S)||void 0===n||n.handleAck({action:WQ.publish,streamId:R.streamId,audioMid:g,videoMid:y,audioTransceiverInit:null===(i=b)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=b)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:{sdp:null===(a=R)||void 0===a||null===(s=a.relayMessage)||void 0===s?void 0:s.sdp,sequenceId:null===(c=R)||void 0===c||null===(u=c.relayMessage)||void 0===u?void 0:u.sequenceId},sdp:null===(d=b)||void 0===d?void 0:d.sdp,stream:t,onSuccess:function(){P._logger.info("publish()","publish success"),e(0)},onFail:function(e){P._logger.info("publish()","publish fail"),r(e)}})})),e.t1=!iL,!e.t1){e.next=76;break}return e.next=76,O;case 76:this.emit("___afterHandleAckInPub"),(I||null!==(f=this._ctx.serverConfig)&&void 0!==f&&f.e2eFeedback)&&this.emit(NU.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}],!0),t.streamId=R.streamId,t.videoMid=y,t.audioMid=g,t.subVideoDescriptions=b.subVideoDescriptions,this._roomConf.report("rtc_publish_stat",{result:"success",is_screen:"0",start:m,message:"unknown"});case 83:case"end":return e.stop()}}),e,this,[[37,44]])}))),function(e){return a.apply(this,arguments)})},{key:"updatePubTrack",value:(o=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R,A,w,C;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._logger.info("updatePubTrack()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,i=t.pubAudio,o=t.pubVideo,a=t.vendorHandler||this._ctx.handler,s=null==n?void 0:n.preprocessingTrack,c=null==r?void 0:r.preprocessingTrack,!o||!c){e.next=12;break}return t.stopBlackFrame(),e.next=9,null===(u=t.videoTransceiver)||void 0===u?void 0:u.sender.replaceTrack(c);case 9:this._updateVideoDescriptions(t),e.next=14;break;case 12:return e.next=14,null===(d=t.videoTransceiver)||void 0===d?void 0:d.sender.replaceTrack(null);case 14:if(null==a||a.updateMaxBitrate(t),!i||!s){e.next=22;break}return h=n.mixType,(p=n.mixedAudioTrack)&&h!==Lh.PLAYOUT&&s.enabled&&(s=p),e.next=20,null===(l=t.audioTransceiver)||void 0===l?void 0:l.sender.replaceTrack(s);case 20:e.next=25;break;case 22:return e.next=24,null===(f=t.audioTransceiver)||void 0===f?void 0:f.sender.replaceTrack(null);case 24:$M(this._ctx.id,"MediaClient.updatePubTrack(audio)","null");case 25:this.emit("___onAfterReplaceTrack");try{$M(this._ctx.id,"MediaClient.updatePubTrack",Xg({audioStreamTrack:bx(s),videoStreamTrack:bx(c)}))}catch(B0){}for(_={localaudio:!!n,localvideo:!!r,videostream:o,audiostream:i,extvideo:(null==r?void 0:r.sourceType)===aG.EXTERNAL,extaudio:(null==n?void 0:n.sourceType)===aG.EXTERNAL,videoType:r?UU.NORMAL:t.pubAttributes.videoType},v={},m=0,g=VS(_);m<g.length;m++)y=Ey(g[m],2),S=y[0],(b=y[1])!==PX(t.pubAttributes,S)&&HX(v,S,b);if(FS(v).length){e.next=32;break}return e.abrupt("return");case 32:return t.observer&&(E=t.observer,k=v.audiostream,T=v.videostream,I=v.localaudio,R=v.localvideo,A=v.extaudio,w=v.extvideo,void 0!==R?void 0!==w?E.setPushVideo(w):E.setEnableVideo(R):void 0!==T&&E.setUnmuteVideo(T),void 0!==I?void 0!==A?E.setPushAudio(A):E.setEnableAudio(I):void 0!==k&&E.setUnmuteAudio(k)),t.pubAttributes=Zl(Zl({},t.pubAttributes),_),t.pubAttributes.videostream||t.stopBlackFrame(),C={roomId:this._roomConf.roomId,streamId:t.streamId,attributes:v},e.next=38,this._ctx.signalingManager.sendSignaling("updateStreamAttributes",C);case 38:if(this.emit("___onAfterUpdateSignaling"),!iL){e.next=42;break}return e.next=42,null==a?void 0:a.setCurrentDescription();case 42:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"unpublish",value:(i=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._logger.info("unpublish()","localStream: %o",t),r={roomId:this._roomConf.roomId,initStreamId:t.initStreamId,streamId:t.streamId},this._ctx.signalingManager.sendSignaling("unpublish",r),n=t.vendorHandler||this._ctx.handler,t.stopBlackFrame(),e.next=7,null==n?void 0:n.handleAck({action:WQ.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 7:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"updatePubBlackFrame",value:(n=Ug(Dg().mark((function e(t){var r,n,i,o=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=t.genBlackFrame()){e.next=3;break}return e.abrupt("return");case 3:null===(r=t.videoTransceiver)||void 0===r||null===(n=r.sender)||void 0===n||n.replaceTrack(i),t.pubAttributes.videoType=UU.BLACK,this._ctx.signalingManager.sendSignaling("updateStreamAttributes",{roomId:this._roomConf.roomId,streamId:t.streamId,attributes:{videoType:UU.BLACK}}),t.on("black-frame-ended",(function(){var e,r;null===(e=t.videoTransceiver)||void 0===e||null===(r=e.sender)||void 0===r||r.replaceTrack(null),t.pubAttributes.videoType=UU.NORMAL,o._ctx.signalingManager.sendSignaling("updateStreamAttributes",{roomId:o._roomConf.roomId,streamId:t.streamId,attributes:{videoType:UU.NORMAL}})}));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"destroy",value:function(e){var t=this;e.forEach((function(e){var r;e&&e.hasPublished&&(null===(r=t._ctx.handler)||void 0===r||r.handleAck({action:WQ.unpublish,audioMid:e.audioMid,videoMid:e.videoMid,stream:e,streamId:e.streamId}))})),this._pubBackOff.clear(),FA(VA(c.prototype),"removeAllListeners",this).call(this)}},{key:"_updateVideoDescriptions",value:(r=Ug(Dg().mark((function e(t){var r,n,i,o;return Dg().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!=(i=null===(r=t.videoTrack)||void 0===r||null===(n=r.preprocessingTrack)||void 0===n?void 0:n.getSettings())&&i.width&&null!=i&&i.height&&null!=i&&i.frameRate){e.next=5;break}return e.abrupt("return");case 5:if(o=t.pubAttributes.videoDescriptions[0],i.width!==o.width||i.height!==o.height||i.frameRate!==o.framerate){e.next=8;break}return e.abrupt("return");case 8:o.width=i.width,o.height=i.height,o.framerate=i.frameRate,o.maxkbps=t.videoEncodeConfig[0].maxKbps||o.maxkbps,this._ctx.signalingManager.sendSignaling("updateStreamAttributes",{roomId:this._roomConf.roomId,streamId:t.streamId,attributes:{videoDescriptions:[o]}});case 13:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_getVendorPubSdpInfo",value:(t=Ug(Dg().mark((function e(t){var r,n,i,o=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new RQ(this._ctx,""),t.vendorHandler=new dZ(this._ctx,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(MU.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:lh.CONNECTION_STATE_CONNECTING,connected:lh.CONNECTION_STATE_CONNECTED,disconnected:lh.CONNECTION_STATE_RECONNECTING}[e],userId:o._roomConf.userId})})),i.once("disconnect",Ug(Dg().mark((function e(){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i.removeAllListeners(),"connected"===(null===(r=o._ctx.peerConnection)||void 0===r?void 0:r.getIceConnectionState())){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 t.apply(this,arguments)})},{key:"_getPubBackOff",value:function(e){return this._pubBackOff.has(e)||this._pubBackOff.set(e,{interval:1e3,retryDuration:0}),this._pubBackOff.get(e)}}]),c}(wU);pZ([cZ,IX],fZ.prototype,"publish",1),pZ([cZ,IX],fZ.prototype,"updatePubTrack",1),pZ([cZ,IX],fZ.prototype,"unpublish",1),pZ([IX],fZ.prototype,"updatePubBlackFrame",1),pZ([IX],fZ.prototype,"_updateVideoDescriptions",1);var _Z,vZ=pT,mZ=KI,gZ=function(e,t,r,n){for(var i,o=n>1?void 0:n?mZ(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&vZ(t,r,o),o},yZ=function(e){jA(p,e);var t,r,n,i,o,a,s,c,u,d,l,h=iw(p);function p(e,t){var r;return Gh(this,p),Jl(dA(r=h.call(this)),"_logger",void 0),Jl(dA(r),"_subBackOff",new hT),Jl(dA(r),"_subResolves",{}),Jl(dA(r),"_ontrackCallbackMap",new hT),r._ctx=e,r._roomConf=t,r._logger=new fD("RoomSubscriber",2,e.id),r}return jh(p,[{key:"subscribe",value:(l=Ug(Dg().mark((function e(t,r,n){return Dg().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 l.apply(this,arguments)})},{key:"_subscribe",value:(d=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,N,M,D,L,U,V,F,B,j,G,H,z,K,W,X,Y,q,J,Q=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._logger.info("subscribe()","mediaType: %o",r),TX("subscribe()",t,this._logger),t.streamState=rH.SUB_ING,k=!1,T=!1,UD(r)&&(T=!0),VD(r)&&(k=!0),k||!this._roomConf.isMultiChatMode()){e.next=9;break}return t.streamState=rH.INIT,e.abrupt("return");case 9:if(I=AD(),R=t.subVideo,A=[],this._subResolves[t.streamId]||(this._subResolves[t.streamId]=[]),A.push(new Hg((function(e,r){Q._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mC(hC.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),kX);t.on("ontrack",(function r(i){"video"===i.mediaType&&(Q._logger.info("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),this._roomConf.isMultiChatMode()||A.push(new Hg((function(e,r){Q._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mC(hC.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),kX);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(Q._logger.info("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),w=function(e){t.ontrack(e)},null===(i=this._ctx.handler)||void 0===i||i.on("ontrack",w),this._ontrackCallbackMap.set(t,w),C=this._ctx.handler,null!==(o=this._ctx.serverConfig)&&void 0!==o&&o.forceUniHandler||!t.enableVendorMode){e.next=28;break}return e.next=22,this._getVendorSubSdpInfo(t,w);case 22:O=e.sent,P=Ey(O,2),C=P[0],x=P[1],e.next=31;break;case 28:return e.next=30,this._ctx.handler.subscribe(t,{multiChatMode:this._roomConf.isMultiChatMode()});case 30:x=e.sent;case 31:if(M=(N=x).audioMid,D=N.videoMid,t.subVideo=k,L={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},U={audio:!this._roomConf.isMultiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:D,audioMid:M,sdpInfo:{sdp:null===(a=x)||void 0===a?void 0:a.partialSdp,semantics:null===(s=x)||void 0===s?void 0:s.semantics,type:null===(c=x)||void 0===c?void 0:c.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!this._roomConf.isMultiChatMode()||T,video:k},qualityLayer:L},extra:{enableSendRTT:!0},peerConnectionMode:null===(u=x)||void 0===u?void 0:u.peerConnectionMode,supportMultiVendor:!0},null!==(d=x)&&void 0!==d&&d.peerConnectionId&&(U.peerConnectionId=x.peerConnectionId),V=this._ctx,F=V.subscribeFallbackOption,B=V.userPriority,"number"==typeof F&&(U.config.fallbackOption=F),B.has(t.userId)&&(U.config.priority=B.get(t.userId)),null!==(l=x)&&void 0!==l&&l.allSsrc&&(U.extra.subscribeSSRC=x.allSsrc),null===(h=x)||void 0===h||!h.signalingAck){e.next=43;break}return e.next=43,new Hg((function(e,r){var n,i,o,a;null===(n=C)||void 0===n||n.handleAck({action:WQ.subscribe,streamId:t.streamId,audioMid:M,videoMid:D,audioTransceiverInit:null===(i=x)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=x)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:null===(a=x)||void 0===a?void 0:a.signalingAck,stream:t,sdp:x.sdp,onSuccess:function(){Q._logger.info("ssrc","success"),e(0)},onFail:function(e){Q._logger.info("ssrc","fail",e),r(e)}})}));case 43:return e.prev=43,this.emit("_test_sub_body_",U),e.next=47,this._ctx.signalingManager.sendSignaling("subscribe",U);case 47:j=e.sent,e.next=81;break;case 50:if(e.prev=50,e.t0=e.catch(43),t.streamState=rH.INIT,e.t0 instanceof Error&&this._roomConf.report("rtc_subscribe_stat",{result:"fail",start:I,message:e.t0.message,stream_user_id:t.userId}),!(e.t0.code>=500&&e.t0.code<600)){e.next=71;break}if(this.emit("_test_sub_5xx_"),!((H=this._getSubBackOff(t.streamId)).retryDuration<6e4)){e.next=69;break}return this._logger.info("subRetry",t.streamId,H.retryDuration),e.next=61,new Hg((function(e){return setTimeout(e,H.interval)}));case 61:return H.retryDuration+=H.interval,H.interval=H.interval>4e3?8e3:2*H.interval,this.emit(oH.SUB_RETRY,{screen:t.isScreen,userId:t.userId}),e.next=66,null===(z=C)||void 0===z?void 0:z.handleAck({action:WQ.unsubscribe,streamId:t.streamId,audioMid:M,videoMid:D,stream:t});case 66:return e.abrupt("return",this._subscribe(t,r,n));case 69:this._logger.info("subRetry","end",t.streamId),this._subBackOff.delete(t.streamId);case 71:return t.subVideo=R,e.next=74,null===(G=C)||void 0===G?void 0:G.rollback({msid:t.streamId,stream:t});case 74:return K={roomId:this._roomConf.roomId,streamId:t.streamId,userId:t.userId},e.next=77,this._ctx.signalingManager.sendSignaling("unsubscribe",K).catch((function(){}));case 77:if(t.streamState=rH.INIT,403!==e.t0.code){e.next=80;break}throw new mC(hC.TOKEN_NO_SUBSCRIBE_PERMISSION,e.t0.message||"token no subscribe permission");case 80:throw e.t0;case 81:if(j.relayMessage){e.next=84;break}throw this._roomConf.report("rtc_error",{error_code:-1009,message:"relayMessage is null"}),new mC(hC.UNEXPECTED_ERROR,"unable to subscribe");case 84:if(W=null!==(p=null===(f=j)||void 0===f?void 0:f.relayMessage)&&void 0!==p?p:{},X=W.audioMid,Y=W.videoMid,Jl(_={},M,X),Jl(_,D,Y),q=_,this._logger.info("sub midmap",t.userId,q),t.videoMid=D,t.audioMid=M,t.subMediaType=r,t.streamState=rH.SUB_ED,t.subLayer=L,this._roomConf.report("rtc_recv_answer",{error_code:0,answer_type:null===(v=j)||void 0===v||null===(m=v.relayMessage)||void 0===m?void 0:m.type,sequence_id:(null===(g=j)||void 0===g||null===(y=g.relayMessage)||void 0===y?void 0:y.sequenceId)||0,message:null===(S=j)||void 0===S||null===(b=S.relayMessage)||void 0===b?void 0:b.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:(null===(E=C)||void 0===E?void 0:E.peerConnectionId)||""}),e.prev=93,null!==(J=x)&&void 0!==J&&J.signalingAck){e.next=97;break}return e.next=97,new Hg((function(e,r){var n,i,o,a,s,c,u;null===(n=C)||void 0===n||n.handleAck({action:WQ.subscribe,streamId:t.streamId,audioMid:M,videoMid:D,audioTransceiverInit:null===(i=x)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=x)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:{sdp:null===(a=j)||void 0===a||null===(s=a.relayMessage)||void 0===s?void 0:s.sdp,sequenceId:null===(c=j)||void 0===c||null===(u=c.relayMessage)||void 0===u?void 0:u.sequenceId},stream:t,sdp:x.sdp,onSuccess:function(){Q._logger.info("sub ack","success"),e(0)},onFail:function(e){Q._logger.info("sub ack","fail",e),r(e)}})}));case 97:return e.next=99,Hg.all(A);case 99:e.next=109;break;case 101:return e.prev=101,e.t1=e.catch(93),e.t1 instanceof Error&&this._roomConf.report("rtc_subscribe_stat",{result:"fail",start:I,message:e.t1.message,stream_user_id:t.userId}),K={roomId:this._roomConf.roomId,streamId:t.streamId,userId:t.userId},e.next=107,this._ctx.signalingManager.sendSignaling("unsubscribe",K).catch((function(){}));case 107:throw t.streamState=rH.INIT,e.t1;case 109:this._roomConf.isMultiChatMode()||(t.subAudio=T),this._roomConf.report("rtc_subscribe_stat",{result:"success",start:I,message:"unknown",stream_user_id:t.userId}),t.startReport((function(e){return Q.emit("onRemoteStreamStats",e)}),C);case 112:case"end":return e.stop()}}),e,this,[[43,50],[93,101]])}))),function(e,t,r){return d.apply(this,arguments)})},{key:"unsubscribe",value:(u=Ug(Dg().mark((function e(t){var r,n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return TX("unsubscribe()",t,this._logger),i={roomId:this._roomConf.roomId,streamId:t.streamId,userId:t.userId},o=t.vendorHandler||this._ctx.handler,this._ctx.signalingManager.sendSignaling("unsubscribe",i).catch((function(){})),t.streamState=rH.INIT,t.subVideo=!1,null===(r=t.observer)||void 0===r||r.setSubscribeVideo(!1),!this._roomConf.isMultiChatMode()&&(null===(n=t.observer)||void 0===n||n.setSubscribeAudio(!1)),e.next=10,null==o?void 0:o.handleAck({action:WQ.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:a=e.sent,this._subResolves[a]&&this._subResolves[a].forEach((function(e){return e(0)})),this._logger.info("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),t.subMediaType=HL.NONE,this._removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(c=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,d;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(TX("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)&uh.AUDIO),d=!!(c&uh.VIDEO),e.next=10,null===(i=this._ctx.handler)||void 0===i?void 0:i.handleAck({action:WQ.removetrack,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:null===(o=t.observer)||void 0===o||o.setPushTrack(!1),null===(a=t.observer)||void 0===a||a.setUnmuteAudio(!u),t.subAudio=!u,null===(s=t.observer)||void 0===s||s.setUnmuteVideo(!d),t.subVideo=!d,t.subMediaType=t.subMediaType-(t.subMediaType&c),t.virtual&&(t.clean(),t.resetHasSubscribed(),t.statsReport.unsubscribe());case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return c.apply(this,arguments)})},{key:"handleRemoveStream",value:(s=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(TX("handleRemoveStream()",t,this._logger),t.subVideo=!1,t.streamState!==rH.INIT){e.next=4;break}return e.abrupt("return");case 4:return e.abrupt("return",this.unsubscribe(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"_removeOnTrackListener",value:function(e){var t=this._ontrackCallbackMap.get(e);if(t){var r=e.vendorHandler||this._ctx.handler;null==r||r.off("ontrack",t),this._ontrackCallbackMap.delete(e)}}},{key:"_getVendorSubSdpInfo",value:(a=Ug(Dg().mark((function e(t,r){var n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new RQ(this._ctx,""),t.vendorHandler=new dZ(this._ctx,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(MU.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:lh.CONNECTION_STATE_CONNECTING,connected:lh.CONNECTION_STATE_CONNECTED,disconnected:lh.CONNECTION_STATE_RECONNECTING}[e],userId:t.userId})})),i.once("disconnect",Ug(Dg().mark((function e(){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==i||i.removeAllListeners(),"connected"===(null===(r=a._ctx.peerConnection)||void 0===r?void 0:r.getIceConnectionState())){e.next=4;break}return a._logger.info("vendor ice failed",t.streamId),e.abrupt("return");case 4:return n=t.subMediaType,e.next=7,a.unsubscribe(t);case 7:return e.next=9,a.subscribe(t,n);case 9:t.vendorHandler&&t.statsReport.setVar(t.vendorHandler),a.emit(oH.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 a.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(o=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._logger.info("subscribe4pushTrack()","streamInfo: %o",r),TX("subscribe4pushTrack()",t,this._logger),t.subAudio=!0,e.next=5,null===(n=this._ctx.handler)||void 0===n?void 0:n.subscribe(t,{multiChatMode:this._roomConf.isMultiChatMode()});case 5:if(a=e.sent){e.next=8;break}throw new mC(hC.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 8:return s=a.audioMid,c=a.videoMid,(u=[]).push(new Hg((function(e,r){var n=setTimeout((function(){return r(new mC(hC.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),kX);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._ctx.handler)||void 0===i||i.on("ontrack",d),this._ontrackCallbackMap.set(t,d),e.next=17,null===(o=this._ctx.handler)||void 0===o?void 0:o.handleAck({action:WQ.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,Hg.all(u);case 19:t.startReport((function(e){return l.emit("onRemoteStreamStats",e)}),this._ctx.handler);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"updateUserAttributes",value:(i=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._logger.info("updateUserAttributes()","attributes: %o",t),e.next=3,this._ctx.signalingManager.sendSignaling("updateUserAttributes",{roomId:this._roomConf.roomId,sessionId:this._roomConf.sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(n=Ug(Dg().mark((function e(t,r){var n;return Dg().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 n={roomId:this._roomConf.roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,this._ctx.signalingManager.sendSignaling("updateSubscribe",n);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 n.apply(this,arguments)})},{key:"updateSubPriority",value:(r=Ug(Dg().mark((function e(t,r){var n;return Dg().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 n={roomId:this._roomConf.roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{priority:r}},e.next=7,this._ctx.signalingManager.sendSignaling("updateSubscribe",n);case 7:return t.priority=r,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.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 f,_;if(h>=(null===(f=d[p])||void 0===f?void 0:f.width)*(null===(_=d[p])||void 0===_?void 0:_.height)){l=p;break}}var v=d[0];if(-1===l)v=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);v=g<.1?d[l-1]:d[l],l=g<.1?l-1:l}return a=null!==(r=null===(n=v)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=v)||void 0===o?void 0:o.video_index)&&void 0!==i?i:l,spatialSubLayer:a}}},{key:"updateSubMediaType",value:(t=Ug(Dg().mark((function e(t,r){var n,i,o,a,s;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=!1,o=!1,UD(r)&&(o=!0),VD(r)&&(i=!0),a={roomId:this._roomConf.roomId,streamList:[t.streamId],config:{enableMediaType:{video:i,audio:!!this._roomConf.isMultiChatMode()||o}}},e.next=6,this._ctx.signalingManager.sendSignaling("updateSubscribe",a);case 6:return this._roomConf.isMultiChatMode()||(null===(s=t.observer)||void 0===s||s.setUnmuteAudio(o),t.subAudio=o),null===(n=t.observer)||void 0===n||n.setUnmuteVideo(i),t.subVideo=i,t.subMediaType=r,e.abrupt("return",t);case 11:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(e){var t=this;e.forEach((function(e){e.forEach((function(e){if(e.hasSubscribed){var r=e.vendorHandler||t._ctx.handler;null==r||r.handleAck({action:WQ.unsubscribe,streamId:e.streamId,audioMid:e.audioMid,videoMid:e.videoMid,stream:e})}}))})),this._subBackOff.clear(),this._ontrackCallbackMap.forEach((function(e,r){t._removeOnTrackListener(r),t._ontrackCallbackMap.delete(r)})),this._subResolves={},FA(VA(p.prototype),"removeAllListeners",this).call(this)}},{key:"_getSubBackOff",value:function(e){return this._subBackOff.has(e)||this._subBackOff.set(e,{interval:1e3,retryDuration:0}),this._subBackOff.get(e)}}]),p}(wU);gZ([cZ,IX],yZ.prototype,"subscribe",1),gZ([cZ,IX],yZ.prototype,"unsubscribe",1),gZ([cZ,IX],yZ.prototype,"unsubscribe4removeTrack",1),gZ([IX],yZ.prototype,"handleRemoveStream",1),gZ([cZ,IX],yZ.prototype,"subscribe4pushTrack",1),gZ([IX],yZ.prototype,"updateUserAttributes",1),gZ([IX],yZ.prototype,"updateSubTrackLayer",1),gZ([IX],yZ.prototype,"updateSubPriority",1);var SZ=(Jl(_Z={},Th.communication,[0]),Jl(_Z,Th.chat,[0]),Jl(_Z,Th.chatRoom,[1,"IES_chatroom"]),Jl(_Z,Th.coHost,[1,"IES_PK"]),Jl(_Z,Th.meeting,[16]),Jl(_Z,Th.classRoom,[0]),_Z),bZ=function(e){jA(a,e);var t,r,n,i,o=iw(a);function a(e,t){var r;return Gh(this,a),Jl(dA(r=o.call(this)),"_logger",void 0),Jl(dA(r),"_authorization",void 0),Jl(dA(r),"_joinRoom5xxTimer",void 0),Jl(dA(r),"_joinTask",void 0),Jl(dA(r),"_sdpInfo",void 0),r._ctx=e,r._roomConf=t,r._logger=new fD("RoomJoin",2,e.id),r._logger.info("constructor","invoke"),r}return jh(a,[{key:"join",value:function(){var e,t,r=this,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._logger.info("join()");var i=new Hg((function(i,o){e=i,t=o,r._callJoinRoom(n).catch((function(e){var t=Array.isArray(e)&&e.length>0?e[0]:e;r._joinRoomFailed(t.message)}))}));return this._joinTask&&n?this._joinTask.startTime=AD():(this._joinTask={startTime:AD(),success:e,fail:t},this._roomConf.joinPromise=i),this._reportJoinRoomStart(),i}},{key:"updateToken",value:(i=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._logger.info("updateToken()","newToken: %o",t),this._ctx.appId&&this._roomConf.userId&&this._roomConf.roomId){e.next=3;break}return e.abrupt("return");case 3:return r={roomId:this._roomConf.roomId,userId:this._roomConf.userId,appId:this._ctx.appId,token:"Bearer ".concat(t)},e.prev=4,e.next=7,this._ctx.signalingManager.sendSignaling("updateToken",r);case 7:e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(4),new mC(hC.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 12:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e){return i.apply(this,arguments)})},{key:"leave",value:(n=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._logger.info("leave()"),this._stopJoinRoom5xxRetry(),this._joinRoomFailed("leave_room"),e.next=5,this._ready2join();case 5:if(!this._ctx.signalingManager.isConnected()){e.next=11;break}return t={Authorization:this._authorization,roomId:this._roomConf.roomId,sessionId:this._roomConf.sessionId},e.next=9,this._ctx.signalingManager.sendSignaling("leaveRoom",t);case 9:e.next=12;break;case 11:return e.abrupt("return",Hg.reject(new mC(hC.NOT_CONNECTED_YET,"server not connected")));case 12:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"destroy",value:function(){this._logger.info("destroy()"),this._joinRoomFailed("leave_room"),this._authorization=void 0,this._stopJoinRoom5xxRetry(),this.removeAllListeners()}},{key:"_ready2join",value:(r=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ctx.signalingManager.connect();case 2:if(this._sdpInfo){e.next=6;break}return e.next=5,null===(t=this._ctx.handler)||void 0===t?void 0:t.getDefaultSdp();case 5:this._sdpInfo=e.sent;case 6:if(a.supportedCodecs){e.next=10;break}return e.next=9,XU();case 9:a.supportedCodecs=e.sent;case 10:return e.abrupt("return",{sdpInfo:this._sdpInfo,supportedCodecs:a.supportedCodecs});case 11:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_callJoinRoom",value:(t=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,N=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._logger.info("_callJoinRoom","invoke"),delete this._sdpInfo,n=this._ctx,i=n.appId,o=n.role,a=n.businessId,s=n.useCloudProxy,c=n.joinRoomParams,u=n.mediaParams,e.next=5,this._ready2join();case 5:if(d=e.sent,l=d.sdpInfo,h=d.supportedCodecs,p={Authorization:CD.token2auth(i,this._roomConf.roomId,this._roomConf.userId,this._roomConf.token),sessionId:this._roomConf.sessionId,timestamp:Date.now(),controlMessage:this._roomConf.getLiveControlMessage(),userAttributes:{extra_info:this._roomConf.userInfo.extraInfo,role:o},sdpInfo:l,params:{supportedCodecs:h,deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:YL.VERSION,deviceId:BL.getDeviceId(),appId:i,roomId:this._roomConf.roomId,userId:this._roomConf.userId,businessId:a,enableCloudProxy:s,channelProfile:SZ[this._roomConf.roomProfileType]?"".concat(SZ[this._roomConf.roomProfileType][0]):"0"},options:{supportCheckTokenPrivilege:!0,supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0,supportMultiVendor:!0}},c)for(f=0,_=VS(c);f<_.length;f++)v=Ey(_[f],2),m=v[0],g=v[1],p.params[m]=g;return u&&(p.mediaParams=u),JL("SIGNAL_CROP_JOINROOM")&&null!==(r=p.sdpInfo)&&void 0!==r&&r.sdp&&(p.sdpInfo.sdp=SY(p.sdpInfo.sdp)),Hg.resolve().then((function(){return N.emit("onSendingJoinMessageHook")})),e.prev=14,R=t?"reconnected":"joinRoom",e.next=18,this._joinRoomWithRetry(R,p);case 18:A=e.sent,this._logger.success("join","send join message success"),w=A.config||{},C=w.engine_WEB,x=w._abtest_vid,this._authorization=p.Authorization,BL.setEngineWebConfig(this._ctx.appId,this._roomConf.roomId,C),this._ctx.serverConfig={videoCodec:(null==C?void 0:C.video_codec)||"H264",audioRed:!(null==C||!C.pub_audio_red),muteReplaceUnsub:!(null===(y=A.config)||void 0===y||!y.mute_replace_unsub),simulcastOnDemand:!(!1===(null===(S=A.config)||void 0===S||null===(b=S.engine_VPM)||void 0===b||null===(E=b.ondemand)||void 0===E?void 0:E.enable)),forceUniHandler:1===(null===(k=A.config)||void 0===k||null===(T=k.vendor_param)||void 0===T?void 0:T.vendor_stream_sub_mode),e2eFeedback:null==C?void 0:C.e2e_feedback},"boolean"==typeof(null==C?void 0:C.av_sync)&&(this._ctx.avSync=C.av_sync),this._roomConf.rtcVid=x,A.vendorConfig&&this._roomConf.setVendorConfig(A.vendorConfig),iG.setAudioStallConfig(C),null!==(I=A.relayMessage)&&void 0!==I&&I.sdp&&(null===(O=this._ctx.handler)||void 0===O||O.createAVMlineAnswerTpl(A.relayMessage.sdp)),this.emit(oH.JOIN_SUCCESS,{joinRes:A,reconnect:t}),this._joinRoomSuccess(A),e.next=37;break;case 33:e.prev=33,e.t0=e.catch(14),P={461:hC.ROOM_FORBIDDEN,462:hC.USER_FORBIDDEN},(null===e.t0||void 0===e.t0?void 0:e.t0.code)>=700&&(null===e.t0||void 0===e.t0?void 0:e.t0.code)<800?this._joinRoomFailed("token_error",hC.INVALID_TOKEN):P[null===e.t0||void 0===e.t0?void 0:e.t0.code]?this._joinRoomFailed((null===e.t0||void 0===e.t0?void 0:e.t0.message)||P[null===e.t0||void 0===e.t0?void 0:e.t0.code],P[null===e.t0||void 0===e.t0?void 0:e.t0.code]):(null===e.t0||void 0===e.t0?void 0:e.t0.code)===hC.TIME_OUT&&this._ctx.joinRoomConfig.useTcpAfterJoinTimeout?(this._logger.error("join",DQ.JOIN_TIMEOUT),this.safeEmit(oH.ON_REJOIN_WITH_TCP),this._ctx.signalingManager.reconnect(DQ.JOIN_TIMEOUT,!0)):e.t0.code===hC.OPERATION_CANCEL&&this._ctx.signalingManager.isReconnecting()||this._joinRoomFailed((null===e.t0||void 0===e.t0?void 0:e.t0.message)||"signaling_error");case 37:case"end":return e.stop()}}),e,this,[[14,33]])}))),function(e){return t.apply(this,arguments)})},{key:"_joinRoomWithRetry",value:function(e,t,r){var n=this;return new Hg((function(i,o){n._ctx.signalingManager.sendSignaling(e,t,void 0,1e4).then((function(e){n.emit("onJoinRoomAck",e),i(e)})).catch((function(a){if(r=r||new WX,a.code>=500&&a.code<600&&AD()-r.initTs<6e4){var s,c=r.getRetryDelay();return n._logger.warn("_joinRoomWithRetry",Gg(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:"_reportJoinRoomStart",value:function(){this._joinTask&&(this.emit("__joinRoomStartReport"),this._roomConf.report("join_room",{type:"begin",start:this._joinTask.startTime,result:!1,reason:""},{enable_cloud_proxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC}))}},{key:"_joinRoomSuccess",value:function(e){this._joinTask&&(this._joinTask.success(e),this.emit("__joinRoomSuccessReport"),this._roomConf.report("join_room",{type:"end",start:this._joinTask.startTime,result:!0,reason:""},{enable_cloud_proxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC}),this._roomConf.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:AD()-this._joinTask.startTime}),delete this._joinTask,delete this._roomConf.joinPromise)}},{key:"_joinRoomFailed",value:function(e,t){this._joinTask&&(this._joinTask.fail(new mC(t||hC.JOIN_ROOM_FAILED,e)),this.emit("__joinRoomFailedReport"),this._roomConf.report("join_room",{type:"end",start:this._joinTask.startTime,result:!1,reason:e},{enable_cloud_proxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC}),delete this._joinTask,delete this._roomConf.joinPromise)}}]),a}(wU);Jl(bZ,"supportedCodecs",void 0);var EZ=pT,kZ=KI,TZ=function(e,t,r,n){for(var i,o=n>1?void 0:n?kZ(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&&EZ(t,r,o),o},IZ=function(){function e(t,r){Gh(this,e),Jl(this,"_logger",void 0),this._ctx=t,this._roomConf=r,this._logger=new fD("RoomMessage",2,t.id)}var t,r;return jh(e,[{key:"sendUserMessage",value:function(e,t){return this._ctx.signalingManager.sendP2PMessage({to:e,from:this._roomConf.userId,room:this._roomConf.roomId,app:this._ctx.appId,msg:t})}},{key:"sendRoomMessage",value:(r=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={clientId:this._roomConf.userId,binary:r,message:"",roomId:this._roomConf.roomId},!r){e.next=7;break}return e.next=4,CD.ab2b64str(t);case 4:n.message=e.sent,e.next=8;break;case 7:n.message=t;case 8:return e.abrupt("return",this._ctx.signalingManager.sendSignaling("customMessage",n));case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"controlMessage",value:(t=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._logger.info("controlMessage()","params: %o",t),r=t,"transcode"===t.type&&(r.roomId=this._roomConf.roomId),e.next=5,this._ctx.signalingManager.sendSignaling("controlMessage",r);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();TZ([IX],IZ.prototype,"sendUserMessage",1),TZ([IX],IZ.prototype,"sendRoomMessage",1),TZ([IX],IZ.prototype,"controlMessage",1);var RZ=pT,AZ=KI,wZ=function(e,t,r,n){for(var i,o=n>1?void 0:n?AZ(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&&RZ(t,r,o),o},CZ={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},xZ=function(e){jA(O,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R,A,w,C,x=iw(O);function O(e,t){var r;return Gh(this,O),Jl(dA(r=x.call(this)),"_localStream",void 0),Jl(dA(r),"_localScreenStream",void 0),Jl(dA(r),"_remoteUsers",new hT),Jl(dA(r),"_remoteStreams",new hT),Jl(dA(r),"_remoteStreamStreamIdUserIdMap",{}),Jl(dA(r),"_virtualStreams",[]),Jl(dA(r),"_serverConfig",void 0),Jl(dA(r),"_userDuplicateLoginTimerMap",new hT),Jl(dA(r),"_networkQualityManager",void 0),Jl(dA(r),"_videoSizeObserver",void 0),Jl(dA(r),"_hasPublished",!1),Jl(dA(r),"_subtitleTool",void 0),Jl(dA(r),"_csrcUserIdMap",{}),Jl(dA(r),"_publishOnDemandItem",void 0),Jl(dA(r),"_onceTriggerBySignal",!1),Jl(dA(r),"_pubTransceiverReady",!1),Jl(dA(r),"_publishOnDemandBusy",!1),Jl(dA(r),"logger",void 0),Jl(dA(r),"_forwardStreamManager",void 0),Jl(dA(r),"_publisher",void 0),Jl(dA(r),"_subscriber",void 0),Jl(dA(r),"_roomJoin",void 0),Jl(dA(r),"_roomMessage",void 0),Jl(dA(r),"_clearSignalListeners",void 0),r.config=e,r._ctx=t,r.logger=new fD("Room",1,t.id),r.logger.info("constructor","invoke"),r._publisher=new fZ(t,e),r._addPublisherListeners(),r._subscriber=new yZ(t,e),r._addSubscriberListeners(),r._roomJoin=new bZ(t,e),r._addJoinRoomHandler(),r._forwardStreamManager=new CX(t,e),r._addForwardStreamListeners(),r._roomMessage=new IZ(t,e),r._networkQualityManager=new pH(t),r._networkQualityManager.reportor=r._reportNetworkQuality.bind(dA(r)),r._videoSizeObserver=new fH(dA(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(dA(r)),r._addSignalListeners(),r}return jh(O,[{key:"hasScreenPublished",get:function(){var e;return null===(e=this._localScreenStream)||void 0===e?void 0:e.hasPublished}},{key:"hasPublished",get:function(){var e;return!(null===(e=this._localStream)||void 0===e||!e.hasPublished)}},{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:"virtualStreams",get:function(){return this._virtualStreams}},{key:"_addSignalListeners",value:function(){var e,t=this,r=(Jl(e={},PU.ON_ADD_STREAM,this._onAddStream.bind(this)),Jl(e,PU.ON_ADD_STREAM_LIST,(function(e){e&&Array.isArray(e.streamList)&&e.streamList.forEach((function(e){return t._onAddStream(e)}))})),Jl(e,PU.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),Jl(e,PU.ON_REMOVE_STREAM_LIST,(function(e){e&&Array.isArray(e.streamList)&&e.streamList.forEach((function(e){return t._onRemoveStream(e)}))})),Jl(e,PU.USER_CONNECTION,this._onUserConnection.bind(this)),Jl(e,PU.USER_CONNECTION_LIST,(function(e){e&&Array.isArray(e.userList)&&e.userList.forEach((function(e){return t._onUserConnection(e)}))})),Jl(e,PU.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),Jl(e,PU.USER_DISCONNECTION_LIST,(function(e){e&&Array.isArray(e.userList)&&e.userList.forEach((function(e){return t._onUserDisconnection(e)}))})),Jl(e,PU.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),Jl(e,PU.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),Jl(e,PU.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),Jl(e,PU.ON_PUSH_TRACK,this._onPushTrack.bind(this)),Jl(e,PU.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),Jl(e,PU.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),Jl(e,PU.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),Jl(e,PU.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),Jl(e,PU.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),Jl(e,PU.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),Jl(e,PU.ON_TOKEN_PUBLISH_PRIVILEGE_WILL_EXPIRE,this._onUserTokePublishPrivilegeWillExpire.bind(this)),Jl(e,PU.ON_TOKEN_PUBLISH_PRIVILEGE_DID_EXPIRED,this._onUserTokenPublishPrivilegeDidExpire.bind(this)),Jl(e,PU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_WILL_EXPIRE,this._onUserTokeSubscribePrivilegeWillExpire.bind(this)),Jl(e,PU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_DID_EXPIRED,this._onUserTokenSubscribePrivilegeDidExpire.bind(this)),Jl(e,PU.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),Jl(e,PU.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),Jl(e,NU.RTT,this._onRTT.bind(this)),Jl(e,NU.SSC,this._onSSC.bind(this)),Jl(e,MU.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),Jl(e,PU.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),Jl(e,PU.ON_FORWARD_DST_ROOM_USER_KICK,this._forwardStreamManager.onForwardDstRoomUserKick.bind(this._forwardStreamManager)),Jl(e,NU.RSCP,this._onRSCP.bind(this)),e);FS(r).forEach((function(e){t._ctx.signalingManager.on(e,r[e])})),this._clearSignalListeners=function(){FS(r).forEach((function(e){t._ctx.signalingManager.off(e,r[e])}))}}},{key:"_addPublisherListeners",value:function(){var e=this;this._publisher.on(oH.PUB_RETRY,(function(t){e.emit(oH.PUB_RETRY,t)})),this._publisher.on(NU.RSCP,this._onRSCP.bind(this)),this._publisher.on(MU.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(t){return e.emit(MU.ON_VENDOR_CONNECTION_STATE_CHANGE,t)}))}},{key:"_addSubscriberListeners",value:function(){var e=this;this._subscriber.on(MU.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(t){return e.emit(MU.ON_VENDOR_CONNECTION_STATE_CHANGE,t)})),this._subscriber.on("onRemoteStreamStats",(function(t){e._networkQualityManager.updateDownlinkStats(t,e._findRemoteStreamByScreen(t.userId,t.isScreen)),e.emit(oH.ON_REMOTE_STREAM_STATS,FD(t))})),this._subscriber.on(oH.RESUBSCRIBE,(function(t){e.emit(oH.RESUBSCRIBE,t)})),this._subscriber.on(oH.SUB_RETRY,(function(t){e.emit(oH.SUB_RETRY,t)}))}},{key:"_addJoinRoomHandler",value:function(){var e=this;this._roomJoin.on(oH.JOIN_SUCCESS,this._onJoinSucc.bind(this)),this._roomJoin.on(oH.ON_REJOIN_WITH_TCP,(function(){e.emit(oH.ON_REJOIN_WITH_TCP)}))}},{key:"_addForwardStreamListeners",value:function(){var e=this;this._forwardStreamManager.on(oH.ON_FORWARD_STREAM_ERROR,(function(t){e.safeEmit(oH.ON_FORWARD_STREAM_ERROR,t)}))}},{key:"_onLocalStreamStats",value:function(e){var t=e.isScreen?this._localScreenStream:this.localStream;this._networkQualityManager.updateUplinkStats(e,t),this.emit(oH.ON_LOCAL_STREAM_STATS,FD(e))}},{key:"join",value:(C=Ug(Dg().mark((function e(){var t,r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("join()"),this.config.startJoinTimestamp=AD(),e.prev=2,e.next=5,this._roomJoin.join();case 5:return r=e.sent,null!==(t=r.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack(),this._initSubtitleTool(),e.abrupt("return",{users:r.clients,streams:r.streams});case 11:if(e.prev=11,e.t0=e.catch(2),e.t0.code===hC.OPERATION_CANCEL){e.next=15;break}throw e.t0;case 15:case"end":return e.stop()}}),e,this,[[2,11]])}))),function(){return C.apply(this,arguments)})},{key:"publishScreen",value:(w=Ug(Dg().mark((function e(t,r,n,i,o){var a,s,c,u,d,l,h,p,f;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishScreen()"),this._localScreenStream||(this._localScreenStream=new nH(this._ctx),this.config.vendorConfig.enableMultiVendor&&(this._localScreenStream.pcSessionId=gx()),this._localScreenStream.isScreen=!0,this._localScreenStream.observer=new lH(this._ctx,this._localScreenStream)),a=!1,s=!1,c=!1,u=!1,!this._localScreenStream.videoTrack&&r?(r.sourceType===VU.EXTERNAL&&(s=!0),a=!0):this._localScreenStream.videoTrack&&!r&&(a=!1),!this._localScreenStream.audioTrack&&n?(n.sourceType===VU.EXTERNAL&&(u=!0),c=!0):this._localScreenStream.audioTrack&&!n&&(c=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(UD(i)&&(this._localScreenStream.pubAudio=o===sH.PUB),VD(i)&&(this._localScreenStream.pubVideo=o===sH.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(!this._localScreenStream.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===(d=this._localScreenStream.observer)||void 0===d||d.setPublish(!0),e.next=22,this._publisher.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return s?null===(l=this._localScreenStream.observer)||void 0===l||l.setPushVideo(a):null===(h=this._localScreenStream.observer)||void 0===h||h.setEnableVideo(a),u?null===(p=this._localScreenStream.observer)||void 0===p||p.setPushAudio(c):null===(f=this._localScreenStream.observer)||void 0===f||f.setEnableAudio(c),e.next=28,this.updatePubScreenTrack();case 28:this._localScreenStream.pubAudio||this._localScreenStream.pubVideo?this._ctx.handler&&this._localScreenStream.startReport(this._onLocalStreamStats.bind(this),this._localScreenStream.vendorHandler||this._ctx.handler):this._localScreenStream.stopReport("unpublish screen");case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return w.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(A=Ug(Dg().mark((function e(){return Dg().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._publisher.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return A.apply(this,arguments)})},{key:"unpublishScreen",value:(R=Ug(Dg().mark((function e(){var t;return Dg().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._publisher.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 R.apply(this,arguments)})},{key:"liveControlMessage",value:(I=Ug(Dg().mark((function e(t){var r,n=this;return Dg().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){e.roomID=n.config.roomId})),e.next=4,this._roomMessage.controlMessage(t);case 4:this.config.setLiveControlMessage("stopped"===t.action?void 0:t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(T=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._roomMessage.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"updateUserAttributes",value:(k=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateUserAttributes","Invoke updateUserAttributes"),e.next=3,this._subscriber.updateUserAttributes({role:this._ctx.role});case 3:case"end":return e.stop()}}),e,this)}))),function(){return k.apply(this,arguments)})},{key:"publish",value:(E=Ug(Dg().mark((function e(t,r,n,i,o,a){var s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=T.length>6&&void 0!==T[6]&&T[6],this.logger.info("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new nH(this._ctx),this.config.vendorConfig.enableMultiVendor&&(this._localStream.pcSessionId=gx()),this._localStream.observer=new lH(this._ctx,this._localStream),c=!0,this._localStream.vendorCode=this.config.vendorConfig.vendorCode||0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,u=this._localStream,d=u.pubAudio,l=u.pubVideo,o&&(UD(o)&&(this._localStream.pubAudio=a===sH.PUB),VD(o)&&(this._localStream.pubVideo=a===sH.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===(h=this._localStream.observer)||void 0===h||h.setLogin(!0):c&&(_=!!this._localStream.videoTrack,v=!!this._localStream.audioTrack,m=(null===(p=this._localStream.videoTrack)||void 0===p?void 0:p.sourceType)===VU.EXTERNAL,g=(null===(f=this._localStream.audioTrack)||void 0===f?void 0:f.sourceType)===VU.EXTERNAL,this.config.isAutoPublish&&!this._hasPublished?(_&&(m?null===(y=this._localStream.observer)||void 0===y||y.setPushVideo(!0):null===(S=this._localStream.observer)||void 0===S||S.setEnableVideo(!0)),v&&(g?null===(b=this._localStream.observer)||void 0===b||b.setPushAudio(!0):null===(E=this._localStream.observer)||void 0===E||E.setEnableAudio(!0))):null===(k=this._localStream.observer)||void 0===k||k.setPublish(!0)),this.emit("___onMediaServerClientPublish"),e.next=18,this._publisher.publish(this._localStream);case 18:this._hasPublished=!0,this.emit(oH.ON_PUBLISH_RESULT,{isScreen:!1,state:oh.PUBLISH_SUCC}),e.next=27;break;case 22:throw e.prev=22,e.t0=e.catch(13),this.emit(oH.ON_PUBLISH_RESULT,{isScreen:!1,state:oh.PUBLISH_FAIL,errorCode:e.t0.code}),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=d,this._localStream.pubVideo=l,e.t1;case 40:this._localStream.pubAudio||this._localStream.pubVideo?this._ctx.handler&&this._localStream.startReport(this._onLocalStreamStats.bind(this),this._localStream.vendorHandler||this._ctx.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 E.apply(this,arguments)})},{key:"updatePubTrack",value:(b=Ug(Dg().mark((function e(){return Dg().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._publisher.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return b.apply(this,arguments)})},{key:"unpublish",value:(S=Ug(Dg().mark((function e(){return Dg().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._publisher.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 S.apply(this,arguments)})},{key:"subscribe",value:(y=Ug(Dg().mark((function e(t,r,n){var i,o;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("subscribe","remoteStream %o",t),t.streamState===rH.INIT){e.next=8;break}if((i=t.subMediaType|r)===t.subMediaType){e.next=7;break}return e.next=6,this._subscriber.updateSubMediaType(t,i);case 6:return e.abrupt("return",e.sent);case 7:return e.abrupt("return");case 8:return o=void 0,n&&(o=this._subscriber.getSubLayer(n,t)),e.next=12,this._subscriber.subscribe(t,r,o);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return y.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(g=Ug(Dg().mark((function e(t,r){var n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(o=this._findRemoteStreamByScreen(t,!1))&&o.hasSubscribed&&!((null===(n=o.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 a=this._subscriber.getSubLayer(r,o),o.originalStreamIndex=a.spatialLayer,e.abrupt("return",this._subscriber.updateSubTrackLayer(o,a));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return g.apply(this,arguments)})},{key:"unsubscribe",value:(m=Ug(Dg().mark((function e(t,r){var n,i;return Dg().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(i=t.subMediaType-(t.subMediaType&r),null!==(n=this._ctx.serverConfig)&&void 0!==n&&n.muteReplaceUnsub||!(i===HL.NONE||this.config.isMultiChatMode()&&i===uh.AUDIO)){e.next=8;break}return e.next=7,this._subscriber.unsubscribe(t);case 7:return e.abrupt("return",e.sent);case 8:return e.next=10,this._subscriber.updateSubMediaType(t,i);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"startSubtitle",value:(v=Ug(Dg().mark((function e(t){return Dg().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 mC(hC.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"updateSubtitleConfig",value:(_=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subtitleTool){e.next=5;break}return e.next=3,this._subtitleTool.update(t);case 3:e.next=6;break;case 5:throw new mC(hC.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"stopSubtitle",value:(f=Ug(Dg().mark((function e(){var t;return Dg().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 f.apply(this,arguments)})},{key:"startForwardStream2Rooms",value:(p=Ug(Dg().mark((function e(t){return Dg().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 p.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(h=Ug(Dg().mark((function e(t){return Dg().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 h.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(l=Ug(Dg().mark((function e(){return Dg().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 l.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(d=Ug(Dg().mark((function e(){return Dg().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 d.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(u=Ug(Dg().mark((function e(){return Dg().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 u.apply(this,arguments)})},{key:"updateMediaParams",value:(c=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._ctx.signalingManager.sendSignaling("updateMediaParams",{roomId:this.config.roomId,mediaParams:t}));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"leave",value:(s=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=c.length>0&&void 0!==c[0]&&c[0],this.logger.info("leave","Invoke leave"),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,e.prev=4,i=by(tx(n=this._remoteStreams).call(n));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(j0){i.e(j0)}finally{i.f()}return this._localStream&&(null===(s=this._localStream.observer)||void 0===s||s.setLogin(!1)),e.next=10,this._roomJoin.leave().catch((function(){}));case 10:this.destroy(),this.config.report("rtc_leave_room",{error_code:0,message:"",elapse:this.config.getStayRoomDuration()}),e.next=22;break;case 14:if(e.prev=14,e.t0=e.catch(4),e.t0 instanceof Error&&this.config.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:this.config.getStayRoomDuration()}),!r){e.next=21;break}throw e.t0;case 21:this.destroy();case 22:case"end":return e.stop()}}),e,this,[[4,14]])}))),function(){return s.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._ctx.userPriority;t.hasSubscribed&&n.has(e)&&r._subscriber.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e,t;this.logger.info("destroy","Invoke destroy"),$M(this._ctx.id,"room_destroy","".concat((new Error).stack)),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._subscriber.destroy(this._remoteStreams),this._publisher.destroy([this.localStream,this.localScreenStream]),this._roomJoin.destroy(),null===(t=this._clearSignalListeners)||void 0===t||t.call(this),this._remoteUsers=new hT;var r,n=by(this._remoteStreams);try{for(n.s();!(r=n.n()).done;){var i=Ey(r.value,2)[1];Array.isArray(i)&&i.forEach((function(e){null==e||e.destroy()}))}}catch(j0){n.e(j0)}finally{n.f()}this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new hT,this._localStream&&(this._localStream.clean(),this._localStream=void 0),this._localScreenStream&&(this._localScreenStream.clean(),this._localScreenStream=void 0),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={},this._forwardStreamManager.destoy()}},{key:"updateToken",value:(a=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateToken","Invoke updateToken"),this.config.token=t,e.prev=2,e.next=5,this._roomJoin.updateToken(t);case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(2),this.safeEmit(oH.ON_ROOM_ERROR,{errorCode:hC.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return a.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){return this._roomMessage.sendUserMessage(e,t)}},{key:"sendRoomMessage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this._roomMessage.sendRoomMessage(e,t)}},{key:"maybeFillBackFrame2Stream",value:(o=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.refreshBlackFrameLifetime(),null!==(r=t.videoTransceiver)&&void 0!==r&&r.sender.track||this._publisher.updatePubBlackFrame(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.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.emit(oH.JOIN_SUCCESS,a),this._serverConfig=o.config,this.config.updateRoomAttributes(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(oH.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&i.safeEmit(oH.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=by(tx(r=this._remoteUsers).call(r));try{for(p.s();!(h=p.n()).done;){var f=h.value;f._stillExist||c.push({clientId:f.userId}),delete f._stillExist}}catch(j0){p.e(j0)}finally{p.f()}o.streams.forEach((function(e){var t=i._findRemoteStreamByScreen(e.clientId,e.screen);i.config.updateUserPubInfo(e),t?(t.stillExist=!0,t.streamId=e.streamId,l.push(e)):d.push(e)}));var _,v=by(tx(n=this._remoteStreams).call(n));try{for(v.s();!(_=v.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:xU.clientDisconnected})}))}}catch(j0){v.e(j0)}finally{v.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)})),this.config.resetUserPubInfo(),a&&this._handleSendOrRecvStreamAfterReconnect(),this.emit("__joinSuccess")}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r,n,i=this;this._localStream&&(this._localStream.clean(),this._localStream.vendorCode=this.config.vendorConfig.vendorCode||0,null===(r=this._localStream.observer)||void 0===r||r.setLogin(!0),this._publisher.publish(this._localStream).then((function(){var e;i._ctx.handler&&(null===(e=i._localStream)||void 0===e||e.startReport(i._onLocalStreamStats.bind(i),i._localStream.vendorHandler||i._ctx.handler)),i.emit(oH.ON_PUBLISH_RESULT,{isScreen:!1,state:oh.PUBLISH_SUCC,retry:!0})})).catch((function(e){i.logger.error("failed repub error:".concat(e)),i.emit(oH.ON_PUBLISH_RESULT,{isScreen:!1,state:oh.PUBLISH_FAIL,errorCode:e.code,retry:!0})})));this._localScreenStream&&(this._localScreenStream.clean(),null===(n=this._localScreenStream.observer)||void 0===n||n.setLogin(!0),this._publisher.publish(this._localScreenStream).then((function(){var e;i._ctx.handler&&(null===(e=i._localScreenStream)||void 0===e||e.startReport(i._onLocalStreamStats.bind(i),i._localScreenStream.vendorHandler||i._ctx.handler)),i.emit(oH.ON_PUBLISH_RESULT,{isScreen:!0,state:oh.PUBLISH_SUCC,retry:!0})})).catch((function(e){i.logger.error("failed repub screen stream error:".concat(e)),i.emit(oH.ON_PUBLISH_RESULT,{isScreen:!0,state:oh.PUBLISH_FAIL,errorCode:e.code,retry:!0})})));var o,a=by(tx(t=this._remoteStreams).call(t));try{for(a.s();!(o=a.n()).done;){var s=o.value;Array.isArray(s)&&s.forEach(function(){var e=Ug(Dg().mark((function e(t){var r,n,o,a,s,c;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=22;break}return t.resetHasSubscribed(),e.prev=2,i.logger.info(Gg(r="start resubscribe ".concat(t.userId," with ")).call(r,t.subMediaType)),VD(t.subMediaType)&&(null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!0)),UD(t.subMediaType)&&(null===(o=t.observer)||void 0===o||o.setSubscribeAudio(!0)),e.next=8,i._subscriber.subscribe(t,t.subMediaType);case 8:i.logger.info(Gg(a="success resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType)),i.safeEmit(oH.RESUBSCRIBE,{stream:t}),i.emit(oH.ON_SUBSCRIBE_RESULT,{state:ih.SUBSCRIBE_SUCC,userId:t.userId,isScreen:t.isScreen,retry:!0}),e.next=22;break;case 13:if(e.prev=13,e.t0=e.catch(2),i.emit(oH.ON_SUBSCRIBE_RESULT,{state:ih.SUBSCRIBE_FAIL,userId:t.userId,isScreen:t.isScreen,errorCode:e.t0.code,retry:!0}),i.logger.error(Gg(s=Gg(c="failed resubscribe ".concat(t.userId," with ")).call(c,t.subMediaType,", error:")).call(s,e.t0)),e.t0.code!==hC.NOT_CONNECTED_YET){e.next=20;break}return t.streamState=rH.SUB_ED,e.abrupt("return");case 20:t.clean(),t.resetHasSubscribed();case 22:case"end":return e.stop()}}),e,null,[[2,13]])})));return function(t){return e.apply(this,arguments)}}())}}catch(j0){a.e(j0)}finally{a.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect(),this._forwardStreamManager.resumeFromReconnect()}},{key:"_handleFFAudioTrack",value:function(){var e,t,r=null===(e=this._ctx.handler)||void 0===e?void 0:e.audioTrack4ff,n=null===(t=this._ctx.handler)||void 0===t?void 0:t.getTransceivers();if(r&&Array.isArray(n)){var i=dI(n).call(n,(function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===r}));if(i){var o=new iH(this._ctx,"ff-stream","ff-stream",!1,!1,CZ);o.virtual=!0,o.audioTransceiver=i,o.audioMid="0",o.audioTrack=KG(r,{streamIndex:BU.VIRTUAL}),this._virtualStreams.push(o),this.safeEmit(oH.SUBSCRIBE_PUSH_TRACK,{stream:o})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?dI(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)?dI(r).call(r,(function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.needEmit,n=void 0===r||r,i=t.fromSignal,o=void 0===i||i,a=t.virtual,s=void 0!==a&&a;if(e.clientId!==this.config.userId){var c=this.config,u=c.isAutoSubscribeAudio,d=c.isAutoSubscribeVideo,l=this._findRemoteStreamByScreen(e.clientId,e.screen);if(l&&l.streamId!==e.streamId){var h,p=null===(h=this._remoteStreams.get(e.clientId))||void 0===h?void 0:wy(h).call(h,(function(e){return e.streamId!==l.streamId}));l.clean(),this._remoteStreams.set(e.clientId,p||[])}var f=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,f)f.attributes=e.attributes;else if((f=new iH(this._ctx,e.clientId,e.streamId,e.screen,!1,e.attributes)).virtual=s,this._initStreamListeners(f),!s){var _=this._remoteStreams.get(e.clientId);_?_.push(f):this._remoteStreams.set(e.clientId,[f])}if(f.remoteSessionId=e.remoteSessionId||"",f.observer=new dH(this._ctx,f),!f.isScreen&&d&&(o&&f.hasVideo&&(f.attributes.extvideo?(f.observer.setExternalVideoSource(!0),f.observer.setPushVideo(!0)):(f.observer.setExternalVideoSource(!1),f.observer.setPublishVideo(!0))),o&&f.hasAudio&&u&&!this.config.isMultiChatMode()&&(f.attributes.extaudio?(f.observer.setExternalAudioSource(!0),f.observer.setPushAudio(!0)):(f.observer.setExternalAudioSource(!1),f.observer.setPublishAudio(!0))),n&&!o)){var v=this.config,m=v.isAutoSubscribeAudio,g=v.isAutoSubscribeVideo;f.observer.setLogin(!0,{audio:!!m&&!this.config.isMultiChatMode(),video:!!g})}return n&&this.safeEmit(PU.ON_ADD_STREAM,{stream:f}),f}}},{key:"_onUserConnection",value:function(e){if(e.clientId!==this.config.userId){var t=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof t)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(t);var r={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,Zl({},r)),this.safeEmit(PU.USER_CONNECTION,{userInfo:r,publishState:this.config.getUserPubInfo(r.userId)}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(oH.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(oH.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t=this,r=e.clientId,n=e.tag,i=e.code,o=e.forbiddenTime;if(r)if(r===this.config.userInfo.userId){var a=null;n===DU.kickedByAdmin?a=hC.KICKED_OUT:n===DU.onUserTokenDidExpire?a=hC.TOKEN_EXPIRED:n===DU.userDuplicateLogin&&(a=hC.DUPLICATE_LOGIN),i===LU.roomDismissByAdmin&&(a=hC.ROOM_DISMISS),a&&this.safeEmit(oH.ON_ROOM_ERROR,{errorCode:a,forbiddenTime:o})}else{var s=th.DROPPED;n===DU.userLeave?s=th.QUIT:n===DU.kickedByAdmin?s=th.KICKED_BY_ADMIN:n===DU.roleChanged&&(s=th.SWITCH_TO_INVISIBLE);var c=function(){var e;t._remoteUsers.delete(r);var n=[];null===(e=t._remoteStreams.get(r))||void 0===e||e.forEach((function(e){n.push(t._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:xU.clientDisconnected}))})),t._remoteStreams.delete(r),Hg.all(n).finally((function(){t.safeEmit(oH.ON_USER_LEAVE,{userInfo:{userId:r},reason:s})}))};if(n===DU.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(r);u&&self.clearTimeout(u);var d=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(r,d)}else c()}}},{key:"_onRemoveStream",value:(i=Ug(Dg().mark((function e(t){var r,n,i,o,a,s=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.clientId!==this.config.userId){e.next=2;break}return e.abrupt("return");case 2:if(r=this._remoteStreams.get(t.clientId)){e.next=5;break}return e.abrupt("return");case 5:if(n=dI(r).call(r,(function(e){return e.streamId===t.streamId}))){e.next=8;break}return e.abrupt("return");case 8:return n.hasVideo&&(null===(i=n.observer)||void 0===i||i.setPublishVideo(!1)),n.hasAudio&&!this.config.isMultiChatMode()&&(null===(o=n.observer)||void 0===o||o.setPublishAudio(!1)),a=wy(r).call(r,(function(e){return e.streamId!==t.streamId})),this._remoteStreams.set(t.clientId,a),e.prev=12,e.next=15,this._subscriber.handleRemoveStream(n).then((function(){n.clean()})).finally((function(){s.safeEmit(PU.ON_REMOVE_STREAM,{stream:n,reason:t.message,callback:function(){return n.destroy()}})}));case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(12),console.error(e.t0);case 20:case"end":return e.stop()}}),e,this,[[12,17]])}))),function(e){return i.apply(this,arguments)})},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(oH.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(oH.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&this.config.updateRoomAttributes(e.roomAttributes),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this.config,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=Zl(Zl({},d),a),h=!1,p=l.localaudio!==d.localaudio,f=!1,_=!1,v=l.localvideo!==d.localvideo,m=!1,g=HL.NONE,y=HL.NONE;if(l.audiostream!==d.audiostream&&(h=l.localaudio,f=!!l.audiostream,l.audiostream?g|=uh.AUDIO:y|=uh.AUDIO),l.videostream!==d.videostream&&(_=l.localvideo,m=!!l.videostream,l.videostream?g|=uh.VIDEO:y|=uh.VIDEO),g&&this.safeEmit(oH.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:sH.PUB,remoteStream:s}),y&&this.safeEmit(oH.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:sH.UNPUB,remoteStream:s}),s.remoteSessionId=e.remoteSessionId||"",s.attributes=l,l.localaudio!==d.localaudio)if(l.localaudio){var S,b,E,k;if((r||s.subAudio)&&l.audiostream)if(l.extaudio)null===(S=s.observer)||void 0===S||S.setExternalAudioSource(!0),null===(b=s.observer)||void 0===b||b.setPushAudio(!0);else null===(E=s.observer)||void 0===E||E.setExternalAudioSource(!1),null===(k=s.observer)||void 0===k||k.setEnableAudio(!0);this.safeEmit(oH.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(oH.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(l.localvideo!==d.localvideo)if(l.localvideo){var w,C,x,O;if((n||s.subVideo)&&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(oH.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var P,N,M,D;if(l.extvideo)null===(P=s.observer)||void 0===P||P.setExternalVideoSource(!0),null===(N=s.observer)||void 0===N||N.setPushVideo(!1);else null===(M=s.observer)||void 0===M||M.setExternalVideoSource(!1),null===(D=s.observer)||void 0===D||D.setEnableVideo(!1);!s.isScreen&&this.safeEmit(oH.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!p&&r)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(f);if(_&&!v&&n)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteVideo(m);"number"==typeof l.videoType&&l.videoType!==d.videoType&&this.safeEmit(oH.VIDEO_TYPE_CHANGE,{userId:s.userId,isScreen:s.isScreen,type:l.videoType===UU.BLACK?CU.BLACK:CU.NORMAL})}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&lC(t).call(t,"audio_mux")){var n=this._onAddStream(Zl(Zl({},e),{},{attributes:CZ}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._subscriber.subscribe4pushTrack(n,e).then((function(){r.safeEmit(oH.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){r.logger.error("subscribe","push track failed %o",e)}))}else{var i;this.config.report("rtc_error",{message:Gg(i="onPushTrack, userId: ".concat(e.clientId,", ")).call(i,e.streamId),error_code:EH.TRACK_ERROR})}}},{key:"_onRemoveTrack",value:function(e){var t=e.clientId,r=e.streamId,n=e.message,i=e.trackType;this.logger.info("_onRemoveTrack","remove track: %o",t);var o=this._findRemoteStream(t,r);o&&(o.removeTrack=!0,this._subscriber.unsubscribe4removeTrack(o,n,i),this.emit(oH.REMOVE_PUSH_TRACK,{stream:o,mediaType:i+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&&Qy(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=Ey(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&&jw(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,c=this,u=by(tx(a=this._remoteStreams).call(a));try{for(u.s();!(s=u.n()).done;){var d=s.value;Array.isArray(d)&&d.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()}))}}catch(j0){u.e(j0)}finally{u.f()}this._virtualStreams.forEach((function(e){var t;c.emit(oH.REMOVE_PUSH_TRACK,{stream:e,mediaType:uh.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){e.state===lh.CONNECTION_STATE_RECONNECTING?this._onReconnecting():e.state===lh.CONNECTION_STATE_RECONNECTED&&this._roomJoin.join(!0)}},{key:"_initStreamListeners",value:function(e){var t=this;e.on("ontrack",(function(e){e.track})),e.on("onSEIMessage",(function(r){t.emit(oH.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:t.config.roomId,streamIndex:e.isScreen?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){var t;null!==(t=this._subtitleTool)&&void 0!==t&&t.onMessageRecv(e)||this.safeEmit(PU.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(PU.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(PU.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new yH(this._ctx,this.config),this._subtitleTool.onEvent=function(t){e.emit(oH.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(oH.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=aH.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=aH.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?aH.START_FAILED:aH.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?aH.STOP_FAILED:aH.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?aH.UPDATE_FAILED:aH.UPDATE_SUCCESS}this.safeEmit(PU.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(PU.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(PU.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onUserTokePublishPrivilegeWillExpire",value:function(){this.safeEmit(PU.ON_TOKEN_PUBLISH_PRIVILEGE_WILL_EXPIRE,null)}},{key:"_onUserTokenPublishPrivilegeDidExpire",value:function(){this.safeEmit(PU.ON_TOKEN_PUBLISH_PRIVILEGE_DID_EXPIRED,null)}},{key:"_onUserTokeSubscribePrivilegeWillExpire",value:function(){this.safeEmit(PU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_WILL_EXPIRE,null)}},{key:"_onUserTokenSubscribePrivilegeDidExpire",value:function(){this.safeEmit(PU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_DID_EXPIRED,null)}},{key:"_onStreamFailed",value:(n=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("publish"!==t.type){e.next=11;break}if(i=void 0,(null===(r=this.localStream)||void 0===r?void 0:r.streamId)===t.streamId?i=this.localStream:(null===(n=this.localScreenStream)||void 0===n?void 0:n.streamId)===t.streamId&&(i=this.localScreenStream),i){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,this._publisher.unpublish(i).catch((function(){}));case 7:i.clean(),this._publisher.publish(i).catch((function(){})),e.next=22;break;case 11:if("subscribe"!==t.type){e.next=22;break}if(o=this._remoteStreamStreamIdUserIdMap[t.streamId],!(a=this._findRemoteStream(o,t.streamId))){e.next=22;break}return s=a.subMediaType,c=a.subLayer,e.next=19,this._subscriber.unsubscribe(a);case 19:return e.next=21,this._subscriber.subscribe(a,s,c);case 21:this.safeEmit(oH.RESUBSCRIBE,{stream:a});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===OU.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=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,f=this;return Dg().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.videoTransceiver){e.next=16;break}return this._publishOnDemandBusy=!0,a=this._publishOnDemandItem,this._publishOnDemandItem=void 0,s=[],c=this._localStream.stream.id,u=this._localStream.videoTransceiver.sender,d=u.getParameters(),Array.isArray(d.encodings)&&Array.isArray(a)&&(h={},this.logger.info("_onPublishOnDemand exec","usedDescriptions: %o",a),a.forEach((function(e){var t;if(null!==(t=e.StreamIds)&&void 0!==t&&Qy(t).call(t,c)){var r,n,i,o,a,s,u,d=null!==(r=null===(n=e.Metadata)||void 0===n?void 0:n.VideoIndex)&&void 0!==r?r:0,l=0;null!==(i=f._ctx.serverConfig)&&void 0!==i&&i.e2eFeedback&&(l=Math.max.apply(Math,Gg(o=iR($g(a=FS(null!==(s=null===(u=e.Metadata)||void 0===u?void 0:u.VideoKbpsHist)&&void 0!==s?s:{})).call(a,(function(e){return Number(e)})))).call(o,[0]))),h[d]={kbps:l}}})),p=iR(this._localStream.pubAttributes.videoDescriptions),d.encodings=$g(l=d.encodings).call(l,(function(e){if(e.rid){if(h[e.rid]){var t;e.active=!0;var r=null===(t=h[e.rid])||void 0===t?void 0:t.kbps;r&&(e.maxBitrate=1e3*OX(e.rid,r,p))}else e.active=!1;var n=Number(e.rid);s[n]=e.active}else{var i,o=null===(i=h[0])||void 0===i?void 0:i.kbps;o&&(e.maxBitrate=1e3*OX(void 0,o,p))}return e})),this.config.report("rtc_invoke_status",{sdk_api_name:"onPublishOnDemand",message:Xg(d.encodings),error_code:0,stream_id:c,elapse:0}),this._ctx.activeSimStreams=s),e.next=13,u.setParameters(d);case 13:this._publishOnDemandBusy=!1,e.next=18;break;case 16:if(null!==(o=this._localStream)&&void 0!==o&&o.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(null!=t&&t.length&&r){var n=t[0];this._ctx.streamRTT[n]={audio:r.audio_rtt,video:r.video_rtt}}}},{key:"_onRSCP",value:function(e,t){var r=this;!!dI(e).call(e,(function(e){var t,n,i;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:Qy(t).call(t,null===(n=r._localStream)||void 0===n||null===(i=n.stream)||void 0===i?void 0:i.id)}))&&(t?this._pubTransceiverReady=!0:this._onceTriggerBySignal=!0,t&&this._onceTriggerBySignal||(this._publishOnDemandItem=e),this._pubTransceiverReady&&this._onPublishOnDemand())}},{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(oH.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(oH.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){this.emit(oH.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:this.config.roomId,userId:e,streamIndex:t?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"setAudioEncodeMaxBitrate",value:(t=Ug(Dg().mark((function e(t,r){var n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(n=t===ch.STREAM_INDEX_MAIN?this.localStream:this.localScreenStream)||!n.pubAudio){e.next=7;break}if(null==(o=null===(i=n.audioTransceiver)||void 0===i?void 0:i.sender.getParameters())||!o.encodings.length){e.next=7;break}return o.encodings[0].maxBitrate=1e3*r,e.next=7,null===(a=n.audioTransceiver)||void 0===a?void 0:a.sender.setParameters(o);case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),O}(wU);wZ([IX],xZ.prototype,"publishScreen",1),wZ([IX],xZ.prototype,"updatePubScreenTrack",1),wZ([IX],xZ.prototype,"unpublishScreen",1),wZ([IX],xZ.prototype,"liveControlMessage",1),wZ([IX],xZ.prototype,"publicStreamControlMessage",1),wZ([IX],xZ.prototype,"updateUserAttributes",1),wZ([IX],xZ.prototype,"publish",1),wZ([IX],xZ.prototype,"updatePubTrack",1),wZ([IX],xZ.prototype,"unpublish",1),wZ([IX],xZ.prototype,"subscribe",1),wZ([IX],xZ.prototype,"updateSubVideoConfig",1),wZ([IX],xZ.prototype,"unsubscribe",1),wZ([IX],xZ.prototype,"startSubtitle",1),wZ([IX],xZ.prototype,"stopSubtitle",1),wZ([IX],xZ.prototype,"startForwardStream2Rooms",1),wZ([IX],xZ.prototype,"updateForwardStream2Rooms",1),wZ([IX],xZ.prototype,"stopForwardStream2Rooms",1),wZ([IX],xZ.prototype,"pauseForwardStream2AllRooms",1),wZ([IX],xZ.prototype,"resumeForwardStream2AllRooms",1),wZ([IX],xZ.prototype,"updateMediaParams",1),wZ([IX],xZ.prototype,"updateRemoteUserPriority",1),wZ([IX],xZ.prototype,"updateToken",1),wZ([IX],xZ.prototype,"sendUserMessage",1),wZ([IX],xZ.prototype,"sendRoomMessage",1),wZ([IX],xZ.prototype,"maybeFillBackFrame2Stream",1);var OZ=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&&wT(r.style,t.style),t.attributes&&VS(t.attributes).forEach((function(e){var t=Ey(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},PZ=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],NZ={playsinline:"","webkit-playsinline":""},MZ={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},DZ=function(e){jA(n,e);var t,r=iw(n);function n(e,t,i){var o;Gh(this,n),Jl(dA(o=r.call(this)),"_containerDom",void 0),Jl(dA(o),"_videoDom",void 0),Jl(dA(o),"userId",void 0),Jl(dA(o),"renderMode",void 0),Jl(dA(o),"mirrorType",ph.MIRROR_TYPE_NONE),Jl(dA(o),"isScreen",void 0),Jl(dA(o),"isLocal",void 0),Jl(dA(o),"played",!1),Jl(dA(o),"_needLoad",!1),Jl(dA(o),"_emitPlayFailed",!1),Jl(dA(o),"_videoContainer",void 0),Jl(dA(o),"_safari15VideoTimer",void 0),Jl(dA(o),"_monitor",void 0),Jl(dA(o),"logger",void 0),Jl(dA(o),"_onLocalTrackMute",void 0),Jl(dA(o),"_onInterruptionEnd",void 0),Jl(dA(o),"_needResume",!1),Jl(dA(o),"_rotate",0),Jl(dA(o),"_rotateDom",void 0),Jl(dA(o),"_resizeObserver",void 0),Jl(dA(o),"_hasManuallyPaused",!1),Jl(dA(o),"isIntersecting",void 0),Jl(dA(o),"intersectionObserver",void 0),Jl(dA(o),"emitVideoEvent",(function(e){var t,r,n={type:"video",rawEvent:e,readyState:(null===(t=o._videoDom)||void 0===t?void 0:t.readyState)||0,userId:o.userId,eventName:e.type,currentTime:(null===(r=o._videoDom)||void 0===r?void 0:r.currentTime)||0,isScreen:o.isScreen};switch(o.emit("playback_event",n),e.type){case"canplay":o.refreshRenderSize("the video started playing."),o._internalPlay();break;case"loadeddata":o._internalPlay();break;case"playing":o.logger.info("VideoPlayerPlaying","[userId-".concat(o.userId,"] video element playing"));break;case"pause":o.logger.info("VideoPlayerPause","[userId-".concat(o.userId,"] video element pause")),o._needResume&&(o.logger.info("VideoPlayerPause","[userId-".concat(o.userId,"] video element resume")),o._internalPlay(),o._needResume=!1)}})),Jl(dA(o),"_internalPlay",(function(){var e,t;if($M(o.engineId,"video _internalPlay",{paused:null===(e=o._videoDom)||void 0===e?void 0:e.paused,hasManuallyPaused:o._hasManuallyPaused}),!o._hasManuallyPaused&&null!==(t=o._videoDom)&&void 0!==t&&t.paused){var r=o._videoDom.play();null!=r&&r.then&&r.then((function(){var e;o.isLocal&&sL&&!o._needLoad&&(null===(e=o._videoDom)||void 0===e||e.load(),o._needLoad=!0)})).catch((function(e){var t,r,n,i,a,s;o._emitPlayFailed||("AbortError"!==e.name?(o._emitPlayFailed=!0,null===(t=o._monitor)||void 0===t||t.report("rtc_error",{message:Gg(r="video autoplay failed, userId: ".concat(o.userId,", ")).call(r,e.name),error_code:EH.AUTOPLAY_FAILED}),o.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(n=o._videoDom)||void 0===n?void 0:n.readyState)||0,userId:o.userId,eventName:"autoplay-error",currentTime:(null===(i=o._videoDom)||void 0===i?void 0:i.currentTime)||0,isScreen:o.isScreen})):null===(a=o._monitor)||void 0===a||a.report("rtc_error",{message:Gg(s="video autoplay failed, userId: ".concat(o.userId,", ")).call(s,e.name),error_code:EH.AUTOPLAY_FAILED}))}))}})),o.engineId=e,o.playerId=t;var a=i.renderDom;o._monitor=YM(e),o.logger=new fD("Player",0,e);var s=i.userId,c=i.isScreen?sh.RENDER_MODE_FIT:sh.RENDER_MODE_HIDDEN;o.renderMode=void 0!==i.renderMode?i.renderMode:c,o._rotate=Number(i.rotation||0);var u="string"==typeof a?document.getElementById(a):a;if(!u)throw new mC(hC.CANT_FIND_DOM,"can't find dom");return o._videoContainer=document.createElement("div"),o._videoContainer.style.width="100%",o._videoContainer.style.height="100%",o._videoContainer.style.position="relative",o._videoContainer.style.overflow="hidden",o._containerDom=u,o.userId=s,o.isLocal=!!i.isLocal,o.isScreen=!!i.isScreen,o._initVideo(),!o.isLocal||15!==(null==wL?void 0:wL[0])&&15!==IL||(o._safari15VideoTimer=window.setTimeout((function(){try{o._videoContainer.style.display="block",setTimeout((function(){o._videoContainer.style.display="flex"}),500)}catch(B0){}}),1e3)),o}return jh(n,[{key:"_initVideo",value:function(){var e,t,r=this;this._videoDom||(this._videoDom=OZ("video",{style:{width:"100%",height:"100%"},attributes:MZ}),this._videoDom.id=Gg(t="".concat(this.userId,"_")).call(t,RD()),this.setRenderMode(this.renderMode),this.mirror(this.mirrorType===ph.MIRROR_TYPE_RENDER));this._containerDom.appendChild(this._videoContainer),kI(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._initInterSectionObserver(),this._initListeners(),this._onLocalTrackMute=function(){r._needResume=!0},this._onInterruptionEnd=function(){r.logger.warn("resume player after iOS interruption"),r._internalPlay()},hG.on(dG.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),hG.on(dG.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),hG.on(dG.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd)}},{key:"_initInterSectionObserver",value:function(){var e=this;!this.intersectionObserver&&"undefined"!=typeof IntersectionObserver&&this._videoDom&&(this.intersectionObserver=new IntersectionObserver((function(t){t[0]&&(e.isIntersecting=t[0].isIntersecting)}),{}),this.intersectionObserver.observe(this._videoDom))}},{key:"_closeIntersectionObserver",value:function(){this.intersectionObserver&&this._videoDom&&(this.intersectionObserver.disconnect(),this.intersectionObserver.unobserve(this._videoDom),delete this.intersectionObserver)}},{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===sh.RENDER_MODE_FILL)s=i,c=n;else{var u=this.renderMode===sh.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&&PZ.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&&PZ.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===sh.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this.renderMode===sh.RENDER_MODE_FILL?this._videoDom.style.objectFit="fill":this._videoDom.style.objectFit="cover")}},{key:"playVideo",value:(t=Ug(Dg().mark((function e(t){var r,n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=this._videoDom,this.logger.info("playVideo","play video track: ".concat(this.userId)),!(i&&i.srcObject instanceof MediaStream&&i.srcObject.getTrackById(null===(r=t.preprocessingTrack)||void 0===r?void 0:r.id))){e.next=5;break}try{$M(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(B0){}return e.abrupt("return");case 5:i||(this._initVideo(),i=this._videoDom),this.logger.info("playVideo","play video by dom: ".concat(null===(n=i)||void 0===n?void 0:n.id)),(o=new MediaStream).addTrack(t.preprocessingTrack),i.srcObject=o,i&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),i&&!this._videoContainer.contains(i)&&this._videoContainer.appendChild(i),setTimeout((function(){return a._internalPlay()})),YL.VIDEO_STALL&&this.emit(AG.START_STALL_OBSERVE),this.played=!0;case 15:case"end":return e.stop()}}),e,this)}))),function(e){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 mC(hC.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||vL?this._videoDom.play():Hg.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 mC(hC.INVALID_PARAMS,"Player not found");return this._videoDom.pause()}}},{key:"mirror",value:function(e){var t;this.logger.info("mirror",Gg(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?ph.MIRROR_TYPE_RENDER:ph.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",Gg(e="stop video track: ".concat(this.userId," ")).call(e,this.playerId.toString())),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,YL.VIDEO_STALL&&this.emit(AG.STOP_STALL_OBSERVE),this._closeIntersectionObserver()}},{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(),FA(VA(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),hG.off(dG.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),hG.off(dG.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),hG.off(dG.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}(IU.EventEmitter),LZ=function(e){jA(i,e);var t,r,n=iw(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(Gh(this,i),Jl(dA(r=n.call(this)),"_containerDom",void 0),Jl(dA(r),"_audioDom",void 0),Jl(dA(r),"_fakeAudioDom",void 0),Jl(dA(r),"userId",void 0),Jl(dA(r),"muted",!1),Jl(dA(r),"_emitPlayFailed",!1),Jl(dA(r),"played",!1),Jl(dA(r),"isScreen",void 0),Jl(dA(r),"_wechatTimer",void 0),Jl(dA(r),"_edgeTimer",void 0),Jl(dA(r),"_monitor",void 0),Jl(dA(r),"logger",void 0),Jl(dA(r),"_pasued",!0),Jl(dA(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());yL&&vL&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),mL&&lL&&"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)})),Jl(dA(r),"_internalPlay",(function(){var e,t;if($M(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=vG.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:EH.AUTOPLAY_FAILED}));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:Gg(n=Gg(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:EH.AUTOPLAY_FAILED})})).finally((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(yL&&mL&&(i=i.then((function(){return new Hg((function(e){setTimeout(Ug(Dg().mark((function t(){var n;return Dg().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(){$M(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:Gg(n=Gg(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:EH.AUTOPLAY_FAILED})})))}catch(l){var c,u,d;r._autoPlayError(l),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:Gg(u=Gg(d="audio autoplay failed, userId: ".concat(r.userId,": ")).call(d,l.message," ")).call(u,l.name),error_code:EH.AUTOPLAY_FAILED})}})),r.engineId=e,a){var u=document.getElementById(a);if(!u)throw new mC(hC.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=YM(e),r.logger=new fD("Player",0,e),r._initAudio(),r}return jh(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=OZ("audio",{style:{display:"none"},attributes:NZ}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Gg(e="".concat(this.userId,"_")).call(e,RD()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&PZ.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&&(PZ.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=Ug(Dg().mark((function e(t){var r,n,i,o,a,s=this;return Dg().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 SG?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.originTrack]),a.addTrack(t.preprocessingTrack)):a.addTrack(t.preprocessingTrack),yL&&mL&&(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 mC(hC.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 mC(hC.INVALID_PARAMS,"Player not found");if(!this.played)return Hg.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=vG.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?Hg.all(r):Hg.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,OG.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=$g(r).call(r,(function(e){return e.deviceId})),Qy(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(),FA(VA(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom),this._edgeTimer&&clearTimeout(this._edgeTimer)}}]),i}(IU.EventEmitter),UZ=function(){var e=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(Jj.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)}}(),VZ=pT,FZ=KI,BZ=function(e,t,r,n){for(var i,o=n>1?void 0:n?FZ(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&&VZ(t,r,o),o},jZ=function(){function e(t,r){Gh(this,e),Jl(this,"_sharedAudioContext",new AudioContext),Jl(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),Jl(this,"_localGainNode",this._sharedAudioContext.createGain()),Jl(this,"_bufferGainNode",this._sharedAudioContext.createGain()),Jl(this,"_audioBufferSource",void 0),Jl(this,"_localSource",void 0),Jl(this,"_context",void 0),Jl(this,"_failedAudioList",[]),Jl(this,"_startingIds",new hT),Jl(this,"_revokeURLs",new vQ),Jl(this,"mixingMap",new hT),Jl(this,"resourcesCache",new hT),Jl(this,"volumeConfig",new hT),Jl(this,"cachedBuffer",[]),Jl(this,"id","AudioMixingManager"),this.engineId=r,this._context=t,this._localGainNode.gain.value=1}var t,r,n;return jh(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=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,f,_,v,m=this;return Dg().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,aU(o=n.type,"mixingType",yX(Lh)),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:Uh.AUDIO_MIXING_STATE_STOPPED,error:pC.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:Uh.AUDIO_MIXING_STATE_FAILED,error:pC.AUDIO_MIXING_ERROR_START_FAILED}),new mC(hC.LOAD_RESOURCES_FAILED,e.statusText)}));case 21:return l=e.sent,HT(r).call(r,"mp3")?h={type:"audio/mpeg"}:HT(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=25,UZ(l,h);case 25:if(e.sent){e.next=29;break}throw this._context.emitMessage({mixId:t,state:Uh.AUDIO_MIXING_STATE_FAILED,error:pC.AUDIO_MIXING_ERROR_START_FAILED}),new mC(hC.LOAD_RESOURCES_FAILED,"invalid audio resource");case 29:(u=new Audio).crossOrigin="anonymous",u.src=Jj.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:Uh.AUDIO_MIXING_STATE_FINISHED,error:pC.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:ch.STREAM_INDEX_MAIN,mediaType:uh.AUDIO});case 43:if(this._startingIds.delete(t),f=this._sharedAudioContext.createMediaElementSource(u),_=this._sharedAudioContext.createGain(),v=this.volumeConfig.get(t),_.gain.value=v?v/100:1,f.connect(_).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:f,audioNode:u,gainNode:_,type:"file"}),o===Lh.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:Uh.AUDIO_MIXING_STATE_PLAYING,error:pC.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:Uh.AUDIO_MIXING_STATE_STOPPED,error:pC.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Uh.AUDIO_MIXING_STATE_PAUSED,error:pC.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:Uh.AUDIO_MIXING_STATE_PLAYING,error:pC.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=Ug(Dg().mark((function e(t,r){var n,i,o=this;return Dg().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 mC(hC.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Uh.AUDIO_MIXING_STATE_FAILED,error:pC.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof mC)throw e;throw new mC(hC.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,HT(r).call(r,"mp3")?i={type:"audio/mpeg"}:HT(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,UZ(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Uh.AUDIO_MIXING_STATE_FAILED,error:pC.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new mC(hC.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Uh.AUDIO_MIXING_STATE_PRELOADED,error:pC.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=Jj.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new Hg((function(e){var r=Jj.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)),Jj.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){aU(e,"type",yX(Lh));var t=this._context.getLocalAudioTrack();if(t){var r=t.preprocessingTrack;if(r&&this.mixMediaStream(new MediaStream([r])),e===Lh.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:Uh.AUDIO_MIXING_STATE_PCM_ENABLED,error:pC.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:Uh.AUDIO_MIXING_STATE_PCM_DISABLED,error:pC.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=Ug(Dg().mark((function e(){var t,r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=by(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:ch.STREAM_INDEX_MAIN,mediaType:uh.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 hT,this._revokeURLs.forEach((function(e){Jj.revokeObjectURL(e)}))}}]),e}();BZ([JM("id","filePath","options")],jZ.prototype,"startAudioMixing",1),BZ([JM("id")],jZ.prototype,"stopAudioMixing",1),BZ([JM("id")],jZ.prototype,"pauseAudioMixing",1),BZ([JM("id")],jZ.prototype,"resumeAudioMixing",1),BZ([JM("id")],jZ.prototype,"preloadAudioMixing",1),BZ([JM("id")],jZ.prototype,"unloadAudioMixing",1),BZ([JM("id")],jZ.prototype,"getAudioMixingVolume",1),BZ([JM("id","volume")],jZ.prototype,"setAudioMixingVolume",1),BZ([JM("id")],jZ.prototype,"getAudioMixingDuration",1),BZ([JM("id")],jZ.prototype,"getAudioMixingCurrentPosition",1),BZ([JM("id","position")],jZ.prototype,"setAudioMixingPosition",1),BZ([JM("type")],jZ.prototype,"enableAudioMixingBuffer",1),BZ([JM()],jZ.prototype,"disableAudioMixingBuffer",1),BZ([JM("buffer")],jZ.prototype,"pushAudioMixingBuffer",1);var GZ=function(e){jA(c,e);var t,r,n,i,o,a,s=iw(c);function c(e){var t;return Gh(this,c),Jl(dA(t=s.call(this)),"_loginSessionId",null),Jl(dA(t),"_userId",null),Jl(dA(t),"_token",null),Jl(dA(t),"_loginResolveCallback",void 0),Jl(dA(t),"_loginRejectCallback",void 0),Jl(dA(t),"_waitLoginToken",!1),Jl(dA(t),"_serverParamsCache",void 0),Jl(dA(t),"id",void 0),Jl(dA(t),"logger",void 0),Jl(dA(t),"_clearListeners",void 0),t._ctx=e,t.id=e.id,t.logger=new fD("RTSClient",1,e.id),t}return jh(c,[{key:"login",value:function(e,t){var r=this;return new Hg((function(n,i){var o;if(r.logger.info("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new mC(hC.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new mC(hC.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=YM(r.id))||void 0===o||o.set({rtm_user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._ctx.signalingManager.connect().then((function(){r._addSignalEventHandler(),r._login()}))}))}},{key:"logout",value:(a=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mC(hC.NOT_LOGIN,"login first");case 2:return e.next=4,this._ctx.signalingManager.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId},{functionType:NQ.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=Ug(Dg().mark((function e(t){var r=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new Hg((function(e,t){r._waitLoginToken?(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=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mC(hC.NOT_LOGIN,"login first");case 2:return e.next=4,this._ctx.signalingManager.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,peerUserId:t},{functionType:NQ.C2RTM});case 4:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(n=Ug(Dg().mark((function e(t,r){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mC(hC.NOT_LOGIN,"login first");case 2:return e.abrupt("return",this._ctx.signalingManager.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:t,room:"",msg:r}));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"setServerParams",value:(r=Ug(Dg().mark((function e(t,r){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,oU(t,"signature"),oU(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new mC(hC.NOT_LOGIN,"login first");case 5:return e.next=7,this._ctx.signalingManager.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,signature:t,url:r},{functionType:NQ.C2RTM}).catch((function(e){throw new mC(hC.UNEXPECTED_ERROR,e.msg)}));case 7:VM.setServerUrl(this.id,r),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=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mC(hC.NOT_LOGIN,"login first");case 2:return e.abrupt("return",this._ctx.signalingManager.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:"",room:"",type:wQ.BUSINESS_SERVER,msg:t}));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){this.logger.info("destroy","invoke."),FA(VA(c.prototype),"removeAllListeners",this).call(this),this._loginResolveCallback&&this._loginRejectCallback&&(this._loginRejectCallback(new mC(hC.LOGIN_FAILED,"logout")),delete this._loginResolveCallback,delete this._loginRejectCallback),this._clearState(),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=RD();this._ctx.signalingManager.sendSignaling("login",{Token:CD.token2auth(this._ctx.appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:YL.VERSION,deviceId:BL.getDeviceId(),appId:this._ctx.appId,userId:this._userId}},{functionType:NQ.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,VM.setRtsSessionId(e.id,t),e._waitLoginToken=!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._waitLoginToken=!1,o>=700&&o<800?708===o?(r=hC.INVALID_PARAMS,n="Invalid userId"):(r=hC.INVALID_TOKEN,n="Invalid token",e._waitLoginToken=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=hC.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new mC(r,a||n))})).finally((function(){delete e._loginResolveCallback,delete e._loginRejectCallback}))}}},{key:"_addSignalEventHandler",value:function(){var e=this,t=function(t){t.state===lh.CONNECTION_STATE_RECONNECTED&&e._login()},r=function(){return e._clearState()},n=function(t){e.emit("onUserMessageReceivedOutsideRoom",{userId:t.from,message:t.msg})},i=function(t){e.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:t.from,message:t.msg})},o=function(t){t.clientId!==e._userId||t.roomId||(e.emit("onUserDisconnection"),e._clearState())};this._ctx.signalingManager.on(MU.ON_CONNECTION_STATE_CHANGE,t),this._ctx.signalingManager.on(MU.ON_RECONNECT_FAILED,r),this._ctx.signalingManager.on(PU.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,n),this._ctx.signalingManager.on(PU.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,i),this._ctx.signalingManager.on(PU.USER_DISCONNECTION,o),this._clearListeners=function(){e._ctx.signalingManager.off(MU.ON_CONNECTION_STATE_CHANGE,t),e._ctx.signalingManager.off(MU.ON_RECONNECT_FAILED,r),e._ctx.signalingManager.off(PU.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,n),e._ctx.signalingManager.off(PU.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,i),e._ctx.signalingManager.off(PU.USER_DISCONNECTION,o)}}},{key:"_clearState",value:function(){var e;null===(e=this._clearListeners)||void 0===e||e.call(this),this._userId=null,this._token=null,this._loginSessionId=null,VM.setRtsSessionId(this.id,"")}}]),c}(IU.EventEmitter),HZ=pT,zZ=KI,KZ=function(e,t,r,n){for(var i,o=n>1?void 0:n?zZ(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&HZ(t,r,o),o},WZ=function(e){jA(a,e);var t,r,n,i,o=iw(a);function a(e){var t;return Gh(this,a),Jl(dA(t=o.call(this)),"_remoteStreams",new hT),Jl(dA(t),"_logger",void 0),Jl(dA(t),"_monitor",void 0),Jl(dA(t),"_ontrackCallbackMap",new hT),t._ctx=e,t._monitor=YM(e.id),t._logger=new fD("PublicStreamManager",1,e.id),t}return jh(a,[{key:"getRemoteStream",value:function(e){return this._remoteStreams.get(e)}},{key:"getRemoteStreams",value:function(){return this._remoteStreams}},{key:"startPlayPublicStream",value:(i=Ug(Dg().mark((function e(t){var r,n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.getRemoteStream(t)){e.next=2;break}throw new mC(hC.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new iH(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=BD(e),i=0;i<t.seiCount;i++)n.safeEmit("onSEIMessageReceived",{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._ctx.signalingManager.connect();case 6:return e.next=8,this._subscribePublicStream(r);case 8:return this._remoteStreams.set(t,r),e.abrupt("return",r);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(n=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getRemoteStream(t)){e.next=3;break}return e.abrupt("return");case 3:return this._remoteStreams.delete(t),e.next=6,this._ctx.signalingManager.connect();case 6:return e.abrupt("return",this._unsubscribePublicStream(r));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"destroy",value:function(){this._remoteStreams.forEach((function(e){e.clean()})),this._remoteStreams=new hT,this.removeAllListeners(),this._ontrackCallbackMap.clear()}},{key:"_subscribePublicStream",value:(r=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,f,_,v,m=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._ctx.handler)||void 0===r?void 0:r.subscribe(t,{multiChatMode:!1});case 2:if(a=e.sent){e.next=5;break}throw new mC(hC.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return s=AD(),c=a.audioMid,u=a.videoMid,e.t0=this._ctx.appId,e.t1=t.streamId,e.t2=c,e.t3=u,e.t4={sdp:a.partialSdp,semantics:a.semantics,type:a.type},e.next=15,XU();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=YL.VERSION,e.t8=BL.getDeviceId(),e.t9=this._ctx.appId,e.t10=this._ctx.businessId,e.t11=this._ctx.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}},d={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,this._ctx.signalingManager.sendSignaling("startPullStream",d);case 27:return l=e.sent,(h=[]).push(new Hg((function(e,r){var n=setTimeout((function(){return r(new mC(hC.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),kX);t.on("ontrack",(function r(i){"video"===i.mediaType&&(m._logger.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),h.push(new Hg((function(e,r){var n=setTimeout((function(){return r(new mC(hC.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),kX);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(m._logger.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p=function(e){t.ontrack(e)},null===(n=this._ctx.handler)||void 0===n||n.on("ontrack",p),this._ontrackCallbackMap.set(t,p),f=l.relayMessage,_=f.sequenceId,v=f.sdp,t.videoMid=u,t.audioMid=c,t.sequenceId=_,t.streamState=rH.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=43,null===(i=this._ctx.handler)||void 0===i?void 0:i.handleAck({action:WQ.subscribe,streamId:t.streamId,audioMid:c,videoMid:u,audioTransceiverInit:a.audioTransceiverInit,videoTransceiverInit:a.videoTransceiverInit,signalingAck:{sdp:v,sequenceId:_},stream:t});case 43:return e.next=45,Hg.all(h);case 45:null===(o=this._monitor)||void 0===o||o.report("rtc_subscribe_stat",{result:"success",start:s,message:"unknown",stream_user_id:t.userId}),t.startReport((function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,m.safeEmit("onRemoteStreamStats",e)}),this._ctx.handler);case 47:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_unsubscribePublicStream",value:(t=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return TX("_unsubscribePublicStream()",t,this._logger),n={appId:this._ctx.appId,streamId:t.streamId},e.prev=2,e.next=5,this._ctx.signalingManager.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=rH.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._ctx.handler)||void 0===r?void 0:r.handleAck({action:WQ.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),t.subMediaType=HL.NONE,this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return t.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t=this._ontrackCallbackMap.get(e);if(t){var r=e.vendorHandler||this._ctx.handler;null==r||r.off("ontrack",t),this._ontrackCallbackMap.delete(e)}}},{key:"handleReconnected",value:function(){var e,t=this,r=by(this._remoteStreams);try{for(r.s();!(e=r.n()).done;){var n=Ey(e.value,2),i=n[0],o=n[1];o.clean(),o.statsReport.unsubscribe(),this._remoteStreams.delete(i),this.startPlayPublicStream(i).then((function(e){t.safeEmit("onResubscribe",{stream:e})}))}}catch(j0){r.e(j0)}finally{r.f()}}}]),a}(wU);KZ([cZ],WZ.prototype,"_subscribePublicStream",1),KZ([cZ],WZ.prototype,"_unsubscribePublicStream",1);var XZ=new fD("AudioDeviceManager",1),YZ=function(e){jA(c,e);var t,r,n,i,o,a,s=iw(c);function c(e,t){var r;return Gh(this,c),Jl(dA(r=s.call(this)),"_audioLevelFetcher",void 0),Jl(dA(r),"_playbackDeviceTestTimer",void 0),Jl(dA(r),"_audioElement",void 0),Jl(dA(r),"_audioTrack",void 0),Jl(dA(r),"_mediaRecorder",void 0),Jl(dA(r),"_recoderTimer",void 0),Jl(dA(r),"_isAudioPlaybackDeviceTesting",!1),Jl(dA(r),"_isAudioDeviceRecordTesting",!1),Jl(dA(r),"_audioCaptureAndRecoderResolve",void 0),Jl(dA(r),"_onAutoplayFailed",void 0),Jl(dA(r),"_audioPlaybackDeviceId",void 0),r._ctx=e,r._extensionManager=t,r}return jh(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=Ug(Dg().mark((function e(t,r){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new mC(hC.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,XZ.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),XZ.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&&(XZ.info("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=Ug(Dg().mark((function e(t,r,n){var i,o=this,a=arguments;return Dg().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 mC(hC.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 3:if(!this._isAudioDeviceRecordTesting&&!this._isAudioPlaybackDeviceTesting){e.next=5;break}throw new mC(hC.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 5:return this._isAudioDeviceRecordTesting=!0,XZ.info("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){XZ.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(){XZ.info("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(XZ.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=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(XZ.info("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new mC(hC.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,OG.getAudioPlaybackDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new mC(hC.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(){XZ.info("destroy()","Invoke"),FA(VA(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=Ug(Dg().mark((function e(t,r){var n,i=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XZ.info("_playAudioFile()",Gg(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new Hg((function(e,n){var o=OZ("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new _G(o),o.onplaying=function(){o.onplaying=null,XZ.info("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=Ug(Dg().mark((function e(t){var r,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:XZ.error("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new mC(hC.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;XZ.warn("_playAudioFile()","autoplay error",e);var r=Gg(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return Hg.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new mC(hC.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&&(XZ.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&&(XZ.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&&(XZ.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=Ug(Dg().mark((function e(t,r){var n,i=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,FG(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r+.01),n=new MediaStream([this._audioTrack.preprocessingTrack]),XZ.info("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new Hg((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=dI(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),XZ.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=Ug(Dg().mark((function n(o){var a,c;return Dg().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return XZ.info("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(Jj.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 mC(hC.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.destroy(),delete this._audioTrack}},{key:"_setAudioCtxSinkId",value:(t=Ug(Dg().mark((function e(){var t,r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=vG.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),XZ.info("setSinkId","ctx.sinkId=".concat(t))}catch(o){XZ.error("setSinkId",Gg(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}(IU.EventEmitter),qZ=function(){return{url:"",video:{codec:wh.H264,width:640,height:360,fps:15,gop:2,kBitRate:JZ(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:Ah.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function JZ(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 QZ(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new mC(hC.INVALID_PARAMS,"Invalid rtmp address")}function ZZ(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new mC(hC.INVALID_PARAMS,"regions should not be empty.");var t,r=by(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new mC(hC.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if(pU(n.userId),"boolean"!=typeof n.isScreenStream)throw new mC(hC.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(j0){r.e(j0)}finally{r.f()}}function $Z(e,t){var r,n,i,o=function(e,r){var n=uS(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=uS(e).call(e,(function(e,t){return null==e?void 0:e[t]}),qZ());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!!dI(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 Qy(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return Qy(t=[Ah.LC,Ah.HEv1,Ah.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return Qy(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:JZ(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:$g(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&&Qy(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&Qy(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 e$,t$={getDefaultValue:qZ,checkStartParams:function(e){var t;QZ(e.url),ZZ(null===(t=e.layout)||void 0===t?void 0:t.regions)},checkUpdateParams:function(e){var t;e.url&&QZ(e.url),ZZ(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return $Z("started",e)},getUpdateParams:function(e){return $Z("layoutChanged",e)}},r$=Yp,n$=ei;wr({target:"Object",stat:!0},{fromEntries:function(e){var t={};return r$(e,(function(e,r){n$(t,e,r)}),{AS_ENTRIES:!0}),t}});var i$,o$=r(te.Object.fromEntries),a$=["ele","fakeEle"],s$=["orgTrack","mediaTrack","preprocessingTrack"],c$=["orgTrack","mediaTrack","preprocessingTrack"],u$=["currentTime","duration","ended","error","muted","networkState","paused","readyState","seekable","sinkId","src","volume"],d$=["currentTime","sampleRate","state","baseLatency","outputLatency","sinkId"],l$=["contentHint","enabled","id","kind","label","muted","readyState"],h$=["currentDirection","direction","mid","stopped"];function p$(e){return f$.apply(this,arguments)}function f$(){return(f$=Ug(Dg().mark((function e(t){var r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Date.now(),n=[],!t._ctx.handler||!t._ctx.handler._peerConnection){e.next=6;break}return e.next=5,t._ctx.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 _$(e){var t={};if(e instanceof MediaStream){t.id=e.id,t.active=e.active;var r=e.getTracks();t.tracks=$g(r).call(r,(function(e){return o$($g(l$).call(l$,(function(t){return[t,e[t]]})))}))}return t}function v$(e){return m$.apply(this,arguments)}function m$(){return(m$=Ug(Dg().mark((function e(t){var r,n,i,o,a;return Dg().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&&t._remoteVideoPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"video",isScreen:!1,isPublic:!1,ele:e?e._videoDom:void 0})})),t._remoteScreenPlayer&&(null===(i=t._remoteScreenPlayer)||void 0===i||i.forEach((function(e,t){n.push({userId:t,mediaType:"video",isScreen:!0,isPublic:!1,ele:e?e._videoDom:void 0})}))),t._remoteAudioPlayer&&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})})),t._localVideoTrack&&t._localVideoTrack.videoPlayers&&t._localVideoTrack.videoPlayers.forEach((function(e,t){n.push({playerId:t.toString(),userId:"__local__",mediaType:"video",isScreen:!1,isPublic:!1,ele:e._videoDom})})),t._localScreenTrack&&t._localScreenTrack.videoPlayers&&t._localScreenTrack.videoPlayers.forEach((function(e,t){n.push({playerId:t.toString(),userId:"__local__",mediaType:"video",isScreen:!0,isPublic:!1,ele:e._videoDom})})),t._room&&t._room._remoteStreams&&t._room._remoteStreams.forEach((function(e,t){e.forEach((function(e){if(e.audioTrack){var r=e.audioTrack._audioPlayer;n.push({userId:t,mediaType:"audio",isScreen:e.isScreen,isPublic:!1,ele:r?r._audioDom:void 0,fakeEle:r?r._fakeAudioDom:void 0})}e.videoTrack&&e.videoTrack.videoPlayers&&e.videoTrack.videoPlayers.forEach((function(r,i){n.push({playerId:i.toString(),userId:t,mediaType:"video",isScreen:e.isScreen,isPublic:!1,ele:r?r._videoDom:void 0})}))}))})),(o=t._publicStreamManager)||(o=t._outsideRoom),o&&o.remoteStreams&&o.remoteStreams.forEach((function(e,t){if(e.audioTrack){var r=e.audioTrack._audioPlayer;n.push({userId:t,mediaType:"audio",isScreen:!1,isPublic:!0,ele:r?r._audioDom:void 0,fakeEle:r?r._fakeAudioDom:void 0})}e.videoTrack&&e.videoTrack.videoPlayers&&e.videoTrack.videoPlayers.forEach((function(e,r){n.push({playerId:r.toString(),userId:t,mediaType:"video",isScreen:!1,isPublic:!0,ele:e?e._videoDom:void 0})}))})),t&&t._room&&t._room._virtualStreams&&t._room._virtualStreams.forEach((function(e,t){if(e.audioTrack){var r=e.audioTrack._audioPlayer;n.push({userId:"virtualStream-".concat(t),mediaType:"audio",isScreen:!1,isPublic:!1,isVirtual:!0,ele:r?r._audioDom:void 0,fakeEle:r?r._fakeAudioDom:void 0})}})),a=$g(n).call(n,(function(e){var t=e.ele,r=e.fakeEle,n=uA(e,a$),i=Zl({ele:Zl({srcObject:t?_$(t.srcObject):void 0},o$($g(u$).call(u$,(function(e){return[e,t[e]]}))))},n);return r&&(i.fakeEle=Zl({srcObject:_$(r.srcObject)},o$($g(u$).call(u$,(function(e){return[e,r[e]]}))))),i})),e.abrupt("return",{timestamp:r,elementStats:a});case 19:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function g$(e){var t,r=[],n=[];e&&e._room&&e._room._remoteStreams&&(n=tx(t=e._room._remoteStreams).call(t));var i,o=by(n);try{for(o.s();!(i=o.n()).done;){i.value.forEach((function(e){e.audioTrack&&r.push(e.audioTrack)}))}}catch(j0){o.e(j0)}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(jC(tx(c=d._audioFetchMap).call(c)).length)return jC(tx(u=d._audioFetchMap).call(u))[0]._ctx;if(d._ap&&d._ap._ac)return d._ap._ac}return null}function y$(e){return S$.apply(this,arguments)}function S$(){return(S$=Ug(Dg().mark((function e(t){var r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Date.now(),n=g$(t),i={},n){e.next=5;break}return e.abrupt("return",{timestamp:r,acState:void 0});case 5:return d$.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 b$(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&&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 E$(e,t){return k$.apply(this,arguments)}function k$(){return(k$=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,f;return Dg().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 Hg((function(e){setTimeout(e,i)}));case 17:return d.getByteTimeDomainData(l),e.next=20,new Hg((function(e){setTimeout(e,i)}));case 20:return h=0,l.forEach((function(e){return h=Math.max(h,Math.abs(e-o))})),f=(p=h/o*a)>s?p:0,u.disconnect(),d.disconnect(),e.abrupt("return",f);case 27:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function T$(e){return I$.apply(this,arguments)}function I$(){return I$=Ug(Dg().mark((function e(t){var r,n,i,o;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1e3,n=Date.now(),i$||(i$=new AudioContext),"suspended"!==i$.state){e.next=6;break}return e.next=6,new Hg((function(e){var r=setTimeout((function(){console.warn("[RTC_AMBULANCE] AudioContext resume failed, try to find one in RTCEngine"),(i$=g$(t))&&console.warn("[RTC_AMBULANCE] find AudioContext in RTCEngine success"),e()}),1e3);i$.resume().then((function(){clearTimeout(r),e()}),(function(){clearTimeout(r),i$=null,e()}))}));case 6:if(i$){e.next=9;break}return console.error("[RTC_AMBULANCE] get volume is not supported"),e.abrupt("return");case 9:return i=b$(t),o=[],e.next=13,Hg.all($g(r=wy(i).call(i,(function(e){return"audio"===e.mediaType}))).call(r,function(){var e=Ug(Dg().mark((function e(t){var r,n,i,a,s;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.orgTrack,n=t.mediaTrack,i=t.preprocessingTrack,a=uA(t,s$),s=Zl({},a),e.next=4,Hg.all([E$(r,i$).then((function(e){s.orgTrackVolume=e})),E$(n,i$).then((function(e){s.mediaTrackVolume=e})),E$(i,i$).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)}))),I$.apply(this,arguments)}function R$(e){return A$.apply(this,arguments)}function A$(){return(A$=Ug(Dg().mark((function e(t){var r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Date.now(),n=b$(t),i=$g(n).call(n,(function(e){var t=e.orgTrack,r=e.mediaTrack,n=e.preprocessingTrack,i=uA(e,c$);return Zl({orgTrack:t?o$($g(l$).call(l$,(function(e){return[e,t[e]]}))):void 0,mediaTrack:r?o$($g(l$).call(l$,(function(e){return[e,r[e]]}))):void 0,preprocessingTrack:n?o$($g(l$).call(l$,(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 w$(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 C$(e){return x$.apply(this,arguments)}function x$(){return(x$=Ug(Dg().mark((function e(t){var r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Date.now(),n=[],t._ctx._handler&&t._ctx._handler._peerConnection&&(n=t._ctx._handler._peerConnection.getTransceivers()),i=[],n.forEach((function(e){var t=Zl({sender:w$(e.sender),receiver:w$(e.receiver)},o$($g(h$).call(h$,(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 O$(e){return P$.apply(this,arguments)}function P$(){return(P$=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={stats:[],mediaElementStates:[],audioContextStates:[],volumes:[],trackStates:[],tranceiverStates:[]},n=[],e.next=4,new Hg((function(e){var i,o=0;i=setTimeout((function a(){n.push(p$(t).then((function(e){r.stats.push(e)})),v$(t).then((function(e){r.mediaElementStates.push(e)})),y$(t).then((function(e){r.audioContextStates.push(e)})),T$(t).then((function(e){r.volumes.push(e)})),R$(t).then((function(e){r.trackStates.push(e)})),C$(t).then((function(e){r.tranceiverStates.push(e)}))),++o>=10?Hg.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 N$=v,M$=uE,D$=zb.getWeakData,L$=Rf,U$=rr,V$=K,F$=ee,B$=Yp,j$=Ze,G$=ro.set,H$=ro.getterFor,z$=Vo.find,K$=Vo.findIndex,W$=N$([].splice),X$=0,Y$=function(e){return e.frozen||(e.frozen=new q$)},q$=function(){this.entries=[]},J$=function(e,t){return z$(e.entries,(function(e){return e[0]===t}))};q$.prototype={get:function(e){var t=J$(this,e);if(t)return t[1]},has:function(e){return!!J$(this,e)},set:function(e,t){var r=J$(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=K$(this.entries,(function(t){return t[0]===e}));return~t&&W$(this.entries,t,1),!!~t}},sE("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),{getConstructor:function(e,t,r,n){var i=e((function(e,i){L$(e,o),G$(e,{type:t,id:X$++,frozen:void 0}),V$(i)||B$(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=H$(t),s=function(e,t,r){var n=a(e),i=D$(U$(t),!0);return!0===i?Y$(n).set(t,r):i[n.id]=r,e};return M$(o,{delete:function(e){var t=a(this);if(!F$(e))return!1;var r=D$(e);return!0===r?Y$(t).delete(e):r&&j$(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!F$(e))return!1;var r=D$(e);return!0===r?Y$(t).has(e):r&&j$(r,t.id)}}),M$(o,r?{get:function(e){var t=a(this);if(F$(e)){var r=D$(e);return!0===r?Y$(t).get(e):r?r[t.id]:void 0}},set:function(e,t){return s(this,e,t)}}:{add:function(e){return s(this,e,!0)}}),i}});var Q$=te.WeakSet,Z$=Ae,$$=function(e){if("object"==typeof e&&"has"in e&&"add"in e&&"delete"in e)return e;throw TypeError(Z$(e)+" is not a weakset")},e0=RE,t0={WeakSet:ae("WeakSet"),add:e0("add",1),has:e0("has",1),remove:e0("delete",1)},r0=$$,n0=t0.add;wr({target:"WeakSet",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=r0(this),t=0,r=arguments.length;t<r;t++)n0(e,arguments[t]);return e}});var i0=$$,o0=t0.remove;wr({target:"WeakSet",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=i0(this),r=!0,n=0,i=arguments.length;n<i;n++)e=o0(t,arguments[n]),r=r&&e;return!!r}}),wr({target:"WeakSet",stat:!0,forced:!0},{from:XE}),wr({target:"WeakSet",stat:!0,forced:!0},{of:qE});var a0=r(Q$),s0=function(){function e(){Gh(this,e),Jl(this,"containers",new a0)}return jh(e,[{key:"getContainerById",value:function(e){return document.getElementById(e)}},{key:"registerContainer",value:function(e){var t;"string"==typeof e&&(e=null!==(t=this.getContainerById(e))&&void 0!==t?t:void 0);return!(!e||this.containers.has(e))&&(this.containers.add(e),!0)}},{key:"unregisterContainer",value:function(e){var t;"string"==typeof e&&(e=null!==(t=this.getContainerById(e))&&void 0!==t?t:void 0);return!!e&&(this.containers.delete(e),!0)}}]),e}(),c0=["videoStats","audioStats"],u0=pT,d0=KI,l0=function(e,t,r,n){for(var i,o=n>1?void 0:n?d0(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&&u0(t,r,o),o},h0=function(e){jA(Le,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,N,M,D,L,U,V,F,B,j,G,H,z,K,W,X,Y,q,J,Q,Z,$,ee,te,re,ne,ie,oe,ae,se,ce,ue,de,le,he,pe,fe,_e,ve,me,ge,ye,Se,be,Ee,ke,Te,Ie,Re,Ae,we,Ce,xe,Oe,Pe,Ne,Me,De=iw(Le);function Le(e,t,r){var n,i,o;return Gh(this,Le),Jl(dA(o=De.call(this)),"monitor",void 0),Jl(dA(o),"logger",void 0),Jl(dA(o),"_room",void 0),Jl(dA(o),"_publicStreamManager",void 0),Jl(dA(o),"_appId",void 0),Jl(dA(o),"_localVideoTrack",void 0),Jl(dA(o),"_localAudioTrack",void 0),Jl(dA(o),"_localImgVideoTrack",void 0),Jl(dA(o),"_localImgScreenTrack",void 0),Jl(dA(o),"_localScreenVideoTrack",void 0),Jl(dA(o),"_localScreenAudioTrack",void 0),Jl(dA(o),"_tempMixingAudioTrack",void 0),Jl(dA(o),"_localAudioVolume",100),Jl(dA(o),"_localScreenAudioVolume",100),Jl(dA(o),"_remoteAudioVolume",new hT),Jl(dA(o),"_remoteScreenAudioVolume",new hT),Jl(dA(o),"_publicAudioVolume",new hT),Jl(dA(o),"_localVideoPlayerConfig",(Jl(n={},ch.STREAM_INDEX_MAIN,new hT),Jl(n,ch.STREAM_INDEX_SCREEN,new hT),n)),Jl(dA(o),"_remoteVideoPlayerConfig",(Jl(i={},ch.STREAM_INDEX_MAIN,new hT),Jl(i,ch.STREAM_INDEX_SCREEN,new hT),i)),Jl(dA(o),"_publicVideoPlayerConfig",new hT),Jl(dA(o),"_publicStreamIds",new hT),Jl(dA(o),"_videoStreamConstraints",Zl({},eU)),Jl(dA(o),"_audioStreamConstraints",{}),Jl(dA(o),"_enableSimulcast",!1),Jl(dA(o),"_videoStreamEncodeConfig",[Zl({},eU)]),Jl(dA(o),"_screenStreamEncodeConfig",[Zl({},tU)]),Jl(dA(o),"_dummyMainImage",void 0),Jl(dA(o),"_dummyScreenImage",void 0),Jl(dA(o),"_trackSourceType",void 0),Jl(dA(o),"_liveTranscodeConfig",void 0),Jl(dA(o),"_startCloudProxyTimestamp",void 0),Jl(dA(o),"_localVideoDeviceId",void 0),Jl(dA(o),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeAudioStreamIds:{},resumeVideoStreamIds:{}}),Jl(dA(o),"_audioVolumeIndicationTimer",void 0),Jl(dA(o),"_dummyMainTimer",void 0),Jl(dA(o),"_dummyScreenTimer",void 0),Jl(dA(o),"_audioPropertiesReportTimer",null),Jl(dA(o),"_mirrorType",ph.MIRROR_TYPE_RENDER),Jl(dA(o),"_audioMixingManager",void 0),Jl(dA(o),"_pubLock",void 0),Jl(dA(o),"_subLocks",void 0),Jl(dA(o),"_audioCaptureLock",void 0),Jl(dA(o),"_videoCaptureLock",void 0),Jl(dA(o),"_screenCaptureLock",void 0),Jl(dA(o),"_subScreenLocks",void 0),Jl(dA(o),"_rtmClient",void 0),Jl(dA(o),"_messageStatisticsObserver",void 0),Jl(dA(o),"_waitForNewToken",!1),Jl(dA(o),"_originIceConfigRequestUrls",void 0),Jl(dA(o),"_originConfigServerUrls",void 0),Jl(dA(o),"_originLogServerUrl",void 0),Jl(dA(o),"_extensionManager",void 0),Jl(dA(o),"_audioDeviceManager",void 0),Jl(dA(o),"_remoteVideoConfig",new hT),Jl(dA(o),"_config",void 0),Jl(dA(o),"_needClosePreTrack",!1),Jl(dA(o),"_containerCollisionDetector",new s0),Jl(dA(o),"_ctx",void 0),Jl(dA(o),"_updateMixAudioTrack",function(){var e=Ug(Dg().mark((function e(t){var r,n,i=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=i.length>1&&void 0!==i[1]?i[1]:Lh.PLAYOUT_AND_PUBLISH,o.logger.info("_updateMixAudioTrack()"),o._localAudioTrack){e.next=5;break}return t&&(o._tempMixingAudioTrack={track:t,type:n}),e.abrupt("return");case 5:if(t?(o._localAudioTrack.mixType=n,o._localAudioTrack.mixedAudioTrack=t):(delete o._localAudioTrack.mixType,delete o._localAudioTrack.mixedAudioTrack),null===(r=o._room)||void 0===r||!r.hasPublished){e.next=9;break}return e.next=9,o._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),Jl(dA(o),"_onAudioMixingMessage",(function(e){o.safeEmit(Fh.onAudioMixingStateChanged,e)})),Jl(dA(o),"_onAudioMixingAutoplayFailed",(function(e){o.safeEmit(Fh.onAutoplayFailed,e)})),o.id=t,o._appId=e,o.monitor=YM(t),o._ctx=new sZ(t,e,r),o._pubLock=new iZ("pubLock"),o._subLocks=new hT,o._subScreenLocks=new hT,o._audioCaptureLock=new iZ("audioCap"),o._videoCaptureLock=new iZ("videoCap"),o._screenCaptureLock=new iZ("screenCap"),o._addDeviceEventHandler(),o._extensionManager=new cG(t),o._audioDeviceManager=new YZ(o._ctx,o._extensionManager),o._audioMixingManager=new jZ({getLocalAudioTrack:function(){return o._localAudioTrack},updateLocalAudioTrack:o._updateMixAudioTrack,emitMessage:o._onAudioMixingMessage,onAutoPlayFailed:o._onAudioMixingAutoplayFailed},t),o._addSignalingEventHandler(),o._publicStreamManager=new WZ(o._ctx),o._addPublicStreamEventHandler(),window.__rtc_engine__=dA(o),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=dA(o),o._trackSourceType={video:$l.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:$l.VIDEO_SOURCE_TYPE_INTERNAL,audio:eh.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:eh.AUDIO_SOURCE_TYPE_INTERNAL},o._config=r,o._rtmClient=new GZ(o._ctx),o._handleRTMClient(o._rtmClient),o._handleAudioDeviceManager(),o._messageStatisticsObserver=new FM(t),o.logger=new fD("Engine",0,t),VM.createRTSMsgReportor(o.id),o._getServerConfig(),o.monitor.reportLongString("NativeDetector",Xg(BS)),o}return jh(Le,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(Me=Ug(Dg().mark((function e(t){var r,n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateToken()","token: %s",t),oU(t,"token"),!this._room||!this._waitForNewToken){e.next=8;break}return this._waitForNewToken=!1,this._room.config.token=t,e.next=7,this._join(this._room);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new mC(hC.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,this._room.updateToken(t);case 12:return r=[],this._room.config.tokenPublishPrivilegeExpired&&this._room.config.isAutoPublish&&this._ctx.visibility&&r.push(this._updatePublish({mediaType:uh.AUDIO_AND_VIDEO})),this._room.config.tokenSubscribePrivilegeExpired&&(n=this._room.config,i=n.isAutoSubscribeAudio,o=n.isAutoSubscribeVideo,(a=(i?uh.AUDIO:0)|(o?uh.VIDEO:0))&&r.push(this._triedResumeAllRemoteStreams(a,!0))),e.next=17,Hg.allSettled(r);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return Me.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(Ne=Ug(Dg().mark((function e(t){var r,n,i,o,a,s=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setVideoCaptureDevice()","deviceId: %s",t),oU(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:if(!vL||!yL){e.next=9;break}if(this._localVideoTrack.originTrack.getSettings().deviceId!==t){e.next=9;break}return e.abrupt("return");case 9:return n=pK({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete n.deviceId,n.facingMode=t):!hL||gL?n.deviceId={exact:t}:delete n.deviceId,yL&&aL&&OL>=85&&OL<=91&&(null===(i=this.localVideoTrack)||void 0===i||i.removePlayerTrack()),this._needClosePreTrack=this._needClosePreTrack||uV,this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.destroy(),delete this._localVideoTrack),this.logger.info("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=17,UG(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.destroy(),delete s._localVideoTrack,UG(n,s._extensionManager).then((function(e){return s._needClosePreTrack=!0,e})).catch(Ug(Dg().mark((function t(){var r;return Dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.logger.error("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,UG(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.destroy()),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 Ne.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(Pe=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setAudioCaptureDevice()","deviceId: %s",t),oU(t,"deviceId"),this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return this._localAudioTrack.destroy(),this._removeLocalTrackEvents(this._localAudioTrack),e.next=9,FG(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 Pe.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){OG.on(Fh.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),OG.on(Fh.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addSignalingEventHandler",value:function(){var e=this,t=this._ctx.signalingManager;t.on(MU.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),t.on(MU.ON_RECONNECT_FAILED,(function(){e.safeEmit(Fh.onError,{errorCode:hC.RECONNECT_FAILED})})),t.on(MU.CONNECT_WITH_TCP,(function(){e.safeEmit(Fh.onIceConnectWithTcp)}))}},{key:"_addPublicStreamEventHandler",value:function(){var e=this;this._publicStreamManager.on("onResubscribe",(function(e){var t=e.stream;t&&(t.audioTrack&&t.audioTrack.play(),t.videoTrack&&t.videoTrack.play(RG))})),this._publicStreamManager.on("onRemoteStreamStats",(function(t){e.safeEmit(Fh.onPublicStreamStats,t)})),this._publicStreamManager.on("onSEIMessageReceived",(function(t){e.safeEmit(Fh.onPublicStreamSEIMessageReceived,t)}))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,N,M,D,L,U,V,F,B,j=this;null===(e=this._room)||void 0===e||e.on(PU.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(PU.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(PU.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(oH.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(oH.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(oH.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(PU.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(PU.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(PU.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(PU.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(PU.ON_TOKEN_PUBLISH_PRIVILEGE_WILL_EXPIRE,this._onUserTokenPublishPrivilegeWillExpire.bind(this)),null===(l=this._room)||void 0===l||l.on(PU.ON_TOKEN_PUBLISH_PRIVILEGE_DID_EXPIRED,this._onUserTokenPublishPrivilegeDidExpired.bind(this)),null===(h=this._room)||void 0===h||h.on(PU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_WILL_EXPIRE,this._onUserTokenSubscribePrivilegeWillExpire.bind(this)),null===(p=this._room)||void 0===p||p.on(PU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_DID_EXPIRED,this._onUserTokenSubscribePrivilegeDidExpired.bind(this)),null===(f=this._room)||void 0===f||f.on(PU.POST_PROCESSING_MESSAGE,(function(e){var t;"2.0"===(null==(t=e)?void 0:t.protocol)?j._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?j._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&j._onLiveTranscodingResult(e)})),null===(_=this._room)||void 0===_||_.on(MU.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return j.safeEmit(Fh.onVendorConnectionStateChanged,e)})),null===(v=this._room)||void 0===v||v.on(oH.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(m=this._room)||void 0===m||m.on(oH.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(g=this._room)||void 0===g||g.on(oH.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(y=this._room)||void 0===y||y.on(oH.ON_PUBLISH_RESULT,(function(e){var t,r,n;e.state===oh.PUBLISH_SUCC&&(null===(r=j._room)||void 0===r||r.config.setTokenPublishPrivilegeExpired(!1));e.state===oh.PUBLISH_FAIL&&e.errorCode===hC.TOKEN_NO_PUBLISH_PERMISSION&&(null===(n=j._room)||void 0===n||n.config.setTokenPublishPrivilegeExpired(!0));var i=!(e.retry||null===(t=j._room)||void 0===t||!t.config.isAutoPublish);i&&j.safeEmit(Fh.onAutoPublishResult,e),j.safeEmit(Fh.onPublishResult,{isScreen:e.isScreen,isAutoPublish:i,errorCode:e.errorCode})})),null===(S=this._room)||void 0===S||S.on(oH.ON_SUBSCRIBE_RESULT,(function(e){var t;e.state===ih.SUBSCRIBE_SUCC&&(null===(t=j._room)||void 0===t||t.config.setTokenSubscribePrivilegeExpired(!1));e.state===ih.SUBSCRIBE_FAIL&&e.errorCode===hC.TOKEN_NO_SUBSCRIBE_PERMISSION&&j._handleLoseSubscribePrivilege(),j.safeEmit(Fh.onSubscribeResult,{userId:e.userId,isScreen:e.isScreen,isAutoSubscribe:!1,errorCode:e.errorCode})})),null===(b=this._room)||void 0===b||b.on(oH.ON_REMOTE_STREAM_STATS,(function(e){j.safeEmit(Fh.onRemoteStreamStats,e)})),null===(E=this._room)||void 0===E||E.on(oH.ON_LOCAL_STREAM_STATS,(function(e){j.safeEmit(Fh.onLocalStreamStats,e)})),null===(k=this._room)||void 0===k||k.on(oH.ON_SUBTITLE_STATE_CHANGED,(function(e){j.safeEmit(Fh.onSubtitleStateChanged,e)})),null===(T=this._room)||void 0===T||T.on(oH.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){j.safeEmit(Fh.onSubtitleMessageReceived,e)})),null===(I=this._room)||void 0===I||I.on(oH.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(R=this._room)||void 0===R||R.on(oH.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;j._updateAudioPlayerState(t),j.safeEmit(Fh.onUserStartAudioCapture,{userId:r})})),null===(A=this._room)||void 0===A||A.on(oH.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;j.safeEmit(Fh.onUserStopAudioCapture,{userId:t})})),null===(w=this._room)||void 0===w||w.on(oH.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;j.safeEmit(Fh.onUserStartVideoCapture,{userId:t})})),null===(C=this._room)||void 0===C||C.on(oH.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;j.safeEmit(Fh.onUserStopVideoCapture,{userId:t})})),null===(x=this._room)||void 0===x||x.on(oH.ON_SEI_MESSAGED_RECEIVED,(function(e){j.safeEmit(Fh.onSEIMessageReceived,e)})),null===(O=this._room)||void 0===O||O.on(oH.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){j.safeEmit(Fh.onRemoteVideoSizeChanged,e,t)})),null===(P=this._room)||void 0===P||P.on(oH.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return j.safeEmit(Fh.onSimulcastSubscribeFallback,e)})),null===(N=this._room)||void 0===N||N.on(oH.ON_VIDEO_STREAM_BANNED,(function(e){j.safeEmit(Fh.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(M=this._room)||void 0===M||M.on(oH.ON_AUDIO_STREAM_BANNED,(function(e){j.safeEmit(Fh.onAudioStreamBanned,{uid:e.uid,banned:e.banned})})),null===(D=this._room)||void 0===D||D.on(oH.ON_FORWARD_STREAM_ERROR,(function(e){j.safeEmit(Fh.onForwardStreamError,e)})),null===(L=this._room)||void 0===L||L.on(oH.ON_REJOIN_WITH_TCP,(function(){j.safeEmit(Fh.onRejoinWithTcp)})),null===(U=this._room)||void 0===U||U.on(oH.PUB_RETRY,(function(e){j.safeEmit(Fh.onPublishRetry,e)})),null===(V=this._room)||void 0===V||V.on(oH.SUB_RETRY,(function(e){j.safeEmit(Fh.onSubscribeRetry,e)})),null===(F=this._room)||void 0===F||F.on(oH.VIDEO_TYPE_CHANGE,(function(e){j.safeEmit(Fh.onSEIStreamUpdate,e)})),null===(B=this._room)||void 0===B||B.on(oH.JOIN_SUCCESS,(function(e){j._ctx.isPreConnection||j.safeEmit(Fh.onConnectionStateChanged,{state:e?lh.CONNECTION_STATE_RECONNECTED:lh.CONNECTION_STATE_CONNECTED})}))}},{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];if(function(e){var t,r=JL("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!Qy(r).call(r,e))||(!(e!==Fh.onRemoteStreamStats||!JL("UPLOAD_REMOTE_STATS"))||!Qy(t=[Fh.onRemoteStreamStats,Fh.onLocalStreamStats,Fh.onAudioVolumeIndication,Fh.onLocalAudioPropertiesReport,Fh.onRemoteAudioPropertiesReport]).call(t,e))}(e)){if(e===Fh.onRemoteStreamStats){var a=JL("UPLOAD_REMOTE_STATS"),s=i[0],c=s.videoStats,u=s.audioStats,d=uA(s,c0);i[0]=Zl({},d),a&uh.VIDEO&&(i[0].videoStats=c),a&uh.AUDIO&&(i[0].audioStats=u)}ZM(this.id,e,i)}return(t=FA(VA(Le.prototype),"safeEmit",this)).call.apply(t,Gg(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(Oe=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ctx.signalingManager.connect();case 2:case"end":return e.stop()}}),e,this)}))),function(){return Oe.apply(this,arguments)})},{key:"joinRoom",value:(xe=Ug(Dg().mark((function e(t,r,n,i){var o,a,s,c,u;return Dg().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),lU(t)||oU(t,"token"),!this._room){e.next=4;break}throw new mC(hC.REPEAT_JOIN,"Already joined");case 4:return hU(r),_U(n),vU((u=new EX({token:t,roomId:r,userInfo:n},this._ctx)).updateRoomConfig(i)),u.setLiveControlMessage(this._liveTranscodeConfig&&t$.getStartParams(this._liveTranscodeConfig)),this._room=new xZ(u,this._ctx),this._addHandlerEventHandler(),this._ctx.useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),null===(o=this._localVideoTrack)||void 0===o||o.setUserId(n.userId),null===(a=this._localScreenVideoTrack)||void 0===a||a.setUserId(n.userId),null===(s=this._localAudioTrack)||void 0===s||s.setUserId(n.userId),null===(c=this._localScreenAudioTrack)||void 0===c||c.setUserId(n.userId),gH(n),e.next=19,this._join(this._room);case 19:return e.abrupt("return",e.sent);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return xe.apply(this,arguments)})},{key:"_join",value:(Ce=Ug(Dg().mark((function e(t){var r,n,i=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.join();case 3:return n=e.sent,this.monitor.set({rtc_session_id:t.config.sessionId}),this._waitForNewToken=!1,this._ctx.audioProfileManager.setRoomId(t.config.roomId),null!==(r=this._room)&&void 0!==r&&r.config.isAutoPublish&&(this._ctx.visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:uh.AUDIO_AND_VIDEO}).catch((function(e){i.logger.error("_join","_updatePublish failed",e)})):(this.safeEmit(Fh.onAutoPublishResult,{isScreen:!1,state:oh.PUBLISH_FAIL}),this.safeEmit(Fh.onPublishResult,{isScreen:!1,isAutoPublish:!0,errorCode:hC.NO_PUBLISH_PERMISSION}))),this.monitor.set({rtc_vid:t.config.rtcVid}),VM.setRoomId(this.id,t.config.roomId),VM.setUserId(this.id,t.config.userId),e.abrupt("return",n);case 14:throw e.prev=14,e.t0=e.catch(0),e.t0.code===hC.INVALID_TOKEN?this._waitForNewToken=!0:(t.destroy(),this._room===t&&delete this._room),e.t0;case 18:case"end":return e.stop()}}),e,this,[[0,14]])}))),function(e){return Ce.apply(this,arguments)})},{key:"leaveRoom",value:(we=Ug(Dg().mark((function e(){var t,r,n=this,i=arguments;return Dg().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()"),r=this._room,delete this._room,this._ctx.resetPubSubLock(aZ.LEAVE),!t){e.next=10;break}return e.next=8,null==r?void 0:r.leave(t);case 8:e.next=11;break;case 10:null==r||r.leave(t).catch();case 11:this._removeHandlerEventHandler(),this._subLocks=new hT,this._subScreenLocks=new hT,this._ctx.audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),null==r||r.destroy(),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){e.forEach((function(e){var t=e.player,r=e.renderDom;null==t||t.destroy(),n._containerCollisionDetector.unregisterContainer(r)}))})),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_MAIN].clear(),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].forEach((function(e){e.forEach((function(e){var t=e.player,r=e.renderDom;null==t||t.destroy(),n._containerCollisionDetector.unregisterContainer(r)}))})),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].clear(),this._publicStreamIds=new hT,VM.setRoomId(this.id,""),VM.setUserId(this.id,""),this.monitor.set({rtc_session_id:"",rtc_vid:""});case 25:case"end":return e.stop()}}),e,this)}))),function(){return we.apply(this,arguments)})},{key:"_destroyLocalTrack",value:function(){this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.destroy(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.destroy(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.destroy(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.destroy(),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;this.logger.info("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,this._subLocks=new hT,this._subScreenLocks=new hT,this._audioCaptureLock=new iZ("audioCap"),this._videoCaptureLock=new iZ("videoCap"),this._screenCaptureLock=new iZ("screenCap"),this._videoStreamConstraints={},this._videoStreamEncodeConfig=[eU],this._screenStreamEncodeConfig=[tU],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeVideoStreamIds:{},resumeAudioStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),VM.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._destroyLocalTrack(),hG.on("".concat(this.id,"capture-end"),this._destroyLocalTrack.bind(this)),this._audioMixingManager.destroy(),this._rtmClient.destroy(),this._publicStreamManager.destroy(),this._publicStreamIds=new hT,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new hT,this._extensionManager.destroy(),this._ctx.destroy(),this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear(),this._localVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){e.player.destroy()})),this._localVideoPlayerConfig[ch.STREAM_INDEX_MAIN].clear(),this._localVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].forEach((function(e){e.player.destroy()})),this._localVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].clear(),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){e.forEach((function(e){e.player.destroy()}))})),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_MAIN].clear(),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].forEach((function(e){e.forEach((function(e){e.player.destroy()}))})),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].clear(),this._publicVideoPlayerConfig.forEach((function(e){e.player.destroy()})),this._publicVideoPlayerConfig.clear()}},{key:"publishStream",value:(Ae=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!VD(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,NG(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t},!0);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return Ae.apply(this,arguments)})},{key:"unpublishStream",value:(Re=Ug(Dg().mark((function e(t,r){var n;return Dg().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:sH.UNPUB},!0);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return Re.apply(this,arguments)})},{key:"publishScreen",value:(Ie=Ug(Dg().mark((function e(t){return Dg().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,!VD(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,DG(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:sH.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof mC)){e.next=18;break}throw e.t0;case 18:throw new mC(hC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return Ie.apply(this,arguments)})},{key:"unpublishScreen",value:(Te=Ug(Dg().mark((function e(t){return Dg().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:sH.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return Te.apply(this,arguments)})},{key:"subscribeStream",value:(ke=Ug(Dg().mark((function e(t,r){return Dg().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 ke.apply(this,arguments)})},{key:"_subscribe",value:(Ee=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n,n!==uh.AUDIO||null===(i=this._room)||void 0===i||!i.config.isMultiChatMode()){e.next=4;break}return this.logger.warn("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 4:if(s=this._room.remoteStreams.get(r),c=null==s?void 0:dI(s).call(s,(function(e){return e.isScreen===t}))){e.next=8;break}throw new mC(hC.STREAM_NOT_EXIST,"stream not exist");case 8:return u=this._pauseAllSubscribeState.audio,d=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&uh.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&uh.VIDEO),this.logger.warn("subscribeStream()","due to pauseAll mediaType: %o",n),l=c.hasSubscribed,h=this._remoteVideoConfig.get(r)||(null===(o=this._room)||void 0===o?void 0:o.config.remoteVideoConfig),c.originalMediaType=n,e.prev=16,e.next=19,this._room.subscribe(c,n,h);case 19:UD(n)&&this._updateAudioPlayerState(c),VD(n)&&this._updateVideoPlayerState(c),f=0,_=0,u!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?f|=uh.AUDIO:_|=uh.AUDIO),d!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?f|=uh.VIDEO:_|=uh.VIDEO),f&&this.pauseAllSubscribedStream(f),_&&this.resumeAllSubscribedStream(_),UD(a)&&(this._pauseAllSubscribeState.resumeAudioStreamIds[c.streamId]=c.streamId),VD(a)&&(this._pauseAllSubscribeState.resumeVideoStreamIds[c.streamId]=c.streamId),(c.audioTrack||c.videoTrack)&&(g=!(t||!(null!==(v=this._room)&&void 0!==v&&v.config.isAutoSubscribeAudio||null!==(m=this._room)&&void 0!==m&&m.config.isAutoSubscribeVideo)),y={userId:r,isScreen:!1,state:ih.SUBSCRIBE_SUCC},g&&this.safeEmit(Fh.onAutoSubscribeResult,y),this.safeEmit(Fh.onSubscribeResult,{userId:r,isScreen:t,isAutoSubscribe:g})),null!==(p=this._room)&&void 0!==p&&p.config.isMultiChatMode()||l||!UD(n)||!c.hasAudio||null===(S=c.observer)||void 0===S||S.setSubscribeAudio(!0),!l&&VD(n)&&c.hasVideo&&(null===(b=c.observer)||void 0===b||b.setSubscribeVideo(!0)),e.next=38;break;case 34:throw e.prev=34,e.t0=e.catch(16),e.t0 instanceof mC&&e.t0.code===hC.TOKEN_NO_SUBSCRIBE_PERMISSION&&this._handleLoseSubscribePrivilege(),e.t0;case 38:case"end":return e.stop()}}),e,this,[[16,34]])}))),function(e,t,r){return Ee.apply(this,arguments)})},{key:"_handleLoseSubscribePrivilege",value:(be=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(t=this._room)||void 0===t||t.config.setTokenSubscribePrivilegeExpired(!0),e.prev=1,e.next=4,this._unSubscribeAllRemoteStreams();case 4:e.next=8;break;case 6:e.prev=6,e.t0=e.catch(1);case 8:case"end":return e.stop()}}),e,this,[[1,6]])}))),function(){return be.apply(this,arguments)})},{key:"unsubscribeStream",value:(Se=Ug(Dg().mark((function e(t,r){return Dg().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 Se.apply(this,arguments)})},{key:"subscribeScreen",value:(ye=Ug(Dg().mark((function e(t,r){return Dg().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 ye.apply(this,arguments)})},{key:"unsubscribeScreen",value:(ge=Ug(Dg().mark((function e(t,r){return Dg().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 ge.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(r!==uh.AUDIO||null===(i=this._room)||void 0===i||!i.config.isMultiChatMode()){var a,s=this._room.remoteStreams.get(t),c=null==s?void 0:dI(s).call(s,(function(t){return t.isScreen===e}));if(!c)throw new mC(hC.STREAM_NOT_EXIST,"stream not exist");if(yL&&OL&&OL>=85&&OL<=91&&r!==uh.AUDIO)null===(a=c.videoTrack)||void 0===a||a.stopAll();return this._room.unsubscribe(c,r).then((function(){n||(UD(r)&&delete o._pauseAllSubscribeState.resumeAudioStreamIds[c.streamId],VD(r)&&delete o._pauseAllSubscribeState.resumeVideoStreamIds[c.streamId])}))}this.logger.warn("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(me=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),pU(t),yU(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 me.apply(this,arguments)})},{key:"startVideoCapture",value:(ve=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startVideoCapture()","deviceId: %s",t),lU(t)||oU(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==$l.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mC(hC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!this._localVideoTrack||this._localVideoTrack.dummy){e.next=8;break}throw new mC(hC.REPEAT_CAPTURE,"Has already capture");case 8:return a=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?(a.facingMode=t,delete a.deviceId):!hL||gL?a.deviceId={exact:t}:delete a.deviceId,this._videoStreamConstraints=a),s={},e.next=13,UG(a,this._extensionManager);case 13:if(c=e.sent,null!==(r=this._videoStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&c.setContentHint(null===(u=this._videoStreamEncodeConfig[0])||void 0===u?void 0:u.contentHint),this._initLocalTrackEvents(c),this._localVideoTrack=c,this._localVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){var t,r;null===(t=p._localVideoTrack)||void 0===t||t.setPlayer(p.id,e,p._mirrorType,null===(r=p._config)||void 0===r?void 0:r.autoPlayPolicy,p._initPlayerEvents.bind(p))})),d=c.originTrack,s=d.getSettings(),l={width:s.width,height:s.height},this._localVideoTrack.resolution=l,this.autoResetVideoEncoderConfig(s),setTimeout((function(){return p.safeEmit(Fh.onLocalVideoSizeChanged,{streamIndex:ch.STREAM_INDEX_MAIN,info:l})})),hG.emit("".concat(this.id,"capture-end")),this._room){e.next=28;break}return e.abrupt("return",s);case 28:return h=this._room.config.isAutoPublish,(null!==(n=this._room.localStream)&&void 0!==n&&n.pubVideo||h)&&this._ctx.visibility&&this._updatePublish(),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableVideo(!0),e.abrupt("return",s);case 32:case"end":return e.stop()}}),e,this)}))),function(e){return ve.apply(this,arguments)})},{key:"stopVideoCapture",value:(_e=Ug(Dg().mark((function e(){var t,r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopVideoCapture()"),this._trackSourceType.video!==$l.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=3;break}throw new mC(hC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 3:if(this._localVideoTrack&&(this._localVideoTrack.dummy||((i=this._extensionManager.getPluginByName(sG.PRE_PROCESSING,"RTCBeautyExtension"))&&i.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.destroy(),this._localImgVideoTrack?this._localVideoTrack.setTrack(this._localImgVideoTrack,this._extensionManager,{isDummy:!0}):this._localVideoTrack=void 0)),this._room){e.next=6;break}return e.abrupt("return");case 6:if(null===(t=this._room.localStream)||void 0===t||!t.pubVideo){e.next=9;break}return e.next=9,this._updatePublish();case 9:null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableVideo(!1);case 10:case"end":return e.stop()}}),e,this)}))),function(){return _e.apply(this,arguments)})},{key:"startAudioCapture",value:(fe=Ug(Dg().mark((function e(t){var r,n,i,o,a,s;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startAudioCapture()","deviceId: $o",t),lU(t)||oU(t,"deviceId"),t&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._trackSourceType.audio!==eh.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new mC(hC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 5:if(!this._localAudioTrack){e.next=7;break}throw new mC(hC.REPEAT_CAPTURE,"Has already capture");case 7:return o={},e.next=10,FG(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 10:if(a=e.sent,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),hG.emit("".concat(this.id,"capture-end")),this._room){e.next=19;break}return e.abrupt("return",o);case 19:return s=this._room.config.isAutoPublish,(null!==(r=this._room.localStream)&&void 0!==r&&r.pubAudio||s)&&this._ctx.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 fe.apply(this,arguments)})},{key:"stopAudioCapture",value:(pe=Ug(Dg().mark((function e(){var t,r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopAudioCapture()"),this._trackSourceType.audio!==eh.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=3;break}throw new mC(hC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 3:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.destroy()),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 pe.apply(this,arguments)})},{key:"checkAudioAndVideoDeviceId",value:function(e,t){var r;return this.logger.print("startAudioAndVideoCapture","optionsOrAudioDeviceId: $o",e,"videoDeviceId: $o",t),lU(t)||oU(t,"videoDeviceId"),lU(e)||("string"==typeof e?(oU(e,"audioDeviceId"),r=e):(r=null==e?void 0:e.audioDeviceId,t=null==e?void 0:e.videoDeviceId,oU(r,"audioDeviceId"),oU(t,"videoDeviceId"))),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,{audioDeviceId:r,videoDeviceId:t}}},{key:"startAudioAndVideoCapture",value:(he=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("startAudioAndVideoCapture","optionsOrAudioDeviceId: $o",t,"videoDeviceId: $o",r),d=this.checkAudioAndVideoDeviceId(t,r),l=d.audioDeviceId,h=d.videoDeviceId,r=h,l&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:l}}),this._trackSourceType.video!==$l.VIDEO_SOURCE_TYPE_EXTERNAL&&this._trackSourceType.audio!==eh.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mC(hC.STREAM_TYPE_NOT_MATCH,this._trackSourceType.video===$l.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 mC(hC.REPEAT_CAPTURE,"video has already capture");case 8:if(!this._localAudioTrack){e.next=10;break}throw new mC(hC.REPEAT_CAPTURE,"audio has already capture");case 10:return p=this._videoStreamConstraints,r&&("user"===r||"environment"===r||"left"===r||"right"===r?(p.facingMode=r,delete p.deviceId):!hL||gL?p.deviceId={exact:r}:delete p.deviceId,this._videoStreamConstraints=p),f={},_={},e.next=16,jG(this._ctx.audioProfileManager.getConstraints(),p,this._extensionManager);case 16:if(v=e.sent,m=v.audioTrack,g=v.videoTrack,null!==(n=this._videoStreamEncodeConfig[0])&&void 0!==n&&n.contentHint&&g.setContentHint(null===(y=this._videoStreamEncodeConfig[0])||void 0===y?void 0:y.contentHint),this._initLocalTrackEvents(g),this._localVideoTrack=g,this._localVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){var t,r;null===(t=k._localVideoTrack)||void 0===t||t.setPlayer(k.id,e,k._mirrorType,null===(r=k._config)||void 0===r?void 0:r.autoPlayPolicy,k._initPlayerEvents.bind(k))})),this._initLocalTrackEvents(m),this._localAudioTrack=m,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),S=g.originTrack,f=S.getSettings(),b={width:f.width||0,height:f.height||0},this._localVideoTrack.resolution=b,this.autoResetVideoEncoderConfig(f),setTimeout((function(){return k.safeEmit(Fh.onLocalVideoSizeChanged,{streamIndex:ch.STREAM_INDEX_MAIN,info:b})})),S=m.originTrack,_=S.getSettings(),hG.emit("".concat(this.id,"capture-end")),this._room){e.next=39;break}return e.abrupt("return",{audioTrackSettings:_,videoTrackSettings:f});case 39:return E=this._room.config.isAutoPublish,(null!==(i=this._room.localStream)&&void 0!==i&&i.pubVideo||null!==(o=this._room.localStream)&&void 0!==o&&o.pubAudio||E)&&this._ctx.visibility&&this._updatePublish(),null===(a=this._room.localStream)||void 0===a||null===(s=a.observer)||void 0===s||s.setEnableVideo(!0),null===(c=this._room.localStream)||void 0===c||null===(u=c.observer)||void 0===u||u.setEnableAudio(!0),e.abrupt("return",{audioTrackSettings:_,videoTrackSettings:f});case 44:case"end":return e.stop()}}),e,this)}))),function(e,t){return he.apply(this,arguments)})},{key:"startVideoAndAudioCapture",value:(le=Ug(Dg().mark((function e(t,r){return Dg().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 le.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return this.logger.info("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(de=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,f=this,_=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=_.length>0&&void 0!==_[0]?_[0]:{},this.logger.info("startScreenCapture()","config: %o",s),this._trackSourceType.screenVideo!==$l.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=4;break}throw new mC(hC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 4:if(this._trackSourceType.screenAudio!==eh.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mC(hC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:return e.next=8,HG(s,this._extensionManager,this._screenStreamEncodeConfig[0]);case 8:if(c=e.sent,u=Ey(c,2),d=u[0],null==(l=u[1])||l.setVolume(this._localScreenAudioVolume),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.destroy()),null===(t=this._localScreenAudioTrack)||void 0===t||t.destroy(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=d,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&d.setContentHint(null===(h=this._screenStreamEncodeConfig[0])||void 0===h?void 0:h.contentHint),p=d.originTrack,setTimeout((function(){var e=p.getSettings(),t={width:e.width,height:e.height};d.resolution=t,f.safeEmit(Fh.onLocalVideoSizeChanged,{streamIndex:ch.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),l&&(this._localScreenAudioTrack=l,this._initLocalTrackEvents(l)),this._localVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].forEach((function(e){var t,r;null===(t=f._localScreenVideoTrack)||void 0===t||t.setPlayer(f.id,e,ph.MIRROR_TYPE_NONE,null===(r=f._config)||void 0===r?void 0:r.autoPlayPolicy,f._initPlayerEvents.bind(f))})),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),!(null!==(n=this._room)&&void 0!==n&&null!==(i=n.localScreenStream)&&void 0!==i&&i.pubAudio||null!==(o=this._room)&&void 0!==o&&null!==(a=o.localScreenStream)&&void 0!==a&&a.pubVideo)){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return de.apply(this,arguments)})},{key:"stopScreenCapture",value:(ue=Ug(Dg().mark((function e(){var t,r,n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopScreenCapture()"),null===(t=this._localScreenVideoTrack)||void 0===t||t.stopAll(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.destroy(),this._localImgScreenTrack&&this._localScreenVideoTrack.setTrack(this._localImgScreenTrack,this._extensionManager,{isDummy:!0}))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.destroy()),this._localScreenAudioTrack=void 0,null!==(r=this._localScreenVideoTrack)&&void 0!==r&&r.dummy||(this._localScreenVideoTrack=void 0),!(null!==(n=this._room)&&void 0!==n&&null!==(i=n.localScreenStream)&&void 0!==i&&i.pubAudio||null!==(o=this._room)&&void 0!==o&&null!==(a=o.localScreenStream)&&void 0!==a&&a.pubVideo)){e.next=9;break}return e.next=9,this._updateScreenPublish();case 9:case"end":return e.stop()}}),e,this)}))),function(){return ue.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){var r;this.logger.info("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),aU(e,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]);var n=e===ch.STREAM_INDEX_MAIN?this._localVideoTrack:this._localScreenVideoTrack,i=null!==(r=null==t?void 0:t.playerId)&&void 0!==r?r:RG;if(null==t||!t.renderDom){var o,a,s;null===(o=this._localVideoPlayerConfig[e].get(i))||void 0===o||null===(a=o.player)||void 0===a||a.destroy();var c=null===(s=this._localVideoPlayerConfig[e].get(i))||void 0===s?void 0:s.renderDom;return this._containerCollisionDetector.unregisterContainer(c),void this._localVideoPlayerConfig[e].delete(i)}mU(t);var u=this._localVideoPlayerConfig[e].get(i);if(!u){var d,l,h,p=t.renderDom;if(!this._containerCollisionDetector.registerContainer(p))return this.monitor.report("rtc_error",{message:"RenderDom is not empty",error_code:EH.DUPLICATE_DOM}),void HD("renderDom is not empty");var f=new DZ(this._ctx.id,i,Zl(Zl({},t),{},{isLocal:!0,isScreen:e===ch.STREAM_INDEX_SCREEN,userId:null!==(d=t.userId)&&void 0!==d?d:"_local_"})),_=Zl(Zl({},t),{},{player:f});return this._localVideoPlayerConfig[e].set(i,_),null==n||n.setPlayer(this.id,_,e===ch.STREAM_INDEX_MAIN?this._mirrorType:ph.MIRROR_TYPE_NONE,null===(l=this._config)||void 0===l?void 0:l.autoPlayPolicy,this._initPlayerEvents.bind(this)),null===(h=_.player)||void 0===h?void 0:h.domElement}void 0!==t.renderMode&&(null==n||n.setRenderMode(i,t.renderMode),u.renderMode=t.renderMode)}},{key:"startLiveTranscoding",value:(ce=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startLiveTranscoding()","transcode: %o",t),t$.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.config)&&n.roomId.length+n.userId.length>126)){e.next=6;break}throw new mC(hC.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(Fh.onStreamMixingEvent,{event:aH.START,error:0,message:""}),!this._room||!this._ctx.signalingManager.isConnected()){e.next=11;break}return e.next=11,this._room.liveControlMessage(t$.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof mC)){e.next=19;break}throw e.t0;case 19:throw new mC(hC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return ce.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(se=Ug(Dg().mark((function e(t){var r,n,i,o;return Dg().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=pK({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,t$.checkUpdateParams(i),this._liveTranscodeConfig=pK(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(Fh.onStreamMixingEvent,{event:aH.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(t$.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof mC)){e.next=21;break}throw e.t0;case 21:throw new mC(hC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return se.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(ae=Ug(Dg().mark((function e(){var t;return Dg().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(Fh.onStreamMixingEvent,{event:aH.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 mC)){e.next=16;break}throw e.t0;case 16:throw new mC(hC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return ae.apply(this,arguments)})},{key:"startSubtitle",value:(oe=Ug(Dg().mark((function e(t){var r;return Dg().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 oe.apply(this,arguments)})},{key:"updateSubtitleConfig",value:(ie=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateSubtitleConfig()","config: %o",t),this._assertNotInRoom(),e.next=4,null===(r=this._room)||void 0===r?void 0:r.updateSubtitleConfig(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return ie.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._ctx.businessId=e,!0)}},{key:"setUserVisibility",value:(ne=Ug(Dg().mark((function e(t){var r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setUserVisibility()","enable: %o",t),t=!!t,this._ctx.visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._ctx.visibility=t,e.abrupt("return");case 7:if(this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),t){e.next=14;break}return e.next=12,this._pubLock.lock();case 12:i=e.sent;try{this._room.unpublish(),this._room.unpublishScreen()}finally{i()}case 14:return this._ctx.visibility=t,e.prev=15,e.next=18,this._room.updateUserAttributes();case 18:e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(15),this._ctx.visibility=!t,e.t0;case 24:t&&null!==(r=this._room)&&void 0!==r&&r.config.isAutoPublish&&this._updatePublish({mediaType:uh.AUDIO_AND_VIDEO});case 25:case"end":return e.stop()}}),e,this,[[15,20]])}))),function(e){return ne.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]:ch.STREAM_INDEX_MAIN)===ch.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:dI(a).call(a,(function(e){return e.isScreen===n})),u=function(){r?t.safeEmit(Fh.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(Fh.onAudioFirstFrameDecoded,{userId:s,isScreen:n}),t.safeEmit(Fh.onRemoteAudioFirstFrame,{userId:s,isScreen:n})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:n})};null==c||!c.observer||c.observer.audioFirstFrameReceived?u():c.observer.once("recvAudioFirstFrame",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,playerId:e.playerId};r?(h.publicStreamId=h.userId,delete h.userId,delete h.isScreen,t.safeEmit(Fh.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(Fh.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(Fh.onVideoFirstFrameRendered,h),t.safeEmit(Fh.onVideoFirstFrameDecoded,h),t.safeEmit(Fh.onRemoteVideoFirstFrame,h)),t.monitor.report("first_remote_video_render",{stream_id:"",stream_user_id:i.userId||""},{isScreen:n})}break;case"autoplay-error":r&&(i.publicStreamId=i.userId),$M(t.id,"autoplay-error",e instanceof DZ?"video":"audio",0,i.userId||"");var p={userId:i.userId,kind:e instanceof DZ?"video":"audio",mediaType:e instanceof DZ?uh.VIDEO:uh.AUDIO,streamIndex:e.isScreen?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN};return e instanceof DZ&&(p.playerId=e.playerId===RG?void 0:e.playerId),void t.safeEmit(Fh.onAutoplayFailed,p)}e instanceof DZ&&(i.playerId=e.playerId===RG?void 0:e.playerId),t.safeEmit(Fh.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=Ug(Dg().mark((function e(n){var i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.monitor.report("rtc_error",{message:Gg(i="track-".concat(r," mediaType: ")).call(i,n.originTrack.kind),error_code:EH.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":Fh.onTrackEnded,"track-mute":Fh.onTrackMute,"track-unmute":Fh.onTrackUnmute}[r],{kind:a,isScreen:o}),!gL&&!fL){e.next=13;break}if("track-mute"!==r){e.next=12;break}if(hG.emit(dG.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&&hG.emit(dG.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(sG.PRE_PROCESSING).forEach((function(t){var n;null==t||null===(n=t.applyConstraints)||void 0===n||n.call(t,r?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN,e)})),t.safeEmit(Fh.onLocalVideoSizeChanged,{streamIndex:r?ch.STREAM_INDEX_SCREEN:ch.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){var r,n,i,o,a,s,c,u;this.logger.info("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),aU(e,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),mU(t);var d=t.userId,l=e===ch.STREAM_INDEX_SCREEN,h=null===(r=this._room)||void 0===r||null===(n=r.remoteStreams.get(d))||void 0===n?void 0:dI(n).call(n,(function(e){return e.isScreen===l})),p=null==h?void 0:h.videoTrack,f=null!==(i=t.playerId)&&void 0!==i?i:RG;null===(o=this._getRemoteVideoPlayerConfig(e,d,f))||void 0===o||null===(a=o.player)||void 0===a||a.destroy();var _,v=null===(s=this._getRemoteVideoPlayerConfig(e,d,f))||void 0===s?void 0:s.renderDom;if(this._containerCollisionDetector.unregisterContainer(v),t.renderDom){var m=t.renderDom;if(!this._containerCollisionDetector.registerContainer(m))return this.monitor.report("rtc_error",{message:"RenderDom is not empty",error_code:EH.DUPLICATE_DOM}),void HD("renderDom is not empty");var g=new DZ(this.id,f,Zl(Zl({},t),{},{isLocal:!1,isScreen:l,userId:d})),y=Zl(Zl({},t),{},{player:g});return this._setRemoteVideoPlayerConfig(e,d,f,y),null==p||p.setPlayer(this.id,y,null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy,this._initPlayerEvents.bind(this)),h&&this._updateVideoPlayerState(h),null===(u=y.player)||void 0===u?void 0:u.domElement}null===(_=this._remoteVideoPlayerConfig[e].get(d))||void 0===_||_.delete(f)}},{key:"setLocalVideoMirrorType",value:function(e){var t;this.logger.info("setLocalVideoMirrorType()","mirrorType: %o",e),aU(e,"mirrorType",[ph.MIRROR_TYPE_NONE,ph.MIRROR_TYPE_RENDER]),this._mirrorType=e,null===(t=this.localVideoTrack)||void 0===t||t.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(re=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setAudioPlaybackDevice()","deviceId: %s",t),oU(t,"deviceId"),e.next=4,this._audioDeviceManager.setSinkId(t);case 4:n=e.sent,null===(r=this._room)||void 0===r||r.remoteStreams.forEach((function(e){e.forEach((function(e){var r;null===(r=e.audioTrack)||void 0===r||r.setPlaybackDevice(t)}))})),this.safeEmit(Fh.onAudioPlaybackDeviceChanged,n),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:Xg(n),error_code:0});case 8:case"end":return e.stop()}}),e,this)}))),function(e){return re.apply(this,arguments)})},{key:"play",value:(te=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,f,_,v,m=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=m.length>1&&void 0!==m[1]?m[1]:uh.AUDIO_AND_VIDEO,i=m.length>2?m[2]:void 0,o=m.length>3?m[3]:void 0,this.logger.info("play()","userId: %s, mediaType: %s, streamIndex: %s",t,n,i),a=null!=o?o:RG,s=!t||t===this._getUserId()||"local_user"===t,c=void 0===i||i===ch.STREAM_INDEX_MAIN,u=void 0===i||i===ch.STREAM_INDEX_SCREEN,d=n!==uh.VIDEO,l=n!==uh.AUDIO,h=[],s&&l&&(c&&this._localVideoTrack&&(this._localVideoTrack.mirror(!!this._mirrorType),(p=this._localVideoTrack.play(a))&&h.push(p)),u&&this._localScreenVideoTrack&&(null===(f=this._localScreenVideoTrack)||void 0===f?void 0:f.manuallyPlay(a))&&h.push()),t===this._audioMixingManager.id&&h.push(this._audioMixingManager.resumeLocalPlay()),_=[],null===(r=this._room)||void 0===r||r.remoteStreams.forEach((function(e,r){t&&t!==r||e.forEach((function(e){e.audioTrack&&_.push(e.audioTrack),e.videoTrack&&_.push(e.videoTrack)}))})),this._publicStreamManager.getRemoteStreams().forEach((function(e,r){t&&t!==r||(e.audioTrack&&_.push(e.audioTrack),e.videoTrack&&_.push(e.videoTrack))})),c||(_=wy(_).call(_,(function(e){return!!e.isScreen}))),u||(_=wy(_).call(_,(function(e){return!e.isScreen}))),d||(_=wy(_).call(_,(function(e){return"audio"!==e.mediaType}))),l||(_=wy(_).call(_,(function(e){return"video"!==e.mediaType}))),d&&(null===(v=this._room)||void 0===v||v.virtualStreams.forEach((function(e){e.audioTrack&&_.push(e.audioTrack)}))),_.forEach((function(e){var t=e.play(a);t&&h.push(t)})),e.abrupt("return",Hg.all(h).then((function(){})));case 23:case"end":return e.stop()}}),e,this)}))),function(e){return te.apply(this,arguments)})},{key:"stop",value:(ee=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,f,_=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=_.length>1&&void 0!==_[1]?_[1]:uh.AUDIO_AND_VIDEO,n=_.length>2?_[2]:void 0,i=_.length>3?_[3]:void 0,this.logger.info("stop()","userId: %s, mediaType: %s, streamIndex: %s, playerId: %s",t,r,n,i),o=null!=i?i:RG,a=!t||t===this._getUserId()||"local_user"===t,s=void 0===n||n===ch.STREAM_INDEX_MAIN,c=void 0===n||n===ch.STREAM_INDEX_SCREEN,u=r!==uh.VIDEO,d=r!==uh.AUDIO,a&&d&&(s&&this._localVideoTrack&&this._localVideoTrack.pause(o),c&&this._localScreenVideoTrack&&this._localScreenVideoTrack.pause(o)),t&&(p=[],null===(l=this._room)||void 0===l||null===(h=l.remoteStreams.get(t))||void 0===h||h.forEach((function(e){e.audioTrack&&p.push(e.audioTrack),e.videoTrack&&p.push(e.videoTrack)})),(null==(f=this._publicStreamManager.getRemoteStream(t))?void 0:f.audioTrack)&&p.push(f.audioTrack),(null==f?void 0:f.videoTrack)&&p.push(f.videoTrack),s||(p=wy(p).call(p,(function(e){return!!e.isScreen}))),c||(p=wy(p).call(p,(function(e){return!e.isScreen}))),u||(p=wy(p).call(p,(function(e){return"audio"!==e.mediaType}))),d||(p=wy(p).call(p,(function(e){return"video"!==e.mediaType}))),p.forEach((function(e){e.pause(o)})));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return ee.apply(this,arguments)})},{key:"getAudioVolume",value:function(e,t){aU(e,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]);var r=0;if(t){var n,i,o,a=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=dI(i).call(i,(function(t){return t.isScreen===(e===ch.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.audioTrack;a&&(r=a.getAudioLevel())}else{var s=e===ch.STREAM_INDEX_MAIN?this._localAudioTrack:this._localScreenAudioTrack;s&&(r=s.getAudioLevel())}return{linearVolume:r,nonlinearVolume:LD(r)}}},{key:"pauseAllSubscribedStream",value:($=Ug(Dg().mark((function e(t){var r=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),UD(t)&&(r._pauseAllSubscribeState.audio=!0),VD(t)&&(r._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",Hg.resolve());case 6:return e.abrupt("return",this._pauseAllRemoteStreams(t));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return $.apply(this,arguments)})},{key:"_pauseAllRemoteStreams",value:(Z=Ug(Dg().mark((function e(t){var r,n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._room){e.next=2;break}return e.abrupt("return",Hg.resolve());case 2:return r=[],this._room.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){if(e.hasSubscribed){e.attributes.audiostream&&UD(t)&&(n._pauseAllSubscribeState.resumeAudioStreamIds[e.streamId]=e.streamId),e.attributes.videostream&&VD(t)&&(n._pauseAllSubscribeState.resumeVideoStreamIds[e.streamId]=e.streamId);var i=n._unsubscribe(e.isScreen,e.userId,t,!0);i&&r.push(i)}}))})),e.abrupt("return",Hg.all(r).then((function(){})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return Z.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(Q=Ug(Dg().mark((function e(t){var r=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),UD(t)&&(r._pauseAllSubscribeState.audio=!1),VD(t)&&(r._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",Hg.resolve());case 6:return e.next=8,this._triedResumeAllRemoteStreams(t,!1);case 8:return e.abrupt("return");case 9:case"end":return e.stop()}}),e,this)}))),function(e){return Q.apply(this,arguments)})},{key:"_triedResumeAllRemoteStreams",value:(J=Ug(Dg().mark((function e(t,r){var n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._room){e.next=2;break}return e.abrupt("return",Hg.resolve());case 2:if(!this._pauseAllSubscribeState.audio||t!==uh.AUDIO){e.next=4;break}return e.abrupt("return",Hg.resolve());case 4:if(!this._pauseAllSubscribeState.video||t!==uh.VIDEO){e.next=6;break}return e.abrupt("return",Hg.resolve());case 6:if(!this._pauseAllSubscribeState.video||!this._pauseAllSubscribeState.audio||t!==uh.AUDIO_AND_VIDEO){e.next=8;break}return e.abrupt("return",Hg.resolve());case 8:return n=[],i=iR(FS(this._pauseAllSubscribeState.resumeAudioStreamIds)),o=iR(FS(this._pauseAllSubscribeState.resumeVideoStreamIds)),this._room.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){if(!r||!e.isScreen){var i=a._pauseAllSubscribeState.resumeAudioStreamIds[e.streamId],o=a._pauseAllSubscribeState.resumeVideoStreamIds[e.streamId];if(i&&UD(t)||o&&VD(t)){var s=a._subscribe(e.isScreen,e.userId,t).then((function(){i&&UD(t)&&delete a._pauseAllSubscribeState.resumeAudioStreamIds[e.streamId],o&&VD(t)&&delete a._pauseAllSubscribeState.resumeVideoStreamIds[e.streamId]}));s&&n.push(s)}}}))})),e.abrupt("return",Hg.all(n).then((function(){var e;return null===(e=a._room)||void 0===e||e.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){a._updateAudioPlayerState(e),a._updateVideoPlayerState(e)}))})),Hg.resolve()})).finally((function(){var e;return null!==(e=a._room)&&void 0!==e&&e.config.tokenSubscribePrivilegeExpired&&(i.forEach((function(e){a._pauseAllSubscribeState.resumeAudioStreamIds[e]=e})),o.forEach((function(e){a._pauseAllSubscribeState.resumeVideoStreamIds[e]=e}))),Hg.resolve()})));case 13:case"end":return e.stop()}}),e,this)}))),function(e,t){return J.apply(this,arguments)})},{key:"sendUserMessage",value:(q=Ug(Dg().mark((function e(t,r){var n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return pU(t),gU(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 q.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(Y=Ug(Dg().mark((function e(t,r){var n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return pU(t),uU(r,"message"),gU(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 Y.apply(this,arguments)})},{key:"sendRoomMessage",value:(X=Ug(Dg().mark((function e(t){var r,n,i,o,a,s=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return gU(t),this._assertNotInRoom(),o=null===(r=this._room)||void 0===r?void 0:r.config.roomId,a=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendRoomMessage(t))||void 0===i?void 0:i.then((function(e){return s._messageStatisticsObserver.countRoomMessage(!0,o,!1,a),e})).catch((function(e){throw s._messageStatisticsObserver.countRoomMessage(!1,o,!1,a),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return X.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(W=Ug(Dg().mark((function e(t){var r,n,i,o,a,s=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return gU(t),this._assertNotInRoom(),o=null===(r=this._room)||void 0===r?void 0:r.config.roomId,a=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendRoomMessage(t,!0))||void 0===i?void 0:i.then((function(e){return s._messageStatisticsObserver.countRoomMessage(!0,o,!0,a),e})).catch((function(e){throw s._messageStatisticsObserver.countRoomMessage(!1,o,!0,a),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return W.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(K=Ug(Dg().mark((function e(){var t,r=arguments;return Dg().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,dU(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._ctx.audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return K.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(z=Ug(Dg().mark((function e(){var t,r=arguments;return Dg().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 z.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(H=Ug(Dg().mark((function e(){var t,r,n,i=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,dU(r),n=Zl(Zl({},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 H.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return this.logger.info("enableSimulcastMode()","enabled: %o",e),!iL&&!pL&&14!==(null==wL?void 0:wL[0])&&(this._enableSimulcast=e,null!==(t=this._room)&&void 0!==t&&t.hasPublished&&HD("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(G=Ug(Dg().mark((function e(t){var r,n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(this.logger.info("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),bU(t=wy(t).call(t,(function(e){return!!e}))),t.length>3&&(HD("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=lI(t).call(t,0,3)),n=1;n<t.length;n++)i=zD(t[0].width)/zD(t[n].width)||1,Math.floor(i)!==i&&HD("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");return jw(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(Zl({},t[0]));case 10:this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(ch.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 G.apply(this,arguments)})},{key:"setVideoEncoderAutoConfigList",value:function(e){if(Array.isArray(e))return jw(e).call(e,(function(e,t){return e.maxKbps-t.maxKbps})),$L(e)}},{key:"autoResetVideoEncoderConfig",value:function(e){var t,r=ZL;if(r.length){this._videoStreamEncodeConfig.length||(this._videoStreamEncodeConfig=[eU]);var n=this._videoStreamEncodeConfig[0],i=e.width||zD(n.width),o=e.height||zD(n.height),a=i*o;if(!(zD(n.width)*zD(n.height)<=a)){var s,c,u=r[0];r.forEach((function(e){var t=zD(e.width)*zD(e.height);s||(a<t?s=e:u=e)})),c=s&&zD(s.width)*zD(s.height)-a<a-zD(u.width)*zD(u.height)?wT({},s):wT({},u),this._videoStreamEncodeConfig=wy(t=this._videoStreamEncodeConfig).call(t,(function(e){return!(c&&zD(e.width)*zD(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",Xg(this._videoStreamEncodeConfig)),$M(this.id,"autoResetVideoEncoderConfig",Xg(this._videoStreamEncodeConfig))}}}},{key:"setScreenEncoderConfig",value:(j=Ug(Dg().mark((function e(t){var r;return Dg().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"===AL){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(ch.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 j.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){var n=this;if(this.logger.info("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!iV())return HD("Your browser does not support sending SEI"),!1;aU(e,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),iU(r,"repeatCount",0,30);var i,o="string"==typeof t?new Uint8Array(CD.str2ab(t)):t;if(!t.length)return this.logger.warn("sei message must not be empty"),!1;if(e===ch.STREAM_INDEX_MAIN){var a,s,c,u;if(!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubAudio||null!==(c=this._room)&&void 0!==c&&null!==(u=c.localStream)&&void 0!==u&&u.pubVideo))return;i=this._room.localStream}else{var d,l,h,p;if(!(null!==(d=this._room)&&void 0!==d&&null!==(l=d.localScreenStream)&&void 0!==l&&l.pubAudio||null!==(h=this._room)&&void 0!==h&&null!==(p=h.localScreenStream)&&void 0!==p&&p.pubVideo))return;i=this._room.localScreenStream}if(o.byteLength>4096)this.logger.warn("sei size must not bigger than 4KB");else{var f;if(!yL)null===(f=this._room)||void 0===f||f.maybeFillBackFrame2Stream(i);var _=RD();i.seiList.push({content:o,uuid:_,repeatCount:r+1}),setTimeout((function(){var e;if(i){var r,o=Jw(e=i.seiList).call(e,(function(e){return e.uuid===_}));if(o>=0)zI(r=i.seiList).call(r,o,1),console.error("[RTC WebSDK] sei timeout for message: %o",t),n.monitor.report("rtc_sdk_callback",{sdk_callback_name:"sendSEIMessage",message:"timeout for message: ".concat(t),error_code:400})}}),JL("SEI_TIME_OUT"))}}},{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=dI(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(Fh.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n,i=e[0],o=uS(t).call(t,(function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=i?o?i.audioPropertiesInfo.nonlinearVolume>o.audioPropertiesInfo.nonlinearVolume?i:o:i:o)&&r.audioPropertiesInfo.nonlinearVolume>-35)(n=r.streamKey?this._room.remoteUsers.get(r.streamKey.userId):this._room.config.userInfo)&&this.safeEmit(Fh.onActiveSpeaker,{userId:n.userId,extraInfo:n.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?fh.NORMAL:i,a=t.audioReportMode,s=void 0===a?_h.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=LD(d),h={streamIndex:ch.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:d,nonlinearVolume:l}};if(c||u)t.push(h);else switch(o){case fh.DISCONNECT:break;case fh.RESET:h.audioPropertiesInfo.linearVolume=0,h.audioPropertiesInfo.nonlinearVolume=-127,t.push(h);break;case fh.NORMAL:t.push(h);break;default:throw new mC(hC.INVALID_PARAMS,"invalid localMainReportMode: ".concat(o," in config"))}}if(e._localScreenAudioTrack){var p=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:ch.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:p,nonlinearVolume:LD(p)}})}if(e.safeEmit(Fh.onLocalAudioPropertiesReport,t),e._room){var f=[];if(e._room.config.isMultiChatMode())e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i=255*t.audioLevel;f.push({streamKey:{userId:t.userId,streamIndex:ch.STREAM_INDEX_MAIN,roomId:null!==(r=null===(n=e._room)||void 0===n?void 0:n.config.roomId)&&void 0!==r?r:""},audioPropertiesInfo:{linearVolume:i,nonlinearVolume:LD(i)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();f.push({streamKey:{userId:r,streamIndex:t.isScreen?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN,roomId:null!==(n=null===(i=e._room)||void 0===i?void 0:i.config.roomId)&&void 0!==n?n:""},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:LD(o)}})}}))}));e.safeEmit(Fh.onRemoteAudioPropertiesReport,f),e._sendActiveSpeaker(t,wy(f).call(f,(function(e){return e.streamKey.streamIndex!==ch.STREAM_INDEX_SCREEN})))}}}),u))}},{key:"setVideoSourceType",value:(B=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T,I,R,A;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),aU(t,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),aU(r,"VideoSourceType",[$l.VIDEO_SOURCE_TYPE_EXTERNAL,$l.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===ch.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,this.logger.print("setVideoSourceType",Gg(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==ch.STREAM_INDEX_MAIN){e.next=17;break}if(u=!1,r===$l.VIDEO_SOURCE_TYPE_EXTERNAL&&(u=!0,(d=this._extensionManager.getPluginByName(sG.PRE_PROCESSING,"RTCBeautyExtension"))&&d.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.destroy()),null===(o=this._localVideoTrack)||void 0===o||o.destroy(),this._localVideoTrack=void 0,l=null===(a=this._room)||void 0===a?void 0:a.config.isAutoPublish,u?null===(h=this._room)||void 0===h||null===(p=h.localStream)||void 0===p||null===(f=p.observer)||void 0===f||f.setEnableVideo(!1):null===(_=this._room)||void 0===_||null===(v=_.localStream)||void 0===v||null===(m=v.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!==ch.STREAM_INDEX_SCREEN){e.next=26;break}if(b=!1,r===$l.VIDEO_SOURCE_TYPE_EXTERNAL&&(b=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.destroy()),null===(g=this._localScreenVideoTrack)||void 0===g||g.destroy(),this._localScreenVideoTrack=void 0,b?null===(E=this._room)||void 0===E||null===(k=E.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setEnableVideo(!1):null===(I=this._room)||void 0===I||null===(R=I.localScreenStream)||void 0===R||null===(A=R.observer)||void 0===A||A.setPushVideo(!1),null===(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 B.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(F=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,f=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setExternalVideoTrack()","index: %o, track: %o",t,r),aU(t,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),sU(r),t!==ch.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.video===$l.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mC(hC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,WG(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===(s=this._videoStreamEncodeConfig[0])||void 0===s?void 0:s.contentHint),this._initLocalTrackEvents(this._localVideoTrack),this._localVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){var t,r;null===(t=f._localVideoTrack)||void 0===t||t.setPlayer(f.id,e,f._mirrorType,null===(r=f._config)||void 0===r?void 0:r.autoPlayPolicy,f._initPlayerEvents.bind(f))})),c=null===(i=this._room)||void 0===i?void 0:i.config.isAutoPublish,!(null!==(o=this._room)&&void 0!==o&&null!==(a=o.localStream)&&void 0!==a&&a.pubVideo||c)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==ch.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenVideo===$l.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new mC(hC.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 19:return e.next=21,JG(r,this._extensionManager);case 21:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),this._localVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].forEach((function(e){var t,r;null===(t=f._localScreenVideoTrack)||void 0===t||t.setPlayer(f.id,e,f._mirrorType,null===(r=f._config)||void 0===r?void 0:r.autoPlayPolicy,f._initPlayerEvents.bind(f))})),null===(u=this._room)||void 0===u||null===(d=u.localScreenStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setPushVideo(!0),null===(h=this._room)||void 0===h||null===(p=h.localScreenStream)||void 0===p||!p.pubVideo){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return F.apply(this,arguments)})},{key:"setAudioSourceType",value:(V=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,f,_,v,m,g,y,S,b,E,k,T;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),aU(t,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),aU(r,"audioSourceType",[eh.AUDIO_SOURCE_TYPE_EXTERNAL,eh.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===ch.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,this.logger.print("setVideoSourceType",Gg(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==ch.STREAM_INDEX_MAIN){e.next=16;break}if(c=!1,this._trackSourceType.audio===eh.AUDIO_SOURCE_TYPE_EXTERNAL&&(c=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.destroy()),this._localAudioTrack=void 0,u=null===(o=this._room)||void 0===o?void 0:o.config.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===(f=p.localStream)||void 0===f||null===(_=f.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!==ch.STREAM_INDEX_SCREEN){e.next=24;break}if(g=!1,this._trackSourceType.audio===eh.AUDIO_SOURCE_TYPE_EXTERNAL&&(g=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.destroy()),this._localScreenAudioTrack=void 0,g?null===(y=this._room)||void 0===y||null===(S=y.localScreenStream)||void 0===S||null===(b=S.observer)||void 0===b||b.setEnableAudio(!1):null===(E=this._room)||void 0===E||null===(k=E.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setPushAudio(!1),null===(v=this._room)||void 0===v||null===(m=v.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 V.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(U=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,f;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setExternalAudioTrack()","index: %o, track: %o",t,r),aU(t,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),sU(r),t!==ch.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===eh.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mC(hC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,YG(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.config.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!==ch.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===eh.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new mC(hC.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,ZG(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===(f=p.localScreenStream)||void 0===f||!f.pubAudio){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return U.apply(this,arguments)})},{key:"login",value:(L=Ug(Dg().mark((function e(t,r){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("login()","token: %o, userInfo: %o",t,r),lU(t)||oU(t,"token"),pU(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return L.apply(this,arguments)})},{key:"logout",value:(D=Ug(Dg().mark((function e(){return Dg().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 D.apply(this,arguments)})},{key:"updateLoginToken",value:(M=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateLoginToken()","token: %o",t),lU(t)||oU(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return M.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(N=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("getPeerOnlineStatus()","userId: %o",t),pU(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return N.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(P=Ug(Dg().mark((function e(t,r){var n,i=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return pU(t),gU(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 P.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(O=Ug(Dg().mark((function e(t,r){var n,i=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return pU(t),uU(r,"message"),gU(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 O.apply(this,arguments)})},{key:"setServerParams",value:(x=Ug(Dg().mark((function e(t,r){return Dg().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 x.apply(this,arguments)})},{key:"sendServerMessage",value:(C=Ug(Dg().mark((function e(t){var r,n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oU(t,"message"),gU(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 C.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(w=Ug(Dg().mark((function e(t){var r,n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return uU(t,"message"),gU(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 w.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new mC(hC.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");this.logger.info("startCloudProxy()",e),oU(e.logProxy,"logProxy"),oU(e.accessProxy,"accessProxy"),oU(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=JL("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=JL("LOG_SERVER_URL"),this._originConfigServerUrls=JL("CONFIG_REQUEST_DOMAINS"),qL("ICE_CONFIG_REQUEST_URLS",e.accessProxy),qL("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)),qL("CONFIG_REQUEST_DOMAINS",[e.configProxy]),BL.clearAccessNode(this._appId),BL.clearAccessUrls(),this._ctx.useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){var e,t,r;if(this._room)throw new mC(hC.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:$g(e).call(e,(function(e){return e.replace("https://","").replace("/dispatch/v1/AccessInfo?Action=GetAccessInfo","")}));qL("ICE_CONFIG_REQUEST_URLS",null!=n?n:[]),qL("LOG_SERVER_URL",null!==(t=this._originLogServerUrl)&&void 0!==t?t:""),qL("CONFIG_REQUEST_DOMAINS",null!==(r=this._originConfigServerUrls)&&void 0!==r?r:[]),BL.clearAccessNode(this._appId),BL.clearAccessUrls(),this._ctx.useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(A=Ug(Dg().mark((function e(t,r){var n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),fU(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new mC(hC.REPEAT_PUSH,"repeat push public media stream");case 5:return o=QL(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 A.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(R=Ug(Dg().mark((function e(t,r){var n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),fU(t),this._assertNotInRoom(),i=QL(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 R.apply(this,arguments)})},{key:"stopPushPublicStream",value:(I=Ug(Dg().mark((function e(t){var r,n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startPushPublicStream()","publicStreamId: %o",t),fU(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 I.apply(this,arguments)})},{key:"startPlayPublicStream",value:(T=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return fU(t),e.next=3,this._publicStreamManager.startPlayPublicStream(t);case 3:n=e.sent,(i=this._publicVideoPlayerConfig.get(t))&&(null===(o=n.videoTrack)||void 0===o||o.setPlayer(this.id,i,null===(a=this._config)||void 0===a?void 0:a.autoPlayPolicy,this._initPlayerEvents.bind(this))),null===(r=n.videoTrack)||void 0===r||r.play(RG),n.audioTrack&&(u=new LZ(this.id,t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===Rh.VIDEO_ONLY||(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)===Rh.PLAY_MANUALLY,isScreen:!1}),n.audioTrack.setPlayer(u),this._initPlayerEvents(u,!0),u.playAudio(n.audioTrack));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(k=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._publicStreamManager.stopPlayPublicStream(t),null==(n=this._publicStreamManager.getRemoteStream(t))||null===(r=n.audioTrack)||void 0===r||r.stop();case 3:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"setAudioProfile",value:(E=Ug(Dg().mark((function e(t){return Dg().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 E.apply(this,arguments)})},{key:"setAudioEncodeMaxBitrate",value:(b=Ug(Dg().mark((function e(t){var r,n,i,o,a,s;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setAudioEncodeMaxBitrate()",t),iU(t,"maxBitrate",6,256),this._ctx.audioProfileManager.setCustomMaxBitrate(t),!this._ctx.audioProfileManager.customMaxBitrate){e.next=10;break}if(!iL||!(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 mC(hC.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(ch.STREAM_INDEX_MAIN,t);case 8:return e.next=10,null===(s=this._room)||void 0===s?void 0:s.setAudioEncodeMaxBitrate(ch.STREAM_INDEX_SCREEN,t);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i,o;this.logger.print("setPublicStreamVideoPlayer()","publicStreamId: %o, videoPlayerOption: %o",e,t);var a=this._publicStreamManager.getRemoteStream(e);if(null===(r=this._publicVideoPlayerConfig.get(e))||void 0===r||null===(n=r.player)||void 0===n||n.destroy(),t.renderDom){var s=new DZ(this._ctx.id,RG,Zl(Zl({},t),{},{isLocal:!1,userId:e})),c=Zl(Zl({},t),{},{player:s});this._publicVideoPlayerConfig.set(e,c),null==a||null===(i=a.videoTrack)||void 0===i||i.setPlayer(this.id,Zl({},c),null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy,this._initPlayerEvents.bind(this))}else this._publicVideoPlayerConfig.delete(e)}},{key:"setDummyCaptureImagePath",value:(S=Ug(Dg().mark((function e(t,r){var n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Hg((function(e,i){oU(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===ch.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new mC(hC.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new mC(hC.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return S.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===ch.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=zD(r.width),c=zD(r.height);if(!a)throw new mC(hC.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===ch.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===ch.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=Ug(Dg().mark((function e(r,n){var i,o;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=18;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.prev=2,e.next=5,t._localVideoTrack.generatePreProcessingTrack();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),t._localVideoTrack.stopAll(),t._localVideoTrack.playAll(),t.safeEmit(Fh.onLocalStreamTrackChangedByExtension,{streamIndex:ch.STREAM_INDEX_MAIN,type:"video"}),r(),null===(i=t._room)||void 0===i||null===(o=i.localStream)||void 0===o||!o.pubVideo){e.next=18;break}return e.next=18,t._updatePublish();case 18:r();case 19:case"end":return e.stop()}}),e,null,[[2,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"registerExtension",value:(y=Ug(Dg().mark((function e(t){var r,n;return Dg().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(),null===(n=this._localVideoTrack)||void 0===n||n.generatePreProcessingTrack();case 18:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return y.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(Xg(t$.getDefaultValue()))}},{key:"_updatePublish",value:(g=Ug(Dg().mark((function e(){var t,r,n,i,o=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:{},r=o.length>1&&void 0!==o[1]&&o[1],this.logger.info("_updatePublish()","config: %o",t),n={mediaType:void 0,invokeByJoinRoom:!1,pubState:sH.PUB},t=Zl(Zl({},n),t),this._ctx.visibility){e.next=7;break}throw new mC(hC.NO_PUBLISH_PERMISSION,"no publish permission");case 7:return e.next=9,this._pubLock.lock();case 9:if(i=e.sent,this._room&&this._ctx.signalingManager.isConnected()){e.next=17;break}if(i(),!r){e.next=16;break}throw new mC(hC.NOT_CONNECTED_YET,"not connected");case 16:return e.abrupt("return");case 17:return e.prev=17,e.next=20,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 20:e.next=30;break;case 22:if(e.prev=22,e.t0=e.catch(17),!(e.t0 instanceof mC)){e.next=29;break}throw e.t0.code===hC.TOKEN_NO_PUBLISH_PERMISSION&&this._room.config.setTokenPublishPrivilegeExpired(!0),e.t0;case 29:throw new mC(hC.UNEXPECTED_ERROR,"unexpected error",e.t0);case 30:return e.prev=30,i(),e.finish(30);case 33:case"end":return e.stop()}}),e,this,[[17,22,30,33]])}))),function(){return g.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(m=Ug(Dg().mark((function e(t,r){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),oU(t,"filePath"),iU(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 m.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this.logger.info("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(v=Ug(Dg().mark((function e(t,r){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),iU(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 v.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{pU(e),aU(t,"priority",[bh.HIGH,bh.MEDIUM,bh.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:(_=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("takeLocalSnapshot()","streamIndex: %o",t),aU(t,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),r=t===ch.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new mC(hC.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return e.abrupt("return",r.snapshot());case 6:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(f=Ug(Dg().mark((function e(t,r){var n,i,o,a,s;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),oU(t,"id"),aU(r,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),s=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=dI(i).call(i,(function(e){return e.isScreen===(r===ch.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._publicStreamManager.getRemoteStream(t))||void 0===a?void 0:a.videoTrack)){e.next=6;break}throw new mC(hC.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",s.snapshot());case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){this.logger.info("setSubscribeFallbackOption()","option: %o",e);try{aU(e,"option",[Sh.DISABLE,Sh.VIDEO_STREAM_LOW,Sh.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===ch.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 yG&&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(null!=o&&o.length){var a,s,c,u,d;if(t===ch.STREAM_INDEX_MAIN)a=dI(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=dI(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){var r=this._publicStreamManager.getRemoteStream(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:"setAudioSelectionConfig",value:(p=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(aU(t,"audioSelectionPriority",[Nh.DEFAULT,Nh.HIGH]),this._ctx.mediaParams||(this._ctx.mediaParams={}),this._ctx.mediaParams.audioSelectionConfig={isHighPriority:t===Nh.HIGH},!this._room){e.next=6;break}return e.next=6,this._room.updateMediaParams(this._ctx.mediaParams);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"setCaptureVolume",value:function(e,t){var r,n,i,o,a,s=this;(aU(e,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),t=EU(t,"volume",0,400),e===ch.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(pU(e),aU(t,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),r=EU(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.config.isMultiChatMode())HD("setPlaybackVolume is not supported in Conference mode");else{var s=t===ch.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:dI(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;oU(e,"publicStreamId"),t=EU(t,"volume",0,400),this._publicAudioVolume.set(e,t),null===(r=this._publicStreamManager.getRemoteStream(e))||void 0===r||null===(n=r.audioTrack)||void 0===n||n.setVolume(t)}},{key:"startForwardStreamToRooms",value:(h=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){hU(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 h.apply(this,arguments)})},{key:"updateForwardStreamToRooms",value:(l=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){hU(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 l.apply(this,arguments)})},{key:"stopForwardStreamToRooms",value:(d=Ug(Dg().mark((function e(){var t;return Dg().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 d.apply(this,arguments)})},{key:"pauseForwardStreamToAllRooms",value:(u=Ug(Dg().mark((function e(){var t;return Dg().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 u.apply(this,arguments)})},{key:"resumeForwardStreamToAllRooms",value:(c=Ug(Dg().mark((function e(){var t;return Dg().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 c.apply(this,arguments)})},{key:"ambulance",value:(s=Ug(Dg().mark((function e(){var t,r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O$(this);case 2:return t=e.sent,r=Xg(t),this.monitor.reportLongString("ambulance",r),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e,this)}))),function(){return s.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(){$M(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(a=Ug(Dg().mark((function e(){var t,r,n,i=arguments;return Dg().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:sH.PUB},t=Zl(Zl({},r),t),this._ctx.visibility){e.next=6;break}throw new mC(hC.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._ctx.signalingManager.isConnected()){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 mC)){e.next=23;break}throw e.t0;case 23:throw new mC(hC.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 a.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){var t;this.logger.info("_updateAudioPlayerState()");var r,n=e.userId,i=e.isScreen,o=null===(t=e.audioTrack)||void 0===t?void 0:t.dangerousGetPlayer();if(e.audioTrack&&e.attributes.audiostream&&e.subAudio){var a,s;if(!o){var c,u;o=new LZ(this.id,n,{muted:(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)===Rh.VIDEO_ONLY||(null===(u=this._config)||void 0===u?void 0:u.autoPlayPolicy)===Rh.PLAY_MANUALLY,isScreen:i}),this._initPlayerEvents(o,!1,i?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN),e.audioTrack.setPlayer(o);var d=this._audioDeviceManager.getSinkId();d&&o.setPlaybackDevice(d)}o.playAudio(e.audioTrack),e.audioTrack.setPlayer(o);var l=i?null!==(a=this._remoteScreenAudioVolume.get(n))&&void 0!==a?a:100:null!==(s=this._remoteAudioVolume.get(n))&&void 0!==s?s:100;if(e.audioTrack.setVolume(l),oL&&fL){var h,p,f=null!==(h=null===(p=this._room)||void 0===p?void 0:p.remoteStreams)&&void 0!==h?h:new hT;r=f,e$&&clearTimeout(e$),e$=setTimeout((function(){var e,t=by(r);try{for(t.s();!(e=t.n()).done;){var n=Ey(e.value,2),i=n[0],o=n[1];null!=i&&lC(i).call(i,"mux")&&o.forEach((function(e){var t;null===(t=e.audioTrack)||void 0===t||t.pause()}))}}catch(j0){t.e(j0)}finally{t.f()}var a,s=by(r);try{for(s.s();!(a=s.n()).done;){var c=Ey(a.value,2),u=c[0],d=c[1];null!=u&&lC(u).call(u,"mux")&&d.forEach((function(e){var t;null===(t=e.audioTrack)||void 0===t||t.play()}))}}catch(j0){s.e(j0)}finally{s.f()}}),2e3)}}else{var _;null===(_=o)||void 0===_||_.stop()}}},{key:"_updateVideoPlayerState",value:function(e){if(this.logger.info("_updateVideoPlayerState()"),e.videoTrack){var t=this._remoteVideoPlayerConfig[e.isScreen?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN].get(e.userId);if(t){var r,n=by(t);try{for(n.s();!(r=n.n()).done;){var i,o=Ey(r.value,2)[1];e.videoTrack.setPlayer(this.id,o,null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy,this._initPlayerEvents.bind(this))}}catch(j0){n.e(j0)}finally{n.f()}}}}},{key:"_onAddStream",value:(o=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c;return Dg().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=HL.NONE,o&&(c|=uh.AUDIO),s&&(c|=uh.VIDEO),!c){e.next=11;break}return e.next=8,new Hg((function(e){return setTimeout(e)}));case 8:r.isScreen?this.safeEmit(Fh.onUserPublishScreen,{userId:r.userId,mediaType:c}):(this.safeEmit(Fh.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(Fh.onUserStartAudioCapture,{userId:r.userId}),a&&this.safeEmit(Fh.onUserStartVideoCapture,{userId:r.userId}));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=HL.NONE;if(null!==(r=this._room)&&void 0!==r&&r.config.isAutoSubscribeAudio&&(i|=uh.AUDIO),null!==(n=this._room)&&void 0!==n&&n.config.isAutoSubscribeVideo&&(i|=uh.VIDEO),i){var o,a,s;if(t&&UD(i))null===(a=e.observer)||void 0===a||a.setAutoSubscribeAudio(!0);if(t&&VD(i))null===(s=e.observer)||void 0===s||s.setAutoSubscribeVideo(!0);null!==(o=this._room)&&void 0!==o&&o.config.tokenSubscribePrivilegeExpired?(UD(i)&&(this._pauseAllSubscribeState.resumeAudioStreamIds[e.streamId]=e.streamId),VD(i)&&(this._pauseAllSubscribeState.resumeVideoStreamIds[e.streamId]=e.streamId)):this._subscribe(!1,e.userId,i)}}},{key:"_onRemoveStream",value:function(e){var t,r=e.stream,n=null!==(t=p0[e.reason])&&void 0!==t?t:dh.STREAM_REMOVE_REASON_OTHER,i=r.isScreen?Fh.onUserUnpublishScreen:Fh.onUserUnpublishStream,o=HL.NONE;r.attributes.audiostream&&(o|=uh.AUDIO),r.attributes.videostream&&(o|=uh.VIDEO),o!==HL.NONE&&(this.safeEmit(i,{userId:r.userId,mediaType:o,reason:n}),this.safeEmit("onRemoveStream",{userId:r.userId,isScreen:r.isScreen})),delete this._pauseAllSubscribeState.resumeAudioStreamIds[r.streamId],delete this._pauseAllSubscribeState.resumeVideoStreamIds[r.streamId],"function"==typeof e.callback&&e.callback()}},{key:"_onUserConnection",value:function(e){var t=this;setTimeout((function(){return t.safeEmit(Fh.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){this.safeEmit(Fh.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(Fh.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,Gg(e=[Fh.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._ctx.useCloudProxy&&e.state===lh.CONNECTION_STATE_CONNECTED&&this.safeEmit(Fh.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),(this._ctx.isPreConnection||e.state!==lh.CONNECTION_STATE_CONNECTED&&e.state!==lh.CONNECTION_STATE_RECONNECTED)&&this.safeEmit(Fh.onConnectionStateChanged,e),e.state===lh.CONNECTION_STATE_RECONNECTING){var t,r,n,i=by(null!==(t=null===(r=this._room)||void 0===r?void 0:r.remoteStreams)&&void 0!==t?t:new hT);try{for(i.s();!(n=i.n()).done;){var o=Ey(n.value,2),a=o[0],s=o[1];lC(a).call(a,"mux")&&s.forEach((function(e){var t;return null===(t=e.audioTrack)||void 0===t?void 0:t.stop()}))}}catch(j0){i.e(j0)}finally{i.f()}}else e.state===lh.CONNECTION_STATE_RECONNECTED&&this._publicStreamManager.handleReconnected()}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){var t,r;e.stream&&(null===(t=e.stream.videoTrack)||void 0===t||t.stopAll(),null===(r=e.stream.audioTrack)||void 0===r||r.stop(),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(Fh.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(Fh.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&uh.AUDIO&&setTimeout((function(){t._updateAudioPlayerState(a)})),n?o===sH.PUB?this.safeEmit(Fh.onUserPublishScreen,s):this.safeEmit(Fh.onUserUnpublishScreen,Zl(Zl({},s),{},{reason:dh.STREAM_REMOVE_REASON_UNPUBLISH})):o===sH.PUB?(s.videoStreamDescriptions=a.attributes.videoDescriptions,this.safeEmit(Fh.onUserPublishStream,s),this._handleAutoSubscribe(a,!0)):this.safeEmit(Fh.onUserUnpublishStream,Zl(Zl({},s),{},{reason:dh.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(Fh.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(Fh.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Fh.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Fh.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(Fh.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(Fh.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Fh.onTokenWillExpire)}},{key:"_onUserTokenPublishPrivilegeWillExpire",value:function(){this.safeEmit(Fh.onTokenPublishPrivilegeWillExpire)}},{key:"_onUserTokenPublishPrivilegeDidExpired",value:(i=Ug(Dg().mark((function e(){var t,r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._room)||void 0===t?void 0:t.unpublish();case 2:return e.next=4,null===(r=this._room)||void 0===r?void 0:r.unpublishScreen();case 4:null===(n=this._room)||void 0===n||n.config.setTokenPublishPrivilegeExpired(!0),this.safeEmit(Fh.onTokenPublishPrivilegeDidExpired,{errorCode:hC.TOKEN_NO_PUBLISH_PERMISSION,message:"Token no longer has publish privilege"});case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_onUserTokenSubscribePrivilegeWillExpire",value:function(){this.safeEmit(Fh.onTokenSubscribePrivilegeWillExpire)}},{key:"_onUserTokenSubscribePrivilegeDidExpired",value:(n=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._handleLoseSubscribePrivilege(),this.safeEmit(Fh.onTokenSubscribePrivilegeDidExpired,{errorCode:hC.TOKEN_NO_SUBSCRIBE_PERMISSION,message:"Token no longer has subscribe privilege"});case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_unSubscribeAllRemoteStreams",value:(r=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._room){e.next=2;break}return e.abrupt("return",Hg.resolve());case 2:return e.abrupt("return",this._pauseAllRemoteStreams(uh.AUDIO_AND_VIDEO));case 3:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(Fh.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Fh.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Fh.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(Fh.onError,{errorCode:hC.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(Fh.onError,{errorCode:hC.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(Fh.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"getSubLock",value:function(e,t){var r,n=e?this._subScreenLocks:this._subLocks,i=n.get(t);i||(i=new iZ(Gg(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;return null===(e=this._ctx.peerConnection)||void 0===e?void 0:e.getIceConnectionState()}},{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.config.isMultiChatMode())}},{key:"checkMediaType",get:function(){return this._checkMediaType}},{key:"assertNotInRoom",get:function(){return this._assertNotInRoom}},{key:"peerConnection",get:function(){var e;return null===(e=this._ctx.peerConnection)||void 0===e?void 0:e.getOriginRTCPeerConnection()}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(Fh.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||!this._ctx.signalingManager.isConnected())throw new mC(hC.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){aU(e,"mediaType",[uh.AUDIO,uh.VIDEO,uh.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e;return(null===(e=this._room)||void 0===e?void 0:e.config.userInfo.userId)||"local_user"}},{key:"_switchTrack",value:(t=Ug(Dg().mark((function e(t){var r,n,i=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,this._localVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){var r;t.setPlayer(i.id,e,i._mirrorType,null===(r=i._config)||void 0===r?void 0:r.autoPlayPolicy,i._initPlayerEvents.bind(i))})),null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.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===VU.INTERNAL;if(i){var o="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: ".concat(o)),$M(this.id,e,o)}return!i}},{key:"_getServerConfig",value:function(){var e=this,t=BL.getServerConfig(this.appId);t.rts_report&&VM.setConfig(t.rts_report),this._ctx.joinRoomConfig.setServerConfig(t.web_join_room),this._preConnect(t),this._getServerConfigExecutor(t),vD({engineId:this.id,appId:this.appId,sdkVersion:JL("VERSION"),requestDomains:JL("CONFIG_REQUEST_DOMAINS"),keys:["rts_report","web_join_room","web_rtc_config"],deviceId:JL("DEVICE_ID")}).then((function(t){BL.setServerConfig(e.appId,t)}))}},{key:"_getServerConfigExecutor",value:function(e){var t,r,n,i;Fx.setParameter("UPLOAD_CONSOLE_ON",!(null==e||null===(t=e.web_rtc_config)||void 0===t||!t.upload_console_on)),Fx.setParameter("UPLOAD_CONSOLE_LENGTH_CUT",null==e||null===(r=e.web_rtc_config)||void 0===r?void 0:r.upload_console_length_cut),Fx.setParameter("UPLOAD_REPORT_LIMIT",null==e||null===(n=e.web_rtc_config)||void 0===n?void 0:n.upload_report_limit),Fx.setParameter("ENABLE_REPORT_IDB_BUFFER",!(null==e||null===(i=e.web_rtc_config)||void 0===i||!i.enable_report_idb_buffer))}},{key:"_preConnect",value:function(e){var t,r=JL("PRE_ICE");"boolean"==typeof(null==e||null===(t=e.web_rtc_config)||void 0===t?void 0:t.pre_ice)&&(r=e.web_rtc_config.pre_ice),r&&(this.logger.print("preConnect","start pre ice connection."),this._ctx.signalingManager.connect(),this.monitor.set({pre_connection:!0}),this._ctx.isPreConnection=!0)}},{key:"_getRemoteVideoPlayerConfig",value:function(e,t,r){var n;return null===(n=this._remoteVideoPlayerConfig[e].get(t))||void 0===n?void 0:n.get(r)}},{key:"_setRemoteVideoPlayerConfig",value:function(e,t,r,n){var i=this._remoteVideoPlayerConfig[e].get(t)||new hT;i.set(r,n),this._remoteVideoPlayerConfig[e].set(t,i)}}]),Le}(wU);l0([JM()],h0.prototype,"updateToken",1),l0([JM(),v0("video")],h0.prototype,"setVideoCaptureDevice",1),l0([JM(),v0("audio")],h0.prototype,"setAudioCaptureDevice",1),l0([JM()],h0.prototype,"connect",1),l0([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=YM(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)}}},JM()],h0.prototype,"joinRoom",1),l0([JM()],h0.prototype,"leaveRoom",1),l0([JM()],h0.prototype,"destroy",1),l0([JM()],h0.prototype,"publishStream",1),l0([JM()],h0.prototype,"unpublishStream",1),l0([JM()],h0.prototype,"publishScreen",1),l0([JM()],h0.prototype,"unpublishScreen",1),l0([JM()],h0.prototype,"subscribeStream",1),l0([f0],h0.prototype,"_subscribe",1),l0([JM()],h0.prototype,"unsubscribeStream",1),l0([JM()],h0.prototype,"subscribeScreen",1),l0([JM()],h0.prototype,"unsubscribeScreen",1),l0([f0],h0.prototype,"_unsubscribe",1),l0([JM(),_0],h0.prototype,"setRemoteVideoConfig",1),l0([JM(),v0("video")],h0.prototype,"startVideoCapture",1),l0([JM(),v0("video")],h0.prototype,"stopVideoCapture",1),l0([JM(),v0("audio")],h0.prototype,"startAudioCapture",1),l0([JM(),v0("audio")],h0.prototype,"stopAudioCapture",1),l0([JM(),v0("all")],h0.prototype,"startAudioAndVideoCapture",1),l0([JM()],h0.prototype,"startVideoAndAudioCapture",1),l0([JM()],h0.prototype,"getAudioMixingManager",1),l0([JM(),m0],h0.prototype,"startScreenCapture",1),l0([JM(),m0],h0.prototype,"stopScreenCapture",1),l0([JM()],h0.prototype,"setLocalVideoPlayer",1),l0([JM()],h0.prototype,"startLiveTranscoding",1),l0([JM()],h0.prototype,"updateLiveTranscoding",1),l0([JM()],h0.prototype,"stopLiveTranscoding",1),l0([JM()],h0.prototype,"startSubtitle",1),l0([JM()],h0.prototype,"updateSubtitleConfig",1),l0([JM()],h0.prototype,"stopSubtitle",1),l0([JM()],h0.prototype,"setBusinessId",1),l0([JM()],h0.prototype,"setUserVisibility",1),l0([JM()],h0.prototype,"setRemoteVideoPlayer",1),l0([JM()],h0.prototype,"setLocalVideoMirrorType",1),l0([JM()],h0.prototype,"setAudioPlaybackDevice",1),l0([JM()],h0.prototype,"play",1),l0([JM()],h0.prototype,"stop",1),l0([JM()],h0.prototype,"getAudioVolume",1),l0([JM()],h0.prototype,"pauseAllSubscribedStream",1),l0([JM()],h0.prototype,"resumeAllSubscribedStream",1),l0([JM()],h0.prototype,"sendUserMessage",1),l0([JM()],h0.prototype,"sendUserBinaryMessage",1),l0([JM()],h0.prototype,"sendRoomMessage",1),l0([JM()],h0.prototype,"sendRoomBinaryMessage",1),l0([JM()],h0.prototype,"setAudioCaptureConfig",1),l0([GD("4.51"),JM()],h0.prototype,"setVideoCaptureConfig",1),l0([JM()],h0.prototype,"enableSimulcastMode",1),l0([JM()],h0.prototype,"setVideoEncoderConfig",1),l0([JM()],h0.prototype,"setScreenEncoderConfig",1),l0([JM()],h0.prototype,"sendSEIMessage",1),l0([GD("4.42"),JM()],h0.prototype,"setAudioVolumeIndicationInterval",1),l0([JM()],h0.prototype,"enableAudioPropertiesReport",1),l0([JM()],h0.prototype,"setVideoSourceType",1),l0([JM()],h0.prototype,"setExternalVideoTrack",1),l0([JM()],h0.prototype,"setAudioSourceType",1),l0([JM()],h0.prototype,"setExternalAudioTrack",1),l0([JM()],h0.prototype,"login",1),l0([JM()],h0.prototype,"logout",1),l0([JM()],h0.prototype,"updateLoginToken",1),l0([JM()],h0.prototype,"getPeerOnlineStatus",1),l0([JM()],h0.prototype,"sendUserMessageOutsideRoom",1),l0([JM()],h0.prototype,"sendUserBinaryMessageOutsideRoom",1),l0([JM()],h0.prototype,"setServerParams",1),l0([JM()],h0.prototype,"sendServerMessage",1),l0([JM()],h0.prototype,"sendServerBinaryMessage",1),l0([JM()],h0.prototype,"startCloudProxy",1),l0([JM()],h0.prototype,"stopCloudProxy",1),l0([JM()],h0.prototype,"startPushPublicStream",1),l0([JM()],h0.prototype,"updatePublicStreamParam",1),l0([JM()],h0.prototype,"stopPushPublicStream",1),l0([JM("streamId")],h0.prototype,"startPlayPublicStream",1),l0([JM("streamId")],h0.prototype,"stopPlayPublicStream",1),l0([JM()],h0.prototype,"setAudioProfile",1),l0([JM()],h0.prototype,"setAudioEncodeMaxBitrate",1),l0([JM()],h0.prototype,"setPublicStreamVideoPlayer",1),l0([JM()],h0.prototype,"setDummyCaptureImagePath",1),l0([JM()],h0.prototype,"registerExtension",1),l0([JM()],h0.prototype,"startAudioPlaybackDeviceTest",1),l0([JM()],h0.prototype,"stopAudioPlaybackDeviceTest",1),l0([JM()],h0.prototype,"startAudioDeviceRecordTest",1),l0([JM()],h0.prototype,"stopAudioDeviceRecordAndPlayTest",1),l0([JM()],h0.prototype,"stopAudioDevicePlayTest",1),l0([JM(),_0],h0.prototype,"setRemoteUserPriority",1),l0([JM()],h0.prototype,"takeLocalSnapshot",1),l0([JM()],h0.prototype,"takeRemoteSnapshot",1),l0([JM()],h0.prototype,"setSubscribeFallbackOption",1),l0([JM()],h0.prototype,"getLocalStreamTrack",1),l0([JM()],h0.prototype,"getRemoteStreamTrack",1),l0([JM()],h0.prototype,"getPublicStreamTrack",1),l0([JM()],h0.prototype,"setRemoteStreamRenderSync",1),l0([JM()],h0.prototype,"setJoinRoomParams",1),l0([JM()],h0.prototype,"setAudioSelectionConfig",1),l0([JM()],h0.prototype,"startForwardStreamToRooms",1),l0([JM()],h0.prototype,"updateForwardStreamToRooms",1),l0([JM()],h0.prototype,"stopForwardStreamToRooms",1),l0([JM()],h0.prototype,"pauseForwardStreamToAllRooms",1),l0([JM()],h0.prototype,"resumeForwardStreamToAllRooms",1);var p0={"client unpublished":dh.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":dh.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":dh.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":dh.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":dh.STREAM_REMOVE_REASON_REPUBLISH,"token publish privilege expired":dh.STREAM_REMOVE_REASON_TOKEN_PRIVILEGE_EXPIRED};function f0(e,t,r){var n=r.value;return r.value=Ug(Dg().mark((function e(){var t,r,i,o,a,s,c,u=arguments;return Dg().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 _0(e,t,r){var n=r.value;return r.value=Ug(Dg().mark((function e(){var t,r,i,o,a,s=arguments;return Dg().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 v0(e){return function(t,r,n){var i=n.value;return n.value=Ug(Dg().mark((function t(){var r,n,o,a,s,c=arguments;return Dg().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,Hg.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 m0(e,t,r){var n=r.value;return r.value=Ug(Dg().mark((function e(){var t,r,i,o,a=arguments;return Dg().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 g0,y0=pT,S0=KI,b0=function(e,t,r,n){for(var i,o=n>1?void 0:n?S0(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&&y0(t,r,o),o},E0=function(e){jA(i,e);var t,r,n=iw(i);function i(e,t,r){var o;return Gh(this,i),Jl(dA(o=n.call(this,e,t,r)),"singleStreamRenderMode",!1),o.id=t,o.logger=new fD("BLWEngine",0,t),$L([{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 jh(i,[{key:"subscribeStream",value:(r=Ug(Dg().mark((function e(t,r){var n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("subscribeStream()","userId: %o, mediaType: %o",t,r),this.singleStreamRenderMode&&VD(r)&&FA(VA(i.prototype),"subscribeScreen",this).call(this,t,uh.VIDEO).catch((function(e){n.logger.error("singleStreamRenderMode subscribeScreen()",e)})),e.abrupt("return",FA(VA(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=Ug(Dg().mark((function e(t,r){var n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this.singleStreamRenderMode&&VD(r)&&FA(VA(i.prototype),"unsubscribeScreen",this).call(this,t,uh.VIDEO).catch((function(e){n.logger.error("singleStreamRenderMode unsubscribeScreen()",e)})),e.abrupt("return",FA(VA(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){return this.logger.print("setRemoteScreenVideoStreamIndex()","streamIndex: %o",e),!this._room&&(this.singleStreamRenderMode=e===ch.STREAM_INDEX_MAIN,!0)}},{key:"setRemoteVideoPlayer",value:function(e,t){if(this.logger.print("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),null==t||delete t.playerId,!this.singleStreamRenderMode||e!==ch.STREAM_INDEX_SCREEN)return FA(VA(i.prototype),"setRemoteVideoPlayer",this).call(this,e,t)}},{key:"destroy",value:function(){this.singleStreamRenderMode=!1,FA(VA(i.prototype),"destroy",this).call(this)}},{key:"_updateVideoPlayerState",value:function(e){var t,r,n,o,a;if(!this.singleStreamRenderMode)return FA(VA(i.prototype),"_updateVideoPlayerState",this).call(this,e);var s,c,u=e.userId,d=null===(t=this._room)||void 0===t?void 0:t.remoteStreams.get(u);Array.isArray(d)&&d.forEach((function(e){e.isScreen?s=e:c=e}));var l,h,p,f=null===(r=c)||void 0===r||null===(n=r.videoTrack)||void 0===n?void 0:n.dangerousGetPlayer(RG);if(!f){var _,v,m,g,y,S,b=null===(_=this._remoteVideoPlayerConfig[ch.STREAM_INDEX_MAIN].get(u))||void 0===_?void 0:_.get(RG);if(!b)return;null===(v=c)||void 0===v||null===(m=v.videoTrack)||void 0===m||m.setPlayer(this.id,b,null===(g=this._config)||void 0===g?void 0:g.autoPlayPolicy,this._initPlayerEvents.bind(this)),f=null===(y=c)||void 0===y||null===(S=y.videoTrack)||void 0===S?void 0:S.dangerousGetPlayer(RG)}if(!e.isScreen&&null!==(o=s)&&void 0!==o&&o.videoTrack&&s.videoHasPublish)return this.logger.print("_updateVideoPlayerState","prevent play main stream"),void(null===(l=f)||void 0===l||l.playVideo(s.videoTrack));e.videoTrack?(null===(h=this._config)||void 0===h?void 0:h.autoPlayPolicy)!==Rh.PLAY_MANUALLY&&(null===(p=f)||void 0===p||p.playVideo(e.videoTrack)):null!==(a=f)&&void 0!==a&&a.played&&f.stop()}},{key:"_handleEngineEvents",value:function(){var e=this;this.on(Fh.onUserPublishScreen,(function(t){if(e.singleStreamRenderMode&&VD(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:dI(i).call(i,(function(e){return!e.isScreen})),a=null==i?void 0:dI(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._room)&&void 0!==n&&n.config.isAutoSubscribeVideo||null!=o&&o.hasSubscribed&&VD(o.subMediaType))&&(e.logger.info("onUserPublishScreen","singleStreamRenderMode subscribeScreen"),e.subscribeScreen(t.userId,uh.VIDEO))}})),this.on(Fh.onUserUnpublishScreen,(function(t){if(e.singleStreamRenderMode&&VD(t.mediaType)){var r,n=null===(r=e._room)||void 0===r?void 0:r.remoteStreams.get(t.userId),i=null==n?void 0:dI(n).call(n,(function(e){return!e.isScreen}));i&&setTimeout((function(){e._updateVideoPlayerState(i)}))}}))}}]),i}(h0);b0([JM()],E0.prototype,"subscribeStream",1),b0([JM()],E0.prototype,"unsubscribeStream",1),b0([JM()],E0.prototype,"setRemoteScreenVideoStreamIndex",1),b0([JM()],E0.prototype,"setRemoteVideoPlayer",1),b0([JM()],E0.prototype,"destroy",1);var k0=new fD("VERTC",0);Cx.storeKey=Gg(g0="".concat(Date.now(),"-")).call(g0,BL.getDeviceId()),BM({rtc_sdk_version:YL.VERSION,device_id:BL.getDeviceId(),log_cache_key:Cx.storeKey}),jM(YL.LOG_SERVER_URL);var T0=1,I0=function(e,t){k0.info("createEngine","Invoke VERTC.createEngine"),oU(e,"appId");var r=(T0++).toString();return qM(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new h0(e,r,t)},R0=function(e,t){k0.print("createBLWEngine","Invoke VERTC.createBLWEngine"),oU(e,"appId");var r=(T0++).toString();return qM(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new E0(e,r,t)},A0=function(e){if(k0.info("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof h0))throw new mC(hC.INVALID_ENGINE,"Invalid engine object");var t;e.destroy(),(t=e.monitor).report("sdk_init_engine",{start:Date.now(),type:"end"}),XM.delete(t.id)},w0=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",OG.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),C0=function(){var e=Ug(Dg().mark((function e(){var t,r,n,i,o,a=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=(t=a.length>0&&void 0!==a[0]?a[0]:{video:!0,audio:!0}).video,n=t.audio,i={video:!1,audio:!1},o=[],r&&o.push(OG.getPermissions({video:!0,force:!0}).then((function(e){i.video=e.video,e.video||(i.videoExceptionError=e.reason)}))),n&&o.push(OG.getPermissions({audio:!0,force:!0}).then((function(e){i.audio=e.audio,e.audio||(i.audioExceptionError=e.reason)}))),e.next=8,Hg.allSettled(o);case 8:return e.abrupt("return",i);case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),x0=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",OG.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),O0=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",OG.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),P0=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",OG.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),N0=function(){return YL.VERSION},M0=function(){return WU()},D0=function(){return YU()},L0=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(Cx.logLevel=t),r&&(Cx.LogfileSize=r)},U0=function(e){Cx.download(e)};function V0(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Xg($g(t).call(t,(function(e){return e instanceof h0?"[ENGINE]":e})))}function F0(e,t){return function(){HM(t,0,V0.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 zM(t,0,V0(e)),e})).catch((function(e){throw zM(t,e.code,e.message),e})):(zM(t,0,V0(r)),r)}}return Zl(Zl(Zl(Zl({},new(jh((function e(){Gh(this,e),Jl(this,"getSdkVersion",F0(N0,"getSdkVersion")),Jl(this,"createEngine",F0(I0,"createEngine")),Jl(this,"createBLWEngine",F0(R0,"createBLWEngine")),Jl(this,"destroyEngine",F0(A0,"destroyEngine")),Jl(this,"enumerateDevices",F0(w0,"enumerateDevices")),Jl(this,"enableDevices",F0(C0,"enableDevices")),Jl(this,"enumerateAudioCaptureDevices",F0(x0,"enumerateAudioCaptureDevices")),Jl(this,"enumerateVideoCaptureDevices",F0(O0,"enumerateVideoCaptureDevices")),Jl(this,"enumerateAudioPlaybackDevices",F0(P0,"enumerateAudioPlaybackDevices")),Jl(this,"getParameter",JL),Jl(this,"setParameter",qL),Jl(this,"isSupported",F0(M0,"isSupported")),Jl(this,"getSupportedCodecs",F0(D0,"getSupportedCodecs")),Jl(this,"events",Fh),Jl(this,"ErrorCode",hC),Jl(this,"platform","BytePlus"),Jl(this,"commitInfo","HEAD<f43b788*>"),Jl(this,"downloadLog",F0(U0,"downloadLog")),Jl(this,"setLogConfig",F0(L0,"setLogConfig"))})))),Mh),Vh),{},{events:Fh})}));
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,l=c.call,d="object"==typeof Reflect&&Reflect.apply||(s?l.bind(u):function(){return l.apply(u,arguments)}),h=a,f=Function.prototype,v=f.call,p=h&&f.bind.bind(v,v),_=h?p:function(e){return function(){return v.apply(e,arguments)}},m=_,g=m({}.toString),y=m("".slice),S=function(e){return y(g(e),8,-1)},b=S,E=_,k=function(e){if("Function"===b(e))return E(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},C={},w=!o((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),x=a,O=Function.prototype.call,N=x?O.bind(O):function(){return O.apply(O,arguments)},P={},M={}.propertyIsEnumerable,D=Object.getOwnPropertyDescriptor,L=D&&!M.call({1:2},1);P.f=L?function(e){var t=D(this,e);return!!t&&t.enumerable}:M;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=_("".split),z=B((function(){return!H("z").propertyIsEnumerable(0)}))?function(e){return"String"===j(e)?G(e,""):H(e)}:H,W=function(e){return null==e},K=W,X=TypeError,Y=function(e){if(K(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=_({}.isPrototypeOf),ce="undefined"!=typeof navigator&&String(navigator.userAgent)||"",ue=i,le=ce,de=ue.process,he=ue.Deno,fe=de&&de.versions||he&&he.version,ve=fe&&fe.v8;ve&&(V=(U=ve.split("."))[0]>0&&U[0]<4?1:+(U[0]+U[1])),!V&&le&&(!(U=le.match(/Edge\/(\d+)/))||U[1]>=74)&&(U=le.match(/Chrome\/(\d+)/))&&(V=+U[1]);var pe=V,_e=pe,me=o,ge=i.String,ye=!!Object.getOwnPropertySymbols&&!me((function(){var e=Symbol("symbol detection");return!ge(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&_e&&_e<41})),Se=ye&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,be=ae,Ee=A,ke=se,Te=Object,Ie=Se?function(e){return"symbol"==typeof e}:function(e){var t=be("Symbol");return Ee(t)&&ke(t.prototype,Te(e))},Re=String,Ae=function(e){try{return Re(e)}catch(t){return"Object"}},Ce=A,we=Ae,xe=TypeError,Oe=function(e){if(Ce(e))return e;throw xe(we(e)+" is not a function")},Ne=Oe,Pe=W,Me=function(e,t){var r=e[t];return Pe(r)?void 0:Ne(r)},De=N,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,{}),We=ze;(Fe.exports=function(e,t){return We[e]||(We[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 Ke=Fe.exports,Xe=Y,Ye=Object,qe=function(e){return Ye(Xe(e))},Je=qe,Qe=_({}.hasOwnProperty),Ze=Object.hasOwn||function(e,t){return Qe(Je(e),t)},$e=_,et=0,tt=Math.random(),rt=$e(1..toString),nt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+rt(++et+tt,36)},it=Ke,ot=Ze,at=nt,st=ye,ct=Se,ut=i.Symbol,lt=it("wks"),dt=ct?ut.for||ut:ut&&ut.withoutSetter||at,ht=function(e){return ot(lt,e)||(lt[e]=st&&ot(ut,e)?ut[e]:dt("Symbol."+e)),lt[e]},ft=N,vt=ee,pt=Ie,_t=Me,mt=function(e,t){var r,n;if("string"===t&&Le(r=e.toString)&&!Ue(n=De(r,e)))return n;if(Le(r=e.valueOf)&&!Ue(n=De(r,e)))return n;if("string"!==t&&Le(r=e.toString)&&!Ue(n=De(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)||pt(e))return e;var r,n=_t(e,yt);if(n){if(void 0===t&&(t="default"),r=ft(n,e,t),!vt(r)||pt(r))return r;throw gt("Can't convert object to primitive value")}return void 0===t&&(t="number"),mt(e,t)},bt=Ie,Et=function(e){var t=St(e,"string");return bt(t)?t:t+""},kt=ee,Tt=i.document,It=kt(Tt)&&kt(Tt.createElement),Rt=function(e){return It?Tt.createElement(e):{}},At=Rt,Ct=!w&&!o((function(){return 7!==Object.defineProperty(At("div"),"a",{get:function(){return 7}}).a})),wt=w,xt=N,Ot=P,Nt=F,Pt=Q,Mt=Et,Dt=Ze,Lt=Ct,Ut=Object.getOwnPropertyDescriptor;C.f=wt?Ut:function(e,t){if(e=Pt(e),t=Mt(t),Lt)try{return Ut(e,t)}catch(r){}if(Dt(e,t))return Nt(!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===Wt||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",Wt=jt.POLYFILL="P",Kt=jt,Xt=Oe,Yt=a,qt=k(k.bind),Jt=function(e,t){return Xt(e),void 0===t?e:Yt?qt(e,t):function(){return e.apply(t,arguments)}},Qt={},Zt=w&&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=w,ir=Ct,or=Zt,ar=rr,sr=Et,cr=TypeError,ur=Object.defineProperty,lr=Object.getOwnPropertyDescriptor,dr="enumerable",hr="configurable",fr="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&&fr in r&&!r[fr]){var n=lr(e,t);n&&n[fr]&&(e[t]=r.value,r={configurable:hr in r?r[hr]:n[hr],enumerable:dr in r?r[dr]:n[dr],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,pr=F,_r=w?function(e,t,r){return vr.f(e,t,pr(1,r))}:function(e,t,r){return e[t]=r,e},mr=i,gr=d,yr=k,Sr=A,br=C.f,Er=Kt,kr=te,Tr=Jt,Ir=_r,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},Cr=function(e,t){var r,n,i,o,a,s,c,u,l,d=e.target,h=e.global,f=e.stat,v=e.proto,p=h?mr:f?mr[d]:(mr[d]||{}).prototype,_=h?kr:kr[d]||Ir(kr,d,{})[d],m=_.prototype;for(o in t)n=!(r=Er(h?o:d+(f?".":"#")+o,e.forced))&&p&&Rr(p,o),s=_[o],n&&(c=e.dontCallGetSet?(l=br(p,o))&&l.value:p[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(_,o,u),v&&(Rr(kr,i=d+"Prototype")||Ir(kr,i,{}),Ir(kr[i],o,a),e.real&&m&&(r||!m[o])&&Ir(m,o,a)))},wr=Math.ceil,xr=Math.floor,Or=Math.trunc||function(e){var t=+e;return(t>0?xr:wr)(t)},Nr=function(e){var t=+e;return t!=t||0===t?0:Or(t)},Pr=Nr,Mr=Math.max,Dr=Math.min,Lr=function(e,t){var r=Pr(e);return r<0?Mr(r+t,0):Dr(r,t)},Ur=Nr,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,Wr=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}},Kr={includes:Wr(!0),indexOf:Wr(!1)},Xr={},Yr=Ze,qr=Q,Jr=Kr.indexOf,Qr=Xr,Zr=_([].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;Cr({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 ln="[object z]"===String(un),dn=ln,hn=A,fn=S,vn=ht("toStringTag"),pn=Object,_n="Arguments"===fn(function(){return arguments}()),mn=dn?fn:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=pn(e),vn))?r:_n?fn(t):"Object"===(n=fn(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={},En=w,kn=Zt,Tn=Qt,In=rr,Rn=Q,An=nn;bn.f=En&&!kn?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 Cn,wn=ae("document","documentElement"),xn=nt,On=Ke("keys"),Nn=function(e){return On[e]||(On[e]=xn(e))},Pn=rr,Mn=bn,Dn=en,Ln=Xr,Un=wn,Vn=Rt,Fn="prototype",Bn="script",jn=Nn("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},Wn=function(){try{Cn=new ActiveXObject("htmlfile")}catch(i){}var e,t,r;Wn="undefined"!=typeof document?document.domain&&Cn?zn(Cn):(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(Cn);for(var n=Dn.length;n--;)delete Wn[Fn][Dn[n]];return Wn()};Ln[jn]=!0;var Kn=Object.create||function(e,t){var r;return null!==e?(Hn[Fn]=Pn(e),r=new Hn,Hn[Fn]=null,r[jn]=e):r=Wn(),void 0===t?r:Mn.f(r,t)},Xn={},Yn=$r,qn=en.concat("length","prototype");Xn.f=Object.getOwnPropertyNames||function(e){return Yn(e,qn)};var Jn={},Qn=Et,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,li=ai,di="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Jn.f=function(e){return di&&"Window"===si(e)?function(e){try{return ui(e)}catch(t){return li(di)}}(e):ui(ci(e))};var hi={};hi.f=Object.getOwnPropertySymbols;var fi=_r,vi=function(e,t,r,n){return n&&n.enumerable?e[t]=r:fi(e,t,r),e},pi=Qt,_i=function(e,t,r){return pi.f(e,t,r)},mi={},gi=ht;mi.f=gi;var yi,Si,bi,Ei=te,ki=Ze,Ti=mi,Ii=Qt.f,Ri=function(e){var t=Ei.Symbol||(Ei.Symbol={});ki(t,e)||Ii(t,e,{value:Ti.f(e)})},Ai=N,Ci=ae,wi=ht,xi=vi,Oi=function(){var e=Ci("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=wi("toPrimitive");t&&!t[n]&&xi(t,n,(function(e){return Ai(r,this)}),{arity:1})},Ni=mn,Pi=ln?{}.toString:function(){return"[object "+Ni(this)+"]"},Mi=ln,Di=Qt.f,Li=_r,Ui=Ze,Vi=Pi,Fi=ht("toStringTag"),Bi=function(e,t,r,n){if(e){var i=r?e:e.prototype;Ui(i,Fi)||Di(i,Fi,{configurable:!0,value:t}),n&&!Mi&&Li(i,"toString",Vi)}},ji=A,Hi=i.WeakMap,Gi=ji(Hi)&&/native code/.test(String(Hi)),zi=i,Wi=ee,Ki=_r,Xi=Ze,Yi=ze,qi=Nn,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,Ki(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(!Wi(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=_(Function.toString);oo(ao.inspectSource)||(ao.inspectSource=function(e){return so(e)});var co=ao.inspectSource,uo=_,lo=o,ho=A,fo=mn,vo=co,po=function(){},_o=[],mo=ae("Reflect","construct"),go=/^\s*(?:class|function)\b/,yo=uo(go.exec),So=!go.exec(po),bo=function(e){if(!ho(e))return!1;try{return mo(po,_o,e),!0}catch(t){return!1}},Eo=function(e){if(!ho(e))return!1;switch(fo(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return So||!!yo(go,vo(e))}catch(t){return!0}};Eo.sham=!0;var ko=!mo||lo((function(){var e;return bo(bo.call)||!bo(Object)||!bo((function(){e=!0}))||e}))?Eo:bo,To=io,Io=ko,Ro=ee,Ao=ht("species"),Co=Array,wo=function(e){var t;return To(e)&&(t=e.constructor,(Io(t)&&(t===Co||To(t.prototype))||Ro(t)&&null===(t=t[Ao]))&&(t=void 0)),void 0===t?Co:t},xo=function(e,t){return new(wo(e))(0===t?0:t)},Oo=Jt,No=z,Po=qe,Mo=jr,Do=xo,Lo=_([].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,l,d){for(var h,f,v=Po(c),p=No(v),_=Oo(u,l),m=Mo(p),g=0,y=d||Do,S=t?y(c,m):r||a?y(c,0):void 0;m>g;g++)if((s||g in p)&&(f=_(h=p[g],g,v),e))if(t)S[g]=f;else if(f)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=Cr,Bo=i,jo=N,Ho=_,Go=w,zo=ye,Wo=o,Ko=Ze,Xo=se,Yo=rr,qo=Q,Jo=Et,Qo=Sn,Zo=F,$o=Kn,ea=nn,ta=Xn,ra=Jn,na=hi,ia=C,oa=Qt,aa=bn,sa=P,ca=vi,ua=_i,la=Ke,da=Xr,ha=nt,fa=ht,va=mi,pa=Ri,_a=Oi,ma=Bi,ga=ro,ya=Vo.forEach,Sa=Nn("hidden"),ba="Symbol",Ea="prototype",ka=ga.set,Ta=ga.getterFor(ba),Ia=Object[Ea],Ra=Bo.Symbol,Aa=Ra&&Ra[Ea],Ca=Bo.TypeError,wa=Bo.QObject,xa=ia.f,Oa=oa.f,Na=ra.f,Pa=sa.f,Ma=Ho([].push),Da=la("symbols"),La=la("op-symbols"),Ua=la("wks"),Va=!wa||!wa[Ea]||!wa[Ea].findChild,Fa=Go&&Wo((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=Da[e]=$o(Aa);return ka(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),Ko(Da,n)?(r.enumerable?(Ko(e,Sa)&&e[Sa][n]&&(e[Sa][n]=!1),r=$o(r,{enumerable:Zo(0,!1)})):(Ko(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(Ka(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(Pa,this,t);return!(this===Ia&&Ko(Da,t)&&!Ko(La,t))&&(!(r||!Ko(this,t)||!Ko(Da,t)||Ko(this,Sa)&&this[Sa][t])||r)},za=function(e,t){var r=qo(e),n=Jo(t);if(r!==Ia||!Ko(Da,n)||Ko(La,n)){var i=xa(r,n);return!i||!Ko(Da,n)||Ko(r,Sa)&&r[Sa][n]||(i.enumerable=!0),i}},Wa=function(e){var t=Na(qo(e)),r=[];return ya(t,(function(e){Ko(Da,e)||Ko(da,e)||Ma(r,e)})),r},Ka=function(e){var t=e===Ia,r=Na(t?La:qo(e)),n=[];return ya(r,(function(e){!Ko(Da,e)||t&&!Ko(Ia,e)||Ma(n,Da[e])})),n};zo||(Ra=function(){if(Xo(Aa,this))throw Ca("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),Ko(this,Sa)&&Ko(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[Ea],"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=Wa,na.f=Ka,va.f=function(e){return Ba(fa(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){pa(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:Wa}),_a(),ma(Ra,ba),da[Sa]=!0;var Xa=ye&&!!Symbol.for&&!!Symbol.keyFor,Ya=Cr,qa=ae,Ja=Ze,Qa=Sn,Za=Ke,$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=Cr,ns=Ze,is=Ie,os=Ae,as=Xa,ss=Ke("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=_([].slice),us=io,ls=A,ds=S,hs=Sn,fs=_([].push),vs=Cr,ps=ae,_s=d,ms=N,gs=_,ys=o,Ss=A,bs=Ie,Es=cs,ks=function(e){if(ls(e))return e;if(us(e)){for(var t=e.length,r=[],n=0;n<t;n++){var i=e[n];"string"==typeof i?fs(r,i):"number"!=typeof i&&"Number"!==ds(i)&&"String"!==ds(i)||fs(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=ps("JSON","stringify"),As=gs(/./.exec),Cs=gs("".charAt),ws=gs("".charCodeAt),xs=gs("".replace),Os=gs(1..toString),Ns=/[\uD800-\uDFFF]/g,Ps=/^[\uD800-\uDBFF]$/,Ms=/^[\uDC00-\uDFFF]$/,Ds=!Ts||ys((function(){var e=ps("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=Es(arguments),n=ks(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},_s(Rs,null,r)},Vs=function(e,t,r){var n=Cs(r,t-1),i=Cs(r,t+1);return As(Ps,e)&&!As(Ms,i)||As(Ms,e)&&!As(Ps,n)?"\\u"+Os(ws(e,0),16):e};Rs&&vs({target:"JSON",stat:!0,arity:3,forced:Ds||Ls},{stringify:function(e,t,r){var n=Es(arguments),i=_s(Ds?Us:Rs,null,n);return Ls&&"string"==typeof i?xs(i,Ns,Vs):i}});var Fs=hi,Bs=qe;Cr({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=pe,Ws=ht("species"),Ks=function(e){return zs>=51||!Gs((function(){var t=[];return(t.constructor={})[Ws]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Xs=Vo.filter;Cr({target:"Array",proto:!0,forced:!Ks("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=Cr,ic=o,oc=Q,ac=C.f,sc=w;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 lc=rc.exports,dc=r(lc),hc=w,fc=io,vc=TypeError,pc=Object.getOwnPropertyDescriptor,_c=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(fc(e)&&!pc(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=_c,Ec=gc;Cr({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;Ec(r+n);for(var i=0;i<n;i++)t[r]=arguments[i],r++;return bc(t,r),r}});var kc,Tc,Ic,Rc=qs("Array").push,Ac=se,Cc=Rc,wc=Array.prototype,xc=r((function(e){var t=e.push;return e===wc||Ac(wc,e)&&t===wc.push?Cc:t})),Oc={},Nc=w,Pc=Ze,Mc=Function.prototype,Dc=Nc&&Object.getOwnPropertyDescriptor,Lc=Pc(Mc,"name"),Uc={EXISTS:Lc,PROPER:Lc&&"something"===function(){}.name,CONFIGURABLE:Lc&&(!Nc||Nc&&Dc(Mc,"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=Nn("IE_PROTO"),zc=Object,Wc=zc.prototype,Kc=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?Wc:null},Xc=o,Yc=A,qc=ee,Jc=Kn,Qc=Kc,Zc=vi,$c=ht("iterator"),eu=!1;[].keys&&("next"in(Ic=[].keys())?(Tc=Qc(Qc(Ic)))!==Object.prototype&&(kc=Tc):eu=!0);var tu=!qc(kc)||Xc((function(){var e={};return kc[$c].call(e)!==e}));Yc((kc=tu?{}:Jc(kc))[$c])||Zc(kc,$c,(function(){return this}));var ru={IteratorPrototype:kc,BUGGY_SAFARI_ITERATORS:eu},nu=ru.IteratorPrototype,iu=Kn,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},lu=_,du=Oe,hu=A,fu=String,vu=TypeError,pu=function(e,t,r){try{return lu(du(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(n){}},_u=rr,mu=function(e){if("object"==typeof e||hu(e))return e;throw vu("Can't set "+fu(e)+" as a prototype")},gu=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=pu(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return _u(r),mu(n),t?e(r,n):r.__proto__=n,r}}():void 0),yu=Cr,Su=N,bu=Uc,Eu=uu,ku=Kc,Tu=Bi,Iu=vi,Ru=Oc,Au=ru,Cu=bu.PROPER,wu=Au.BUGGY_SAFARI_ITERATORS,xu=ht("iterator"),Ou="keys",Nu="values",Pu="entries",Mu=function(){return this},Du=function(e,t,r,n,i,o,a){Eu(r,t,n);var s,c,u,l=function(e){if(e===i&&p)return p;if(!wu&&e in f)return f[e];switch(e){case Ou:case Nu:case Pu:return function(){return new r(this,e)}}return function(){return new r(this)}},d=t+" Iterator",h=!1,f=e.prototype,v=f[xu]||f["@@iterator"]||i&&f[i],p=!wu&&v||l(i),_="Array"===t&&f.entries||v;if(_&&(s=ku(_.call(new e)))!==Object.prototype&&s.next&&(Tu(s,d,!0,!0),Ru[d]=Mu),Cu&&i===Nu&&v&&v.name!==Nu&&(h=!0,p=function(){return Su(v,this)}),i)if(c={values:l(Nu),keys:o?p:l(Ou),entries:l(Pu)},a)for(u in c)(wu||h||!(u in f))&&Iu(f,u,c[u]);else yu({target:t,proto:!0,forced:wu||h},c);return a&&f[xu]!==p&&Iu(f,xu,p,{name:i}),Ru[t]=p,c},Lu=function(e,t){return{value:e,done:t}},Uu=Q,Vu=Oc,Fu=ro;Qt.f;var Bu=Du,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 Wu={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},Ku=i,Xu=mn,Yu=_r,qu=Oc,Ju=ht("toStringTag");for(var Qu in Wu){var Zu=Ku[Qu],$u=Zu&&Zu.prototype;$u&&Xu($u)!==Ju&&Yu($u,Ju,Qu),qu[Qu]=qu.Array}var el=o,tl=function(e,t){var r=[][e];return!!r&&el((function(){r.call(null,t||function(){return 1},1)}))},rl=Vo.forEach,nl=tl("forEach")?[].forEach:function(e){return rl(this,e,arguments.length>1?arguments[1]:void 0)};Cr({target:"Array",proto:!0,forced:[].forEach!==nl},{forEach:nl});var il=qs("Array").forEach,ol=mn,al=Ze,sl=se,cl=il,ul=Array.prototype,ll={DOMTokenList:!0,NodeList:!0},dl=r((function(e){var t=e.forEach;return e===ul||sl(ul,e)&&t===ul.forEach||al(ll,ol(e))?cl:t})),hl=ae,fl=Xn,vl=hi,pl=rr,_l=_([].concat),ml=hl("Reflect","ownKeys")||function(e){var t=fl.f(pl(e)),r=vl.f;return r?_l(t,r(e)):t},gl=ml,yl=Q,Sl=C,bl=ei;Cr({target:"Object",stat:!0,sham:!w},{getOwnPropertyDescriptors:function(e){for(var t,r,n=yl(e),i=Sl.f,o=gl(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&bl(a,t,r);return a}});var El=r(te.Object.getOwnPropertyDescriptors),kl={exports:{}},Tl=Cr,Il=w,Rl=bn.f;Tl({target:"Object",stat:!0,forced:Object.defineProperties!==Rl,sham:!Il},{defineProperties:Rl});var Al=te.Object,Cl=kl.exports=function(e,t){return Al.defineProperties(e,t)};Al.defineProperties.sham&&(Cl.sham=!0);var wl=r(kl.exports),xl={exports:{}},Ol=Cr,Nl=w,Pl=Qt.f;Ol({target:"Object",stat:!0,forced:Object.defineProperty!==Pl,sham:!Nl},{defineProperty:Pl});var Ml=te.Object,Dl=xl.exports=function(e,t,r){return Ml.defineProperty(e,t,r)};Ml.defineProperty.sham&&(Dl.sham=!0);var Ll=xl.exports,Ul=r(Ll),Vl=Cr,Fl=o,Bl=io,jl=ee,Hl=qe,Gl=jr,zl=gc,Wl=ei,Kl=xo,Xl=Ks,Yl=pe,ql=ht("isConcatSpreadable"),Jl=Yl>=51||!Fl((function(){var e=[];return e[ql]=!1,e.concat()[0]!==e})),Ql=function(e){if(!jl(e))return!1;var t=e[ql];return void 0!==t?!!t:Bl(e)};Vl({target:"Array",proto:!0,arity:1,forced:!Jl||!Xl("concat")},{concat:function(e){var t,r,n,i,o,a=Hl(this),s=Kl(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(Ql(o=-1===t?a:arguments[t]))for(i=Gl(o),zl(c+i),r=0;r<i;r++,c++)r in o&&Wl(s,c,o[r]);else zl(c+1),Wl(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 Zl=Oi;Ri("toPrimitive"),Zl();var $l=ae,ed=Bi;Ri("toStringTag"),ed($l("Symbol"),"Symbol"),Ri("unscopables"),Bi(i.JSON,"JSON",!0);var td=te.Symbol,rd=ht,nd=Qt.f,id=rd("metadata"),od=Function.prototype;void 0===od[id]&&nd(od,id,{value:null}),Ri("asyncDispose"),Ri("dispose"),Ri("metadata");var ad=td,sd=_,cd=ae("Symbol"),ud=cd.keyFor,ld=sd(cd.prototype.valueOf),dd=cd.isRegisteredSymbol||function(e){try{return void 0!==ud(ld(e))}catch(t){return!1}};Cr({target:"Symbol",stat:!0},{isRegisteredSymbol:dd});for(var hd=Ke,fd=ae,vd=_,pd=Ie,_d=ht,md=fd("Symbol"),gd=md.isWellKnownSymbol,yd=fd("Object","getOwnPropertyNames"),Sd=vd(md.prototype.valueOf),bd=hd("wks"),Ed=0,kd=yd(md),Td=kd.length;Ed<Td;Ed++)try{var Id=kd[Ed];pd(md[Id])&&_d(Id)}catch(KJ){}var Rd=function(e){if(gd&&gd(e))return!0;try{for(var t=Sd(e),r=0,n=yd(bd),i=n.length;r<i;r++)if(bd[n[r]]==t)return!0}catch(KJ){}return!1};Cr({target:"Symbol",stat:!0,forced:!0},{isWellKnownSymbol:Rd}),Ri("matcher"),Ri("observable"),Cr({target:"Symbol",stat:!0,name:"isRegisteredSymbol"},{isRegistered:dd}),Cr({target:"Symbol",stat:!0,name:"isWellKnownSymbol",forced:!0},{isWellKnown:Rd}),Ri("metadataKey"),Ri("patternMatch"),Ri("replaceAll");var Ad=ad,Cd=r(Ad),wd=_,xd=Nr,Od=Sn,Nd=Y,Pd=wd("".charAt),Md=wd("".charCodeAt),Dd=wd("".slice),Ld=function(e){return function(t,r){var n,i,o=Od(Nd(t)),a=xd(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Md(o,a))<55296||n>56319||a+1===s||(i=Md(o,a+1))<56320||i>57343?e?Pd(o,a):n:e?Dd(o,a,a+2):i-56320+(n-55296<<10)+65536}},Ud={codeAt:Ld(!1),charAt:Ld(!0)},Vd=Ud.charAt,Fd=Sn,Bd=ro,jd=Du,Hd=Lu,Gd="String Iterator",zd=Bd.set,Wd=Bd.getterFor(Gd);jd(String,"String",(function(e){zd(this,{type:Gd,string:Fd(e),index:0})}),(function(){var e,t=Wd(this),r=t.string,n=t.index;return n>=r.length?Hd(void 0,!0):(e=Vd(r,n),t.index+=e.length,Hd(e,!1))}));var Kd=r(mi.f("iterator"));function Xd(e){return(Xd="function"==typeof Cd&&"symbol"==typeof Kd?function(e){return typeof e}:function(e){return e&&"function"==typeof Cd&&e.constructor===Cd&&e!==Cd.prototype?"symbol":typeof e})(e)}var Yd=r(mi.f("toPrimitive"));function qd(e){var t=function(e,t){if("object"!==Xd(e)||null===e)return e;var r=e[Yd];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==Xd(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Xd(t)?t:String(t)}function Jd(e,t,r){return(t=qd(t))in e?Ul(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Qd(e,t){var r=cn(e);if(Hs){var n=Hs(e);t&&(n=tc(n).call(n,(function(t){return dc(e,t).enumerable}))),xc(r).apply(r,n)}return r}function Zd(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?dl(r=Qd(Object(i),!0)).call(r,(function(t){Jd(e,t,i[t])})):El?wl(e,El(i)):dl(n=Qd(Object(i))).call(n,(function(t){Ul(e,t,dc(i,t))}))}return e}var $d=function(e){return e[e.VIDEO_SOURCE_TYPE_EXTERNAL=0]="VIDEO_SOURCE_TYPE_EXTERNAL",e[e.VIDEO_SOURCE_TYPE_INTERNAL=1]="VIDEO_SOURCE_TYPE_INTERNAL",e}($d||{}),eh=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}(eh||{}),th=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}(th||{}),rh=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(rh||{}),nh=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(nh||{}),ih=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(ih||{}),oh=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(oh||{}),ah=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(ah||{}),sh=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}(sh||{}),ch=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(ch||{}),uh=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(uh||{}),lh=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[e.STREAM_REMOVE_REASON_TOKEN_PRIVILEGE_EXPIRED=6]="STREAM_REMOVE_REASON_TOKEN_PRIVILEGE_EXPIRED",e}(lh||{}),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||{}),hh=function(e){return e.ICE_FAILED="iceFailed",e.NODE_CHANGE="nodeChange",e.JOIN_TIMEOUT="joinTimeout",e.NOTIFY_RECONNECT="notifyReconnect",e}(hh||{}),fh=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(fh||{}),vh=function(e){return e[e.NORMAL=0]="NORMAL",e[e.DISCONNECT=1]="DISCONNECT",e[e.RESET=2]="RESET",e}(vh||{}),ph=function(e){return e[e.MICROPHONE=0]="MICROPHONE",e[e.AUDIOMIXING=1]="AUDIOMIXING",e}(ph||{}),_h=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(_h||{}),mh=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(mh||{}),gh=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}(gh||{}),yh=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(yh||{}),Sh=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}(Sh||{}),bh=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(bh||{}),Eh=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}(Eh||{}),kh=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(kh||{}),Th=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}(Th||{}),Ih=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}(Ih||{}),Rh=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}(Rh||{}),Ah=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(Ah||{}),Ch=function(e){return e.H264="H264",e.H265="H265",e}(Ch||{}),wh=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(wh||{}),xh=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e[e.UPDATED=3]="UPDATED",e}(xh||{}),Oh=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}(Oh||{}),Nh=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}(Nh||{}),Ph=function(e){return e[e.DEFAULT=0]="DEFAULT",e[e.HIGH=1]="HIGH",e}(Ph||{}),Mh=Object.freeze({__proto__:null,AAC_PROFILE:Ah,AudioProfileType:Ih,AudioReportMode:ph,AudioSelectionPriority:Ph,AudioSourceType:eh,ChannelProfile:rh,ConnectionState:dh,FallbackOrRecoverReason:kh,ForwardStreamError:Nh,ForwardStreamState:Oh,LocalMainReportMode:vh,LogChannel:_h,MediaType:uh,MirrorMode:ah,MirrorType:fh,NetworkQuality:Eh,PublicInterpolationMode:yh,PublicStreamType:gh,PublishState:oh,RTCAutoPlayPolicy:Rh,ReconnectReason:hh,RemoteUserPriority:bh,RoomProfileType:Th,SUBTITLE_MODE:wh,StreamIndex:ch,StreamRemoveReason:lh,SubscribeFallbackOption:Sh,SubscribeMode:nh,SubscribeState:ih,SubtitleEventType:xh,TRANSCODING_VIDEO_CODEC:Ch,USER_ONLINE_STATUS:mh,UserOfflineReason:th,VideoRenderMode:sh,VideoSourceType:$d}),Dh=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}(Dh||{}),Lh=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(Lh||{}),Uh=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}(Uh||{}),Vh=Object.freeze({__proto__:null,AudioMixingDualMonoMode:Dh,AudioMixingState:Uh,AudioMixingType:Lh}),Fh=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.onTokenPublishPrivilegeWillExpire="onTokenPublishPrivilegeWillExpire",e.onTokenPublishPrivilegeDidExpired="onTokenPublishPrivilegeDidExpired",e.onTokenSubscribePrivilegeWillExpire="onTokenSubscribePrivilegeWillExpire",e.onTokenSubscribePrivilegeDidExpired="onTokenSubscribePrivilegeDidExpired",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.onSEIStreamUpdate="onSEIStreamUpdate",e}(Fh||{});function Bh(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),Ul(e,qd(n.key),n)}}function jh(e,t,r){return t&&Bh(e.prototype,t),r&&Bh(e,r),Ul(e,"prototype",{writable:!1}),e}function Hh(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Cr({target:"Object",stat:!0,sham:!w},{create:Kn});var Gh=te.Object,zh=r((function(e,t){return Gh.create(e,t)})),Wh=qe,Kh=Kc,Xh=Vc;Cr({target:"Object",stat:!0,forced:o((function(){Kh(1)})),sham:!Xh},{getPrototypeOf:function(e){return Kh(Wh(e))}});var Yh=r(te.Object.getPrototypeOf);Cr({target:"Object",stat:!0},{setPrototypeOf:gu});var qh=te.Object.setPrototypeOf,Jh=r(qh),Qh=Ze,Zh=ml,$h=C,ef=Qt,tf=ee,rf=_r,nf=Error,of=_("".replace),af=String(nf("zxcasd").stack),sf=/\n\s*at [^:]*:[^\n]*/,cf=sf.test(af),uf=F,lf=!o((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",uf(1,7)),7!==e.stack)})),df=_r,hf=function(e,t){if(cf&&"string"==typeof e&&!nf.prepareStackTrace)for(;t--;)e=of(e,sf,"");return e},ff=lf,vf=Error.captureStackTrace,pf=Oc,_f=ht("iterator"),mf=Array.prototype,gf=function(e){return void 0!==e&&(pf.Array===e||mf[_f]===e)},yf=mn,Sf=Me,bf=W,Ef=Oc,kf=ht("iterator"),Tf=function(e){if(!bf(e))return Sf(e,kf)||Sf(e,"@@iterator")||Ef[yf(e)]},If=N,Rf=Oe,Af=rr,Cf=Ae,wf=Tf,xf=TypeError,Of=function(e,t){var r=arguments.length<2?wf(e):t;if(Rf(r))return Af(If(r,e));throw xf(Cf(e)+" is not iterable")},Nf=N,Pf=rr,Mf=Me,Df=function(e,t,r){var n,i;Pf(e);try{if(!(n=Mf(e,"return"))){if("throw"===t)throw r;return r}n=Nf(n,e)}catch(KJ){i=!0,n=KJ}if("throw"===t)throw r;if(i)throw n;return Pf(n),r},Lf=Jt,Uf=N,Vf=rr,Ff=Ae,Bf=gf,jf=jr,Hf=se,Gf=Of,zf=Tf,Wf=Df,Kf=TypeError,Xf=function(e,t){this.stopped=e,this.result=t},Yf=Xf.prototype,qf=function(e,t,r){var n,i,o,a,s,c,u,l=r&&r.that,d=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),f=!(!r||!r.IS_ITERATOR),v=!(!r||!r.INTERRUPTED),p=Lf(t,l),_=function(e){return n&&Wf(n,"normal",e),new Xf(!0,e)},m=function(e){return d?(Vf(e),v?p(e[0],e[1],_):p(e[0],e[1])):v?p(e,_):p(e)};if(h)n=e.iterator;else if(f)n=e;else{if(!(i=zf(e)))throw Kf(Ff(e)+" is not iterable");if(Bf(i)){for(o=0,a=jf(e);a>o;o++)if((s=m(e[o]))&&Hf(Yf,s))return s;return new Xf(!1)}n=Gf(e,i)}for(c=h?e.next:n.next;!(u=Uf(c,n)).done;){try{s=m(u.value)}catch(KJ){Wf(n,"throw",KJ)}if("object"==typeof s&&s&&Hf(Yf,s))return s}return new Xf(!1)},Jf=Sn,Qf=Cr,Zf=se,$f=Kc,ev=gu,tv=function(e,t,r){for(var n=Zh(t),i=ef.f,o=$h.f,a=0;a<n.length;a++){var s=n[a];Qh(e,s)||r&&Qh(r,s)||i(e,s,o(t,s))}},rv=Kn,nv=_r,iv=F,ov=function(e,t){tf(t)&&"cause"in t&&rf(e,"cause",t.cause)},av=function(e,t,r,n){ff&&(vf?vf(e,t):df(e,"stack",hf(r,n)))},sv=qf,cv=function(e,t){return void 0===e?arguments.length<2?"":t:Jf(e)},uv=ht("toStringTag"),lv=Error,dv=[].push,hv=function(e,t){var r,n=Zf(fv,this);ev?r=ev(lv(),n?$f(this):fv):(r=n?this:rv(fv),nv(r,uv,"Error")),void 0!==t&&nv(r,"message",cv(t)),av(r,hv,r.stack,1),arguments.length>2&&ov(r,arguments[2]);var i=[];return sv(e,dv,{that:i}),nv(r,"errors",i),r};ev?ev(hv,lv):tv(hv,lv,{name:!0});var fv=hv.prototype=rv(lv.prototype,{constructor:iv(1,hv),message:iv(1,""),name:iv(1,"AggregateError")});Qf({global:!0,constructor:!0,arity:2},{AggregateError:hv});var vv,pv,_v,mv,gv="process"===S(i.process),yv=ae,Sv=_i,bv=w,Ev=ht("species"),kv=function(e){var t=yv(e);bv&&t&&!t[Ev]&&Sv(t,Ev,{configurable:!0,get:function(){return this}})},Tv=se,Iv=TypeError,Rv=function(e,t){if(Tv(t,e))return e;throw Iv("Incorrect invocation")},Av=ko,Cv=Ae,wv=TypeError,xv=function(e){if(Av(e))return e;throw wv(Cv(e)+" is not a constructor")},Ov=rr,Nv=xv,Pv=W,Mv=ht("species"),Dv=function(e,t){var r,n=Ov(e).constructor;return void 0===n||Pv(r=Ov(n)[Mv])?t:Nv(r)},Lv=TypeError,Uv=function(e,t){if(e<t)throw Lv("Not enough arguments");return e},Vv=/(?:ipad|iphone|ipod).*applewebkit/i.test(ce),Fv=i,Bv=d,jv=Jt,Hv=A,Gv=Ze,zv=o,Wv=wn,Kv=cs,Xv=Rt,Yv=Uv,qv=Vv,Jv=gv,Qv=Fv.setImmediate,Zv=Fv.clearImmediate,$v=Fv.process,ep=Fv.Dispatch,tp=Fv.Function,rp=Fv.MessageChannel,np=Fv.String,ip=0,op={},ap="onreadystatechange";zv((function(){vv=Fv.location}));var sp=function(e){if(Gv(op,e)){var t=op[e];delete op[e],t()}},cp=function(e){return function(){sp(e)}},up=function(e){sp(e.data)},lp=function(e){Fv.postMessage(np(e),vv.protocol+"//"+vv.host)};Qv&&Zv||(Qv=function(e){Yv(arguments.length,1);var t=Hv(e)?e:tp(e),r=Kv(arguments,1);return op[++ip]=function(){Bv(t,void 0,r)},pv(ip),ip},Zv=function(e){delete op[e]},Jv?pv=function(e){$v.nextTick(cp(e))}:ep&&ep.now?pv=function(e){ep.now(cp(e))}:rp&&!qv?(mv=(_v=new rp).port2,_v.port1.onmessage=up,pv=jv(mv.postMessage,mv)):Fv.addEventListener&&Hv(Fv.postMessage)&&!Fv.importScripts&&vv&&"file:"!==vv.protocol&&!zv(lp)?(pv=lp,Fv.addEventListener("message",up,!1)):pv=ap in Xv("script")?function(e){Wv.appendChild(Xv("script"))[ap]=function(){Wv.removeChild(this),sp(e)}}:function(e){setTimeout(cp(e),0)});var dp={set:Qv,clear:Zv},hp=function(){this.head=null,this.tail=null};hp.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 fp,vp,pp,_p,mp,gp=hp,yp=/ipad|iphone|ipod/i.test(ce)&&"undefined"!=typeof Pebble,Sp=/web0s(?!.*chrome)/i.test(ce),bp=i,Ep=Jt,kp=C.f,Tp=dp.set,Ip=gp,Rp=Vv,Ap=yp,Cp=Sp,wp=gv,xp=bp.MutationObserver||bp.WebKitMutationObserver,Op=bp.document,Np=bp.process,Pp=bp.Promise,Mp=kp(bp,"queueMicrotask"),Dp=Mp&&Mp.value;if(!Dp){var Lp=new Ip,Up=function(){var e,t;for(wp&&(e=Np.domain)&&e.exit();t=Lp.get();)try{t()}catch(KJ){throw Lp.head&&fp(),KJ}e&&e.enter()};Rp||wp||Cp||!xp||!Op?!Ap&&Pp&&Pp.resolve?((_p=Pp.resolve(void 0)).constructor=Pp,mp=Ep(_p.then,_p),fp=function(){mp(Up)}):wp?fp=function(){Np.nextTick(Up)}:(Tp=Ep(Tp,bp),fp=function(){Tp(Up)}):(vp=!0,pp=Op.createTextNode(""),new xp(Up).observe(pp,{characterData:!0}),fp=function(){pp.data=vp=!vp}),Dp=function(e){Lp.head||fp(),Lp.add(e)}}var Vp=Dp,Fp=function(e){try{return{error:!1,value:e()}}catch(KJ){return{error:!0,value:KJ}}},Bp=i.Promise,jp="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Hp=!jp&&!gv&&"object"==typeof window&&"object"==typeof document,Gp=i,zp=Bp,Wp=A,Kp=Kt,Xp=co,Yp=ht,qp=Hp,Jp=jp,Qp=pe,Zp=zp&&zp.prototype,$p=Yp("species"),e_=!1,t_=Wp(Gp.PromiseRejectionEvent),r_={CONSTRUCTOR:Kp("Promise",(function(){var e=Xp(zp),t=e!==String(zp);if(!t&&66===Qp)return!0;if(!Zp.catch||!Zp.finally)return!0;if(!Qp||Qp<51||!/native code/.test(e)){var r=new zp((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[$p]=n,!(e_=r.then((function(){}))instanceof n))return!0}return!t&&(qp||Jp)&&!t_})),REJECTION_EVENT:t_,SUBCLASSING:e_},n_={},i_=Oe,o_=TypeError,a_=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw o_("Bad Promise constructor");t=e,r=n})),this.resolve=i_(t),this.reject=i_(r)};n_.f=function(e){return new a_(e)};var s_,c_,u_=Cr,l_=gv,d_=i,h_=N,f_=vi,v_=Bi,p_=kv,__=Oe,m_=A,g_=ee,y_=Rv,S_=Dv,b_=dp.set,E_=Vp,k_=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(KJ){}},T_=Fp,I_=gp,R_=ro,A_=Bp,C_=r_,w_=n_,x_="Promise",O_=C_.CONSTRUCTOR,N_=C_.REJECTION_EVENT,P_=R_.getterFor(x_),M_=R_.set,D_=A_&&A_.prototype,L_=A_,U_=D_,V_=d_.TypeError,F_=d_.document,B_=d_.process,j_=w_.f,H_=j_,G_=!!(F_&&F_.createEvent&&d_.dispatchEvent),z_="unhandledrejection",W_=function(e){var t;return!(!g_(e)||!m_(t=e.then))&&t},K_=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,l=e.domain;try{s?(a||(2===t.rejection&&Q_(t),t.rejection=1),!0===s?r=o:(l&&l.enter(),r=s(o),l&&(l.exit(),i=!0)),r===e.promise?u(V_("Promise-chain cycle")):(n=W_(r))?h_(n,r,c,u):c(r)):u(o)}catch(KJ){l&&!i&&l.exit(),u(KJ)}},X_=function(e,t){e.notified||(e.notified=!0,E_((function(){for(var r,n=e.reactions;r=n.get();)K_(r,e);e.notified=!1,t&&!e.rejection&&q_(e)})))},Y_=function(e,t,r){var n,i;G_?((n=F_.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),d_.dispatchEvent(n)):n={promise:t,reason:r},!N_&&(i=d_["on"+e])?i(n):e===z_&&k_("Unhandled promise rejection",r)},q_=function(e){h_(b_,d_,(function(){var t,r=e.facade,n=e.value;if(J_(e)&&(t=T_((function(){l_?B_.emit("unhandledRejection",n,r):Y_(z_,r,n)})),e.rejection=l_||J_(e)?2:1,t.error))throw t.value}))},J_=function(e){return 1!==e.rejection&&!e.parent},Q_=function(e){h_(b_,d_,(function(){var t=e.facade;l_?B_.emit("rejectionHandled",t):Y_("rejectionhandled",t,e.value)}))},Z_=function(e,t,r){return function(n){e(t,n,r)}},$_=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,X_(e,!0))},em=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw V_("Promise can't be resolved itself");var n=W_(t);n?E_((function(){var r={done:!1};try{h_(n,t,Z_(em,r,e),Z_($_,r,e))}catch(KJ){$_(r,KJ,e)}})):(e.value=t,e.state=1,X_(e,!1))}catch(KJ){$_({done:!1},KJ,e)}}};O_&&(U_=(L_=function(e){y_(this,U_),__(e),h_(s_,this);var t=P_(this);try{e(Z_(em,t),Z_($_,t))}catch(KJ){$_(t,KJ)}}).prototype,(s_=function(e){M_(this,{type:x_,done:!1,notified:!1,parent:!1,reactions:new I_,rejection:!1,state:0,value:void 0})}).prototype=f_(U_,"then",(function(e,t){var r=P_(this),n=j_(S_(this,L_));return r.parent=!0,n.ok=!m_(e)||e,n.fail=m_(t)&&t,n.domain=l_?B_.domain:void 0,0===r.state?r.reactions.add(n):E_((function(){K_(n,r)})),n.promise})),c_=function(){var e=new s_,t=P_(e);this.promise=e,this.resolve=Z_(em,t),this.reject=Z_($_,t)},w_.f=j_=function(e){return e===L_||undefined===e?new c_(e):H_(e)}),u_({global:!0,constructor:!0,wrap:!0,forced:O_},{Promise:L_}),v_(L_,x_,!1,!0),p_(x_);var tm=ht("iterator"),rm=!1;try{var nm=0,im={next:function(){return{done:!!nm++}},return:function(){rm=!0}};im[tm]=function(){return this},Array.from(im,(function(){throw 2}))}catch(KJ){}var om=function(e,t){if(!t&&!rm)return!1;var r=!1;try{var n={};n[tm]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(KJ){}return r},am=Bp,sm=r_.CONSTRUCTOR||!om((function(e){am.all(e).then(void 0,(function(){}))})),cm=N,um=Oe,lm=n_,dm=Fp,hm=qf;Cr({target:"Promise",stat:!0,forced:sm},{all:function(e){var t=this,r=lm.f(t),n=r.resolve,i=r.reject,o=dm((function(){var r=um(t.resolve),o=[],a=0,s=1;hm(e,(function(e){var c=a++,u=!1;s++,cm(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 fm=Cr,vm=r_.CONSTRUCTOR;Bp&&Bp.prototype,fm({target:"Promise",proto:!0,forced:vm,real:!0},{catch:function(e){return this.then(void 0,e)}});var pm=N,_m=Oe,mm=n_,gm=Fp,ym=qf;Cr({target:"Promise",stat:!0,forced:sm},{race:function(e){var t=this,r=mm.f(t),n=r.reject,i=gm((function(){var i=_m(t.resolve);ym(e,(function(e){pm(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var Sm=N,bm=n_;Cr({target:"Promise",stat:!0,forced:r_.CONSTRUCTOR},{reject:function(e){var t=bm.f(this);return Sm(t.reject,void 0,e),t.promise}});var Em=rr,km=ee,Tm=n_,Im=function(e,t){if(Em(e),km(t)&&t.constructor===e)return t;var r=Tm.f(e);return(0,r.resolve)(t),r.promise},Rm=Cr,Am=Bp,Cm=r_.CONSTRUCTOR,wm=Im,xm=ae("Promise"),Om=!Cm;Rm({target:"Promise",stat:!0,forced:true},{resolve:function(e){return wm(Om&&this===xm?Am:this,e)}});var Nm=N,Pm=Oe,Mm=n_,Dm=Fp,Lm=qf;Cr({target:"Promise",stat:!0,forced:sm},{allSettled:function(e){var t=this,r=Mm.f(t),n=r.resolve,i=r.reject,o=Dm((function(){var r=Pm(t.resolve),i=[],o=0,a=1;Lm(e,(function(e){var s=o++,c=!1;a++,Nm(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 Um=N,Vm=Oe,Fm=ae,Bm=n_,jm=Fp,Hm=qf,Gm="No one promise resolved";Cr({target:"Promise",stat:!0,forced:sm},{any:function(e){var t=this,r=Fm("AggregateError"),n=Bm.f(t),i=n.resolve,o=n.reject,a=jm((function(){var n=Vm(t.resolve),a=[],s=0,c=1,u=!1;Hm(e,(function(e){var l=s++,d=!1;c++,Um(n,t,e).then((function(e){d||u||(u=!0,i(e))}),(function(e){d||u||(d=!0,a[l]=e,--c||o(new r(a,Gm)))}))})),--c||o(new r(a,Gm))}));return a.error&&o(a.value),n.promise}});var zm=Cr,Wm=Bp,Km=o,Xm=ae,Ym=A,qm=Dv,Jm=Im,Qm=Wm&&Wm.prototype;zm({target:"Promise",proto:!0,real:!0,forced:!!Wm&&Km((function(){Qm.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=qm(this,Xm("Promise")),r=Ym(e);return this.then(r?function(r){return Jm(t,e()).then((function(){return r}))}:e,r?function(r){return Jm(t,e()).then((function(){throw r}))}:e)}});var Zm=te.Promise,$m=n_;Cr({target:"Promise",stat:!0},{withResolvers:function(){var e=$m.f(this);return{promise:e.promise,resolve:e.resolve,reject:e.reject}}});var eg=Zm,tg=n_,rg=Fp;Cr({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=tg.f(this),r=rg(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var ng=eg,ig=r(ng),og=Cr,ag=io,sg=_([].reverse),cg=[1,2];og({target:"Array",proto:!0,forced:String(cg)===String(cg.reverse())},{reverse:function(){return ag(this)&&(this.length=this.length),sg(this)}});var ug=qs("Array").reverse,lg=se,dg=ug,hg=Array.prototype,fg=function(e){var t=e.reverse;return e===hg||lg(hg,e)&&t===hg.reverse?dg:t},vg=r(fg),pg=Cr,_g=io,mg=ko,gg=ee,yg=Lr,Sg=jr,bg=Q,Eg=ei,kg=ht,Tg=cs,Ig=Ks("slice"),Rg=kg("species"),Ag=Array,Cg=Math.max;pg({target:"Array",proto:!0,forced:!Ig},{slice:function(e,t){var r,n,i,o=bg(this),a=Sg(o),s=yg(e,a),c=yg(void 0===t?a:t,a);if(_g(o)&&(r=o.constructor,(mg(r)&&(r===Ag||_g(r.prototype))||gg(r)&&null===(r=r[Rg]))&&(r=void 0),r===Ag||void 0===r))return Tg(o,s,c);for(n=new(void 0===r?Ag:r)(Cg(c-s,0)),i=0;s<c;s++,i++)s in o&&Eg(n,i,o[s]);return n.length=i,n}});var wg=qs("Array").slice,xg=se,Og=wg,Ng=Array.prototype,Pg=function(e){var t=e.slice;return e===Ng||xg(Ng,e)&&t===Ng.slice?Og:t},Mg=r(Pg);function Dg(){Dg=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Ul||function(e,t,r){e[t]=r.value},o="function"==typeof Cd?Cd:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,r){return Ul(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 l(e,t,r,n){var o=t&&t.prototype instanceof m?t:m,a=zh(o.prototype),s=new w(n||[]);return i(a,"_invoke",{value:I(e,r,s)}),a}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(n){return{type:"throw",arg:n}}}t.wrap=l;var h="suspendedStart",f="suspendedYield",v="executing",p="completed",_={};function m(){}function g(){}function y(){}var S={};u(S,a,(function(){return this}));var b=Yh&&Yh(Yh(x([])));b&&b!==r&&n.call(b,a)&&(S=b);var E=y.prototype=m.prototype=zh(S);function k(e){var t;dl(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=d(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Xd(l)&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(l).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===p){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===_)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=p,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var u=d(t,r,n);if("normal"===u.type){if(i=n.done?p:f,u.arg===_)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=p,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")),_;var o=d(i,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,_;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,_):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,_)}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 C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],dl(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(Xd(t)+" is not iterable")}return g.prototype=y,i(E,"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 Jh?Jh(e,y):(e.__proto__=y,u(e,c,"GeneratorFunction")),e.prototype=zh(E),e},t.awrap=function(e){return{__await:e}},k(T.prototype),u(T.prototype,s,(function(){return this})),t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=ig);var a=new T(l(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},k(E),u(E,c,"Generator"),u(E,a,(function(){return this})),u(E,"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 vg(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,w.prototype={constructor:w,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,dl(r=this.tryEntries).call(r,C),!t)for(var i in this)"t"===i.charAt(0)&&n.call(this,i)&&!isNaN(+Mg(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,_):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),_},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),C(r),_}},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;C(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),_}},t}function Lg(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(KJ){return void r(KJ)}s.done?t(c):ig.resolve(c).then(n,i)}function Ug(e){return function(){var t=this,r=arguments;return new ig((function(n,i){var o=e.apply(t,r);function a(e){Lg(o,n,i,a,s,"next",e)}function s(e){Lg(o,n,i,a,s,"throw",e)}a(void 0)}))}}var Vg=qs("Array").concat,Fg=se,Bg=Vg,jg=Array.prototype,Hg=r((function(e){var t=e.concat;return e===jg||Fg(jg,e)&&t===jg.concat?Bg:t})),Gg=r(ng),zg=te,Wg=d;zg.JSON||(zg.JSON={stringify:JSON.stringify});var Kg=function(e,t,r){return Wg(zg.JSON.stringify,null,arguments)},Xg=r(Kg),Yg=Vo.map;Cr({target:"Array",proto:!0,forced:!Ks("map")},{map:function(e){return Yg(this,e,arguments.length>1?arguments[1]:void 0)}});var qg=qs("Array").map,Jg=se,Qg=qg,Zg=Array.prototype,$g=r((function(e){var t=e.map;return e===Zg||Jg(Zg,e)&&t===Zg.map?Qg:t})),ey=r(Tf);Cr({target:"Array",stat:!0},{isArray:io});var ty=r(te.Array.isArray),ry=rr,ny=Df,iy=Jt,oy=N,ay=qe,sy=function(e,t,r,n){try{return n?t(ry(r)[0],r[1]):t(r)}catch(KJ){ny(e,"throw",KJ)}},cy=gf,uy=ko,ly=jr,dy=ei,hy=Of,fy=Tf,vy=Array,py=function(e){var t=ay(e),r=uy(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=iy(i,n>2?arguments[2]:void 0));var a,s,c,u,l,d,h=fy(t),f=0;if(!h||this===vy&&cy(h))for(a=ly(t),s=r?new this(a):vy(a);a>f;f++)d=o?i(t[f],f):t[f],dy(s,f,d);else for(l=(u=hy(t,h)).next,s=r?new this:[];!(c=oy(l,u)).done;f++)d=o?sy(u,i,[c.value,f],!0):c.value,dy(s,f,d);return s.length=f,s},_y=py;Cr({target:"Array",stat:!0,forced:!om((function(e){Array.from(e)}))},{from:_y});var my=te.Array.from,gy=r(my);function yy(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 Sy(e,t){var r;if(e){if("string"==typeof e)return yy(e,t);var n=Mg(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?gy(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?yy(e,t):void 0}}function by(e,t){var r=void 0!==Cd&&ey(e)||e["@@iterator"];if(!r){if(ty(e)||(r=Sy(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 Ey(e,t){return function(e){if(ty(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==Cd&&ey(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(l){u=!0,i=l}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||Sy(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 ky=Cr,Ty=o,Iy=Jn.f;ky({target:"Object",stat:!0,forced:Ty((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:Iy});var Ry=te.Object,Ay=r((function(e){return Ry.getOwnPropertyNames(e)})),Cy=r(ec),wy=Kr.includes;Cr({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return wy(this,e,arguments.length>1?arguments[1]:void 0)}});var xy=qs("Array").includes,Oy=ee,Ny=S,Py=ht("match"),My=function(e){var t;return Oy(e)&&(void 0!==(t=e[Py])?!!t:"RegExp"===Ny(e))},Dy=TypeError,Ly=function(e){if(My(e))throw Dy("The method doesn't accept regular expressions");return e},Uy=ht("match"),Vy=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Uy]=!1,"/./"[e](t)}catch(n){}}return!1},Fy=Cr,By=Ly,jy=Y,Hy=Sn,Gy=Vy,zy=_("".indexOf);Fy({target:"String",proto:!0,forced:!Gy("includes")},{includes:function(e){return!!~zy(Hy(jy(this)),Hy(By(e)),arguments.length>1?arguments[1]:void 0)}});var Wy=qs("String").includes,Ky=se,Xy=xy,Yy=Wy,qy=Array.prototype,Jy=String.prototype,Qy=r((function(e){var t=e.includes;return e===qy||Ky(qy,e)&&t===qy.includes?Xy:"string"==typeof e||e===Jy||Ky(Jy,e)&&t===Jy.includes?Yy:t})),Zy=Oe,$y=qe,eS=z,tS=jr,rS=TypeError,nS=function(e){return function(t,r,n,i){Zy(r);var o=$y(t),a=eS(o),s=tS(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 rS("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}},iS={left:nS(!1),right:nS(!0)}.left;Cr({target:"Array",proto:!0,forced:!gv&&pe>79&&pe<83||!tl("reduce")},{reduce:function(e){var t=arguments.length;return iS(this,e,t,t>1?arguments[1]:void 0)}});var oS=qs("Array").reduce,aS=se,sS=oS,cS=Array.prototype,uS=r((function(e){var t=e.reduce;return e===cS||aS(cS,e)&&t===cS.reduce?sS:t})),lS=w,dS=o,hS=_,fS=Kc,vS=nn,pS=Q,_S=hS(P.f),mS=hS([].push),gS=lS&&dS((function(){var e=Object.create(null);return e[2]=2,!_S(e,2)})),yS=function(e){return function(t){for(var r,n=pS(t),i=vS(n),o=gS&&null===fS(n),a=i.length,s=0,c=[];a>s;)r=i[s++],lS&&!(o?r in n:_S(n,r))||mS(c,e?[r,n[r]]:n[r]);return c}},SS={entries:yS(!0),values:yS(!1)}.entries;Cr({target:"Object",stat:!0},{entries:function(e){return SS(e)}});var bS,ES,kS,TS,IS,RS,AS,CS,wS,xS,OS,NS,PS,MS,DS,LS,US,VS=r(te.Object.entries),FS=r(sn),BS={};function jS(e,t){try{var r;return Qy(r=e[t].toString()).call(r,"[native code]")?"native":"non-native"}catch(n){return"untouchable"}}var HS=uS(bS="undefined"!=typeof window?[[null===(ES=window.RTCPeerConnection)||void 0===ES?void 0:ES.prototype,"RTCPeerConnection.prototype"],[window.RTCPeerConnection,"RTCPeerConnection"],[null===(kS=window.RTCDataChannel)||void 0===kS?void 0:kS.prototype,"RTCDataChannel.prototype"],[window.RTCDataChannel,"RTCDataChannel"],[null===(TS=window.MediaStreamTrack)||void 0===TS?void 0:TS.prototype,"MediaStreamTrack.prototype"],[window.MediaStreamTrack,"MediaStreamTrack"],[null===(IS=window.MediaStream)||void 0===IS?void 0:IS.prototype,"MediaStream.prototype"],[window.MediaStream,"MediaStream"],[null===(RS=window.HTMLAudioElement)||void 0===RS?void 0:RS.prototype,"HTMLAudioElement.prototype"],[null===(AS=window.HTMLVideoElement)||void 0===AS?void 0:AS.prototype,"HTMLVideoElement.prototype"],[null===(CS=window.HTMLMediaElement)||void 0===CS?void 0:CS.prototype,"HTMLMediaElement.prototype"],[null!==(wS=null===(xS=window.AudioContext)||void 0===xS?void 0:xS.prototype)&&void 0!==wS?wS:null===(OS=window.webkitAudioContext)||void 0===OS?void 0:OS.prototype,"AudioContext.prototype"],[null===(NS=window.BaseAudioContext)||void 0===NS?void 0:NS.prototype,"BaseAudioContext.prototype"],[null===(PS=window.AudioNode)||void 0===PS?void 0:PS.prototype,"AudioNode.prototype"],[window.navigator.mediaDevices,"navigator.mediaDevices"],[window.console,"console"]]:[]).call(bS,(function(e,t){var r=Ey(t,2),n=r[0],i=r[1];return Hg(e).call(e,function(e,t){var r;if(!e)return[];var n=Ay(e);return $g(r=Cy(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&&HS.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 GS,zS=by(HS);try{for(zS.s();!(GS=zS.n()).done;){var WS,KS=GS.value,XS=KS.obj,YS=KS.prefix,qS=KS.attr,JS=Hg(WS="".concat(YS,".")).call(WS,qS);BS[JS]=jS(XS,qS)}}catch(XJ){zS.e(XJ)}finally{zS.f()}"undefined"!=typeof window&&(Qy(MS=window.location.search).call(MS,"_rtc_debug_")||(null===(DS=window.localStorage)||void 0===DS?void 0:DS.getItem("_rtc_debug_")))&&console.log("RTC_AMBULANCE",BS);var QS=$g(LS=Cy(US=VS(BS)).call(US,(function(e){var t=Ey(e,2);return t[0],"non-native"===t[1]}))).call(LS,(function(e){var t=Ey(e,2),r=t[0];return t[1],r}));FS(QS).length&&console.warn("RTC_AMBULANCE","have non-native code:\n",QS.join("\n"));var ZS="\t\n\v\f\r                 \u2028\u2029\ufeff",$S=Y,eb=Sn,tb=ZS,rb=_("".replace),nb=RegExp("^["+tb+"]+"),ib=RegExp("(^|[^"+tb+"])["+tb+"]+$"),ob=function(e){return function(t){var r=eb($S(t));return 1&e&&(r=rb(r,nb,"")),2&e&&(r=rb(r,ib,"$1")),r}},ab={start:ob(1),end:ob(2),trim:ob(3)},sb=i,cb=o,ub=_,lb=Sn,db=ab.trim,hb=ZS,fb=sb.parseInt,vb=sb.Symbol,pb=vb&&vb.iterator,_b=/^[+-]?0x/i,mb=ub(_b.exec),gb=8!==fb(hb+"08")||22!==fb(hb+"0x16")||pb&&!cb((function(){fb(Object(pb))}))?function(e,t){var r=db(lb(e));return fb(r,t>>>0||(mb(_b,r)?16:10))}:fb;Cr({global:!0,forced:parseInt!==gb},{parseInt:gb});var yb=r(te.parseInt),Sb={exports:{}},bb=o((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),Eb=o,kb=ee,Tb=S,Ib=bb,Rb=Object.isExtensible,Ab=Eb((function(){Rb(1)}))||Ib?function(e){return!!kb(e)&&((!Ib||"ArrayBuffer"!==Tb(e))&&(!Rb||Rb(e)))}:Rb,Cb=!o((function(){return Object.isExtensible(Object.preventExtensions({}))})),wb=Cr,xb=_,Ob=Xr,Nb=ee,Pb=Ze,Mb=Qt.f,Db=Xn,Lb=Jn,Ub=Ab,Vb=Cb,Fb=!1,Bb=nt("meta"),jb=0,Hb=function(e){Mb(e,Bb,{value:{objectID:"O"+jb++,weakData:{}}})},Gb=Sb.exports={enable:function(){Gb.enable=function(){},Fb=!0;var e=Db.f,t=xb([].splice),r={};r[Bb]=1,e(r).length&&(Db.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===Bb){t(n,i,1);break}return n},wb({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Lb.f}))},fastKey:function(e,t){if(!Nb(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!Pb(e,Bb)){if(!Ub(e))return"F";if(!t)return"E";Hb(e)}return e[Bb].objectID},getWeakData:function(e,t){if(!Pb(e,Bb)){if(!Ub(e))return!0;if(!t)return!1;Hb(e)}return e[Bb].weakData},onFreeze:function(e){return Vb&&Fb&&Ub(e)&&!Pb(e,Bb)&&Hb(e),e}};Ob[Bb]=!0;var zb=Sb.exports,Wb=Cr,Kb=i,Xb=zb,Yb=o,qb=_r,Jb=qf,Qb=Rv,Zb=A,$b=ee,eE=W,tE=Bi,rE=Qt.f,nE=Vo.forEach,iE=w,oE=ro.set,aE=ro.getterFor,sE=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=Kb[e],c=s&&s.prototype,u={};if(iE&&Zb(s)&&(o||c.forEach&&!Yb((function(){(new s).entries().next()})))){var l=(n=t((function(t,r){oE(Qb(t,l),{type:e,collection:new s}),eE(r)||Jb(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,d=aE(e);nE(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"===e||"set"===e;!(e in c)||o&&"clear"===e||qb(l,e,(function(r,n){var i=d(this).collection;if(!t&&o&&!$b(r))return"get"===e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||rE(l,"size",{configurable:!0,get:function(){return d(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Xb.enable();return tE(n,e,!1,!0),u[e]=n,Wb({global:!0,forced:!0},u),o||r.setStrong(n,e,i),n},cE=vi,uE=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:cE(e,n,t[n],r);return e},lE=Kn,dE=_i,hE=uE,fE=Jt,vE=Rv,pE=W,_E=qf,mE=Du,gE=Lu,yE=kv,SE=w,bE=zb.fastKey,EE=ro.set,kE=ro.getterFor,TE={getConstructor:function(e,t,r,n){var i=e((function(e,i){vE(e,o),EE(e,{type:t,index:lE(null),first:void 0,last:void 0,size:0}),SE||(e.size=0),pE(i)||_E(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=kE(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=bE(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),SE?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=bE(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key===t)return r};return hE(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,SE?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),SE?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=fE(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)}}),hE(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)}}),SE&&dE(o,"size",{configurable:!0,get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=kE(t),o=kE(n);mE(e,t,(function(e,t){EE(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)?gE("keys"===t?r.key:"values"===t?r.value:[r.key,r.value],!1):(e.target=void 0,gE(void 0,!0))}),r?"entries":"values",!r,!0),yE(t)}};sE("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),TE);var IE=te.Map,RE=function(e,t){return 1===t?function(t,r){return t[e](r)}:function(t,r,n){return t[e](r,n)}},AE=RE,CE=ae("Map"),wE={Map:CE,set:AE("set",2),get:AE("get",1),has:AE("has",1),remove:AE("delete",1),proto:CE.prototype},xE=Cr,OE=Oe,NE=Y,PE=qf,ME=wE.Map,DE=wE.has,LE=wE.get,UE=wE.set,VE=_([].push);xE({target:"Map",stat:!0,forced:true},{groupBy:function(e,t){NE(e),OE(t);var r=new ME,n=0;return PE(e,(function(e){var i=t(e,n++);DE(r,i)?VE(LE(r,i),e):UE(r,i,[e])})),r}});var FE=IE,BE=Jt,jE=N,HE=Oe,GE=xv,zE=W,WE=qf,KE=[].push,XE=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return GE(this),(t=void 0!==a)&&HE(a),zE(e)?new this:(r=[],t?(n=0,i=BE(a,o>2?arguments[2]:void 0),WE(e,(function(e){jE(KE,r,i(e,n++))}))):WE(e,KE,{that:r}),new this(r))};Cr({target:"Map",stat:!0,forced:!0},{from:XE});var YE=cs,qE=function(){return new this(YE(arguments))};Cr({target:"Map",stat:!0,forced:!0},{of:qE});var JE=Ae,QE=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(JE(e)+" is not a map")},ZE=QE,$E=wE.remove;Cr({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=ZE(this),r=!0,n=0,i=arguments.length;n<i;n++)e=$E(t,arguments[n]),r=r&&e;return!!r}});var ek=QE,tk=wE.get,rk=wE.has,nk=wE.set;Cr({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,t){var r,n,i=ek(this);return rk(i,e)?(r=tk(i,e),"update"in t&&(r=t.update(r,e,i),nk(i,e,r)),r):(n=t.insert(e,i),nk(i,e,n),n)}});var ik=N,ok=function(e,t,r){for(var n,i,o=r?e:e.iterator,a=e.next;!(n=ik(a,o)).done;)if(void 0!==(i=t(n.value)))return i},ak=ok,sk=function(e,t,r){return r?ak(e.entries(),(function(e){return t(e[1],e[0])}),!0):e.forEach(t)},ck=Jt,uk=QE,lk=sk;Cr({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=uk(this),r=ck(e,arguments.length>1?arguments[1]:void 0);return!1!==lk(t,(function(e,n){if(!r(e,n,t))return!1}),!0)}});var dk=Jt,hk=QE,fk=sk,vk=wE.Map,pk=wE.set;Cr({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=hk(this),r=dk(e,arguments.length>1?arguments[1]:void 0),n=new vk;return fk(t,(function(e,i){r(e,i,t)&&pk(n,i,e)})),n}});var _k=Jt,mk=QE,gk=sk;Cr({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=mk(this),r=_k(e,arguments.length>1?arguments[1]:void 0),n=gk(t,(function(e,n){if(r(e,n,t))return{value:e}}),!0);return n&&n.value}});var yk=Jt,Sk=QE,bk=sk;Cr({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=Sk(this),r=yk(e,arguments.length>1?arguments[1]:void 0),n=bk(t,(function(e,n){if(r(e,n,t))return{key:n}}),!0);return n&&n.key}});var Ek=function(e,t){return e===t||e!=e&&t!=t},kk=QE,Tk=sk;Cr({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return!0===Tk(kk(this),(function(t){if(Ek(t,e))return!0}),!0)}});var Ik=N,Rk=qf,Ak=A,Ck=Oe,wk=wE.Map;Cr({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new(Ak(this)?this:wk);Ck(t);var n=Ck(r.set);return Rk(e,(function(e){Ik(n,r,t(e),e)})),r}});var xk=QE,Ok=sk;Cr({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){var t=Ok(xk(this),(function(t,r){if(t===e)return{key:r}}),!0);return t&&t.key}});var Nk=Jt,Pk=QE,Mk=sk,Dk=wE.Map,Lk=wE.set;Cr({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=Pk(this),r=Nk(e,arguments.length>1?arguments[1]:void 0),n=new Dk;return Mk(t,(function(e,i){Lk(n,r(e,i,t),e)})),n}});var Uk=Jt,Vk=QE,Fk=sk,Bk=wE.Map,jk=wE.set;Cr({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=Vk(this),r=Uk(e,arguments.length>1?arguments[1]:void 0),n=new Bk;return Fk(t,(function(e,i){jk(n,i,r(e,i,t))})),n}});var Hk=QE,Gk=qf,zk=wE.set;Cr({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=Hk(this),r=arguments.length,n=0;n<r;)Gk(arguments[n++],(function(e,r){zk(t,e,r)}),{AS_ENTRIES:!0});return t}});var Wk=Oe,Kk=QE,Xk=sk,Yk=TypeError;Cr({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=Kk(this),r=arguments.length<2,n=r?void 0:arguments[1];if(Wk(e),Xk(t,(function(i,o){r?(r=!1,n=i):n=e(n,i,o,t)})),r)throw Yk("Reduce of empty map with no initial value");return n}});var qk=Jt,Jk=QE,Qk=sk;Cr({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=Jk(this),r=qk(e,arguments.length>1?arguments[1]:void 0);return!0===Qk(t,(function(e,n){if(r(e,n,t))return!0}),!0)}});var Zk=Oe,$k=QE,eT=TypeError,tT=wE.get,rT=wE.has,nT=wE.set;Cr({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=$k(this),n=arguments.length;Zk(t);var i=rT(r,e);if(!i&&n<3)throw eT("Updating absent value");var o=i?tT(r,e):Zk(n>2?arguments[2]:void 0)(e,r);return nT(r,e,t(o,e,r)),r}});var iT=N,oT=Oe,aT=A,sT=rr,cT=TypeError,uT=function(e,t){var r,n=sT(this),i=oT(n.get),o=oT(n.has),a=oT(n.set),s=arguments.length>2?arguments[2]:void 0;if(!aT(t)&&!aT(s))throw cT("At least one callback required");return iT(o,n,e)?(r=iT(i,n,e),aT(t)&&(r=t(r),iT(a,n,e,r))):aT(s)&&(r=s(),iT(a,n,e,r)),r};Cr({target:"Map",proto:!0,real:!0,forced:!0},{upsert:uT}),Cr({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:uT});var lT=FE,dT=r(lT),hT=r(lT),fT=r(Ll),vT=w,pT=_,_T=N,mT=o,gT=nn,yT=hi,ST=P,bT=qe,ET=z,kT=Object.assign,TT=Object.defineProperty,IT=pT([].concat),RT=!kT||mT((function(){if(vT&&1!==kT({b:1},kT(TT({},"a",{enumerable:!0,get:function(){TT(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!==kT({},e)[r]||gT(kT({},t)).join("")!==n}))?function(e,t){for(var r=bT(e),n=arguments.length,i=1,o=yT.f,a=ST.f;n>i;)for(var s,c=ET(arguments[i++]),u=o?IT(gT(c),o(c)):gT(c),l=u.length,d=0;l>d;)s=u[d++],vT&&!_T(a,c,s)||(r[s]=c[s]);return r}:kT,AT=RT;Cr({target:"Object",stat:!0,arity:2,forced:Object.assign!==AT},{assign:AT});var CT=r(te.Object.assign),wT=Cr,xT=k;C.f;var OT=Fr,NT=Sn,PT=Ly,MT=Y,DT=Vy,LT=xT("".endsWith),UT=xT("".slice),VT=Math.min;wT({target:"String",proto:!0,forced:!DT("endsWith")},{endsWith:function(e){var t=NT(MT(this));PT(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:VT(OT(r),n),o=NT(e);return LT?LT(t,o,i):UT(t,i-o.length,i)===o}});var FT=qs("String").endsWith,BT=se,jT=FT,HT=String.prototype,GT=r((function(e){var t=e.endsWith;return"string"==typeof e||e===HT||BT(HT,e)&&t===HT.endsWith?jT:t})),zT=!0,WT=!0;function KT(e,t,r){var n=e.match(t);return n&&n.length>=r&&yb(n[r],10)}function XT(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 hT),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===FS(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},fT(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 YT(e){return"boolean"!=typeof e?new Error("Argument type: "+Xd(e)+". Please use a boolean."):(zT=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function qT(e){return"boolean"!=typeof e?new Error("Argument type: "+Xd(e)+". Please use a boolean."):(WT=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function JT(){if("object"===("undefined"==typeof window?"undefined":Xd(window))){if(zT)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function QT(e,t){WT&&console.warn(e+" is deprecated, please use "+t+" instead.")}function ZT(e){return"[object Object]"===Object.prototype.toString.call(e)}function $T(e){var t;return ZT(e)?uS(t=FS(e)).call(t,(function(t,r){var n=ZT(e[r]),i=n?$T(e[r]):e[r],o=n&&!FS(i).length;return void 0===i||o?t:CT(t,Jd({},r,i))}),{}):e}function eI(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),FS(t).forEach((function(n){GT(n).call(n,"Id")?eI(e,e.get(t[n]),r):GT(n).call(n,"Ids")&&t[n].forEach((function(t){eI(e,e.get(t),r)}))})))}function tI(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new hT;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&&eI(e,r,i)}))})),i}var rI=Cr,nI=Vo.find,iI="find",oI=!0;iI in[]&&Array(1)[iI]((function(){oI=!1})),rI({target:"Array",proto:!0,forced:oI},{find:function(e){return nI(this,e,arguments.length>1?arguments[1]:void 0)}});var aI=qs("Array").find,sI=se,cI=aI,uI=Array.prototype,lI=r((function(e){var t=e.find;return e===uI||sI(uI,e)&&t===uI.find?cI:t})),dI=r(Pg),hI=Cr,fI=Kr.indexOf,vI=tl,pI=k([].indexOf),_I=!!pI&&1/pI([1],1,-0)<0;hI({target:"Array",proto:!0,forced:_I||!vI("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return _I?pI(this,e,t)||0:fI(this,e,t)}});var mI=qs("Array").indexOf,gI=se,yI=mI,SI=Array.prototype,bI=function(e){var t=e.indexOf;return e===SI||gI(SI,e)&&t===SI.indexOf?yI:t},EI=r(bI),kI=r(bI),TI=Ae,II=TypeError,RI=function(e,t){if(!delete e[t])throw II("Cannot delete property "+TI(t)+" of "+TI(e))},AI=Cr,CI=qe,wI=Lr,xI=Nr,OI=jr,NI=_c,PI=gc,MI=xo,DI=ei,LI=RI,UI=Ks("splice"),VI=Math.max,FI=Math.min;AI({target:"Array",proto:!0,forced:!UI},{splice:function(e,t){var r,n,i,o,a,s,c=CI(this),u=OI(c),l=wI(e,u),d=arguments.length;for(0===d?r=n=0:1===d?(r=0,n=u-l):(r=d-2,n=FI(VI(xI(t),0),u-l)),PI(u+r-n),i=MI(c,n),o=0;o<n;o++)(a=l+o)in c&&DI(i,o,c[a]);if(i.length=n,r<n){for(o=l;o<u-n;o++)s=o+r,(a=o+n)in c?c[s]=c[a]:LI(c,s);for(o=u;o>u-n+r;o--)LI(c,o-1)}else if(r>n)for(o=u-n;o>l;o--)s=o+r-1,(a=o+n-1)in c?c[s]=c[a]:LI(c,s);for(o=0;o<r;o++)c[o+l]=arguments[o+2];return NI(c,u-n+r),i}});var BI=qs("Array").splice,jI=se,HI=BI,GI=Array.prototype,zI=r((function(e){var t=e.splice;return e===GI||jI(GI,e)&&t===GI.splice?HI:t})),WI=r(lc),KI=JT;function XI(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==Xd(e)||e.mandatory||e.optional)return e;var t,r={};(FS(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===Xd(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()+dI(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=Hg(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(Xg(e)))&&"object"===Xd(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(Xg(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===Xd(e.video)){var a=e.video.facingMode;a=a&&("object"===Xd(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=Cy(t).call(t,(function(e){return"videoinput"===e.kind}));var r=lI(t).call(t,(function(e){return s.some((function(t){var r;return Qy(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&Qy(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),KI("chrome: "+Xg(e)),i(e)}));e.video=n(e.video)}return KI("chrome: "+Xg(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 Gg.reject(o(e))}))}))}}}}function YI(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function qI(e){if("object"===Xd(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){fT(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=lI(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=lI(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 XT(e,"track",(function(e){return e.transceiver||fT(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function JI(e){if("object"===Xd(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||[],dI(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=kI(t=this._senders).call(t,e);-1!==i&&zI(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=lI(r=t._senders).call(r,(function(t){return t.track===e}));o&&zI(n=t._senders).call(n,kI(i=t._senders).call(i,o),1)}))}}else if("object"===Xd(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},fT(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 QI(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=dI(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 hT($g(t=FS(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 Gg((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function ZI(e){if("object"===Xd(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 tI(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}),XT(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 tI(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?Gg.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Gg.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function $I(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},$g(e=FS(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===kI(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(lI(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=Cy(t=this.getSenders()).call(t,(function(e){return-1===kI(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Hg(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&&FS(this._shimmedLocalStreams).forEach((function(r){var n,i,o=kI(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&zI(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function eR(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return $I(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},$g(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(lI(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=dI([]).call(arguments,1);if(1!==s.length||!lI(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(lI(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),Gg.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 lI(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){var e=this,t=arguments;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,FS(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=WI(e.RTCPeerConnection.prototype,"localDescription");fT(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||{},FS(this._streams).forEach((function(n){var i;lI(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 FS(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 tR(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}))}function rR(e,t){XT(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 nR=Object.freeze({__proto__:null,fixNegotiationNeeded:rR,shimAddTrackRemoveTrack:eR,shimAddTrackRemoveTrackWithNative:$I,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:JI,shimGetStats:QI,shimGetUserMedia:XI,shimMediaStream:YI,shimOnTrack:qI,shimPeerConnection:tR,shimSenderReceiverGetStats:ZI});function iR(e){return function(e){if(ty(e))return yy(e)}(e)||function(e){if(void 0!==Cd&&null!=ey(e)||null!=e["@@iterator"])return gy(e)}(e)||Sy(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 oR=i,aR=o,sR=Sn,cR=ab.trim,uR=ZS,lR=_("".charAt),dR=oR.parseFloat,hR=oR.Symbol,fR=hR&&hR.iterator,vR=1/dR(uR+"-0")!=-1/0||fR&&!aR((function(){dR(Object(fR))}))?function(e){var t=cR(sR(e)),r=dR(t);return 0===r&&"-"===lR(t,0)?-0:r}:dR;Cr({global:!0,forced:parseFloat!==vR},{parseFloat:vR});var pR=r(te.parseFloat);function _R(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){QT("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"===Xd(e)&&"object"===Xd(e.audio)&&(e=JSON.parse(Xg(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"===Xd(e)&&(e=JSON.parse(Xg(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function mR(e){"object"===Xd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&fT(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function gR(e,t){if("object"===Xd(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}));var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=dI(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,CT({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function yR(e){if("object"===Xd(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):Gg.resolve(new hT)}}}function SR(e){if("object"===Xd(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}),XT(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function bR(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;QT("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&Qy(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function ER(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function kR(e){if("object"===Xd(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=iR(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&&!(pR(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(pR(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===FS(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 TR(e){if("object"===Xd(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=Hg(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function IR(e){if("object"===Xd(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?Gg.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function RR(e){if("object"===Xd(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?Gg.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var AR=Object.freeze({__proto__:null,shimAddTransceiver:kR,shimCreateAnswer:RR,shimCreateOffer:IR,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,Gg.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})},shimGetParameters:TR,shimGetUserMedia:_R,shimOnTrack:mR,shimPeerConnection:gR,shimRTCDataChannel:ER,shimReceiverGetStats:SR,shimRemoveStream:bR,shimSenderGetStats:yR});function CR(e){if("object"===Xd(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=[]),Qy(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?Qy(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=kI(t=this._localStreams).call(t,e);if(-1!==i){zI(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){Qy(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function wR(e){if("object"===Xd(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){fT(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=[]),!Qy(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=[]),!(kI(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 xR(e){if("object"===Xd(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),Gg.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),Gg.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),Gg.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Gg.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Gg.resolve()):n},t.addIceCandidate=s}}function OR(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(NR(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function NR(e){return e&&void 0!==e.video?CT({},e,{video:$T(e.video)}):e}function PR(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")?(QT("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(Xg(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&&fT(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function MR(e){"object"===Xd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&fT(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function DR(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=lI(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=lI(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 LR(e){"object"!==Xd(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var UR=Object.freeze({__proto__:null,shimAudioContext:LR,shimCallbacksAPI:xR,shimConstraints:NR,shimCreateOfferLegacy:DR,shimGetUserMedia:OR,shimLocalStreamsAPI:CR,shimRTCIceServerUrls:PR,shimRemoteStreamsAPI:wR,shimTrackEventTransceiver:MR}),VR=Uc.PROPER,FR=o,BR=ZS,jR=ab.trim;Cr({target:"String",proto:!0,forced:function(e){return FR((function(){return!!BR[e]()||"​…᠎"!=="​…᠎"[e]()||VR&&BR[e].name!==e}))}("trim")},{trim:function(){return jR(this)}});var HR,GR,zR=qs("String").trim,WR=se,KR=zR,XR=String.prototype,YR=r((function(e){var t=e.trim;return"string"==typeof e||e===XR||WR(XR,e)&&t===XR.trim?KR:t})),qR={exports:{}};HR=qR,(GR={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=GR.generateIdentifier(),GR.splitLines=function(e){var t;return $g(t=YR(e).call(e).split("\n")).call(t,(function(e){return YR(e).call(e)}))},GR.splitSections=function(e){var t=e.split("\nm=");return $g(t).call(t,(function(e,t){var r;return YR(r=t>0?"m="+e:e).call(r)+"\r\n"}))},GR.getDescription=function(e){var t=GR.splitSections(e);return t&&t[0]},GR.getMediaSections=function(e){var t=GR.splitSections(e);return t.shift(),t},GR.matchPrefix=function(e,t){var r;return Cy(r=GR.splitLines(e)).call(r,(function(e){return 0===kI(e).call(e,t)}))},GR.parseCandidate=function(e){for(var t,r={foundation:(t=0===kI(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:yb(t[3],10),ip:t[4],address:t[4],port:yb(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=yb(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},GR.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(" ")},GR.parseIceOptions=function(e){return e.substr(14).split(" ")},GR.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:yb(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=yb(t[1],10),r.channels=3===t.length?yb(t[2],10):1,r.numChannels=r.channels,r},GR.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"},GR.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:yb(r[0],10),direction:kI(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},GR.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},GR.parseFmtp=function(e){for(var t,r={},n=e.substr(kI(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=YR(o=n[i]).call(o).split("="),r[YR(a=t[0]).call(a)]=t[1]}return r},GR.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&FS(e.parameters).length){var n=[];FS(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},GR.parseRtcpFb=function(e){var t=e.substr(kI(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},GR.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},GR.parseSsrcMedia=function(e){var t=kI(e).call(e," "),r={ssrc:yb(e.substr(7,t-7),10)},n=kI(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},GR.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:$g(t).call(t,(function(e){return yb(e,10)}))}},GR.getMid=function(e){var t=GR.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},GR.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},GR.getDtlsParameters=function(e,t){var r=GR.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:$g(r).call(r,GR.parseFingerprint)}},GR.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},GR.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:yb(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:dI(t).call(t,3)}},GR.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===Xd(e.keyParams)?GR.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},GR.parseCryptoKeyParams=function(e){if(0!==kI(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}},GR.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},GR.getCryptoParameters=function(e,t){var r=GR.matchPrefix(e+t,"a=crypto:");return $g(r).call(r,GR.parseCryptoLine)},GR.getIceParameters=function(e,t){var r=GR.matchPrefix(e+t,"a=ice-ufrag:")[0],n=GR.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},GR.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},GR.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=GR.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=GR.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=GR.parseRtpMap(o),c=GR.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=c.length?GR.parseFmtp(c[0]):{},s.rtcpFeedback=$g(a=GR.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,GR.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return GR.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(GR.parseExtmap(e))})),t},GR.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=$g(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+=GR.writeRtpMap(e),n+=GR.writeFmtp(e),n+=GR.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+=GR.writeExtmap(e)})),n},GR.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],c=GR.parseRtpParameters(e),u=-1!==kI(t=c.fecMechanisms).call(t,"RED"),l=-1!==kI(r=c.fecMechanisms).call(r,"ULPFEC"),d=Cy(n=$g(i=GR.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return GR.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=d.length>0&&d[0].ssrc,f=$g(o=GR.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return $g(t).call(t,(function(e){return yb(e,10)}))}));f.length>0&&f[0].length>1&&f[0][0]===h&&(a=f[0][1]),c.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:h,codecPayloadType:yb(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),u&&((t=JSON.parse(Xg(t))).fec={ssrc:h,mechanism:l?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var v,p,_=GR.matchPrefix(e,"b=");return _.length&&(_=0===kI(v=_[0]).call(v,"b=TIAS:")?yb(_[0].substr(7),10):0===kI(p=_[0]).call(p,"b=AS:")?1e3*yb(_[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=_}))),s},GR.parseRtcpParameters=function(e){var t,r,n={},i=Cy(t=$g(r=GR.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return GR.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=GR.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=GR.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},GR.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},GR.parseMsid=function(e){var t,r,n,i=GR.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=Cy(t=$g(r=GR.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return GR.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},GR.parseSctpDescription=function(e){var t,r=GR.parseMLine(e),n=GR.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=yb(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=GR.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:yb(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=GR.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:yb(a[0],10),protocol:a[1],maxMessageSize:t}}},GR.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("")},GR.generateSessionId=function(){return Math.random().toString().substr(2,21)},GR.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||GR.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},GR.getDirection=function(e,t){for(var r=GR.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?GR.getDirection(t):"sendrecv"},GR.getKind=function(e){return GR.splitLines(e)[0].split(" ")[0].substr(2)},GR.isRejected=function(e){return"0"===e.split(" ",2)[1]},GR.parseMLine=function(e){var t=GR.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:yb(t[1],10),protocol:t[2],fmt:dI(t).call(t,3).join(" ")}},GR.parseOLine=function(e){var t=GR.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:yb(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},GR.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=GR.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},HR.exports=GR;var JR=qR.exports,QR=r(JR),ZR=e({__proto__:null,default:QR},[JR]);function $R(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===Xd(e)&&e.candidate&&0===kI(r=e.candidate).call(r,"a=")&&((e=JSON.parse(Xg(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=QR.parseCandidate(e.candidate),o=CT(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,XT(e,"icecandidate",(function(t){return t.candidate&&fT(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function eA(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||XT(e,"icecandidate",(function(e){if(e.candidate){var t=QR.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function tA(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||fT(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&&fT(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=QR.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=QR.parseMLine(e);return r&&"application"===r.kind&&-1!==kI(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=yb(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=QR.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=yb(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={};fT(c,"maxMessageSize",{get:function(){return i}}),this._sctp=c}return r.apply(this,arguments)}}}function rA(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},XT(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 nA(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;fT(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),fT(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 iA(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!==kI(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=Cy(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==YR(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 oA(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?Gg.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Gg.resolve())})}}function aA(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"!==Xd(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 sA=Object.freeze({__proto__:null,removeExtmapAllowMixed:iA,shimAddIceCandidateNullOrEmpty:oA,shimConnectionState:nA,shimMaxMessageSize:tA,shimParameterlessSetLocalDescription:aA,shimRTCIceCandidate:$R,shimRTCIceCandidateRelayProtocol:eA,shimSendThrowTypeError:rA});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=JT,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=KT(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=KT(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=KT(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),i={browserDetails:n,commonShim:sA,extractVersion:KT,disableLog:YT,disableWarnings:qT,sdp:ZR};switch(n.browser){case"chrome":if(!nR||!tR||!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=nR,oA(e,n),aA(e),XI(e,n),YI(e),tR(e,n),qI(e),eR(e,n),JI(e),QI(e),ZI(e),rR(e,n),$R(e),eA(e),nA(e),tA(e,n),rA(e),iA(e,n);break;case"firefox":if(!AR||!gR||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),i;r("adapter.js shimming firefox."),i.browserShim=AR,oA(e,n),aA(e),_R(e,n),gR(e,n),mR(e),bR(e),yR(e),SR(e),ER(e),kR(e),TR(e),IR(e),RR(e),$R(e),nA(e),tA(e,n),rA(e);break;case"safari":if(!UR||!t.shimSafari)return r("Safari shim is not included in this adapter release."),i;r("adapter.js shimming safari."),i.browserShim=UR,oA(e,n),aA(e),PR(e),DR(e),xR(e),CR(e),wR(e),MR(e),OR(e),LR(e),$R(e),eA(e),tA(e,n),rA(e),iA(e,n);break;default:r("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var cA=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=cA.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 uA(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var lA=Ze,dA=function(e){return void 0!==e&&(lA(e,"value")||lA(e,"writable"))},hA=N,fA=ee,vA=rr,pA=dA,_A=C,mA=Kc;Cr({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return vA(t)===o?t[r]:(n=_A.f(t,r))?pA(n)?n.value:void 0===n.get?void 0:hA(n.get,o):fA(i=mA(t))?e(i,r,o):void 0}});var gA=te.Reflect.get,yA=r(gA),SA=_,bA=Oe,EA=ee,kA=Ze,TA=cs,IA=a,RA=Function,AA=SA([].concat),CA=SA([].join),wA={},xA=IA?RA.bind:function(e){var t=bA(this),r=t.prototype,n=TA(arguments,1),i=function(){var r=AA(n,TA(arguments));return this instanceof i?function(e,t,r){if(!kA(wA,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";wA[t]=RA("C,a","return new C("+CA(n,",")+")")}return wA[t](e,r)}(t,r.length,r):t.apply(e,r)};return EA(r)&&(i.prototype=r),i},OA=xA;Cr({target:"Function",proto:!0,forced:Function.bind!==OA},{bind:OA});var NA=qs("Function").bind,PA=se,MA=NA,DA=Function.prototype,LA=r((function(e){var t=e.bind;return e===DA||PA(DA,e)&&t===DA.bind?MA:t}));function UA(e){var t;return(UA=Jh?LA(t=Yh).call(t):function(e){return e.__proto__||Yh(e)})(e)}function VA(){var e;"undefined"!=typeof Reflect&&yA?VA=LA(e=yA).call(e):VA=function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=UA(e)););return e}(e,t);if(n){var i=dc(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return VA.apply(this,arguments)}function FA(e,t){var r;return(FA=Jh?LA(r=Jh).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function BA(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=zh(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Ul(e,"prototype",{writable:!1}),t&&FA(e,t)}var jA=Cr,HA=d,GA=xA,zA=xv,WA=rr,KA=ee,XA=Kn,YA=o,qA=ae("Reflect","construct"),JA=Object.prototype,QA=[].push,ZA=YA((function(){function e(){}return!(qA((function(){}),[],e)instanceof e)})),$A=!YA((function(){qA((function(){}))})),eC=ZA||$A;jA({target:"Reflect",stat:!0,forced:eC,sham:eC},{construct:function(e,t){zA(e),WA(t);var r=arguments.length<3?e:zA(arguments[2]);if($A&&!ZA)return qA(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 HA(QA,n,t),new(HA(GA,e,n))}var i=r.prototype,o=XA(KA(i)?i:JA),a=HA(e,o,t);return KA(a)?a:o}});var tC=r(te.Reflect.construct);function rC(){if("undefined"==typeof Reflect||!tC)return!1;if(tC.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(tC(Boolean,[],(function(){}))),!0}catch(e){return!1}}function nC(e){var t=rC();return function(){var r,n=UA(e);if(t){var i=UA(this).constructor;r=tC(n,arguments,i)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===Xd(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return uA(e)}(this,r)}}var iC=ai,oC=Math.floor,aC=function(e,t){var r=e.length,n=oC(r/2);return r<8?sC(e,t):cC(e,aC(iC(e,0,n),t),aC(iC(e,n),t),t)},sC=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},cC=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},uC=aC,lC=ce.match(/firefox\/(\d+)/i),dC=!!lC&&+lC[1],hC=/MSIE|Trident/.test(ce),fC=ce.match(/AppleWebKit\/(\d+)\./),vC=!!fC&&+fC[1],pC=Cr,_C=_,mC=Oe,gC=qe,yC=jr,SC=RI,bC=Sn,EC=o,kC=uC,TC=tl,IC=dC,RC=hC,AC=pe,CC=vC,wC=[],xC=_C(wC.sort),OC=_C(wC.push),NC=EC((function(){wC.sort(void 0)})),PC=EC((function(){wC.sort(null)})),MC=TC("sort"),DC=!EC((function(){if(AC)return AC<70;if(!(IC&&IC>3)){if(RC)return!0;if(CC)return CC<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++)wC.push({k:t+n,v:r})}for(wC.sort((function(e,t){return t.v-e.v})),n=0;n<wC.length;n++)t=wC[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));pC({target:"Array",proto:!0,forced:NC||!PC||!MC||!DC},{sort:function(e){void 0!==e&&mC(e);var t=gC(this);if(DC)return void 0===e?xC(t):xC(t,e);var r,n,i=[],o=yC(t);for(n=0;n<o;n++)n in t&&OC(i,t[n]);for(kC(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:bC(t)>bC(r)?1:-1}}(e)),r=yC(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)SC(t,n++);return t}});var LC=qs("Array").sort,UC=se,VC=LC,FC=Array.prototype,BC=r((function(e){var t=e.sort;return e===FC||UC(FC,e)&&t===FC.sort?VC:t})),jC=Cr,HC=Vo.findIndex,GC="findIndex",zC=!0;GC in[]&&Array(1)[GC]((function(){zC=!1})),jC({target:"Array",proto:!0,forced:zC},{findIndex:function(e){return HC(this,e,arguments.length>1?arguments[1]:void 0)}});var WC=qs("Array").findIndex,KC=se,XC=WC,YC=Array.prototype,qC=r((function(e){var t=e.findIndex;return e===YC||KC(YC,e)&&t===YC.findIndex?XC:t})),JC=Cr,QC=k;C.f;var ZC=Fr,$C=Sn,ew=Ly,tw=Y,rw=Vy,nw=QC("".startsWith),iw=QC("".slice),ow=Math.min;JC({target:"String",proto:!0,forced:!rw("startsWith")},{startsWith:function(e){var t=$C(tw(this));ew(e);var r=ZC(ow(arguments.length>1?arguments[1]:void 0,t.length)),n=$C(e);return nw?nw(t,n,r):iw(t,r,r+n.length)===n}});var aw=qs("String").startsWith,sw=se,cw=aw,uw=String.prototype,lw=r((function(e){var t=e.startsWith;return"string"==typeof e||e===uw||sw(uw,e)&&t===uw.startsWith?cw:t})),dw=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.TOKEN_NO_PUBLISH_PERMISSION="TOKEN_NO_PUBLISH_PERMISSION",e.TOKEN_NO_SUBSCRIBE_PERMISSION="TOKEN_NO_SUBSCRIBE_PERMISSION",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}(dw||{}),hw=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}(hw||{});function fw(e,t,r){var n;rC()?fw=LA(n=tC).call(n):fw=function(e,t,r){var n=[null];xc(n).apply(n,t);var i=new(LA(Function).apply(e,n));return r&&FA(i,r.prototype),i};return fw.apply(null,arguments)}function vw(e){var t="function"==typeof dT?new dT:void 0;return vw=function(e){if(null===e||(r=e,-1===EI(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 fw(e,arguments,UA(this).constructor)}return i.prototype=zh(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),FA(i,e)},vw(e)}var pw=r(qh),_w=function(e){BA(r,e);var t=nC(r);function r(e,n,i){var o;return Hh(this,r),Jd(uA(o=t.call(this,n)),"code",void 0),Jd(uA(o),"message",void 0),Jd(uA(o),"error",void 0),o.code=e,o.message=n,o.error=i,pw(uA(o),r.prototype),o}return jh(r,[{key:"toString",value:function(){var e;return Hg(e="SDKError: ".concat(this.code," ")).call(e,this.message)}}]),r}(vw(Error)),mw=Nr,gw=Sn,yw=Y,Sw=RangeError,bw=_,Ew=Fr,kw=Sn,Tw=Y,Iw=bw((function(e){var t=gw(yw(this)),r="",n=mw(e);if(n<0||n===1/0)throw Sw("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r})),Rw=bw("".slice),Aw=Math.ceil,Cw=function(e){return function(t,r,n){var i,o,a=kw(Tw(t)),s=Ew(r),c=a.length,u=void 0===n?" ":kw(n);return s<=c||""===u?a:((o=Iw(u,Aw((i=s-c)/u.length))).length>i&&(o=Rw(o,0,i)),e?a+o:o+a)}},ww={start:Cw(!1),end:Cw(!0)},xw=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(ce),Ow=ww.end;Cr({target:"String",proto:!0,forced:xw},{padEnd:function(e){return Ow(this,e,arguments.length>1?arguments[1]:void 0)}});var Nw=qs("String").padEnd,Pw=se,Mw=Nw,Dw=String.prototype,Lw=r((function(e){var t=e.padEnd;return"string"==typeof e||e===Dw||Pw(Dw,e)&&t===Dw.padEnd?Mw:t})),Uw=gb;Cr({target:"Number",stat:!0,forced:Number.parseInt!==Uw},{parseInt:Uw});var Vw=r(te.Number.parseInt),Fw=r(my),Bw=r(fg),jw=Math.log,Hw=Math.LOG10E;Cr({target:"Math",stat:!0},{log10:Math.log10||function(e){return jw(e)*Hw}});var Gw=r(te.Math.log10);Cr({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991});var zw,Ww=r(9007199254740991),Kw=qs("Array").values,Xw=mn,Yw=Ze,qw=se,Jw=Kw,Qw=Array.prototype,Zw={DOMTokenList:!0,NodeList:!0},$w=r((function(e){var t=e.values;return e===Qw||qw(Qw,e)&&t===Qw.values||Yw(Zw,Xw(e))?Jw:t})),ex=qs("Array").keys,tx=mn,rx=Ze,nx=se,ix=ex,ox=Array.prototype,ax={DOMTokenList:!0,NodeList:!0},sx=r((function(e){var t=e.keys;return e===ox||nx(ox,e)&&t===ox.keys||rx(ax,tx(e))?ix:t})),cx=new Uint8Array(16);function ux(){if(!zw&&!(zw="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 zw(cx)}var lx=/^(?:[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 dx=[],hx=0;hx<256;++hx)dx.push((hx+256).toString(16).substr(1));function fx(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(dx[e[t+0]]+dx[e[t+1]]+dx[e[t+2]]+dx[e[t+3]]+"-"+dx[e[t+4]]+dx[e[t+5]]+"-"+dx[e[t+6]]+dx[e[t+7]]+"-"+dx[e[t+8]]+dx[e[t+9]]+"-"+dx[e[t+10]]+dx[e[t+11]]+dx[e[t+12]]+dx[e[t+13]]+dx[e[t+14]]+dx[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&lx.test(e)}(r))throw TypeError("Stringified UUID is invalid");return r}function vx(e,t,r){var n=(e=e||{}).random||(e.rng||ux)();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 fx(n)}var px=function(){return"undefined"==typeof window},_x=function(){return vx()},mx=function(e){return"number"==typeof e};function gx(e){return null==e?"undefined | null":"string"==typeof e?e:Xg({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function yx(e){return null==e?"undefined | null":"string"==typeof e?e:Xg({id:e.id,active:e.active})}function Sx(e){return null==e?"undefined | null":"string"==typeof e?e:Xg({track:gx(e.track)})}function bx(e){return null==e?"undefined | null":"string"==typeof e?e:Xg({track:gx(e.track)})}function Ex(e){return null==e?"undefined | null":"string"==typeof e?e:Xg({currentDirection:e.currentDirection,direction:e.direction,mid:e.mid,stopped:e.stopped,receiver:bx(e.receiver),sender:Sx(e.sender)})}var kx="@byted/ve-rtc",Tx="@byted/ve-rtc-cache-size",Ix=function(){function e(){Hh(this,e),Jd(this,"storeKey",void 0),Jd(this,"logLevel",void 0),Jd(this,"LogfileSize",void 0),Jd(this,"db",void 0),Jd(this,"logId",void 0),Jd(this,"cacheLog",void 0),Jd(this,"cachedSize",void 0),Jd(this,"preCacheTime",void 0),Jd(this,"timer",void 0),Jd(this,"_getSize",(function(e){return new Blob(e).size/1048576})),this.storeKey="",this.logId=1,this.cacheLog="",this.logLevel="none",this.LogfileSize=100,this._createStore()}return jh(e,[{key:"_createStore",value:function(){var e=this;if(!px()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(kx);try{localStorage.removeItem(Tx)}catch(KJ){}},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(Tx);if(t)this.cachedSize=Number(t);else $w(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(KJ){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(Tx,"".concat(this.cachedSize))}catch(KJ){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(kx,e).objectStore(kx)}},{key:"set",value:function(e){var t=this;return new Gg((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Hg(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,l,d=Hg(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Hg(s=Hg(c="".concat(d?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(Hg(u="".concat(d)).call(u,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Hg(l="".concat(t.cacheLog)).call(l,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(XJ){var f;if(!e)return n(XJ);t.cacheLog+=Hg(f="\n\n".concat(t.logId,": ")).call(f,e),t.logId++,n(XJ)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Hg(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new Gg((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 Gg((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 sx(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 Gg((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 Gg((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}(),Rx=new Ix,Ax=ww.start;Cr({target:"String",proto:!0,forced:xw},{padStart:function(e){return Ax(this,e,arguments.length>1?arguments[1]:void 0)}});var Cx=qs("String").padStart,wx=se,xx=Cx,Ox=String.prototype,Nx=r((function(e){var t=e.padStart;return"string"==typeof e||e===Ox||wx(Ox,e)&&t===Ox.padStart?xx:t})),Px=function(){function e(){Hh(this,e),Jd(this,"_all",{})}return jh(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||zI(r).call(r,kI(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||dI(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,Hg(t=[e]).call(t,n))}catch(KJ){console.error(KJ)}}},{key:"destroy",value:function(){this._all={}}}]),e}(),Mx=["UPLOAD_CONSOLE_LENGTH_CUT","UPLOAD_REPORT_LIMIT"];var Dx=function(e){BA(r,e);var t=nC(r);function r(){var e,n;Hh(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(uA(n=t.call.apply(t,Hg(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 jh(r,[{key:"setParameter",value:function(e,t){if(function(e){return Qy(Mx).call(Mx,e)}(e))try{var r=Number(t);if(Number.isNaN(r))return;this.config[e]=r}catch(i){var n;return void console.warn(Hg(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 FS(this.config)}}]),r}(Px),Lx=new Dx,Ux=io,Vx=jr,Fx=gc,Bx=Jt,jx=function(e,t,r,n,i,o,a,s){for(var c,u,l=i,d=0,h=!!a&&Bx(a,s);d<n;)d in r&&(c=h?h(r[d],d,t):r[d],o>0&&Ux(c)?(u=Vx(c),l=jx(e,t,c,u,l,o-1)-1):(Fx(l+1),e[l]=c),l++),d++;return l},Hx=jx,Gx=qe,zx=jr,Wx=Nr,Kx=xo;Cr({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Gx(this),r=zx(t),n=Kx(t,0);return n.length=Hx(n,t,t,r,0,void 0===e?1:Wx(e)),n}});var Xx=qs("Array").flat,Yx=se,qx=Xx,Jx=Array.prototype,Qx=r((function(e){var t=e.flat;return e===Jx||Yx(Jx,e)&&t===Jx.flat?qx:t})),Zx={};!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=dI(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==Xd(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 Hg([]).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)}(Zx);var $x={},eO={},tO={},rO=Zx,nO=0,iO=1;function oO(e){for(var t=e.length;--t>=0;)e[t]=0}var aO=0,sO=29,cO=256,uO=cO+1+sO,lO=30,dO=19,hO=2*uO+1,fO=15,vO=16,pO=7,_O=256,mO=16,gO=17,yO=18,SO=[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],bO=[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],EO=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],kO=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],TO=new Array(2*(uO+2));oO(TO);var IO=new Array(2*lO);oO(IO);var RO=new Array(512);oO(RO);var AO=new Array(256);oO(AO);var CO=new Array(sO);oO(CO);var wO,xO,OO,NO=new Array(lO);function PO(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 MO(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function DO(e){return e<256?RO[e]:RO[256+(e>>>7)]}function LO(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function UO(e,t,r){e.bi_valid>vO-r?(e.bi_buf|=t<<e.bi_valid&65535,LO(e,e.bi_buf),e.bi_buf=t>>vO-e.bi_valid,e.bi_valid+=r-vO):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function VO(e,t,r){UO(e,r[2*t],r[2*t+1])}function FO(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function BO(e,t,r){var n,i,o=new Array(fO+1),a=0;for(n=1;n<=fO;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]=FO(o[s]++,s))}}function jO(e){var t;for(t=0;t<uO;t++)e.dyn_ltree[2*t]=0;for(t=0;t<lO;t++)e.dyn_dtree[2*t]=0;for(t=0;t<dO;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*_O]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function HO(e){e.bi_valid>8?LO(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 GO(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 zO(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&GO(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!GO(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function WO(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?VO(e,i,t):(VO(e,(o=AO[i])+cO+1,t),0!==(a=SO[o])&&UO(e,i-=CO[o],a),VO(e,o=DO(--n),r),0!==(a=bO[o])&&UO(e,n-=NO[o],a))}while(s<e.last_lit);VO(e,_O,t)}function KO(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=hO,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--)zO(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],zO(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++,zO(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,l=t.stat_desc.static_tree,d=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,f=t.stat_desc.extra_base,v=t.stat_desc.max_length,p=0;for(o=0;o<=fO;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<hO;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>v&&(o=v,p++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=f&&(a=h[n-f]),s=c[2*n],e.opt_len+=s*(o+a),d&&(e.static_len+=s*(l[2*n+1]+a)));if(0!==p){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]--,p-=2}while(p>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),BO(o,u,e.bl_count)}function XO(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*mO]++):s<=10?e.bl_tree[2*gO]++:e.bl_tree[2*yO]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function YO(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{VO(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(VO(e,i,e.bl_tree),s--),VO(e,mO,e.bl_tree),UO(e,s-3,2)):s<=10?(VO(e,gO,e.bl_tree),UO(e,s-3,3)):(VO(e,yO,e.bl_tree),UO(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}oO(NO);var qO=!1;function JO(e,t,r,n){UO(e,(aO<<1)+(n?1:0),3),function(e,t,r,n){HO(e),n&&(LO(e,r),LO(e,~r)),rO.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}tO._tr_init=function(e){qO||(!function(){var e,t,r,n,i,o=new Array(fO+1);for(r=0,n=0;n<sO-1;n++)for(CO[n]=r,e=0;e<1<<SO[n];e++)AO[r++]=n;for(AO[r-1]=n,i=0,n=0;n<16;n++)for(NO[n]=i,e=0;e<1<<bO[n];e++)RO[i++]=n;for(i>>=7;n<lO;n++)for(NO[n]=i<<7,e=0;e<1<<bO[n]-7;e++)RO[256+i++]=n;for(t=0;t<=fO;t++)o[t]=0;for(e=0;e<=143;)TO[2*e+1]=8,e++,o[8]++;for(;e<=255;)TO[2*e+1]=9,e++,o[9]++;for(;e<=279;)TO[2*e+1]=7,e++,o[7]++;for(;e<=287;)TO[2*e+1]=8,e++,o[8]++;for(BO(TO,uO+1,o),e=0;e<lO;e++)IO[2*e+1]=5,IO[2*e]=FO(e,5);wO=new PO(TO,SO,cO+1,uO,fO),xO=new PO(IO,bO,0,lO,fO),OO=new PO(new Array(0),EO,0,dO,pO)}(),qO=!0),e.l_desc=new MO(e.dyn_ltree,wO),e.d_desc=new MO(e.dyn_dtree,xO),e.bl_desc=new MO(e.bl_tree,OO),e.bi_buf=0,e.bi_valid=0,jO(e)},tO._tr_stored_block=JO,tO._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 nO;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return iO;for(t=32;t<cO;t++)if(0!==e.dyn_ltree[2*t])return iO;return nO}(e)),KO(e,e.l_desc),KO(e,e.d_desc),a=function(e){var t;for(XO(e,e.dyn_ltree,e.l_desc.max_code),XO(e,e.dyn_dtree,e.d_desc.max_code),KO(e,e.bl_desc),t=dO-1;t>=3&&0===e.bl_tree[2*kO[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?JO(e,t,r,n):4===e.strategy||o===i?(UO(e,2+(n?1:0),3),WO(e,TO,IO)):(UO(e,4+(n?1:0),3),function(e,t,r,n){var i;for(UO(e,t-257,5),UO(e,r-1,5),UO(e,n-4,4),i=0;i<n;i++)UO(e,e.bl_tree[2*kO[i]+1],3);YO(e,e.dyn_ltree,t-1),YO(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),WO(e,e.dyn_ltree,e.dyn_dtree)),jO(e),n&&HO(e)},tO._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*(AO[r]+cO+1)]++,e.dyn_dtree[2*DO(t)]++),e.last_lit===e.lit_bufsize-1},tO._tr_align=function(e){UO(e,2,3),VO(e,_O,TO),function(e){16===e.bi_valid?(LO(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 ZO=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 $O,eN=function(e,t,r,n){var i=ZO,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},tN={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"},rN=Zx,nN=tO,iN=QO,oN=eN,aN=tN,sN=0,cN=4,uN=0,lN=-2,dN=-1,hN=4,fN=2,vN=8,pN=9,_N=286,mN=30,gN=19,yN=2*_N+1,SN=15,bN=3,EN=258,kN=EN+bN+1,TN=42,IN=103,RN=113,AN=666,CN=1,wN=2,xN=3,ON=4;function NN(e,t){return e.msg=aN[t],t}function PN(e){return(e<<1)-(e>4?9:0)}function MN(e){for(var t=e.length;--t>=0;)e[t]=0}function DN(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(rN.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 LN(e,t){nN._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,DN(e.strm)}function UN(e,t){e.pending_buf[e.pending++]=t}function VN(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function FN(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-kN?e.strstart-(e.w_size-kN):0,u=e.window,l=e.w_mask,d=e.prev,h=e.strstart+EN,f=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]===f&&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=EN-(h-o),o=h-EN,n>a){if(e.match_start=t,a=n,n>=s)break;f=u[o+a-1],v=u[o+a]}}}while((t=d[t&l])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function BN(e){var t,r,n,i,o,a,s,c,u,l,d=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=d+(d-kN)){rN.arraySet(e.window,e.window,d,d,0),e.match_start-=d,e.strstart-=d,e.block_start-=d,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=d?n-d:0}while(--r);t=r=d;do{n=e.prev[--t],e.prev[t]=n>=d?n-d:0}while(--r);i+=d}if(0===e.strm.avail_in)break;if(a=e.strm,s=e.window,c=e.strstart+e.lookahead,u=i,l=void 0,(l=a.avail_in)>u&&(l=u),r=0===l?0:(a.avail_in-=l,rN.arraySet(s,a.input,a.next_in,l,c),1===a.state.wrap?a.adler=iN(a.adler,s,l,c):2===a.state.wrap&&(a.adler=oN(a.adler,s,l,c)),a.next_in+=l,a.total_in+=l,l),e.lookahead+=r,e.lookahead+e.insert>=bN)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+bN-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<bN)););}while(e.lookahead<kN&&0!==e.strm.avail_in)}function jN(e,t){for(var r,n;;){if(e.lookahead<kN){if(BN(e),e.lookahead<kN&&t===sN)return CN;if(0===e.lookahead)break}if(r=0,e.lookahead>=bN&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+bN-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-kN&&(e.match_length=FN(e,r)),e.match_length>=bN)if(n=nN._tr_tally(e,e.strstart-e.match_start,e.match_length-bN),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=bN){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+bN-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=nN._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(LN(e,!1),0===e.strm.avail_out))return CN}return e.insert=e.strstart<bN-1?e.strstart:bN-1,t===cN?(LN(e,!0),0===e.strm.avail_out?xN:ON):e.last_lit&&(LN(e,!1),0===e.strm.avail_out)?CN:wN}function HN(e,t){for(var r,n,i;;){if(e.lookahead<kN){if(BN(e),e.lookahead<kN&&t===sN)return CN;if(0===e.lookahead)break}if(r=0,e.lookahead>=bN&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+bN-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=bN-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-kN&&(e.match_length=FN(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===bN&&e.strstart-e.match_start>4096)&&(e.match_length=bN-1)),e.prev_length>=bN&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-bN,n=nN._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-bN),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+bN-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=bN-1,e.strstart++,n&&(LN(e,!1),0===e.strm.avail_out))return CN}else if(e.match_available){if((n=nN._tr_tally(e,0,e.window[e.strstart-1]))&&LN(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return CN}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=nN._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<bN-1?e.strstart:bN-1,t===cN?(LN(e,!0),0===e.strm.avail_out?xN:ON):e.last_lit&&(LN(e,!1),0===e.strm.avail_out)?CN:wN}function GN(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 zN(){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=vN,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 rN.Buf16(2*yN),this.dyn_dtree=new rN.Buf16(2*(2*mN+1)),this.bl_tree=new rN.Buf16(2*(2*gN+1)),MN(this.dyn_ltree),MN(this.dyn_dtree),MN(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new rN.Buf16(SN+1),this.heap=new rN.Buf16(2*_N+1),MN(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new rN.Buf16(2*_N+1),MN(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 WN(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=fN,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?TN:RN,e.adler=2===t.wrap?0:1,t.last_flush=sN,nN._tr_init(t),uN):NN(e,lN)}function KN(e){var t,r=WN(e);return r===uN&&((t=e.state).window_size=2*t.w_size,MN(t.head),t.max_lazy_match=$O[t.level].max_lazy,t.good_match=$O[t.level].good_length,t.nice_match=$O[t.level].nice_length,t.max_chain_length=$O[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=bN-1,t.match_available=0,t.ins_h=0),r}function XN(e,t,r,n,i,o){if(!e)return lN;var a=1;if(t===dN&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>pN||r!==vN||n<8||n>15||t<0||t>9||o<0||o>hN)return NN(e,lN);8===n&&(n=9);var s=new zN;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+bN-1)/bN),s.window=new rN.Buf8(2*s.w_size),s.head=new rN.Buf16(s.hash_size),s.prev=new rN.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new rN.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,KN(e)}$O=[new GN(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(BN(e),0===e.lookahead&&t===sN)return CN;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,LN(e,!1),0===e.strm.avail_out))return CN;if(e.strstart-e.block_start>=e.w_size-kN&&(LN(e,!1),0===e.strm.avail_out))return CN}return e.insert=0,t===cN?(LN(e,!0),0===e.strm.avail_out?xN:ON):(e.strstart>e.block_start&&(LN(e,!1),e.strm.avail_out),CN)})),new GN(4,4,8,4,jN),new GN(4,5,16,8,jN),new GN(4,6,32,32,jN),new GN(4,4,16,16,HN),new GN(8,16,32,32,HN),new GN(8,16,128,128,HN),new GN(8,32,128,256,HN),new GN(32,128,258,1024,HN),new GN(32,258,258,4096,HN)],eO.deflateInit=function(e,t){return XN(e,t,vN,15,8,0)},eO.deflateInit2=XN,eO.deflateReset=KN,eO.deflateResetKeep=WN,eO.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?lN:(e.state.gzhead=t,uN):lN},eO.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?NN(e,lN):lN;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===AN&&t!==cN)return NN(e,0===e.avail_out?-5:lN);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===TN)if(2===n.wrap)e.adler=0,UN(n,31),UN(n,139),UN(n,8),n.gzhead?(UN(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)),UN(n,255&n.gzhead.time),UN(n,n.gzhead.time>>8&255),UN(n,n.gzhead.time>>16&255),UN(n,n.gzhead.time>>24&255),UN(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),UN(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(UN(n,255&n.gzhead.extra.length),UN(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=oN(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(UN(n,0),UN(n,0),UN(n,0),UN(n,0),UN(n,0),UN(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),UN(n,3),n.status=RN);else{var a=vN+(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=RN,VN(n,a),0!==n.strstart&&(VN(n,e.adler>>>16),VN(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=oN(e.adler,n.pending_buf,n.pending-i,i)),DN(e),i=n.pending,n.pending!==n.pending_buf_size));)UN(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=oN(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=oN(e.adler,n.pending_buf,n.pending-i,i)),DN(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,UN(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=oN(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=oN(e.adler,n.pending_buf,n.pending-i,i)),DN(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,UN(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=oN(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=IN)}else n.status=IN;if(n.status===IN&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&DN(e),n.pending+2<=n.pending_buf_size&&(UN(n,255&e.adler),UN(n,e.adler>>8&255),e.adler=0,n.status=RN)):n.status=RN),0!==n.pending){if(DN(e),0===e.avail_out)return n.last_flush=-1,uN}else if(0===e.avail_in&&PN(t)<=PN(r)&&t!==cN)return NN(e,-5);if(n.status===AN&&0!==e.avail_in)return NN(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==sN&&n.status!==AN){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(BN(e),0===e.lookahead)){if(t===sN)return CN;break}if(e.match_length=0,r=nN._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(LN(e,!1),0===e.strm.avail_out))return CN}return e.insert=0,t===cN?(LN(e,!0),0===e.strm.avail_out?xN:ON):e.last_lit&&(LN(e,!1),0===e.strm.avail_out)?CN:wN}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=EN){if(BN(e),e.lookahead<=EN&&t===sN)return CN;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=bN&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+EN;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=EN-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=bN?(r=nN._tr_tally(e,1,e.match_length-bN),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=nN._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(LN(e,!1),0===e.strm.avail_out))return CN}return e.insert=0,t===cN?(LN(e,!0),0===e.strm.avail_out?xN:ON):e.last_lit&&(LN(e,!1),0===e.strm.avail_out)?CN:wN}(n,t):$O[n.level].func(n,t);if(s!==xN&&s!==ON||(n.status=AN),s===CN||s===xN)return 0===e.avail_out&&(n.last_flush=-1),uN;if(s===wN&&(1===t?nN._tr_align(n):5!==t&&(nN._tr_stored_block(n,0,0,!1),3===t&&(MN(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),DN(e),0===e.avail_out))return n.last_flush=-1,uN}return t!==cN?uN:n.wrap<=0?1:(2===n.wrap?(UN(n,255&e.adler),UN(n,e.adler>>8&255),UN(n,e.adler>>16&255),UN(n,e.adler>>24&255),UN(n,255&e.total_in),UN(n,e.total_in>>8&255),UN(n,e.total_in>>16&255),UN(n,e.total_in>>24&255)):(VN(n,e.adler>>>16),VN(n,65535&e.adler)),DN(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?uN:1)},eO.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==TN&&69!==t&&73!==t&&91!==t&&t!==IN&&t!==RN&&t!==AN?NN(e,lN):(e.state=null,t===RN?NN(e,-3):uN):lN},eO.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,l=t.length;if(!e||!e.state)return lN;if(2===(o=(r=e.state).wrap)||1===o&&r.status!==TN||r.lookahead)return lN;for(1===o&&(e.adler=iN(e.adler,t,l,0)),r.wrap=0,l>=r.w_size&&(0===o&&(MN(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new rN.Buf8(r.w_size),rN.arraySet(u,t,l-r.w_size,r.w_size,0),t=u,l=r.w_size),a=e.avail_in,s=e.next_in,c=e.input,e.avail_in=l,e.next_in=0,e.input=t,BN(r);r.lookahead>=bN;){n=r.strstart,i=r.lookahead-(bN-1);do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+bN-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=bN-1,BN(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=bN-1,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,uN},eO.deflateInfo="pako deflate (from Nodeca project)";var YN={},qN=Zx,JN=!0,QN=!0;try{String.fromCharCode.apply(null,[0])}catch(YJ){JN=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(YJ){QN=!1}for(var ZN=new qN.Buf8(256),$N=0;$N<256;$N++)ZN[$N]=$N>=252?6:$N>=248?5:$N>=240?4:$N>=224?3:$N>=192?2:1;function eP(e,t){if(t<65534&&(e.subarray&&QN||!e.subarray&&JN))return String.fromCharCode.apply(null,qN.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}ZN[254]=ZN[254]=1,YN.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 qN.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},YN.buf2binstring=function(e){return eP(e,e.length)},YN.binstring2buf=function(e){for(var t=new qN.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},YN.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=ZN[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 eP(s,n)},YN.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+ZN[e[r]]>t?r:t};var tP=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},rP=eO,nP=Zx,iP=YN,oP=tN,aP=tP,sP=Object.prototype.toString,cP=0,uP=-1,lP=0,dP=8;function hP(e){if(!(this instanceof hP))return new hP(e);this.options=nP.assign({level:uP,method:dP,chunkSize:16384,windowBits:15,memLevel:8,strategy:lP,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 aP,this.strm.avail_out=0;var r=rP.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==cP)throw new Error(oP[r]);if(t.header&&rP.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?iP.string2buf(t.dictionary):"[object ArrayBuffer]"===sP.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=rP.deflateSetDictionary(this.strm,n))!==cP)throw new Error(oP[r]);this._dict_set=!0}}function fP(e,t){var r=new hP(t);if(r.push(e,!0),r.err)throw r.msg||oP[r.err];return r.result}hP.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=iP.string2buf(e):"[object ArrayBuffer]"===sP.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 nP.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=rP.deflate(i,n))&&r!==cP)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(iP.buf2binstring(nP.shrinkBuf(i.output,i.next_out))):this.onData(nP.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=rP.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===cP):2!==n||(this.onEnd(cP),i.avail_out=0,!0)},hP.prototype.onData=function(e){this.chunks.push(e)},hP.prototype.onEnd=function(e){e===cP&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=nP.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},$x.Deflate=hP,$x.deflate=fP,$x.deflateRaw=function(e,t){return(t=t||{}).raw=!0,fP(e,t)},$x.gzip=function(e,t){return(t=t||{}).gzip=!0,fP(e,t)};var vP={},pP=rr,_P=N,mP=Ze,gP=se,yP=function(){var e=pP(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},SP=RegExp.prototype,bP=se,EP=function(e){var t=e.flags;return void 0!==t||"flags"in SP||mP(e,"flags")||!gP(SP,e)?t:_P(yP,e)},kP=RegExp.prototype,TP=r((function(e){return e===kP||bP(kP,e)?EP(e):e.flags})),IP={},RP=Zx,AP=15,CP=[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],wP=[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],xP=[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],OP=[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],NP=Zx,PP=QO,MP=eN,DP=function(e,t){var r,n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,R=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,u=r.wsize,l=r.whave,d=r.wnext,h=r.window,f=r.hold,v=r.bits,p=r.lencode,_=r.distcode,m=(1<<r.lenbits)-1,g=(1<<r.distbits)-1;e:do{v<15&&(f+=I[n++]<<v,v+=8,f+=I[n++]<<v,v+=8),y=p[f&m];t:for(;;){if(f>>>=S=y>>>24,v-=S,0===(S=y>>>16&255))R[o++]=65535&y;else{if(!(16&S)){if(0==(64&S)){y=p[(65535&y)+(f&(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&&(f+=I[n++]<<v,v+=8),b+=f&(1<<S)-1,f>>>=S,v-=S),v<15&&(f+=I[n++]<<v,v+=8,f+=I[n++]<<v,v+=8),y=_[f&g];r:for(;;){if(f>>>=S=y>>>24,v-=S,!(16&(S=y>>>16&255))){if(0==(64&S)){y=_[(65535&y)+(f&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(E=65535&y,v<(S&=15)&&(f+=I[n++]<<v,(v+=8)<S&&(f+=I[n++]<<v,v+=8)),(E+=f&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(f>>>=S,v-=S,E>(S=o-a)){if((S=E-S)>l&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(k=0,T=h,0===d){if(k+=u-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}else if(d<S){if(k+=u+d-S,(S-=d)<b){b-=S;do{R[o++]=h[k++]}while(--S);if(k=0,d<b){b-=S=d;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}}else if(k+=d-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}for(;b>2;)R[o++]=T[k++],R[o++]=T[k++],R[o++]=T[k++],b-=3;b&&(R[o++]=T[k++],b>1&&(R[o++]=T[k++]))}else{k=o-E;do{R[o++]=R[k++],R[o++]=R[k++],R[o++]=R[k++],b-=3}while(b>2);b&&(R[o++]=R[k++],b>1&&(R[o++]=R[k++]))}break}}break}}while(n<i&&o<s);n-=b=v>>3,f&=(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=f,r.bits=v},LP=function(e,t,r,n,i,o,a,s){var c,u,l,d,h,f,v,p,_,m=s.bits,g=0,y=0,S=0,b=0,E=0,k=0,T=0,I=0,R=0,A=0,C=null,w=0,x=new RP.Buf16(16),O=new RP.Buf16(16),N=null,P=0;for(g=0;g<=AP;g++)x[g]=0;for(y=0;y<n;y++)x[t[r+y]]++;for(E=m,b=AP;b>=1&&0===x[b];b--);if(E>b&&(E=b),0===b)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<b&&0===x[S];S++);for(E<S&&(E=S),I=1,g=1;g<=AP;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<AP;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?(C=N=a,f=19):1===e?(C=CP,w-=257,N=wP,P-=257,f=256):(C=xP,N=OP,f=-1),A=0,y=0,g=S,h=o,k=E,T=0,l=-1,d=(R=1<<E)-1,1===e&&R>852||2===e&&R>592)return 1;for(;;){v=g-T,a[y]<f?(p=0,_=a[y]):a[y]>f?(p=N[P+a[y]],_=C[w+a[y]]):(p=96,_=0),c=1<<g-T,S=u=1<<k;do{i[h+(A>>T)+(u-=c)]=v<<24|p<<16|_|0}while(0!==u);for(c=1<<g-1;A&c;)c>>=1;if(0!==c?(A&=c-1,A+=c):A=0,y++,0==--x[g]){if(g===b)break;g=t[r+a[y]]}if(g>E&&(A&d)!==l){for(0===T&&(T=E),h+=S,I=1<<(k=g-T);k+T<b&&!((I-=x[k+T])<=0);)k++,I<<=1;if(R+=1<<k,1===e&&R>852||2===e&&R>592)return 1;i[l=A&d]=E<<24|k<<16|h-o|0}}return 0!==A&&(i[h+A]=g-T<<24|64<<16|0),s.bits=E,0},UP=1,VP=2,FP=0,BP=-2,jP=1,HP=12,GP=30,zP=852,WP=592;function KP(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function XP(){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 NP.Buf16(320),this.work=new NP.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function YP(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=jP,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new NP.Buf32(zP),t.distcode=t.distdyn=new NP.Buf32(WP),t.sane=1,t.back=-1,FP):BP}function qP(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,YP(e)):BP}function JP(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)?BP:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,qP(e))):BP}function QP(e,t){var r,n;return e?(n=new XP,e.state=n,n.window=null,(r=JP(e,t))!==FP&&(e.state=null),r):BP}var ZP,$P,eM=!0;function tM(e){if(eM){var t;for(ZP=new NP.Buf32(512),$P=new NP.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(LP(UP,e.lens,0,288,ZP,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;LP(VP,e.lens,0,32,$P,0,e.work,{bits:5}),eM=!1}e.lencode=ZP,e.lenbits=9,e.distcode=$P,e.distbits=5}function rM(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 NP.Buf8(o.wsize)),n>=o.wsize?(NP.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),NP.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(NP.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}IP.inflateReset=qP,IP.inflateReset2=JP,IP.inflateResetKeep=YP,IP.inflateInit=function(e){return QP(e,15)},IP.inflateInit2=QP,IP.inflate=function(e,t){var r,n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R=0,A=new NP.Buf8(4),C=[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 BP;(r=e.state).mode===HP&&(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,l=r.bits,d=s,h=c,k=FP;e:for(;;)switch(r.mode){case jP:if(0===r.wrap){r.mode=13;break}for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(2&r.wrap&&35615===u){r.check=0,A[0]=255&u,A[1]=u>>>8&255,r.check=MP(r.check,A,2,0),u=0,l=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=GP;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=GP;break}if(l-=4,E=8+(15&(u>>>=4)),0===r.wbits)r.wbits=E;else if(E>r.wbits){e.msg="invalid window size",r.mode=GP;break}r.dmax=1<<E,e.adler=r.check=1,r.mode=512&u?10:HP,u=0,l=0;break;case 2:for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(r.flags=u,8!=(255&TP(r))){e.msg="unknown compression method",r.mode=GP;break}if(57344&TP(r)){e.msg="unknown header flags set",r.mode=GP;break}r.head&&(r.head.text=u>>8&1),512&TP(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=MP(r.check,A,2,0)),u=0,l=0,r.mode=3;case 3:for(;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.head&&(r.head.time=u),512&TP(r)&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=MP(r.check,A,4,0)),u=0,l=0,r.mode=4;case 4:for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&TP(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=MP(r.check,A,2,0)),u=0,l=0,r.mode=5;case 5:if(1024&TP(r)){for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&TP(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=MP(r.check,A,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&TP(r)&&((f=r.length)>s&&(f=s),f&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),NP.arraySet(r.head.extra,n,o,f,E)),512&TP(r)&&(r.check=MP(r.check,n,f,o)),s-=f,o+=f,r.length-=f),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&TP(r)){if(0===s)break e;f=0;do{E=n[o+f++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&f<s);if(512&TP(r)&&(r.check=MP(r.check,n,f,o)),s-=f,o+=f,E)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&TP(r)){if(0===s)break e;f=0;do{E=n[o+f++],r.head&&E&&r.length<65536&&(r.head.comment+=String.fromCharCode(E))}while(E&&f<s);if(512&TP(r)&&(r.check=MP(r.check,n,f,o)),s-=f,o+=f,E)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&TP(r)){for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=GP;break}u=0,l=0}r.head&&(r.head.hcrc=TP(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=HP;break;case 10:for(;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}e.adler=r.check=KP(u),u=0,l=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=l,2;e.adler=r.check=1,r.mode=HP;case HP:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}switch(r.last=1&u,l-=1,3&(u>>>=1)){case 0:r.mode=14;break;case 1:if(tM(r),r.mode=20,6===t){u>>>=2,l-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=GP}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=GP;break}if(r.length=65535&u,u=0,l=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(f=r.length){if(f>s&&(f=s),f>c&&(f=c),0===f)break e;NP.arraySet(i,n,o,f,a),s-=f,o+=f,c-=f,a+=f,r.length-=f;break}r.mode=HP;break;case 17:for(;l<14;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(r.nlen=257+(31&u),u>>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=GP;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;l<3;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.lens[C[r.have++]]=7&u,u>>>=3,l-=3}for(;r.have<19;)r.lens[C[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,T={bits:r.lenbits},k=LP(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid code lengths set",r.mode=GP;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,!((_=R>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(g<16)u>>>=_,l-=_,r.lens[r.have++]=g;else{if(16===g){for(I=_+2;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(u>>>=_,l-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=GP;break}E=r.lens[r.have-1],f=3+(3&u),u>>>=2,l-=2}else if(17===g){for(I=_+3;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}l-=_,E=0,f=3+(7&(u>>>=_)),u>>>=3,l-=3}else{for(I=_+7;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}l-=_,E=0,f=11+(127&(u>>>=_)),u>>>=7,l-=7}if(r.have+f>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=GP;break}for(;f--;)r.lens[r.have++]=E}}if(r.mode===GP)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=GP;break}if(r.lenbits=9,T={bits:r.lenbits},k=LP(UP,r.lens,0,r.nlen,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid literal/lengths set",r.mode=GP;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},k=LP(VP,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,T),r.distbits=T.bits,k){e.msg="invalid distances set",r.mode=GP;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=l,DP(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,l=r.bits,r.mode===HP&&(r.back=-1);break}for(r.back=0;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((_=R>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(m&&0==(240&m)){for(y=_,S=m,b=g;m=(R=r.lencode[b+((u&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(_=R>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}u>>>=y,l-=y,r.back+=y}if(u>>>=_,l-=_,r.back+=_,r.length=g,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=HP;break}if(64&m){e.msg="invalid literal/length code",r.mode=GP;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(I=r.extra;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,l-=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,!((_=R>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(0==(240&m)){for(y=_,S=m,b=g;m=(R=r.distcode[b+((u&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(_=R>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}u>>>=y,l-=y,r.back+=y}if(u>>>=_,l-=_,r.back+=_,64&m){e.msg="invalid distance code",r.mode=GP;break}r.offset=g,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(I=r.extra;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=GP;break}r.mode=25;case 25:if(0===c)break e;if(f=h-c,r.offset>f){if((f=r.offset-f)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=GP;break}f>r.wnext?(f-=r.wnext,v=r.wsize-f):v=r.wnext-f,f>r.length&&(f=r.length),p=r.window}else p=i,v=a-r.offset,f=r.length;f>c&&(f=c),c-=f,r.length-=f;do{i[a++]=p[v++]}while(--f);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(;l<32;){if(0===s)break e;s--,u|=n[o++]<<l,l+=8}if(h-=c,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=TP(r)?MP(r.check,i,h,a-h):PP(r.check,i,h,a-h)),h=c,(TP(r)?u:KP(u))!==r.check){e.msg="incorrect data check",r.mode=GP;break}u=0,l=0}r.mode=28;case 28:if(r.wrap&&TP(r)){for(;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=GP;break}u=0,l=0}r.mode=29;case 29:k=1;break e;case GP:k=-3;break e;case 31:return-4;default:return BP}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,(r.wsize||h!==e.avail_out&&r.mode<GP&&(r.mode<27||4!==t))&&rM(e,e.output,e.next_out,h-e.avail_out),d-=e.avail_in,h-=e.avail_out,e.total_in+=d,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=TP(r)?MP(r.check,i,h,e.next_out-h):PP(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===HP?128:0)+(20===r.mode||15===r.mode?256:0),(0===d&&0===h||4===t)&&k===FP&&(k=-5),k},IP.inflateEnd=function(e){if(!e||!e.state)return BP;var t=e.state;return t.window&&(t.window=null),e.state=null,FP},IP.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?BP:(r.head=t,t.done=!1,FP):BP},IP.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?BP:11===r.mode&&PP(1,t,n,0)!==r.check?-3:rM(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,FP):BP},IP.inflateInfo="pako inflate (from Nodeca project)";var nM={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 iM=IP,oM=Zx,aM=YN,sM=nM,cM=tN,uM=tP,lM=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},dM=Object.prototype.toString;function hM(e){if(!(this instanceof hM))return new hM(e);this.options=oM.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 uM,this.strm.avail_out=0;var r=iM.inflateInit2(this.strm,t.windowBits);if(r!==sM.Z_OK)throw new Error(cM[r]);if(this.header=new lM,iM.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=aM.string2buf(t.dictionary):"[object ArrayBuffer]"===dM.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=iM.inflateSetDictionary(this.strm,t.dictionary))!==sM.Z_OK))throw new Error(cM[r])}function fM(e,t){var r=new hM(t);if(r.push(e,!0),r.err)throw r.msg||cM[r.err];return r.result}hM.prototype.push=function(e,t){var r,n,i,o,a,s=this.strm,c=this.options.chunkSize,u=this.options.dictionary,l=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?sM.Z_FINISH:sM.Z_NO_FLUSH,"string"==typeof e?s.input=aM.binstring2buf(e):"[object ArrayBuffer]"===dM.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 oM.Buf8(c),s.next_out=0,s.avail_out=c),(r=iM.inflate(s,sM.Z_NO_FLUSH))===sM.Z_NEED_DICT&&u&&(r=iM.inflateSetDictionary(this.strm,u)),r===sM.Z_BUF_ERROR&&!0===l&&(r=sM.Z_OK,l=!1),r!==sM.Z_STREAM_END&&r!==sM.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==sM.Z_STREAM_END&&(0!==s.avail_in||n!==sM.Z_FINISH&&n!==sM.Z_SYNC_FLUSH)||("string"===this.options.to?(i=aM.utf8border(s.output,s.next_out),o=s.next_out-i,a=aM.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&oM.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(oM.shrinkBuf(s.output,s.next_out)))),0===s.avail_in&&0===s.avail_out&&(l=!0)}while((s.avail_in>0||0===s.avail_out)&&r!==sM.Z_STREAM_END);return r===sM.Z_STREAM_END&&(n=sM.Z_FINISH),n===sM.Z_FINISH?(r=iM.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===sM.Z_OK):n!==sM.Z_SYNC_FLUSH||(this.onEnd(sM.Z_OK),s.avail_out=0,!0)},hM.prototype.onData=function(e){this.chunks.push(e)},hM.prototype.onEnd=function(e){e===sM.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=oM.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},vP.Inflate=hM,vP.inflate=fM,vP.inflateRaw=function(e,t){return(t=t||{}).raw=!0,fM(e,t)},vP.ungzip=fM;var vM={};(0,Zx.assign)(vM,$x,vP,nM);var pM=r(vM),_M=1,mM=function(){function e(t){Hh(this,e),Jd(this,"lockingPromise",Gg.resolve()),Jd(this,"locks",0),Jd(this,"name",""),Jd(this,"lockId",void 0),this.lockId=_M++,t&&(this.name=t)}return jh(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t=this;this.locks+=1;var r=new Gg((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}(),gM="BytePlusRTC",yM=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},SM=function(){function e(t){Hh(this,e),Jd(this,"storeName",void 0),Jd(this,"pendingList",[]),this.storeName=t,!px()&&yM()&&this._checkAndCreateStore(t)}var t,r,n,i,o,a,s;return jh(e,[{key:"_checkAndCreateStore",value:(s=Ug(Dg().mark((function t(r,n){var i,o,a=this;return Dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e._promiseLock.lock();case 2:if(i=t.sent,!yM().databases){t.next=6;break}return t.next=6,new Gg((function(e){var t=function(){return yM().databases().finally(e)};o=setInterval(t,100),t()})).finally((function(){return clearInterval(o)}));case 6:return t.abrupt("return",new Gg((function(t){e.db&&(e.db.close(),delete e.db);var o=n?yM().open(gM,n):yM().open(gM);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=Ug(Dg().mark((function e(t){var r,n,i,o;return Dg().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=Ug(Dg().mark((function t(r){var n,i=this;return Dg().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 Gg((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=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{n=Xg(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=Ug(Dg().mark((function e(t){var r,n;return Dg().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=Ug(Dg().mark((function e(t,r){var n;return Dg().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 Gg((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=Ug(Dg().mark((function e(t){var r;return Dg().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 Gg((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=Ug(Dg().mark((function e(t){var r;return Dg().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 Gg((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 bM(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],EI(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],EI(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}Jd(SM,"db",void 0),Jd(SM,"state","init"),Jd(SM,"_promiseLock",new mM("iDB"));var EM=["message"];var kM,TM,IM,RM=new(function(){function e(){Hh(this,e),Jd(this,"name","LongStringReportor"),Jd(this,"inBuffer",[]),Jd(this,"outBuffer",[])}return jh(e,[{key:"push",value:function(e){var t;e.message&&this.inBuffer.push(Zd(Zd({},e),{},{message:{id:dI(t=_x()).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=Xg(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=Zd(Zd({},bM(i,EM)),{},{message:Zd(Zd({},o),{},{msg:""})}),s=Xg(a).length,c=e-s,u=Zd({},a);if(c>o.msg.length)u.message.msg=o.msg,this.inBuffer.shift();else{if(!(c>=10))break;var l,d,h=dI(l=o.msg).call(l,0,c);u.message.msg=h,u.message.end=!1,this.inBuffer[0].message.msg=dI(d=o.msg).call(d,c),this.inBuffer[0].message.index++}var f=Xg(u.message),v=f.length;e-=v+s,r+=v+s,t.push(Zd(Zd({},u),{},{message:f}))}return{payload:t,payloadSize:r}}},{key:"unshift",value:function(e){this.outBuffer=Hg(e).call(e,this.outBuffer)}},{key:"get",value:function(){var e,t;return Hg(e=[]).call(e,iR(this.outBuffer),iR($g(t=this.inBuffer).call(t,(function(e){return Zd(Zd({},e),{},{message:Xg(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(Zd(Zd({},e),{},{message:JSON.parse(e.message)}))):t.outBuffer.push(e)})),this.outBuffer=Hg(r).call(r,this.outBuffer),this.inBuffer=Hg(n).call(n,this.inBuffer)}},{key:"isEmpty",value:function(){return 0===this.inBuffer.length&&0===this.outBuffer.length}}]),e}()),AM={product_line:"rtc",report_version:"5",os:"web",user_agent:px()?"":null===(kM=navigator)||void 0===kM?void 0:kM.userAgent,platform:"web",product:"webrtc",app_state:"active"},CM="LogReportor",wM="undefined"!=typeof window&&(Qy(TM=window.location.search).call(TM,"_rtc_debug_")||(null===(IM=window.localStorage)||void 0===IM?void 0:IM.getItem("_rtc_debug_"))),xM=function(){function e(t){Hh(this,e),Jd(this,"_buffer",void 0),this._buffer=new SM(t)}var t,r;return jh(e,[{key:"set",value:(r=Ug(Dg().mark((function e(t,r){return Dg().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=Ug(Dg().mark((function e(t){var r,n;return Dg().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}(),OM=function(){function e(){var t=this;Hh(this,e),Jd(this,"reportCommon",AM),Jd(this,"reportIds",new hT),Jd(this,"dataBuffer",[]),Jd(this,"reportorList",[]),Jd(this,"dbBuffer",void 0),Jd(this,"posting",!1),Jd(this,"sucSendTimer",void 0),Jd(this,"preSucTime",0),Jd(this,"errSendTimer",void 0),Jd(this,"errSendDelay",100),Jd(this,"_logServerUrl",void 0),Jd(this,"_retryCount",0),Jd(this,"_reportLimit",5e5),Jd(this,"_disableTimeout",!1),px()||(window.addEventListener("beforeunload",(function(){clearTimeout(t.errSendTimer),clearTimeout(t.sucSendTimer),t.send(void 0,!0)})),wM&&(window.__rtc_debug_reportor__=this)),Lx.on("UPLOAD_REPORT_LIMIT",(function(e){t.setReportLimit(e)})),Lx.on("ENABLE_REPORT_IDB_BUFFER",(function(e){e&&t.enableIndexedDBBuffer()})),setTimeout((function(){t.reportorList.push(sD),t.reportorList.push(RM)}))}var t;return jh(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.reportCommon=CT(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&&(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 xM("ReportorDBBuffer"),this.dbBuffer.get(CM).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(iR(this.dataBuffer),CM),this.reportorList.forEach((function(t){var r;null===(r=e.dbBuffer)||void 0===r||r.set(iR(t.get()),t.name)}))}catch(r){}}},{key:"unshift",value:function(e){var t;this.dataBuffer=Hg(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+=Xg(e[n]).length)>t)return n;return e.length}(this.dataBuffer,this._reportLimit);0===r&&this.dataBuffer.length>0&&(this._reportLimit=Xg(this.dataBuffer[0]).length+10,r=1,BM("update report limit to ".concat(this._reportLimit)));var n=zI(e=this.dataBuffer).call(e,0,r),i=Xg(n).length,o=[n],a=this._reportLimit-i;return this.reportorList.forEach((function(e){var r=zI(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),!px()&&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=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,h;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.backup(),i=uS(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=wM,s={data:t||Qx(o).call(o),header:Zd(Zd({},this.reportCommon),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},c={method:"POST",body:a?Xg(s):pM.gzip(Xg(s))},!this._disableTimeout)try{u=new AbortController,c.signal=u.signal,setTimeout((function(){u.abort()}),1e4)}catch(f){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!==(l=e.sent).status&&304!==l.status){e.next=23;break}return e.t0=JSON,e.next=21,l.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),d=e.t2;case 28:t||(this.posting=!1),h&&0===h.StatusCode?t||r||this.sucSend():(setTimeout((function(){var e,t,r,n;BM(Hg(e="reportor post error, resJSON:".concat(null===(t=h)||void 0===t?void 0:t.toString()," err:")).call(e,d),null!==(r=null===(n=l)||void 0===n?void 0:n.status)&&void 0!==r?r:-1)}),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 NM=new OM,PM=function(){function e(t){Hh(this,e),Jd(this,"modifyIds",{pre_connection:!1}),this.id=t}return jh(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=Zd(Zd(Zd({event_key:e,rtc_timestamp:Date.now()},this.modifyIds),t),{},{common_extra_info:Xg(i),report_id:NM.getReportId(this.modifyIds.engine_session_id)});!px()&&window.__onRTCReport&&(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.modifyIds.engine_session_id,o,NM.getCommonStats()));NM.push(o)}},{key:"reportLog",value:function(e){var t=Zd(Zd({event_key:"rtc_invoke_status",sdk_api_name:"console_log",rtc_timestamp:Date.now()},this.modifyIds),{},{message:e});sD.push(t)}},{key:"reportLongString",value:function(e,t){var r=Zd(Zd({event_key:"rtc_invoke_status",sdk_api_name:"sdk_long_string_".concat(e),rtc_timestamp:Date.now()},this.modifyIds),{},{message:t});RM.push(r)}},{key:"set",value:function(e){this.modifyIds=CT(this.modifyIds,e)}},{key:"destroy",value:function(){}}]),e}(),MM=function(){function e(t){Hh(this,e),Jd(this,"_preTime",Date.now()),Jd(this,"_one2oneNum",0),Jd(this,"_one2manyNum",0),Jd(this,"_one2oneMsgCache",new hT),Jd(this,"_one2manyMsgCache",new hT),Jd(this,"roomId",""),Jd(this,"userId",""),Jd(this,"rtsSessionId",""),Jd(this,"logger",void 0),Jd(this,"serverUrl","server"),this.id=t,this.logger=new hD("MessageReportor",1)}return jh(e,[{key:"needReport",value:function(t){return!!e.config&&(Date.now()-this._preTime>=36e5&&(this._preTime=Date.now(),this._one2oneNum=0,this._one2manyNum=0),"one2one"===t&&this._one2oneNum<e.config.max_one2one_fpt_per_hour&&Math.random()<=e.config.one2one_fpt_ratio/100||"one2many"===t&&this._one2manyNum<e.config.max_one2many_fpt_per_hour&&Math.random()<=e.config.one2many_fpt_ratio/100)}},{key:"cacheP2PMsg",value:function(t){var r;this._one2oneMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateP2PMsg",value:function(e,t){var r=this._one2oneMsgCache.get(e);r&&this._one2oneMsgCache.set(e,Zd(Zd({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateOne2ManyMsg",value:function(e,t){var r=this._one2manyMsgCache.get(e);r&&this._one2manyMsgCache.set(e,Zd(Zd({},r),t))}},{key:"reportP2PMsg",value:function(e){var t=this._one2oneMsgCache.get(e);t&&this.logger.info("reportP2PMsg",t.type,Xg(t))}},{key:"reportOne2ManyMsg",value:function(e){var t=this._one2manyMsgCache.get(e);t&&this.logger.info("reportOne2ManyMsg",t.type,Xg(t))}},{key:"reportMsgRecv",value:function(t){var r;t.config_version=(null===(r=e.config)||void 0===r?void 0:r.version)||"",this.logger.info("reportMsgRecv",t.type,Xg(t))}},{key:"destroy",value:function(){this._one2manyNum=0,this._one2oneNum=0,this._one2manyMsgCache.clear(),this._one2oneMsgCache.clear(),this._preTime=Date.now(),this.roomId="",this.userId="",this.rtsSessionId=""}}]),e}();Jd(MM,"config",void 0);var DM=new hT,LM={_cache:DM,setServerUrl:function(e,t){var r=DM.get(e);r&&(r.serverUrl=t)},setConfig:function(e){new hD("MessageReportor",1).info("setConfig","get config: ".concat(Xg(e))),MM.config=e},setRtsSessionId:function(e,t){var r=DM.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=DM.get(e)||new MM(e);return DM.set(e,t),t},destroyRTSMsgReportor:function(e){var t=DM.get(e);t&&(t.destroy(),DM.delete(e))},setRoomId:function(e,t){var r=DM.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=DM.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=DM.get(e);if(null!=r&&r.needReport("one2one")){var n=t.to?"one2one":"one2server";t.enable_report=!0,t.report_msg_id=t.id,r.cacheP2PMsg({rts_session_id:r.rtsSessionId,msg_id:"".concat(t.id),node_role:"src_sdk",from:t.from,to:t.to||r.serverUrl,msg_type:n,type:n,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;t.enable_report&&mx(t.report_msg_id)&&(null===(n=DM.get(e))||void 0===n||n.updateP2PMsg("".concat(t.report_msg_id),{send_ts:Date.now(),msg_size:r}))},updateP2PMsgAck:function(e,t,r){if(t.enable_report&&mx(t.report_msg_id)){var n=DM.get(e);null==n||n.updateP2PMsg("".concat(t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==n||n.reportP2PMsg("".concat(t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n=DM.get(e);return null!=n&&n.needReport("one2many")&&(r.enable_report=!0,r.report_msg_id=t,n.cacheCustomMsg({rts_session_id:n.rtsSessionId,msg_id:"".concat(t),node_role:"src_sdk",from:r.clientId,to:n.roomId||r.roomId,msg_type:"one2many",type:"one2many",rts_room_id:n.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:""})),r},reportP2PMsgRecv:function(e,t,r){if(t.enable_report&&mx(t.report_msg_id)){var n=DM.get(e),i=t.to?"one2one":"one2many";null==n||n.reportMsgRecv({rts_session_id:n.rtsSessionId,msg_id:"".concat(t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",msg_type:i,type:i,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?"":n.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},updateOne2ManyMsgAck:function(e,t,r){if(t.enable_report&&mx(t.report_msg_id)){var n=DM.get(e);n&&(null==n||n.updateOne2ManyMsg("".concat(t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==n||n.reportOne2ManyMsg("".concat(t.report_msg_id)))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&mx(t.report_msg_id)){var n=DM.get(e);n&&n.updateOne2ManyMsg("".concat(t.report_msg_id),{send_ts:Date.now(),msg_size:r})}},reportOne2ManyMsgRecv:function(e,t,r){if(t.enable_report&&mx(t.report_msg_id)){var n=DM.get(e);null==n||n.reportMsgRecv({rts_session_id:n.rtsSessionId,msg_id:"".concat(t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",msg_type:"one2many",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:n.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}}},UM=function(){function e(t){Hh(this,e),Jd(this,"_timer",void 0),Jd(this,"userMessage",{}),Jd(this,"roomMessage",{}),this.id=t,this._setTimer()}return jh(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(FS(this.userMessage).length||FS(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){}},{key:"_reset",value:function(){this.userMessage={},this.roomMessage={}}},{key:"_checkInitUserMessage",value:function(e,t){var r,n;this.userMessage[Hg(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Hg(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[Hg(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Hg(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Hg(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Hg(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)&&(Qy(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[Hg(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/2<=100?(a.dc_send_ack_100++,a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r/2<=200?(a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r/2<=400?(a.dc_send_ack_400++,a.dc_send_ack_1s++):r/2<=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/2<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t/2<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t/2<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t/2<=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||0,i.s2e_time||0):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}(),VM=function(e){NM.setCommonStats(e)},FM=function(e){NM.setUrl(e)};new PM("global");var BM=function(e,t,r){},jM=new hT,HM=function(e){return jM.get(e)},GM=function(e,t){var r=new PM(e);return r.set(Zd(Zd({},t),{},{engine_session_id:_x()})),jM.set(e,r),r};function zM(){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,o=arguments.length,a=new Array(o),s=0;s<o;s++)a[s]=arguments[s];var c,u=this.engineId||this.id;t.forEach((function(e,t){a[t]}));try{c=i.apply(this,a)}catch(l){throw KM(u,r,l.message,l.code||-1),l}return"function"==typeof(null===(e=c)||void 0===e?void 0:e.then)?c.then((function(e){return KM(u,r,[null!=e?e:{}]),e})).catch((function(e){throw KM(u,r,e.message,e.code),e})):(KM(u,r,[null!==(n=c)&&void 0!==n?n:{}]),c)}}}}var WM,KM=function(e,t,r){var n;Xg(Array.isArray(r)?(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>XM){var c,u,l,d,h,f=new DataView(o),v=$g(c=Fw({length:XM/2})).call(c,(function(e,t){return f.getUint8(t)})),p=$g(u=Bw(l=$g(d=Fw({length:XM/2})).call(d,(function(e,t){return a-1-t}))).call(l)).call(u,(function(e){return f.getUint8(e)}));s=Hg(h=[]).call(h,iR(v),["..."],iR(p))}else s=Fw(new Uint8Array(o));return Hg(n=Hg(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return $g(t).call(t,e);if(Qy(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var _={};for(var m in t)_[m]=e(t[m]);return _}return t instanceof Function?"[User Function]":t},$g(n=r).call(n,(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>XM){var c,u,l,d,h,f=new DataView(o),v=$g(c=Fw({length:XM/2})).call(c,(function(e,t){return f.getUint8(t)})),p=$g(u=Bw(l=$g(d=Fw({length:XM/2})).call(d,(function(e,t){return a-1-t}))).call(l)).call(u,(function(e){return f.getUint8(e)}));s=Hg(h=[]).call(h,iR(v),["..."],iR(p))}else s=Fw(new Uint8Array(o));return Hg(n=Hg(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return $g(t).call(t,e);if(Qy(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var _={};for(var m in t)_[m]=e(t[m]);return _}if(t instanceof Function)return"[User Function]";return t}))):r)},XM=10;var YM="undefined"!=typeof window&&Qy(WM=window.location.search).call(WM,"_rtc_upload_console_");function qM(e,t){return $g(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 gx(e);if(e instanceof MediaStream)return yx(e);if(e instanceof RTCRtpSender)return Sx(e);if(e instanceof RTCRtpReceiver)return bx(e);if(e instanceof RTCRtpTransceiver)return Ex(e);r=Xg(e)}catch(n){r=e.toString()}return r&&r.length>=t&&(r=dI(r).call(r,0,t)),r})).join(", ")}var JM,QM,ZM,$M,eD,tD,rD,nD,iD,oD,aD,sD=new(function(){function e(){var t=this;Hh(this,e),Jd(this,"name","ConsoleReportor"),Jd(this,"_uuid","".concat(Math.floor(899*Math.random())+100)),Jd(this,"_consoleReportId",0),Jd(this,"_engineReportIdMap",new hT),Jd(this,"_enabled","NULL"),Jd(this,"_consoleCutLength",Lx.getParameter("UPLOAD_CONSOLE_LENGTH_CUT")),Jd(this,"buffer",[]),YM&&setTimeout((function(){t.switchOn()}),0),Lx.on("UPLOAD_CONSOLE_ON",(function(e){e?t.switchOn():t.turnOff()})),Lx.on("UPLOAD_CONSOLE_LENGTH_CUT",(function(e){t._consoleCutLength=e}))}return jh(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,l,d,h,f,v,p,_,m,g,y,S=this;if("OFF"!==this._enabled){var b=HM(t),E=this._consoleReportId++,k=this.getEngineConsoleId(t),T=qM(c,this._consoleCutLength),I=iR(c),R="".concat(s).replace(/%o|%s/gi,(function(){return qM([I.shift()],S._consoleCutLength)})),A=Hg(u=Hg(l=Hg(d=Hg(h=Hg(f=Hg(v=Hg(p=Hg(_=Hg(m=Hg(g=Hg(y="[".concat(this._uuid,"-")).call(y,E,"][")).call(g,t,"-")).call(m,k,"]-")).call(_,r,"-")).call(p,e,"[")).call(v,n,"]")).call(f,i,"[")).call(h,o,".")).call(d,a,"] ")).call(l,R," ")).call(u,T);b&&b.reportLog(A)}}},{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=Xg(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:zI(t=this.buffer).call(t,0,n),payloadSize:i}}},{key:"unshift",value:function(e){this.buffer=Hg(e).call(e,this.buffer)}},{key:"get",value:function(){return this.buffer}},{key:"set",value:function(e){this.buffer=Hg(e).call(e,this.buffer)}},{key:"isEmpty",value:function(){return"OFF"===this._enabled||0===this.buffer.length}}]),e}()),cD="[VERTC]",uD="#0050b3",lD=(Jd(JM={},"DEBUG","rgba(0, 0, 0, 0)"),Jd(JM," INFO","rgba(93, 173, 226, 0)"),Jd(JM," WARN","rgba(255, 119, 0, 0.3)"),Jd(JM,"ERROR","rgba(255, 0, 0, 0.3)"),Jd(JM," SUCC","rgba(0, 119, 0, 0.3)"),JM),dD="undefined"!=typeof window&&(Qy(QM=window.location.search).call(QM,"_rtc_debug_")||(null===(ZM=window.localStorage)||void 0===ZM?void 0:ZM.getItem("_rtc_debug_"))),hD=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"global";Hh(this,e),Jd(this,"indent",void 0),Jd(this,"module",void 0),Jd(this,"_engineId",void 0),this.module=t,this.indent=r,this._engineId=n}return jh(e,[{key:"_print",value:function(e,t){for(var r,n,i,o,a,s,c,u,l=arguments.length,d=new Array(l>2?l-2:0),h=2;h<l;h++)d[h-2]=arguments[h];var f=d.shift();try{var v,p,_,m,g=Hg(v=[]).call(v,d),y="".concat(f).replace(/%o/gi,(function(){var e=g.shift();return Xg(e)}));Rx.set(Hg(p=Hg(_=Hg(m="".concat(cD,"[").concat(this.module,".")).call(m,t,"] ")).call(_,y," ")).call(p,$g(g).call(g,(function(e){return Xg(e)})).join(", ")))}catch(KJ){}for(var S="",b=0;b<this.indent;b++)S+=" ";var E=fD();sD.report(cD,this._engineId,E,e,S,this.module,t,f,d),dD&&(r=console).log.apply(r,Hg(n=[Hg(i=Hg(o=Hg(a=Hg(s=Hg(c=Hg(u="%c".concat(E,"-")).call(u,cD,"%c[")).call(c,e,"]%c")).call(s,S,"[")).call(a,this.module,".")).call(o,t,"] ")).call(i,f),"color:".concat(uD,";"),"background-color:".concat(lD[e],";"),"color:".concat(uD,";")]).call(n,d))}},{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,Hg(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,Hg(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,Hg(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,Hg(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,Hg(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,Hg(t=[" SUCC",e]).call(t,n))}}]),e}(),fD=function(){var e,t,r=new Date;return Hg(e="".concat(r.toTimeString().split(" ")[0],":")).call(e,Nx(t=r.getMilliseconds().toString()).call(t,3,"0"))},vD=function(e){var t;HM(e.engineId);var r={keys:sx(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId,deviceId:e.deviceId},n=$g(t=e.requestDomains).call(t,(function(e){return"https://".concat(e,"/decision/v1/multi")})),i=$g(n).call(n,function(){var e=Ug(Dg().mark((function e(t,n){var i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:Xg(r)}).then((function(e){return e.json()}));case 2:return i=e.sent,e.abrupt("return",{result:i,index:n});case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}());return new Gg((function(e){(function(e){return new Gg((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)}))}))}))})(i).then((function(t){var r=t.result;t.index,e(r)})).catch((function(e){}))}))},pD=function(){return"undefined"==typeof window},_D=pD()?"":window.navigator.userAgent;function mD(){var e="none";return pD()||(null!==_D.match("Firefox")?e="mozilla":null!==_D.match("Chrome")?(e="chrome-stable",null!==_D.match("Electron")&&(e="electron")):(null!==_D.match("Safari")||null!==_D.match("AppleWebKit"))&&(e="safari")),e}var gD,yD="mozilla"===mD(),SD="safari"===mD(),bD="chrome-stable"===mD(),ED=!pD()&&/CriOS/i.test(_D),kD=!pD()&&/Edg\//i.test(_D),TD=!pD()&&/EdgA/i.test(_D),ID=!pD()&&/EdgiOS/i.test(_D),RD=kD||TD||ID,AD=!pD()&&/DingTalk/i.test(navigator.userAgent),CD=!pD()&&/OPR\//.test(navigator.userAgent),wD=!pD()&&(!!/(iPad)/i.exec(_D)||/Macintosh/i.test(_D)&&"ontouchend"in document),xD=!pD()&&/Macintosh/i.test(_D),OD=!pD()&&/MicroMessenger/i.test(_D),ND=!pD()&&Qy($M=_D.toLowerCase()).call($M,"mobile"),PD=!pD()&&!!/(iPhone|iPad|iPod)/i.exec(_D),MD=!pD()&&/Android/i.test(_D),DD=!pD()&&/Windows/i.test(_D),LD=0,UD="0",VD=!pD()&&(null===(eD=_D.match(/version\/(\d+)/i))||void 0===eD?void 0:eD[1]);SD&&VD&&(LD=Number(VD),UD=null===(gD=navigator.userAgent.match(/version\/(\d+\.\d+)/i))||void 0===gD?void 0:gD[1]);var FD=!pD()&&(null===(tD=_D.match(/Firefox\/(\d+)/i))||void 0===tD?void 0:tD[1]);yD&&FD&&(LD=Number(FD));var BD=LD,jD=LD,HD=UD,GD=null!==(rD=!pD()&&(null===(nD=_D.match(/ ([\d_]+) like Mac OS X/i))||void 0===nD||null===(iD=nD[1])||void 0===iD?void 0:$g(oD=iD.split("_")).call(oD,(function(e){return yb(e)}))))&&void 0!==rD?rD:[],zD=0,WD=!pD()&&(null===(aD=_D.match(/Chrome\/(\d+)/i))||void 0===aD?void 0:aD[1]);WD&&(zD=Number(WD));var KD=zD,XD="BytePlus",YD="RTC_DEVICE_ID",qD="RTC_ACCESS_NODE",JD="RTC_ACCESS_URLS",QD="ENGINE_WEB_CONFIG",ZD="SERVER_CONFIG",$D=function(){function e(){Hh(this,e)}return jh(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,Xg(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}(),eL=function(e){BA(r,e);var t=nC(r);function r(){return Hh(this,r),t.apply(this,arguments)}return jh(r,[{key:"getDeviceId",value:function(){if(pD())return"";var e=this.get(YD);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}(16)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return VM({device_id:e}),this.set(YD,e),e}},{key:"getAccessNode",value:function(e){var t;return this.get(Hg(t="".concat(qD,"_").concat(e,"-")).call(t,XD))}},{key:"setAccessNode",value:function(e,t,r){var n;return this.set(Hg(n="".concat(qD,"_").concat(e,"-")).call(n,XD),t,1e3*r)}},{key:"deleteAccessNode",value:function(e,t){var r,n=this.getAccessNode(e),i=this.getTtl(Hg(r="".concat(qD,"_").concat(e,"-")).call(r,XD));Array.isArray(n)&&n.length>0&&((n=Cy(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;if(e)this.delete(Hg(t="".concat(qD,"_").concat(e,"-")).call(t,XD));else for(var r in localStorage)lw(r).call(r,qD)&&localStorage.removeItem(r)}},{key:"getAccessUrls",value:function(){return this.get("".concat(JD,"-").concat(XD))}},{key:"setAccessUrls",value:function(e){var t=$g(e).call(e,(function(e){var t,r=e.host,n=e.path;return Hg(t="https://".concat(r)).call(t,n)}));return this.set("".concat(JD,"-").concat(XD),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(JD,"-").concat(XD))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Hg(r=Hg(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(QD);return(null==a||null===(i=lI(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=Hg(n=Hg(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(QD)||[];return(a=Cy(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(QD,dI(a).call(a,-5))}}},{key:"getServerConfig",value:function(e){var t,r="".concat(e),n=this.get(ZD);return(null==n||null===(t=lI(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(ZD)||[];return(n=Cy(n).call(n,(function(e){return e.key!==r}))).push({key:r,config:t}),this.set(ZD,dI(n).call(n,-5))}}}]),r}($D),tL=new eL,rL=new hD("JoinRoomConfig",0),nL=function(){function e(t){var r;Hh(this,e),Jd(this,"_useTcpAfterJoinTimeout",e.DEFAULT_CONF.useTcpAfterJoinTimeout),Jd(this,"_joinWithTcpOnly",e.DEFAULT_CONF.joinWithTcpOnly),Jd(this,"_joinWithTcpOnlyDelay",e.DEFAULT_CONF.joinWithTcpOnlyDelay),Jd(this,"_blackBrowserRegexList",[]),this._engineId=t,kI(r=location.search).call(r,"__rtc_tcp_only__")>-1&&(this._joinWithTcpOnly=!0,this._joinWithTcpOnlyDelay=0),this._report()}return jh(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 lI(e=this._blackBrowserRegexList).call(e,(function(e){return new RegExp(e).test(navigator.userAgent)}))}},{key:"setServerConfig",value:function(e){var t,r,n,i=!1;"boolean"==typeof(null==e||null===(t=e.use_tcp_after_join_timeout)||void 0===t?void 0:t.enable)&&(this._useTcpAfterJoinTimeout=e.use_tcp_after_join_timeout.enable,i=!0),"boolean"==typeof(null==e||null===(r=e.join_with_tcp_only)||void 0===r?void 0:r.enable)&&(this._joinWithTcpOnly=e.join_with_tcp_only.enable,i=!0),"number"==typeof(null==e||null===(n=e.join_with_tcp_only)||void 0===n?void 0:n.delay_ms)&&(this._joinWithTcpOnlyDelay=e.join_with_tcp_only.delay_ms,i=!0),e&&Array.isArray(e.black_browser_regex_list)&&(this._blackBrowserRegexList=e.black_browser_regex_list,i=!0),i&&this._report()}},{key:"toString",value:function(){return Xg({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(){rL.print("_report",this.toString()),this._engineId,this.toString()}}],[{key:"setDefaulConf",value:function(t){var r=t.useTcpAfterJoinTimeout,n=t.joinWithTcpOnly,i=t.joinWithTcpOnlyDelay;return"boolean"==typeof r&&(e.DEFAULT_CONF.useTcpAfterJoinTimeout=r),"boolean"==typeof n&&(e.DEFAULT_CONF.joinWithTcpOnly=n),"number"==typeof i&&(e.DEFAULT_CONF.joinWithTcpOnlyDelay=Math.max(0,i)),e.DEFAULT_CONF}}]),e}();Jd(nL,"DEFAULT_CONF",{useTcpAfterJoinTimeout:!0,joinWithTcpOnly:!1,joinWithTcpOnlyDelay:5e3});var iL="rtc-access-ag.bytedance.com,rtc-access.bytedance.com,rtc-access2-hl.bytedance.com,rtcg-access.bytevcloud.com".split(",");function oL(){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 aL="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",sL="rtc.rtcplus.com".split(","),cL={VERSION:"4.62.0-beta-oc-1000774380.4",ICE_CONFIG_REQUEST_URLS_INTERNAL:$g(iL).call(iL,oL),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:aL,CONFIG_REQUEST_DOMAINS:sL,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:nL.DEFAULT_CONF,SIGNAL_COMPRESSION:!0,SIGNAL_CROP_JOINROOM:!0,VIDEO_STALL_DATA:500,AUDIO_STALL_DATA:200,IOS_SAFARI_ORIENTATION:!1,BLACK_FRAME_LIFETIME:6e4,FALLBACK_ENCODE_CODEC:"",SEI_TIME_OUT:2e3,SEI_COUNT_FPS:1,PRE_ICE:!1,STATS_LOOP_INTERVAL:1e3,HIDDEN_STATS:!1};function uL(e,t){var r;if(Hg(r="key: ".concat(e,", value: ")).call(r,t),"VERSION"!==e){if("JOIN_ROOM_CONFIG"===e)return nL.setDefaulConf(t);if("ICE_CONFIG_REQUEST_URLS"===e){var n="string"==typeof t?[t]:t;return cL.ICE_CONFIG_REQUEST_URLS=$g(n).call(n,oL),tL.clearAccessUrls(),void tL.clearAccessNode()}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 i=t===_h.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===_h.domestic?aL:"string"==typeof t?t:void 0;i&&(cL.LOG_SERVER_URL=i,FM(i))}else if("OVERSEA"===e)return VM({extra_is_oversea:t?"1":"0"}),void(cL.OVERSEA=t);if("CONFIG_REQUEST_DOMAINS"===e&&Array.isArray(t)&&t.length>0)cL.CONFIG_REQUEST_DOMAINS=t;else if(!("SEI_TIME_OUT"===e&&"number"!=typeof t||"SEI_COUNT_FPS"===e&&"number"!=typeof t)){"DEVICE_ID"===e&&tL.setDeviceId(t);var o=Lx.getKeys();Qy(o).call(o,e)?Lx.setParameter(e,t):cL[e]=t}}else{var a="string"==typeof t?[t]:t;cL.FORCE_ENABLED_REPORT_CALLBACKS=a}else VM({product:t});else VM({platform:t});else cL.VIDEO_STALL_100MS=YL()&&!!t;else cL.AUDIO_STALL_DATA=Math.max(200,Number(t));else cL.VIDEO_STALL_DATA=Math.max(500,Number(t))}}function lL(e){return"DEVICE_ID"===e?tL.getDeviceId():cL[e]}function dL(e,t,r){var n,i,o,a,s,c,u,l,d;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)||yh.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===(l=r.layout)||void 0===l||null===(d=l.regions)||void 0===d?void 0:$g(d).call(d,(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 hL=[];function fL(e){hL=e}var vL,pL={width:640,height:480,frameRate:15,maxKbps:600},_L={width:1920,height:1080,frameRate:15,maxKbps:3e3},mL=new Uint8Array(16);function gL(){if(!vL&&!(vL="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 vL(mL)}for(var yL=[],SL=0;SL<256;++SL){var bL;yL.push(dI(bL=(SL+256).toString(16)).call(bL,1))}var EL={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function kL(e,t,r){if(EL.randomUUID&&!t&&!e)return EL.randomUUID();var n=(e=e||{}).random||(e.rng||gL)();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(yL[e[t+0]]+yL[e[t+1]]+yL[e[t+2]]+yL[e[t+3]]+"-"+yL[e[t+4]]+yL[e[t+5]]+"-"+yL[e[t+6]]+yL[e[t+7]]+"-"+yL[e[t+8]]+yL[e[t+9]]+"-"+yL[e[t+10]]+yL[e[t+11]]+yL[e[t+12]]+yL[e[t+13]]+yL[e[t+14]]+yL[e[t+15]]).toLowerCase()}(n)}var TL=new TextDecoder,IL=new TextEncoder,RL=function(){return kL()},AL=function(){return Date.now()};function CL(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,l=n;u<l.length;u++){var d=l[u];s.set(d,c),c+=d.length}return s}var wL=function(){function e(){Hh(this,e)}var t,r;return jh(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(Cy(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=VS(t);n<i.length;n++){var o=Ey(i[n],2),a=o[0],s=o[1];null!==s&&"object"===Xd(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return TL.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 IL.encode(e).buffer}},{key:"ab2b64str",value:(r=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Gg((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=Ug(Dg().mark((function e(t,r){return Dg().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:Hg(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 xL(e){return new Gg((function(t){window.setTimeout(t,e)}))}function OL(){for(var e,t,r=Number(Lw(e=dI(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=Lw(r).call(r,28,"1").split(""),i=[];n.length;)i.push(zI(n).call(n,0,7));return $g(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return Vw(r+e.join(""),2)}))}var NL,PL=function(){return Math.floor(65535*Math.random())};function ML(e){return"string"==typeof e&&kI(e).call(e,"__web__rtc__rtt__")>-1}var DL=function(){var e=Ug(Dg().mark((function e(){var t,r,n,i=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],!NL){e.next=3;break}return e.abrupt("return",NL);case 3:return(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=10,r.createOffer();case 10:return n=e.sent,null==r||r.close(),NL=n.sdp,e.abrupt("return",n.sdp);case 14:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),LL=function(e){return new Gg((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 UL(e){return Number(Math.max(-127,10*Gw(Math.pow(e/255,2))).toFixed(2))}function VL(e){return(e&uh.AUDIO)===uh.AUDIO}function FL(e){return(e&uh.VIDEO)===uh.VIDEO}function BL(e){var t={};return FS(e).forEach((function(r){"object"===Xd(e[r])?t[r]=BL(e[r]):lw(r).call(r,"_")&&!lL("HIDDEN_STATS")||(t[r]=e[r])})),t}function jL(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 HL(e){return void 0===e}function GL(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Hg(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 zL(e){console.warn("[RTC WebSDK]: ".concat(e))}function WL(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 KL=function(){function e(){Hh(this,e),Jd(this,"_id",void 0),this._id=Math.ceil(Math.random()*Ww)}return jh(e,[{key:"getMessageId",value:function(){return++this._id>Ww&&(this._id=0),this._id}}]),e}();function XL(e,t){if("boolean"!=typeof e)throw new _w(dw.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}var YL=function(){return!px()&&"function"==typeof HTMLVideoElement.prototype.requestVideoFrameCallback};function qL(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 _w(dw.INVALID_PARAMS,Hg(r=Hg(n="Invalid ".concat(t,": the value range is [")).call(n,i,", ")).call(r,o,"]. integer only"))}function JL(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 _w(dw.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 _w(dw.INVALID_PARAMS,Hg(r=Hg(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function QL(e,t,r){var n;if(!Qy(r).call(r,e))throw new _w(dw.INVALID_PARAMS,Hg(n="Invalid ".concat(t,": The value can only be set as ")).call(n,Xg(r)))}function ZL(e){if(!(e instanceof MediaStreamTrack))throw new _w(dw.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function $L(e,t){if(rU(e))throw new _w(dw.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function eU(e,t){if(!(e instanceof ArrayBuffer))throw new _w(dw.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function tU(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=FS(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(o){}}function rU(e){return null==e}function nU(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._-]{1,128}$/.test(e))throw new _w(dw.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function iU(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._-]{1,128}$/.test(e))throw new _w(dw.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function oU(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._-]{1,128}$/.test(e))throw new _w(dw.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function aU(e){$L(e,"userInfo"),iU(e.userId),rU(e.extraInfo)||JL(e.extraInfo,"userInfo.extraInfo",1,200)}function sU(e){$L(e,"roomConfig"),XL(e.isAutoPublish,"roomConfig.isAutoPublish"),XL(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),XL(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),rU(e.roomProfileType)||QL(e.roomProfileType,"roomConfig",[Th.communication,Th.chat,Th.chatRoom,Th.coHost,Th.meeting,Th.classRoom])}function cU(e){$L(e,"videoPlayerOption")}function uU(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 _w(dw.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:wL.str2ab(Xg(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new _w(dw.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function lU(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new _w(dw.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function dU(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 _w(dw.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function hU(e){var t,r=by(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;qL(null==n?void 0:n.maxKbps,"maxKbps"),dU(null==n?void 0:n.width,"width"),dU(null==n?void 0:n.height,"height"),dU(null==n?void 0:n.frameRate,"frameRate")}}catch(XJ){r.e(XJ)}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 qL(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var vU=r(js),pU={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?dI(n).call(n,1):n);return vU?Hg(i).call(i,vU(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,l=this._events[s],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,o),!0;case 6:return l.fn.call(l.context,t,n,i,o,a),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var h,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,n);break;case 4:l[u].fn.call(l[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];l[u].fn.apply(l[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=[],l=s.length;c<l;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}(pU);var _U=pU.exports,mU=r(_U),gU=new hD("VERTC",0),yU=function(e){BA(n,e);var t,r=nC(n);function n(){return Hh(this,n),r.apply(this,arguments)}return jh(n,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var r,i,o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return(r=VA(UA(n.prototype),"emit",this)).call.apply(r,Hg(i=[this,e]).call(i,a))}catch(KJ){return gU.error("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,KJ),console.error(KJ),Boolean(t)}}},{key:"asyncEmit",value:(t=Ug(Dg().mark((function e(t){var r,i,o,a=this,s=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=s.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=s[o];return e.next=3,Gg.resolve().then((function(){try{var e,r;(e=VA(UA(n.prototype),"emit",a)).call.apply(e,Hg(r=[a,t]).call(r,i))}catch(KJ){gU.error("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",t,KJ),console.error(KJ)}}));case 3:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),n}(_U.EventEmitter),SU=function(e){return e[e.BLACK=0]="BLACK",e[e.NORMAL=1]="NORMAL",e}(SU||{}),bU=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}(bU||{}),EU=function(e){return e.PushLimitWarn="PushLimitWarn",e.OTHER="OTHER",e}(EU||{}),kU=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.ON_TOKEN_PUBLISH_PRIVILEGE_WILL_EXPIRE="onTokenPublishPrivilegeWillExpire",e.ON_TOKEN_PUBLISH_PRIVILEGE_DID_EXPIRED="onTokenPublishPrivilegeDidExpired",e.ON_TOKEN_SUBSCRIBE_PRIVILEGE_WILL_EXPIRE="onTokenSubscribePrivilegeWillExpire",e.ON_TOKEN_SUBSCRIBE_PRIVILEGE_DID_EXPIRED="onTokenSubscribePrivilegeDidExpired",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}(kU||{}),TU=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(TU||{}),IU=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ON_VENDOR_CONNECTION_STATE_CHANGE="onVendorConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e.ON_RECONNECT_FAILED="onReconnectFailed",e.CONNECT_WITH_TCP="onIceConnectWithTcp",e}(IU||{}),RU=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(RU||{}),AU=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(AU||{}),CU=function(e){return e[e.NORMAL=0]="NORMAL",e[e.BLACK=1]="BLACK",e}(CU||{}),wU=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(wU||{}),xU=function(e){return e.AUDIO="audio",e.VIDEO="video",e}(xU||{}),OU=function(e){return e.MAIN="main",e.SCREEN="screen",e.PUBLIC="public",e.VIRTUAL="virtual",e}(OU||{}),NU=function(e){BA(r,e);var t=nC(r);function r(e,n){var i;return Hh(this,r),Jd(uA(i=t.call(this)),"trackId",RL()),Jd(uA(i),"trackInfo",void 0),Jd(uA(i),"_originTrack",void 0),Jd(uA(i),"_channelCount",void 0),i.trackInfo=n,i._originTrack=e,i._channelCount=e.getSettings().channelCount,i}return jh(r,[{key:"dummy",get:function(){return this.trackInfo.isDummy}},{key:"virtual",get:function(){return"virtual"===this.trackInfo.streamIndex}},{key:"isScreen",get:function(){return"screen"===this.trackInfo.streamIndex}},{key:"isPublic",get:function(){return"public"===this.trackInfo.streamIndex}},{key:"sourceType",get:function(){return this.trackInfo.sourceType}},{key:"mediaType",get:function(){return this.trackInfo.mediaType}},{key:"captureSessionId",get:function(){return this.trackInfo.captureSessionId}},{key:"streamIndex",get:function(){var e=this.trackInfo.streamIndex;return"main"===e?ch.STREAM_INDEX_MAIN:"screen"===e?ch.STREAM_INDEX_SCREEN:void 0}},{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}(yU),PU=function(e){BA(n,e);var t,r=nC(n);function n(e,t,i){var o;return Hh(this,n),Jd(uA(o=r.call(this,e,i)),"_mediaTrack",void 0),Jd(uA(o),"_preProcessingTrack",void 0),Jd(uA(o),"_extensionManager",void 0),Jd(uA(o),"isTrackReady",void 0),Jd(uA(o),"handleTrackEnded",(function(){o.emit("track-ended",uA(o)),o.destroy()})),Jd(uA(o),"handleMute",(function(){o.emit("track-mute",uA(o))})),Jd(uA(o),"handleUnmute",(function(){o.emit("track-unmute",uA(o))})),o._extensionManager=t,o._initListeners(),o.isTrackReady=o.generatePreProcessingTrack(),o}return jh(n,[{key:"mediaTrack",get:function(){var e;return null!==(e=this._mediaTrack)&&void 0!==e?e:this._originTrack},set:function(e){this.mediaTrack.id!==e.id&&(this._mediaTrack=e,this.isTrackReady=this.generatePreProcessingTrack())}},{key:"preprocessingTrack",get:function(){var e;return null!==(e=this._preProcessingTrack)&&void 0!==e?e:this.mediaTrack}},{key:"extensionManager",set:function(e){this._extensionManager=e,this.isTrackReady=this.generatePreProcessingTrack()}},{key:"generatePreProcessingTrack",value:(t=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._preProcessingTrack=void 0,e.prev=1,e.next=4,this._extensionManager.getPreProcessingTrack(this);case 4:(t=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=t),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(){return t.apply(this,arguments)})},{key:"destroy",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(),VA(UA(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}(NU),MU=function(e){BA(r,e);var t=nC(r);function r(e,n){var i;return Hh(this,r),Jd(uA(i=t.call(this,e,n)),"_mediaTrack",void 0),i._originTrack=e,i}return jh(r,[{key:"mediaTrack",get:function(){var e;return null!==(e=this._mediaTrack)&&void 0!==e?e:this._originTrack},set:function(e){this.mediaTrack.id!==e.id&&(this._mediaTrack=e)}},{key:"preprocessingTrack",get:function(){return this.mediaTrack}}]),r}(NU),DU=i;Cr({global:!0,forced:DU.globalThis!==DU},{globalThis:DU});var LU=r(i),UU=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!pD()&&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,KU();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,WU();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)}}(),VU=function(){var e=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.next=3,KU();case 3:if(e.t0=e.sent,!e.t0){e.next=8;break}return e.next=7,WU();case 7:e.t0=e.sent;case 8:if(!e.t0){e.next=10;break}t.push("H264");case 10:return e.next=12,YU();case 12:if(e.t1=e.sent,!e.t1){e.next=17;break}return e.next=16,XU();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)}}(),FU=function(){var e=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,VU();case 2:return t=e.sent,e.abrupt("return",$g(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),BU={};function jU(e){var t,r=!1,n=by(e.split("\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value;if(Qy(i).call(i,"level-asymmetry-allowed=1")&&Qy(i).call(i,"packetization-mode=1")&&Qy(i).call(i,"profile-level-id=42e0")){r=!0;break}}}catch(XJ){n.e(XJ)}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 HU=function(){var e=Ug(Dg().mark((function e(t){var r,n;return Dg().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,null==r||r.close(),e.abrupt("return",n.sdp.toLowerCase());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),GU=function(){var e=Ug(Dg().mark((function e(){var t,r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,HU("sendonly");case 2:if(r=e.sent,!Qy(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,HU("sendonly");case 6:r=e.sent;case 7:return BU.h264encode=jU(r),BU.vp8encode=kI(r).call(r,"vp8")>-1,e.abrupt("return",BU);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),zU=function(){var e=Ug(Dg().mark((function e(){var t,r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,HU("recvonly");case 2:if(r=e.sent,!Qy(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,HU("recvonly");case 6:r=e.sent;case 7:return BU.h264decode=jU(r),BU.vp8decode=kI(r).call(r,"vp8")>-1,e.abrupt("return",BU);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),WU=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==BU.h264encode){e.next=9;break}return e.prev=1,e.next=4,GU();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",BU.h264encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),KU=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==BU.h264decode){e.next=9;break}return e.prev=1,e.next=4,zU();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",BU.h264decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),XU=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==BU.vp8encode){e.next=9;break}return e.prev=1,e.next=4,GU();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",BU.vp8encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),YU=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==BU.vp8decode){e.next=9;break}return e.prev=1,e.next=4,zU();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",BU.vp8decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),qU=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},JU=function(){return xD?bD&&KD>=70||yD&&jD>=80||SD&&BD>=14:DD?bD&&KD>=70||yD&&jD>=80:PD?GD[0]>=14:!!MD&&(bD&&KD>=86)},QU=bD&&KD<=114,ZU=!yD||jD>=96,$U=!(SD&&BD<=14),eV=MD&&bD||PD&&(17===GD[0]||16===GD[0]),tV=void 0!==LU&&"PressureObserver"in LU,rV="undefined"!=typeof window&&window.Worker,nV=!(SD&&BD<=14),iV=function(e){return e[e.NONE=0]="NONE",e}(iV||{}),oV={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)?oV.getAnnexbNals(e):oV.getAvccNals(e)},getAnnexbNals:function(e){for(var t=[],r=oV.getHeaderPositionAnnexB(e),n=r.pos,i=n;n<e.length-4;){var o,a,s=new Uint8Array(dI(o=e.buffer).call(o,n,n+r.headerLength));r.pos===e.position&&e.skip(r.headerLength),i=(r=oV.getHeaderPositionAnnexB(e)).pos;var c={header:s,body:new Uint8Array(dI(a=e.buffer).call(a,n+s.byteLength,i)),type:-1};oV.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(dI(n=e.buffer).call(n,e.position,e.position+4));e.skip(4);var a=new Uint8Array(dI(i=e.buffer).call(i,e.position,e.position+r));e.skip(r);var s={header:o,body:a,type:-1};oV.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}}},aV=function(){function e(t){Hh(this,e),Jd(this,"_position",0),Jd(this,"_dataview",void 0),this._dataview=new DataView(t)}return jh(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}(),sV=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(sV||{}),cV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),uV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]);function lV(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function dV(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 hV=function(){function e(){Hh(this,e)}return jh(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?cV:uV,s=lV(e.byteLength+a.byteLength),c=function(e){var t,r=[],n=0,i=by(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(XJ){i.e(XJ)}finally{i.f()}return new Uint8Array(r)}(e);return new Uint8Array(Hg(t=[]).call(t,iR(n),iR(i),iR(o),iR(s),iR(a),iR(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=dI(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=Ey(dV(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=uV.byteLength&&i>=uV.byteLength&&dI(t).call(t,r,r+uV.byteLength).toString()===uV.toString()?(r+=uV.byteLength,o=1):t.byteLength>=uV.byteLength&&i>=uV.byteLength&&dI(t).call(t,r,r+cV.byteLength).toString()===cV.toString()&&(r+=cV.byteLength,o=0),{type:o,payload:dI(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new hT,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=Ey(dV(e.payload,r),2),i=n[0];r=n[1];var o,a=Ey(dV(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,dI(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=by(e);try{for(n.s();!(t=n.n()).done;){var i=Ey(t.value,2),o=i[0],a=i[1],s=lV(o),c=lV(a.byteLength);r.push(s,c,a)}}catch(XJ){n.e(XJ)}finally{n.f()}var u=uS(r).call(r,(function(e,t){return e+t.byteLength}),0),l=new Uint8Array(u);return uS(r).call(r,(function(e,t){return l.set(t,e),e+t.byteLength}),0),l}}]),e}(),fV=o,vV=ht("iterator"),pV=!fV((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[vV]||"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})),_V=Cr,mV=i,gV=N,yV=_,SV=w,bV=pV,EV=vi,kV=_i,TV=uE,IV=Bi,RV=uu,AV=ro,CV=Rv,wV=A,xV=Ze,OV=Jt,NV=mn,PV=rr,MV=ee,DV=Sn,LV=Kn,UV=F,VV=Of,FV=Tf,BV=Uv,jV=uC,HV=ht("iterator"),GV="URLSearchParams",zV=GV+"Iterator",WV=AV.set,KV=AV.getterFor(GV),XV=AV.getterFor(zV),YV=Object.getOwnPropertyDescriptor,qV=function(e){if(!SV)return mV[e];var t=YV(mV,e);return t&&t.value},JV=qV("fetch"),QV=qV("Request"),ZV=qV("Headers"),$V=QV&&QV.prototype,eF=ZV&&ZV.prototype,tF=mV.RegExp,rF=mV.TypeError,nF=mV.decodeURIComponent,iF=mV.encodeURIComponent,oF=yV("".charAt),aF=yV([].join),sF=yV([].push),cF=yV("".replace),uF=yV([].shift),lF=yV([].splice),dF=yV("".split),hF=yV("".slice),fF=/\+/g,vF=Array(4),pF=function(e){return vF[e-1]||(vF[e-1]=tF("((?:%[\\da-f]{2}){"+e+"})","gi"))},_F=function(e){try{return nF(e)}catch(KJ){return e}},mF=function(e){var t=cF(e,fF," "),r=4;try{return nF(t)}catch(KJ){for(;r;)t=cF(t,pF(r--),_F);return t}},gF=/[!'()~]|%20/g,yF={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},SF=function(e){return yF[e]},bF=function(e){return cF(iF(e),gF,SF)},EF=RV((function(e,t){WV(this,{type:zV,iterator:VV(KV(e).entries),kind:t})}),"Iterator",(function(){var e=XV(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),kF=function(e){this.entries=[],this.url=null,void 0!==e&&(MV(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===oF(e,0)?hF(e,1):e:DV(e)))};kF.prototype={type:GV,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=FV(e);if(c)for(r=(t=VV(e,c)).next;!(n=gV(r,t)).done;){if(o=(i=VV(PV(n.value))).next,(a=gV(o,i)).done||(s=gV(o,i)).done||!gV(o,i).done)throw rF("Expected sequence with length 2");sF(this.entries,{key:DV(a.value),value:DV(s.value)})}else for(var u in e)xV(e,u)&&sF(this.entries,{key:u,value:DV(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=dF(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=dF(t,"="),sF(this.entries,{key:mF(uF(r)),value:mF(aF(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],sF(r,bF(e.key)+"="+bF(e.value));return aF(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var TF=function(){CV(this,IF);var e=WV(this,new kF(arguments.length>0?arguments[0]:void 0));SV||(this.size=e.entries.length)},IF=TF.prototype;if(TV(IF,{append:function(e,t){var r=KV(this);BV(arguments.length,2),sF(r.entries,{key:DV(e),value:DV(t)}),SV||this.length++,r.updateURL()},delete:function(e){for(var t=KV(this),r=BV(arguments.length,1),n=t.entries,i=DV(e),o=r<2?void 0:arguments[1],a=void 0===o?o:DV(o),s=0;s<n.length;){var c=n[s];if(c.key!==i||void 0!==a&&c.value!==a)s++;else if(lF(n,s,1),void 0!==a)break}SV||(this.size=n.length),t.updateURL()},get:function(e){var t=KV(this).entries;BV(arguments.length,1);for(var r=DV(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){var t=KV(this).entries;BV(arguments.length,1);for(var r=DV(e),n=[],i=0;i<t.length;i++)t[i].key===r&&sF(n,t[i].value);return n},has:function(e){for(var t=KV(this).entries,r=BV(arguments.length,1),n=DV(e),i=r<2?void 0:arguments[1],o=void 0===i?i:DV(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=KV(this);BV(arguments.length,1);for(var n,i=r.entries,o=!1,a=DV(e),s=DV(t),c=0;c<i.length;c++)(n=i[c]).key===a&&(o?lF(i,c--,1):(o=!0,n.value=s));o||sF(i,{key:a,value:s}),SV||(this.size=i.length),r.updateURL()},sort:function(){var e=KV(this);jV(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=KV(this).entries,n=OV(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 EF(this,"keys")},values:function(){return new EF(this,"values")},entries:function(){return new EF(this,"entries")}},{enumerable:!0}),EV(IF,HV,IF.entries,{name:"entries"}),EV(IF,"toString",(function(){return KV(this).serialize()}),{enumerable:!0}),SV&&kV(IF,"size",{get:function(){return KV(this).entries.length},configurable:!0,enumerable:!0}),IV(TF,GV),_V({global:!0,constructor:!0,forced:!bV},{URLSearchParams:TF}),!bV&&wV(ZV)){var RF=yV(eF.has),AF=yV(eF.set),CF=function(e){if(MV(e)){var t,r=e.body;if(NV(r)===GV)return t=e.headers?new ZV(e.headers):new ZV,RF(t,"content-type")||AF(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),LV(e,{body:UV(0,DV(r)),headers:UV(0,t)})}return e};if(wV(JV)&&_V({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return JV(e,arguments.length>1?CF(arguments[1]):{})}}),wV(QV)){var wF=function(e){return CV(this,$V),new QV(e,arguments.length>1?CF(arguments[1]):{})};$V.constructor=wF,wF.prototype=$V,_V({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:wF})}}var xF,OF={URLSearchParams:TF,getState:KV},NF=_,PF=2147483647,MF=/[^\0-\u007E]/,DF=/[.\u3002\uFF0E\uFF61]/g,LF="Overflow: input needs wider integers to process",UF=RangeError,VF=NF(DF.exec),FF=Math.floor,BF=String.fromCharCode,jF=NF("".charCodeAt),HF=NF([].join),GF=NF([].push),zF=NF("".replace),WF=NF("".split),KF=NF("".toLowerCase),XF=function(e){return e+22+75*(e<26)},YF=function(e,t,r){var n=0;for(e=r?FF(e/700):e>>1,e+=FF(e/t);e>455;)e=FF(e/35),n+=36;return FF(n+36*e/(e+38))},qF=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=jF(e,r++);if(i>=55296&&i<=56319&&r<n){var o=jF(e,r++);56320==(64512&o)?GF(t,((1023&i)<<10)+(1023&o)+65536):(GF(t,i),r--)}else GF(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&&GF(t,BF(n));var c=t.length,u=c;for(c&&GF(t,"-");u<i;){var l=PF;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<l&&(l=n);var d=u+1;if(l-o>FF((PF-a)/d))throw UF(LF);for(a+=(l-o)*d,o=l,r=0;r<e.length;r++){if((n=e[r])<o&&++a>PF)throw UF(LF);if(n===o){for(var h=a,f=36;;){var v=f<=s?1:f>=s+26?26:f-s;if(h<v)break;var p=h-v,_=36-v;GF(t,BF(XF(v+p%_))),h=FF(p/_),f+=36}GF(t,BF(XF(h))),s=YF(a,d,u===c),a=0,u++}}a++,o++}return HF(t,"")},JF=Cr,QF=w,ZF=pV,$F=i,eB=Jt,tB=_,rB=vi,nB=_i,iB=Rv,oB=Ze,aB=RT,sB=py,cB=ai,uB=Ud.codeAt,lB=function(e){var t,r,n=[],i=WF(zF(KF(e),DF,"."),".");for(t=0;t<i.length;t++)r=i[t],GF(n,VF(MF,r)?"xn--"+qF(r):r);return HF(n,".")},dB=Sn,hB=Bi,fB=Uv,vB=OF,pB=ro,_B=pB.set,mB=pB.getterFor("URL"),gB=vB.URLSearchParams,yB=vB.getState,SB=$F.URL,bB=$F.TypeError,EB=$F.parseInt,kB=Math.floor,TB=Math.pow,IB=tB("".charAt),RB=tB(/./.exec),AB=tB([].join),CB=tB(1..toString),wB=tB([].pop),xB=tB([].push),OB=tB("".replace),NB=tB([].shift),PB=tB("".split),MB=tB("".slice),DB=tB("".toLowerCase),LB=tB([].unshift),UB="Invalid scheme",VB="Invalid host",FB="Invalid port",BB=/[a-z]/i,jB=/[\d+-.a-z]/i,HB=/\d/,GB=/^0x/i,zB=/^[0-7]+$/,WB=/^\d+$/,KB=/^[\da-f]+$/i,XB=/[\0\t\n\r #%/:<>?@[\\\]^|]/,YB=/[\0\t\n\r #/:<>?@[\\\]^|]/,qB=/^[\u0000-\u0020]+/,JB=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,QB=/[\t\n\r]/g,ZB=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)LB(t,e%256),e=kB(e/256);return AB(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+=CB(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},$B={},ej=aB({},$B,{" ":1,'"':1,"<":1,">":1,"`":1}),tj=aB({},ej,{"#":1,"?":1,"{":1,"}":1}),rj=aB({},tj,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),nj=function(e,t){var r=uB(e,0);return r>32&&r<127&&!oB(t,e)?e:encodeURIComponent(e)},ij={ftp:21,file:null,http:80,https:443,ws:80,wss:443},oj=function(e,t){var r;return 2===e.length&&RB(BB,IB(e,0))&&(":"===(r=IB(e,1))||!t&&"|"===r)},aj=function(e){var t;return e.length>1&&oj(MB(e,0,2))&&(2===e.length||"/"===(t=IB(e,2))||"\\"===t||"?"===t||"#"===t)},sj=function(e){return"."===e||"%2e"===DB(e)},cj={},uj={},lj={},dj={},hj={},fj={},vj={},pj={},_j={},mj={},gj={},yj={},Sj={},bj={},Ej={},kj={},Tj={},Ij={},Rj={},Aj={},Cj={},wj=function(e,t,r){var n,i,o,a=dB(e);if(t){if(i=this.parse(a))throw bB(i);this.searchParams=null}else{if(void 0!==r&&(n=new wj(r,!0)),i=this.parse(a,null,n))throw bB(i);(o=yB(new gB)).bindURL(this),this.searchParams=o}};wj.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||cj,l=0,d="",h=!1,f=!1,v=!1;for(e=dB(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=OB(e,qB,""),e=OB(e,JB,"$1")),e=OB(e,QB,""),n=sB(e);l<=n.length;){switch(i=n[l],u){case cj:if(!i||!RB(BB,i)){if(t)return UB;u=lj;continue}d+=DB(i),u=uj;break;case uj:if(i&&(RB(jB,i)||"+"===i||"-"===i||"."===i))d+=DB(i);else{if(":"!==i){if(t)return UB;d="",u=lj,l=0;continue}if(t&&(c.isSpecial()!==oB(ij,d)||"file"===d&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=d,t)return void(c.isSpecial()&&ij[c.scheme]===c.port&&(c.port=null));d="","file"===c.scheme?u=bj:c.isSpecial()&&r&&r.scheme===c.scheme?u=dj:c.isSpecial()?u=pj:"/"===n[l+1]?(u=hj,l++):(c.cannotBeABaseURL=!0,xB(c.path,""),u=Rj)}break;case lj:if(!r||r.cannotBeABaseURL&&"#"!==i)return UB;if(r.cannotBeABaseURL&&"#"===i){c.scheme=r.scheme,c.path=cB(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=Cj;break}u="file"===r.scheme?bj:fj;continue;case dj:if("/"!==i||"/"!==n[l+1]){u=fj;continue}u=_j,l++;break;case hj:if("/"===i){u=mj;break}u=Ij;continue;case fj:if(c.scheme=r.scheme,i===xF)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=cB(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=cB(r.path),c.query="",u=Aj;else{if("#"!==i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=cB(r.path),c.path.length--,u=Ij;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=cB(r.path),c.query=r.query,c.fragment="",u=Cj}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=Ij;continue}u=mj}else u=_j;break;case pj:if(u=_j,"/"!==i||"/"!==IB(d,l+1))continue;l++;break;case _j:if("/"!==i&&"\\"!==i){u=mj;continue}break;case mj:if("@"===i){h&&(d="%40"+d),h=!0,o=sB(d);for(var p=0;p<o.length;p++){var _=o[p];if(":"!==_||v){var m=nj(_,rj);v?c.password+=m:c.username+=m}else v=!0}d=""}else if(i===xF||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(h&&""===d)return"Invalid authority";l-=sB(d).length+1,d="",u=gj}else d+=i;break;case gj:case yj:if(t&&"file"===c.scheme){u=kj;continue}if(":"!==i||f){if(i===xF||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(c.isSpecial()&&""===d)return VB;if(t&&""===d&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(d))return a;if(d="",u=Tj,t)return;continue}"["===i?f=!0:"]"===i&&(f=!1),d+=i}else{if(""===d)return VB;if(a=c.parseHost(d))return a;if(d="",u=Sj,t===yj)return}break;case Sj:if(!RB(HB,i)){if(i===xF||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()||t){if(""!==d){var g=EB(d,10);if(g>65535)return FB;c.port=c.isSpecial()&&g===ij[c.scheme]?null:g,d=""}if(t)return;u=Tj;continue}return FB}d+=i;break;case bj:if(c.scheme="file","/"===i||"\\"===i)u=Ej;else{if(!r||"file"!==r.scheme){u=Ij;continue}switch(i){case xF:c.host=r.host,c.path=cB(r.path),c.query=r.query;break;case"?":c.host=r.host,c.path=cB(r.path),c.query="",u=Aj;break;case"#":c.host=r.host,c.path=cB(r.path),c.query=r.query,c.fragment="",u=Cj;break;default:aj(AB(cB(n,l),""))||(c.host=r.host,c.path=cB(r.path),c.shortenPath()),u=Ij;continue}}break;case Ej:if("/"===i||"\\"===i){u=kj;break}r&&"file"===r.scheme&&!aj(AB(cB(n,l),""))&&(oj(r.path[0],!0)?xB(c.path,r.path[0]):c.host=r.host),u=Ij;continue;case kj:if(i===xF||"/"===i||"\\"===i||"?"===i||"#"===i){if(!t&&oj(d))u=Ij;else if(""===d){if(c.host="",t)return;u=Tj}else{if(a=c.parseHost(d))return a;if("localhost"===c.host&&(c.host=""),t)return;d="",u=Tj}continue}d+=i;break;case Tj:if(c.isSpecial()){if(u=Ij,"/"!==i&&"\\"!==i)continue}else if(t||"?"!==i)if(t||"#"!==i){if(i!==xF&&(u=Ij,"/"!==i))continue}else c.fragment="",u=Cj;else c.query="",u=Aj;break;case Ij:if(i===xF||"/"===i||"\\"===i&&c.isSpecial()||!t&&("?"===i||"#"===i)){if(".."===(s=DB(s=d))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"===i||"\\"===i&&c.isSpecial()||xB(c.path,"")):sj(d)?"/"===i||"\\"===i&&c.isSpecial()||xB(c.path,""):("file"===c.scheme&&!c.path.length&&oj(d)&&(c.host&&(c.host=""),d=IB(d,0)+":"),xB(c.path,d)),d="","file"===c.scheme&&(i===xF||"?"===i||"#"===i))for(;c.path.length>1&&""===c.path[0];)NB(c.path);"?"===i?(c.query="",u=Aj):"#"===i&&(c.fragment="",u=Cj)}else d+=nj(i,tj);break;case Rj:"?"===i?(c.query="",u=Aj):"#"===i?(c.fragment="",u=Cj):i!==xF&&(c.path[0]+=nj(i,$B));break;case Aj:t||"#"!==i?i!==xF&&("'"===i&&c.isSpecial()?c.query+="%27":c.query+="#"===i?"%23":nj(i,$B)):(c.fragment="",u=Cj);break;case Cj:i!==xF&&(c.fragment+=nj(i,ej))}l++}},parseHost:function(e){var t,r,n;if("["===IB(e,0)){if("]"!==IB(e,e.length-1))return VB;if(t=function(e){var t,r,n,i,o,a,s,c=[0,0,0,0,0,0,0,0],u=0,l=null,d=0,h=function(){return IB(e,d)};if(":"===h()){if(":"!==IB(e,1))return;d+=2,l=++u}for(;h();){if(8===u)return;if(":"!==h()){for(t=r=0;r<4&&RB(KB,h());)t=16*t+EB(h(),16),d++,r++;if("."===h()){if(0===r)return;if(d-=r,u>6)return;for(n=0;h();){if(i=null,n>0){if(!("."===h()&&n<4))return;d++}if(!RB(HB,h()))return;for(;RB(HB,h());){if(o=EB(h(),10),null===i)i=o;else{if(0===i)return;i=10*i+o}if(i>255)return;d++}c[u]=256*c[u]+i,2!=++n&&4!==n||u++}if(4!==n)return;break}if(":"===h()){if(d++,!h())return}else if(h())return;c[u++]=t}else{if(null!==l)return;d++,l=++u}}if(null!==l)for(a=u-l,u=7;0!==u&&a>0;)s=c[u],c[u--]=c[l+a-1],c[l+--a]=s;else if(8!==u)return;return c}(MB(e,1,-1)),!t)return VB;this.host=t}else if(this.isSpecial()){if(e=lB(e),RB(XB,e))return VB;if(t=function(e){var t,r,n,i,o,a,s,c=PB(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"===IB(i,0)&&(o=RB(GB,i)?16:8,i=MB(i,8===o?1:2)),""===i)a=0;else{if(!RB(10===o?WB:8===o?zB:KB,i))return e;a=EB(i,o)}xB(r,a)}for(n=0;n<t;n++)if(a=r[n],n===t-1){if(a>=TB(256,5-t))return null}else if(a>255)return null;for(s=wB(r),n=0;n<r.length;n++)s+=r[n]*TB(256,3-n);return s}(e),null===t)return VB;this.host=t}else{if(RB(YB,e))return VB;for(t="",r=sB(e),n=0;n<r.length;n++)t+=nj(r[n],$B);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return oB(ij,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&oj(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+=ZB(i),null!==o&&(u+=":"+o)):"file"===t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+AB(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw bB(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new xj(e.path[0]).origin}catch(KJ){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+ZB(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(dB(e)+":",cj)},getUsername:function(){return this.username},setUsername:function(e){var t=sB(dB(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=nj(t[r],rj)}},getPassword:function(){return this.password},setPassword:function(e){var t=sB(dB(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=nj(t[r],rj)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?ZB(e):ZB(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,gj)},getHostname:function(){var e=this.host;return null===e?"":ZB(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,yj)},getPort:function(){var e=this.port;return null===e?"":dB(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=dB(e))?this.port=null:this.parse(e,Sj))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+AB(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Tj))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=dB(e))?this.query=null:("?"===IB(e,0)&&(e=MB(e,1)),this.query="",this.parse(e,Aj)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=dB(e))?("#"===IB(e,0)&&(e=MB(e,1)),this.fragment="",this.parse(e,Cj)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var xj=function(e){var t=iB(this,Oj),r=fB(arguments.length,1)>1?arguments[1]:void 0,n=_B(t,new wj(e,!1,r));QF||(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())},Oj=xj.prototype,Nj=function(e,t){return{get:function(){return mB(this)[e]()},set:t&&function(e){return mB(this)[t](e)},configurable:!0,enumerable:!0}};if(QF&&(nB(Oj,"href",Nj("serialize","setHref")),nB(Oj,"origin",Nj("getOrigin")),nB(Oj,"protocol",Nj("getProtocol","setProtocol")),nB(Oj,"username",Nj("getUsername","setUsername")),nB(Oj,"password",Nj("getPassword","setPassword")),nB(Oj,"host",Nj("getHost","setHost")),nB(Oj,"hostname",Nj("getHostname","setHostname")),nB(Oj,"port",Nj("getPort","setPort")),nB(Oj,"pathname",Nj("getPathname","setPathname")),nB(Oj,"search",Nj("getSearch","setSearch")),nB(Oj,"searchParams",Nj("getSearchParams")),nB(Oj,"hash",Nj("getHash","setHash"))),rB(Oj,"toJSON",(function(){return mB(this).serialize()}),{enumerable:!0}),rB(Oj,"toString",(function(){return mB(this).serialize()}),{enumerable:!0}),SB){var Pj=SB.createObjectURL,Mj=SB.revokeObjectURL;Pj&&rB(xj,"createObjectURL",eB(Pj,SB)),Mj&&rB(xj,"revokeObjectURL",eB(Mj,SB))}hB(xj,"URL"),JF({global:!0,constructor:!0,forced:!ZF,sham:!QF},{URL:xj});var Dj=Cr,Lj=o,Uj=Uv,Vj=Sn,Fj=pV,Bj=ae("URL");Dj({target:"URL",stat:!0,forced:!(Fj&&Lj((function(){Bj.canParse()})))},{canParse:function(e){var t=Uj(arguments.length,1),r=Vj(e),n=t<2||void 0===arguments[1]?void 0:Vj(arguments[1]);try{return!!new Bj(r,n)}catch(KJ){return!1}}});var jj,Hj,Gj=r(te.URL),zj="undefined"!=typeof window&&(Qy(jj=window.location.search).call(jj,"_rtc_debug_")||(null===(Hj=window.localStorage)||void 0===Hj?void 0:Hj.getItem("_rtc_debug_")));function Wj(e){var t=PressureObserver.supportedSources,r="thermal";r=null!=t&&Qy(t).call(t,"thermal")?"thermal":"cpu",new PressureObserver((function(t){t.forEach((function(t){t.source===r&&e(t.state)}))})).observe(r,{sampleInterval:2e3})}var Kj=new(function(){function e(){var t=this;if(Hh(this,e),Jd(this,"_state",void 0),tV)try{if(rV){var r=new Blob(["(".concat(Wj.toString(),")(self.postMessage)")],{type:"text/javascript"});new Worker(Gj.createObjectURL(r)).onmessage=function(e){t._state=e.data}}else Wj((function(e){t._state=e}))}catch(n){}}return jh(e,[{key:"state",get:function(){return zj&&!px()&&(window.thermal_status=this._state),this._state}}]),e}());sE("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),TE);var Xj=te.Set,Yj=Ae,qj=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(Yj(e)+" is not a set")},Jj=RE,Qj=ae("Set"),Zj=Qj.prototype,$j={Set:Qj,add:Jj("add",1),has:Jj("has",1),remove:Jj("delete",1),proto:Zj},eH=ok,tH=function(e,t,r){return r?eH(e.keys(),t,!0):e.forEach(t)},rH=tH,nH=$j.Set,iH=$j.add,oH=function(e){var t=new nH;return rH(e,(function(e){iH(t,e)})),t},aH=function(e){return e.size},sH=Oe,cH=rr,uH=N,lH=Nr,dH=function(e){return{iterator:e,next:e.next,done:!1}},hH="Invalid size",fH=RangeError,vH=TypeError,pH=Math.max,_H=function(e,t,r,n){this.set=e,this.size=t,this.has=r,this.keys=n};_H.prototype={getIterator:function(){return dH(cH(uH(this.keys,this.set)))},includes:function(e){return uH(this.has,this.set,e)}};var mH=function(e){cH(e);var t=+e.size;if(t!=t)throw vH(hH);var r=lH(t);if(r<0)throw fH(hH);return new _H(e,pH(r,0),sH(e.has),sH(e.keys))},gH=qj,yH=oH,SH=aH,bH=mH,EH=tH,kH=ok,TH=$j.has,IH=$j.remove,RH=function(e){var t=gH(this),r=bH(e),n=yH(t);return SH(t)<=r.size?EH(t,(function(e){r.includes(e)&&IH(n,e)})):kH(r.getIterator(),(function(e){TH(t,e)&&IH(n,e)})),n},AH=function(){return!1},CH=RH;Cr({target:"Set",proto:!0,real:!0,forced:!AH()},{difference:CH});var wH=qj,xH=aH,OH=mH,NH=tH,PH=ok,MH=$j.Set,DH=$j.add,LH=$j.has,UH=function(e){var t=wH(this),r=OH(e),n=new MH;return xH(t)>r.size?PH(r.getIterator(),(function(e){LH(t,e)&&DH(n,e)})):NH(t,(function(e){r.includes(e)&&DH(n,e)})),n},VH=UH;Cr({target:"Set",proto:!0,real:!0,forced:!AH()},{intersection:VH});var FH=qj,BH=$j.has,jH=aH,HH=mH,GH=tH,zH=ok,WH=Df,KH=function(e){var t=FH(this),r=HH(e);if(jH(t)<=r.size)return!1!==GH(t,(function(e){if(r.includes(e))return!1}),!0);var n=r.getIterator();return!1!==zH(n,(function(e){if(BH(t,e))return WH(n,"normal",!1)}))},XH=KH;Cr({target:"Set",proto:!0,real:!0,forced:!AH()},{isDisjointFrom:XH});var YH=qj,qH=aH,JH=tH,QH=mH,ZH=function(e){var t=YH(this),r=QH(e);return!(qH(t)>r.size)&&!1!==JH(t,(function(e){if(!r.includes(e))return!1}),!0)},$H=ZH;Cr({target:"Set",proto:!0,real:!0,forced:!AH()},{isSubsetOf:$H});var eG=qj,tG=$j.has,rG=aH,nG=mH,iG=ok,oG=Df,aG=function(e){var t=eG(this),r=nG(e);if(rG(t)<r.size)return!1;var n=r.getIterator();return!1!==iG(n,(function(e){if(!tG(t,e))return oG(n,"normal",!1)}))},sG=aG;Cr({target:"Set",proto:!0,real:!0,forced:!AH()},{isSupersetOf:sG});var cG=qj,uG=oH,lG=mH,dG=ok,hG=$j.add,fG=$j.has,vG=$j.remove,pG=function(e){var t=cG(this),r=lG(e).getIterator(),n=uG(t);return dG(r,(function(e){fG(t,e)?vG(n,e):hG(n,e)})),n},_G=pG;Cr({target:"Set",proto:!0,real:!0,forced:!AH()},{symmetricDifference:_G});var mG=qj,gG=$j.add,yG=oH,SG=mH,bG=ok,EG=function(e){var t=mG(this),r=SG(e).getIterator(),n=yG(t);return bG(r,(function(e){gG(n,e)})),n},kG=EG;Cr({target:"Set",proto:!0,real:!0,forced:!AH()},{union:kG});var TG=Xj;Cr({target:"Set",stat:!0,forced:!0},{from:XE}),Cr({target:"Set",stat:!0,forced:!0},{of:qE});var IG=qj,RG=$j.add;Cr({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=IG(this),t=0,r=arguments.length;t<r;t++)RG(e,arguments[t]);return e}});var AG=qj,CG=$j.remove;Cr({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=AG(this),r=!0,n=0,i=arguments.length;n<i;n++)e=CG(t,arguments[n]),r=r&&e;return!!r}});var wG=Jt,xG=qj,OG=tH;Cr({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=xG(this),r=wG(e,arguments.length>1?arguments[1]:void 0);return!1!==OG(t,(function(e){if(!r(e,e,t))return!1}),!0)}});var NG=mn,PG=Ze,MG=W,DG=Oc,LG=ht("iterator"),UG=Object,VG=A,FG=function(e){if(MG(e))return!1;var t=UG(e);return void 0!==t[LG]||"@@iterator"in t||PG(DG,NG(t))},BG=ee,jG=ae("Set"),HG=function(e){return function(e){return BG(e)&&"number"==typeof e.size&&VG(e.has)&&VG(e.keys)}(e)?e:FG(e)?new jG(e):e},GG=N,zG=HG,WG=RH;Cr({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){return GG(WG,this,zG(e))}});var KG=Jt,XG=qj,YG=tH,qG=$j.Set,JG=$j.add;Cr({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=XG(this),r=KG(e,arguments.length>1?arguments[1]:void 0),n=new qG;return YG(t,(function(e){r(e,e,t)&&JG(n,e)})),n}});var QG=Jt,ZG=qj,$G=tH;Cr({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=ZG(this),r=QG(e,arguments.length>1?arguments[1]:void 0),n=$G(t,(function(e){if(r(e,e,t))return{value:e}}),!0);return n&&n.value}});var ez=N,tz=HG,rz=UH;Cr({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){return ez(rz,this,tz(e))}});var nz=N,iz=HG,oz=KH;Cr({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){return nz(oz,this,iz(e))}});var az=N,sz=HG,cz=ZH;Cr({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){return az(cz,this,sz(e))}});var uz=N,lz=HG,dz=aG;Cr({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){return uz(dz,this,lz(e))}});var hz=Cr,fz=_,vz=qj,pz=tH,_z=Sn,mz=fz([].join),gz=fz([].push);hz({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=vz(this),r=void 0===e?",":_z(e),n=[];return pz(t,(function(e){gz(n,e)})),mz(n,r)}});var yz=Jt,Sz=qj,bz=tH,Ez=$j.Set,kz=$j.add;Cr({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=Sz(this),r=yz(e,arguments.length>1?arguments[1]:void 0),n=new Ez;return bz(t,(function(e){kz(n,r(e,e,t))})),n}});var Tz=Oe,Iz=qj,Rz=tH,Az=TypeError;Cr({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=Iz(this),r=arguments.length<2,n=r?void 0:arguments[1];if(Tz(e),Rz(t,(function(i){r?(r=!1,n=i):n=e(n,i,i,t)})),r)throw Az("Reduce of empty set with no initial value");return n}});var Cz=Jt,wz=qj,xz=tH;Cr({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=wz(this),r=Cz(e,arguments.length>1?arguments[1]:void 0);return!0===xz(t,(function(e){if(r(e,e,t))return!0}),!0)}});var Oz=N,Nz=HG,Pz=pG;Cr({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){return Oz(Pz,this,Nz(e))}});var Mz=N,Dz=HG,Lz=EG;Cr({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){return Mz(Lz,this,Dz(e))}});var Uz=r(TG),Vz=["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"],Fz=new hT,Bz=!0,jz=function(){var e=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Gg((function(e){var r={all:[],getTrackStats:function(){return[]}},n=lL("STATS_SCALLBACK_SUPPORT");if(Bz&&bD&&void 0===window.InstallTrigger&&QU&&n)try{var i,o,a,s;null===(i=t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!Qy(Vz).call(Vz,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(Zd(Zd({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return Cy(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(){Bz=!1,e(r)}))}catch(c){Bz=!1,e(r)}else e(r)})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Hz=function(){var e=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c;return Dg().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 hT,n.forEach((function(e){var t=o.get(e.type)||new hT;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,l=e.transportId,d=e.trackId,h=e.playoutId;if(null===(r=o.get("codec"))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=o.get("transport"))||void 0===n||n.forEach((function(e){e.id===l&&(s=e,t.add(e))})),null===(i=o.get("track"))||void 0===i||i.forEach((function(e){e.id===d&&t.add(e)})),null===(a=o.get("media-playout"))||void 0===a||a.forEach((function(e){e.id===h&&t.add(e)})),s){var f,v,p=s,_=p.localCertificateId,m=p.remoteCertificateId,g=p.selectedCandidatePairId;null===(f=o.get("certificate"))||void 0===f||f.forEach((function(e){(e.id===_||e.id===m)&&t.add(e)})),null===(v=o.get("candidate-pair"))||void 0===v||v.forEach((function(e){e.id===g&&(c=e,t.add(e))}))}if(c){var y,S,b=c,E=b.localCandidateId,k=b.remoteCandidateId;null===(y=o.get("local-candidate"))||void 0===y||y.forEach((function(e){e.id===E&&t.add(e)})),null===(S=o.get("remote-candidate"))||void 0===S||S.forEach((function(e){e.id===k&&t.add(e)}))}}))},o.get("media-source")?null===(s=o.get("media-source"))||void 0===s||s.forEach((function(e){var t,r=new Uz;r.add(e);var n=[];null===(t=o.get("outbound-rtp"))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=o.get("remote-inbound-rtp"))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=Fw(r)})):o.get("track")&&(null===(c=o.get("track"))||void 0===c||c.forEach((function(e){var t,r=new Uz;r.add(e);var n=[];null===(t=o.get("outbound-rtp"))||void 0===t||t.forEach((function(t){var i;t.trackId===e.id&&(r.add(t),n.push(t),null===(i=o.get("remote-inbound-rtp"))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=Fw(r)}))),null===(r=o.get("inbound-rtp"))||void 0===r||r.forEach((function(e){var t,r=new Uz;r.add(e),null===(t=o.get("remote-outbound-rtp"))||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("track"))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(s=t.trackIdentifier)})));i[s]=Fw(r)})),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Gz=function(){var e=Ug(Dg().mark((function e(t,r,n,i){var o,a,s,c,u,l;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!yD&&!SD){e.next=22;break}if(a=[],e.prev=5,!i){e.next=12;break}return e.next=9,i.getStats();case 9:e.t0=e.sent,e.next=15;break;case 12:return e.next=14,t.getStats(r);case 14:e.t0=e.sent;case 15:e.t0.forEach((function(e){a.push(e)})),e.next=21;break;case 19:e.prev=19,e.t1=e.catch(5);case 21:return e.abrupt("return",a);case 22:return(!(s=Fz.get(t))||Date.now()-s.timestamp>150)&&(s={timestamp:Date.now(),statsPromise:Hz(t),extraStatsPromise:jz(t)},Fz.set(t,s)),e.next=26,s.statsPromise;case 26:if(c=e.sent,u=(o?c[o]:c.all)||[],n){e.next=33;break}return e.next=31,s.extraStatsPromise;case 31:l=e.sent,u=Hg(u).call(u,(o?l.getTrackStats(o):l.all)||[]);case 33:return e.abrupt("return",u);case 34:case"end":return e.stop()}}),e,null,[[5,19]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),zz=function(){function e(t){Hh(this,e),Jd(this,"_timer",void 0),Jd(this,"_reportTimer",void 0),Jd(this,"handler",void 0),Jd(this,"_monitor",void 0),Jd(this,"logger",void 0),Jd(this,"_destroyed",!1),this._context=t,this._monitor=HM(t.id),this.logger=new hD("Stats",3,t.id)}return jh(e,[{key:"setVar",value:function(e){this.handler=e}},{key:"stopReport",value:function(e){var t;this._reportTimer&&(this.logger.info("stopReport","invoke"),clearTimeout(this._reportTimer),delete this._reportTimer,this._context.id,Hg(t="reason: ".concat(e,", stack: ")).call(t,(new Error).stack),this._stream.streamId)}},{key:"filterIllegal",value:function(e){var t={};return FS(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"),this._context.id,"".concat((new Error).stack),"".concat(this._stream.streamId),this.stopReport("destroy"),clearTimeout(this._timer),this._destroyed=!0}}]),e}(),Wz=function(e){BA(o,e);var t,r,n,i=nC(o);function o(e,t){var r;return Hh(this,o),Jd(uA(r=i.call(this,e)),"_stats",{audioStats:{},videoStats:{}}),Jd(uA(r),"_preReports",{audio:{},video:{}}),r._stream=t,r}return jh(o,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t){this._destroyed=!1}},{key:"getLocalStats",value:function(){return this._stats}},{key:"_getLocalStats",value:(n=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,l,d;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=null===(i=this._stream.audioTrack)||void 0===i?void 0:i.preprocessingTrack,c=null===(o=this._stream.videoTrack)||void 0===o?void 0:o.preprocessingTrack,0!==FS(r.audio).length){e.next=9;break}return e.next=5,this.getAudioStats(s,r,null===(u=t.audioTrack)||void 0===u?void 0:u.getAudioLevel(),n);case 5:return e.next=7,this.getVideoStats(c,r,n);case 7:return e.next=9,xL(150);case 9:return e.next=11,this.getAudioStats(s,r,null===(a=t.audioTrack)||void 0===a?void 0:a.getAudioLevel(),n);case 11:return l=e.sent,e.next=14,this.getVideoStats(c,r,n);case 14:return d=e.sent,e.abrupt("return",{audioStats:l,videoStats:d,isScreen:t.isScreen});case 16:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"getAudioStats",value:(r=Ug(Dg().mark((function e(t,r,n,i){var o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c={},u={timestamp:Date.now()},l=this._stream,d=l.streamId,h=l.audioMid,f=l.isScreen,v=l.pubAttributes,p=l.pubAudio,_=l.audioTrack,m={media_type:"audio",is_screen:!!f,direction:"up",stream_id:d,vid:h,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:v.localaudio?"capture_state_on":"capture_state_off",mute_state:p?"mute_state_off":"mute_state_on",thermal_status:Kj.state},_&&(m.playback_volume=_.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",c);case 7:return e.next=9,null===(o=this._context.peerConnection)||void 0===o?void 0:o.getStatsWithLowFrequency(t,!1,null===(a=this._stream.audioTransceiver)||void 0===a?void 0:a.sender);case 9:if((g=e.sent).length){e.next=12;break}return e.abrupt("return",c);case 12:if(g.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,o=e.clockRate,a=e.roundTripTime,s=e.channels,l=e.audioLevel,d=e.mimeType,h=e.availableIncomingBitrate,f=e.availableOutgoingBitrate,v=e.bytesReceived,p=e.nominated,_=e.id,g=e.currentRoundTripTime,y=e.state,S=e.writable,b=e.requestsReceived,E=e.responsesReceived,k=e.requestsSent,T=e.consentRequestsSent,I=e.responsesSent,R=e.jitter,A=e.candidateType,C=e.ip,w=e.address,x=e.networkType,O=e.port,N=e.protocol,P=e.nackCount,M=e.retransmittedBytesSent,D=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(u.packetsSent=r,u.bytesSent=i,m.bytes=i,m.packetsSent=r,m.nackCount=P,m.ssrc=U,m.retransmitted_bytes_sent=M,m.retransmitted_packets_sent=D,u.retransmittedBytesSent=M,u.retransmittedPacketsSent=D):"remote-inbound-rtp"===t?(u.packetsLost=n,m.packetsLost=n,m.net_jitter=1e3*R,c.rtt=1e3*a,m.rtt=c.rtt,c._fractionLost=j||0):"codec"===t?(c.recordSampleRate=o,c.numChannels=s,m.codecName=d):"media-source"===t&&void 0!==l?(m.audio_level=l?-10*Gw(Math.pow(l,2)):l,m.volume=255*l,m.total_audio_energy=V,m.totalInputDuration=F):"ssrc"===t&&"audio"===B?m.send_level=L:"candidate-pair"===t?(m.ice_available_incoming_bitrate=h,m.ice_available_outgoing_bitrate=f,m.ice_bytes_received=v,m.ice_bytes_sent=i,m.ice_nominated=Number(p),m.ice_pair_id=_,m.ice_pair_rtt=g,m.ice_pair_state=y,m.ice_pair_writable=S,m.recv_ping_requests=b,m.recv_ping_responses=E,m.sent_ping_requests_before_first_response=k,m.sent_ping_requests_total=k+(T||0),m.sent_ping_responses=I):"local-candidate"===t?(m.local_candidate_type=A,m.local_ip=C||w,m.local_network_type=x,m.local_port=O,m.protocol=N):"remote-candidate"===t&&(m.remote_candidate_type=A,m.remote_ip=C||w,m.remote_port=O);var H=lL("STATS_SCALLBACK_SUPPORT");QU&&H||"media-source"===t&&(m.send_level=l)})),m.send_level?m.send_level<1?m._sendVolumeLevel=32767*m.send_level:m._sendVolumeLevel=m.send_level:(y=(null==_?void 0:_.getAudioLevel())||0,m._sendVolumeLevel=Math.round(y/255*32767)),void 0===m.volume&&void 0!==n&&(m.volume=n,m.audio_level=n?-10*Gw(Math.pow(n/255,2)):n),(S=r.audio).timestamp){e.next=19;break}return r.audio=u,e.abrupt("return",this.filterIllegal(c));case 19:return void 0!==u.packetsLost&&(c.audioLossRate=Math.max(0,u.packetsLost-S.packetsLost)/(u.packetsSent-S.packetsSent),c.audioLossRate=Number.isNaN(c.audioLossRate)?0:c.audioLossRate,m.fraction_lost=c.audioLossRate),c.statsInterval=u.timestamp-S.timestamp,m.stats_interval=c.statsInterval,c.sendKBitrate=(u.bytesSent-S.bytesSent||0)/c.statsInterval*8,m.mediaBitratebps=Math.round(1e3*c.sendKBitrate),m.bandwidth=Math.round(m.mediaBitratebps/1024),void 0!==u.retransmittedBytesSent&&(m.retransmitBitratebps=(u.retransmittedBytesSent-S.retransmittedBytesSent||0)/c.statsInterval),r.audio=u,m.vendor_mode=this._stream.vendorCode||0,m.pc_session_id=null===(s=this.handler)||void 0===s?void 0:s.peerConnectionId,c._retransmittedRate=(u.retransmittedPacketsSent-S.retransmittedPacketsSent)/(u.packetsSent-S.packetsSent),void 0===c.audioLossRate&&(c.audioLossRate=c._retransmittedRate,m.fraction_lost=c.audioLossRate),c._fractionLost=Math.max(c._fractionLost,c.audioLossRate),c._sendVolumeLevel=m._sendVolumeLevel,e.abrupt("return",this.filterIllegal(c));case 35:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c={},u={timestamp:Date.now(),simulcast:{}},l=this._stream,d=l.streamId,h=l.videoMid,f=l.isScreen,v=l.pubAttributes,p=l.enableSimulcast,_=l.pubVideo,m={media_type:"video",is_screen:!!f,direction:"up",stream_id:d,vid:h,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:v.localvideo?"capture_state_on":"capture_state_off",mute_state:_?"mute_state_off":"mute_state_on",thermal_status:Kj.state},t&&this.handler){e.next=6;break}return e.abrupt("return",c);case 6:return m.cap_frame_width=t.getSettings().width,m.cap_frame_height=t.getSettings().height,m.frameRateSent=t.getSettings().frameRate,c.isScreen=f,m.is_intersecting=Xg(null===(i=this._stream)||void 0===i||null===(o=i.videoTrack)||void 0===o?void 0:o.intersection()),e.next=13,null===(a=this._context.peerConnection)||void 0===a?void 0:a.getStatsWithLowFrequency(t,!1,null===(s=this._stream.videoTransceiver)||void 0===s?void 0:s.sender);case 13:if((g=e.sent).length){e.next=16;break}return e.abrupt("return",c);case 16:if(y=0,g.forEach((function(e){var t=e.type,n=e.framesEncoded,i=e.packetsLost,o=e.bytesSent,a=e.framesSent,s=e.retransmittedBytesSent,l=e.totalPacketSendDelay,d=e.totalEncodeTime,h=e.firCount,f=e.targetBitrate,v=e.roundTripTime,_=e.mimeType,g=e.frameWidth,S=e.frameHeight,b=e.packetsSent,E=e.googActualEncBitrate,k=e.googAvailableReceiveBandwidth,T=e.googAvailableSendBandwidth,I=e.googAvgEncodeMs,R=e.googBucketDelay,A=e.googEncodeUsagePercent,C=e.googFrameRateInput,w=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,O=e.bytesReceived,N=e.nominated,P=e.id,M=e.currentRoundTripTime,D=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,W=e.qpSum,K=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,le=e.googFrameRateSent,de=e.keyFramesEncoded,he=e.scalabilityMode,fe=e.framesPerSecond,ve=e.frames;"outbound-rtp"===t?(p&&(ie?u.simulcast[ie]=e:u.simulcast[y]=e,y++),u.framesEncoded=n||u.framesEncoded||0,m.key_frames_encoded=de||0,u.bytesSent=o||u.bytesSent||0,u.framesSent=a||u.framesSent,m.bytes=o||m.bytes||0,u.packetsSent=b||u.packetsSent||0,m.packetsSent=b||m.packetsSent||0,m.nackCount=H||m.nackCount||0,m.pli_count=G||m.pli_count||0,m.qp_sum=W||m.qp_sum||0,m.ssrc=Z||m.ssrc||0,m.retransmitted_packets_sent=te,u.retransmittedPacketsSent=te,u.retransmittedBytesSent=s,m.encoder_implementation=re,m.qualityLimitationReason=se,m.qualityLimitationDurations=ce,m.scalabilityMode=he,void 0!==g&&((!c.encodedFrameWidth||g>c.encodedFrameWidth)&&(c.encodedFrameWidth=g),(!c.encodedFrameHeight||S>c.encodedFrameHeight)&&(c.encodedFrameHeight=S),m.frame_size_height=S,m.frame_size_width=g)):"track"===t?(c.encodedFrameWidth=g,c.encodedFrameHeight=S,m.frame_size_height=S,m.frame_size_width=g):"remote-inbound-rtp"===t?(u.packetsLost=i,c.rtt=1e3*v,m.rtt=c.rtt,m.jitter=1e3*ne,m.packetsLost=i,c._fractionLost=oe||0):"codec"===t?(c.codecType=_,m.codecName=_):"candidate-pair"===t?(m.ice_available_incoming_bitrate=w,m.ice_available_outgoing_bitrate=x,m.ice_bytes_received=O,m.ice_bytes_sent=o,m.ice_nominated=Number(N),m.ice_pair_id=P,m.ice_pair_rtt=M,m.ice_pair_state=D,m.ice_pair_writable=L,m.recv_ping_requests=K,m.recv_ping_responses=X,m.sent_ping_requests_before_first_response=q,m.sent_ping_requests_total=q+J,m.sent_ping_responses=Q):"local-candidate"===t?(m.local_candidate_type=U,m.local_ip=V||F,m.local_network_type=B,m.local_port=j,m.protocol=z):"remote-candidate"===t?(m.remote_candidate_type=U,m.remote_ip=V||F,m.remote_port=j):"VideoBwe"===t?(m.encBitratebps=E,m.available_receive_bandwidth=k,m.available_send_bandwidth=T,m.bucket_delay=R,m.retransmitBitratebps=Y,m.targetEncBitratebps=$,m.transmit_bitrate=ee,c._sendBandWidth=Number(T)):"ssrc"===t&&(m.avg_encode_ms=I,m.encodeUsage=A,m.frame_rate_input=C,m.orignal_input_Framerate=Number(C),m.ddaptationChanges=ae,m.firsReceived=ue,m.frameRateSent=le);var pe=lL("STATS_SCALLBACK_SUPPORT");if(!QU||!pe){var _e=r.video,me=u.timestamp-_e.timestamp;if("outbound-rtp"===t){var ge=o-_e.bytesSent,ye=s-_e.retransmittedBytesSent;m.encBitratebps=Math.round(8e3*(ge-ye)/me),m.bucket_delay=l/b,m.retransmitBitratebps=Math.round(8e3*ye/me),m.targetEncBitratebps=f,m.transmit_bitrate=Math.round(1e3*(o-_e.bytesSent)*8/me),m.avg_encode_ms=1e3*d/n,m.firsReceived=h+G}else"candidate-pair"===t?(m.available_send_bandwidth=x,c._sendBandWidth=x):"media-source"===t&&(m.frame_rate_input=fe,m.orignal_input_Framerate=Number(fe),m.frame_input=ve)}})),(S=r.video).timestamp){e.next=22;break}return r.video=u,e.abrupt("return",this.filterIllegal(c));case 22:return c.statsInterval=u.timestamp-S.timestamp,m.stats_interval=c.statsInterval,b=FS(u.simulcast),p?(m.sim_enc_width=[],m.sim_enc_height=[],m.sim_enc_bps=[],m.sim_enc_framerate=[],m.sim_enc_key_frames=[],m.sim_rids=[],m.sim_enc_bandwidth=[],m.sim_sent_framerate=[],m.sim_fraction_lost=[],m.sim_keyencoded=[],m.active_sim_streams=this._context.activeSimStreams||[],m.sim_retransmittedRate=[],k=!1,BC(b).call(b,(function(e,t){return Number(e)-Number(t)})).forEach((function(e){var t=u.simulcast[e],r=t.frameWidth,n=t.frameHeight,i=t.bytesSent,o=t.framesEncoded,a=t.framesSent,s=t.packetsLost,l=t.packetsSent,d=t.qualityLimitationReason,h=t.qualityLimitationDurations,f=t.qualityLimitationResolutionChanges,v=t.retransmittedPacketsSent,p=t.pliCount,_=t.keyFramesEncoded;void 0!==d&&(m.sim_qualityLimitationReason||(m.sim_qualityLimitationReason=[],m.sim_qualityLimitationDurations=[],m.sim_qualityLimitationResolutionChanges=[]),m.sim_qualityLimitationReason.push(d),m.sim_qualityLimitationDurations.push(h),m.sim_qualityLimitationResolutionChanges.push(f));var g=S.simulcast[e];if(m.sim_enc_width.push(r||0),m.sim_enc_height.push(n||0),m.sim_enc_key_frames.push(_||0),g){var y=(i-g.bytesSent||0)/c.statsInterval;m.sim_enc_bps.push(Math.round(8e3*y)),m.sim_enc_bandwidth.push(Math.round(8e3*y/1024));var b=1e3*(o-g.framesEncoded)/c.statsInterval;m.sim_enc_framerate.push(Math.round(b)),m.sim_rids.push(e);var E=void 0!==a?a-g.framesSent:o-g.framesEncoded,T=1e3*E/c.statsInterval;m.sim_sent_framerate.push(Math.round(T));var I=(s-g.packetsLost)/(l-g.packetsSent);c._retransmittedRate=(v-g.retransmittedPacketsSent)/(l-g.packetsSent),I=Number.isNaN(I)?0:I,m.sim_fraction_lost.push(I),m.sim_keyencoded.push(p-g.pliCount>0),m.sim_retransmittedRate.push(c._retransmittedRate),r>0&&!k&&(c.rid=e,c.sentKBitrate=8*y,c.encoderOutputFrameRate=b,c.encodedFrameCount=E,c.sentFrameRate=T,c.videoLossRate=I,k=!0)}})),m.vendor_mode=this._stream.vendorCode||0,m.pc_session_id=null===(E=this.handler)||void 0===E?void 0:E.peerConnectionId):(c.encodedFrameCount=void 0!==u.framesSent?u.framesSent-S.framesSent:u.framesEncoded-S.framesEncoded,c.sentKBitrate=(u.bytesSent-S.bytesSent||0)/c.statsInterval*8,m.bitrate=Math.round(1e3*c.sentKBitrate),m.bandwidth=Math.round(m.bitrate/1024),c.encoderOutputFrameRate=1e3*(u.framesEncoded-S.framesEncoded)/c.statsInterval,m.frame_rate_encoded=Math.round(c.encoderOutputFrameRate),c.sentFrameRate=1e3*c.encodedFrameCount/c.statsInterval,m.frame_rate_sent=Math.round(c.sentFrameRate),c.videoLossRate=Math.max(0,u.packetsLost-S.packetsLost)/(u.packetsSent-S.packetsSent),c.videoLossRate=Number.isNaN(c.videoLossRate)?0:c.videoLossRate,m.fraction_lost=c.videoLossRate,c._retransmittedRate=(u.retransmittedPacketsSent-S.retransmittedPacketsSent)/(u.packetsSent-S.packetsSent),m.vendor_mode=this._stream.vendorCode||0,m.pc_session_id=null===(T=this.handler)||void 0===T?void 0:T.peerConnectionId),r.video=u,c._fractionLost=Math.max(c._fractionLost,c.videoLossRate),c._captureResolutionWidth=m.cap_frame_width,c._captureResolutionHeight=m.cap_frame_height,e.abrupt("return",this.filterIllegal(c));case 31:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})}]),o}(zz),Kz=function(e){BA(a,e);var t,r,n,i,o=nC(a);function a(e,t){var r;return Hh(this,a),Jd(uA(r=o.call(this,e)),"_stats",{audioStats:{},videoStats:{}}),Jd(uA(r),"_preReports",{audio:{},video:{}}),r._stream=t,r}return jh(a,[{key:"setRemoteStreamStatsEvtInterval",value:(i=Ug(Dg().mark((function e(t,r){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._reportTimer){e.next=2;break}return e.abrupt("return");case 2:this.logger.info("setRemoteStreamStatsEvtInterval","invoke"),this.setVar(r),this._destroyed=!1;case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"getRemoteStreamStats",value:function(){return this._stats}},{key:"_getRemoteStreamStats",value:(n=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,l,d;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=null===(i=t.videoTrack)||void 0===i?void 0:i.originTrack,c=null===(o=t.audioTrack)||void 0===o?void 0:o.originTrack,0!==FS(r.audio).length){e.next=9;break}return e.next=5,this.getRemoteAudioStats(c,r,null===(u=this._stream.audioTrack)||void 0===u?void 0:u.getAudioLevel(),n);case 5:return e.next=7,this.getRemoteVideoStats(s,r,n);case 7:return e.next=9,xL(150);case 9:return e.next=11,this.getRemoteAudioStats(c,r,null===(a=this._stream.audioTrack)||void 0===a?void 0:a.getAudioLevel(),n);case 11:return l=e.sent,e.next=14,this.getRemoteVideoStats(s,r,n);case 14:return d=e.sent,e.abrupt("return",{audioStats:l,videoStats:d,isScreen:t.isScreen,userId:t.userId,streamId:t.streamId});case 16:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"unsubscribe",value:function(){this.logger.info("unsubscribe","invoke"),VA(UA(a.prototype),"stopReport",this).call(this,"unsubscribe"),this._stream.stopAudioStallObserve()}},{key:"getRemoteAudioStats",value:(r=Ug(Dg().mark((function e(t,r,n,i){var o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(l={},d={},h=this._stream,f=h.streamId,v=h.userId,p=h.isScreen,_=h.audioMid,m=h.subMediaType,g=h._attributes,y=h.virtual,S=h.audioTrack,b={media_type:"audio",is_screen:!!p,direction:"down",stream_id:f,stream_user_id:v,vid:_,audio_mux:y,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:VL(m)?"mute_state_off":"mute_state_on",remote_user_capture_state:g.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:g.localaudio&&g.audiostream?"mute_state_off":"mute_state_on",thermal_status:Kj.state},S&&(b.playback_volume=S.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",l);case 7:return e.next=9,null===(o=this._context.peerConnection)||void 0===o?void 0:o.getStatsWithLowFrequency(t,!1,null===(a=this._stream.audioTransceiver)||void 0===a?void 0:a.receiver);case 9:if((E=e.sent).length){e.next=12;break}return e.abrupt("return",l);case 12:if(E.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,o=e.bytesReceived,a=e.jitterBufferDelay,s=e.jitterBufferEmittedCount,c=e.clockRate,u=e.channels,h=e.totalSamplesReceived,v=e.concealedSamples,p=e.silentConcealedSamples,_=e.concealmentEvents,m=e.totalRoundTripTime,g=e.packetsDiscarded,y=e.state,S=e.currentRoundTripTime,E=e.audioLevel,k=e.totalAudioEnergy,I=e.totalSamplesDuration,R=e.mimeType,A=e.googDecodingNormal,C=e.googDecodingMuted,w=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,O=e.bytesSent,N=e.nominated,P=e.id,M=e.writable,D=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,W=e.requestsSent,K=e.consentRequestsSent,X=e.responsesSent,Y=e.ssrc,q=e.nackCount,J=e.lastPacketReceivedTimestamp,Q=e.concealmentevents,Z=e.fecPacketsReceived;if("inbound-rtp"===t)d.packetsLost=r,d.packetsReceived=i,b.packetsLost=r,b.packetsReceived=i,b.packetsDiscarded=g,b.nackCount=q,b.lastPacketReceivedTimestamp=J,b.concealmentevents=Q,d.bytesReceived=o,void 0!==a&&(l.jitterBufferDelay=a/s*1e3,b.average_jitter_buffer_delay_ms=l.jitterBufferDelay),void 0!==h&&(d.totalSamplesReceived=h,l.concealedSamples=v,d.concealedSamples=v,d.silentConcealedSamples=p,b.concealedSamples=v,l.concealmentEvents=_,b.totalSamplesReceived=h),void 0!==Z&&(b.fec_packets_received=Z,d.fecPacketsReceived=Z),b.jitter=1e3*D,b.ssrc=Y,void 0!==E&&0!==E?(b.audio_level=E?-10*Gw(Math.pow(E,2)):E,b.volume=255*E):(b.volume=null!=n?n:255*E,b.audio_level=n?-10*Gw(Math.pow(n/255,2)):n),void 0!==k&&(b.total_audio_energy=k),void 0!==I&&(b.totalAudioDuration=I);else if("codec"===t)l.recordSampleRate=c,u&&(l.numChannels=u),b.codecName=R;else if("candidate-pair"===t){var $,ee;b.ice_available_incoming_bitrate=w,b.ice_available_outgoing_bitrate=x,b.ice_bytes_received=o,b.ice_bytes_sent=O,b.ice_nominated=Number(N),b.ice_pair_id=P,b.ice_pair_rtt=S,b.rtt=1e3*S,b.rtt&&null!==($=T._context.streamRTT)&&void 0!==$&&null!==(ee=$[f])&&void 0!==ee&&ee.audio&&(b.total_rtt_ms=Math.round(b.rtt+T._context.streamRTT[f].audio)),b.ice_pair_state=y,b.ice_pair_writable=M,b.recv_ping_requests=G,b.recv_ping_responses=z,b.sent_ping_requests_before_first_response=W,b.sent_ping_requests_total=W+(K||0),b.sent_ping_responses=X,"succeeded"===y&&(l.rtt=1e3*S,l.total_rtt=1e3*m)}else"track"===t&&void 0!==E?(0===E&&0!==n?(b.volume=n,b.audio_level=n?-10*Gw(Math.pow(n/255,2)):n):(b.audio_level=E?-10*Gw(Math.pow(E,2)):E,b.volume=255*E),b.total_audio_energy=k,b.totalAudioDuration=I):"ssrc"===t?(b.decodingNormal=A,b.recvAudioLevel=H,b.decodingMuted=C):"local-candidate"===t?(b.local_candidate_type=L,b.local_ip=U||V,b.local_network_type=F,b.local_port=B,b.protocol=j):"remote-candidate"===t&&(b.remote_candidate_type=L,b.remote_ip=U||V,b.remote_port=B)})),(k=r.audio).timestamp){e.next=18;break}return d.timestamp=Date.now(),r.audio=d,e.abrupt("return",this.filterIllegal(l));case 18:if(void 0===d.concealedSamples){e.next=25;break}return b.interval_concealed_samples=d.concealedSamples-k.concealedSamples,b.interval_samples_received=d.totalSamplesReceived-k.totalSamplesReceived,b.interval_silent_concealed_samples=d.silentConcealedSamples-k.silentConcealedSamples,e.next=24,this._stream.updateAudioStallInfo(b,l,d);case 24:e.sent;case 25:return d.timestamp=Date.now(),l.audioLossRate=Math.max(0,d.packetsLost-k.packetsLost)/(d.packetsReceived-k.packetsReceived+(d.packetsLost-k.packetsLost)),l.audioLossRate=Number.isNaN(l.audioLossRate)?0:l.audioLossRate,b.fraction_lost=l.audioLossRate,l.statsInterval=d.timestamp-k.timestamp,b.stats_interval=l.statsInterval,l.receivedKBitrate=(d.bytesReceived-k.bytesReceived||0)/l.statsInterval*8,b.bandwidth=Math.round(1e3*l.receivedKBitrate/1024),void 0!==d.concealedSamples&&(l.receivedSampleRate=1e3*b.interval_samples_received/l.statsInterval),void 0!==d.fecPacketsReceived&&(b.fecBitratebps=(d.fecPacketsReceived-k.fecPacketsReceived||0)/l.statsInterval),b.average_jitter_buffer_delay_ms&&b.total_rtt_ms&&(l.e2eDelay=b.average_jitter_buffer_delay_ms+b.total_rtt_ms),null!==(s=this._context.streamRTT)&&void 0!==s&&null!==(c=s[f])&&void 0!==c&&c.audio&&(l.totalRtt=(b.rtt?b.rtt:0)+this._context.streamRTT[f].audio),r.audio=d,b.vendor_mode=this._stream.vendorCode||0,b.pc_session_id=null===(u=this.handler)||void 0===u?void 0:u.peerConnectionId,e.abrupt("return",this.filterIllegal(l));case 42:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(l={},d={timestamp:Date.now()},h=this._stream,f=h.streamId,v=h.userId,p=h.isScreen,_=h.subMediaType,m=h._attributes,g=Zd({media_type:"video",is_screen:!!p,direction:"down",stream_id:f,stream_user_id:v,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:FL(_)?"mute_state_off":"mute_state_on",remote_user_capture_state:m.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:m.localvideo&&m.videostream?"mute_state_off":"mute_state_on",is_intersecting:Xg(null===(i=this._stream.videoTrack)||void 0===i?void 0:i.intersection()),thermal_status:Kj.state},this._stream.getVideoRenderInfo()),t&&this.handler){e.next=6;break}return e.abrupt("return",l);case 6:return l.isScreen=p,e.next=9,null===(o=this._context.peerConnection)||void 0===o?void 0:o.getStatsWithLowFrequency(t,!1,null===(a=this._stream.videoTransceiver)||void 0===a?void 0:a.receiver);case 9:if((y=e.sent).length){e.next=12;break}return e.abrupt("return",l);case 12:if(y.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,i=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,s=e.framesDecoded,c=e.jitterBufferDelay,u=e.jitterBufferEmittedCount,h=e.mimeType,v=e.firCount,p=e.availableIncomingBitrate,_=e.availableOutgoingBitrate,m=e.bytesSent,y=e.nominated,S=e.id,b=e.currentRoundTripTime,E=e.state,k=e.writable,T=e.candidateType,R=e.ip,A=e.address,C=e.networkType,w=e.port,x=e.nackCount,O=e.pliCount,N=e.protocol,P=e.requestsReceived,M=e.responsesReceived,D=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,W=e.framesDropped;if("inbound-rtp"===t)d.packetsLost=i,g.packetsLost=i,d.packetsReceived=o,g.packetsReceived=o,d.bytesReceived=a,g.bytes=a,d.framesDecoded=s,d.totalDecodeTime=H,void 0!==c&&(d.jitterBufferDelay=c/u*1e3,g.average_jitter_buffer_delay_ms=d.jitterBufferDelay),g.fir_count=v,g.nackCount=x,d.nackCount=x,g.pli_count=O,g.ssrc=V,g.framesDropped=W,g.jitter=1e3*F,g.framesReceived=B,d.framesReceived=B,g.framesDecoded=s,g.key_frames_decoded=j,g.decoder_name=G,g.last_packet_received_timestamp=z,void 0!==n&&(l.width=n,g.frame_size_width=n,l.height=r,g.frame_size_height=r);else if("track"===t&&void 0!==n)l.width=n,g.frame_size_width=n,l.height=r,g.frame_size_height=r,void 0!==B&&(g.framesReceived=B,d.framesReceived=B);else if("codec"===t)g.codecName=h;else if("candidate-pair"===t){var K,X;g.ice_available_incoming_bitrate=p,g.ice_available_outgoing_bitrate=_,g.ice_bytes_received=a,g.ice_bytes_sent=m,g.ice_nominated=Number(y),g.ice_pair_id=S,g.ice_pair_rtt=b,g.rtt=1e3*b,g.rtt&&null!==(K=I._context.streamRTT)&&void 0!==K&&null!==(X=K[f])&&void 0!==X&&X.video&&(g.total_rtt_ms=Math.round(g.rtt+(I._context.streamRTT[f].video||0))),l.rtt=g.rtt,g.ice_pair_state=E,g.ice_pair_writable=k,g.recv_ping_requests=P,g.recv_ping_responses=M,g.sent_ping_requests_before_first_response=D,g.sent_ping_requests_total=D+(L||0),g.sent_ping_responses=U}else"local-candidate"===t?(g.local_candidate_type=T,g.local_ip=R||A,g.local_network_type=C,g.local_port=w,g.protocol=N):"remote-candidate"===t&&(g.remote_candidate_type=T,g.remote_ip=R||A,g.remote_port=w)})),(S=r.video).timestamp){e.next=17;break}return r.video=d,e.abrupt("return",this.filterIllegal(l));case 17:return b=Math.max(0,d.packetsLost-S.packetsLost),E=d.packetsReceived-S.packetsReceived,l.videoLossRate=b/(E+b),l._receivePackets=d.packetsReceived,l._receivePacketsLost=d.packetsLost,S.totalDecodeTime&&S.framesDecoded&&d.framesDecoded!==S.framesDecoded&&(k=d.totalDecodeTime-S.totalDecodeTime,T=d.framesDecoded-S.framesDecoded,g.decode_elapse_per_frame=Number((k/T*1e3).toFixed(2))),l._retransmittedRate=(d.nackCount-S.nackCount)/(E+b),l.videoLossRate=Number.isNaN(l.videoLossRate)?0:l.videoLossRate,g.fraction_lost=l.videoLossRate,l.statsInterval=d.timestamp-S.timestamp,g.stats_interval=l.statsInterval,l.receivedKBitrate=(d.bytesReceived-S.bytesReceived||0)/l.statsInterval*8,g.bitrate=Math.round(1e3*l.receivedKBitrate),g.bandwidth=Math.round(g.bitrate/1024),l.decoderOutputFrameRate=1e3*(d.framesDecoded-S.framesDecoded)/l.statsInterval,l.receivedFrameRate=1e3*(d.framesReceived-S.framesReceived)/l.statsInterval,g.frame_rate_decoded=Math.round(l.decoderOutputFrameRate),g.frame_rate_received=Math.round(l.receivedFrameRate),g.average_jitter_buffer_delay_ms&&g.total_rtt_ms&&(l.e2eDelay=g.average_jitter_buffer_delay_ms+g.total_rtt_ms),null!==(s=this._context.streamRTT)&&void 0!==s&&null!==(c=s[f])&&void 0!==c&&c.video&&(l.totalRtt=(g.rtt?g.rtt:0)+(this._context.streamRTT[f].video||0)),r.video=d,this._stream.updateVideoStallInfo(g,l,n),g.vendor_mode=this._stream.vendorCode||0,g.pc_session_id=null===(u=this.handler)||void 0===u?void 0:u.peerConnectionId,e.abrupt("return",this.filterIllegal(l));case 43:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"destroy",value:function(){VA(UA(a.prototype),"destroy",this).call(this),VA(UA(a.prototype),"stopReport",this).call(this,"destroy"),this._stream.stopAudioStallObserve()}}]),a}(zz),Xz=function(){function e(t,r){Hh(this,e),Jd(this,"_removeHandler",void 0),Jd(this,"_remotePauseHandler",void 0),Jd(this,"_prePts",void 0),Jd(this,"_stallList",void 0),Jd(this,"_videoInWaiting",!1),Jd(this,"_videoInWaitingCallback",!1),Jd(this,"_videoInWaiting100ms",!1),Jd(this,"_isPaused",void 0),Jd(this,"_pauseStart",0),Jd(this,"_pauseDuration",0),Jd(this,"_requestVideoFrameCallbackTimer",void 0),Jd(this,"_logger",void 0),Jd(this,"_player",void 0),Jd(this,"_recentVideoInfo",void 0),Jd(this,"_stallTimeThreshold",void 0),Jd(this,"_openVideoStall100ms",cL.VIDEO_STALL_100MS);var n=t?1500:SD||yD?550:500;this._stallTimeThreshold={report:n,callback:Math.max(cL.VIDEO_STALL_DATA,n)},this._logger=new hD("VideoStallObserver",1,r)}return jh(e,[{key:"start",value:function(e){var t=this;if(this._logger.print("start","invoke"),this._player=e,YL())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 r=function(r){return t._onVideoTimeupdate(r,e)};e.on("playback_event",r),this._removeHandler=function(){return e.off("playback_event",r)}}var n=function(e){return t._onVideoPause(e)};e.on("playback_event",n),this._remotePauseHandler=function(){return e.off("playback_event",n)}}},{key:"getRecentRenderInfo4Report",value:function(){var e=this,t={};return this._recentVideoInfo&&FS(this._recentVideoInfo).forEach((function(r){var n,i=r.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return Hg(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&&((SD||yD)&&(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=AL(),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=AL();else if("play"===e.eventName&&this._isPaused){this._isPaused=!1;var t=AL()-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}(),Yz=function(){function e(t){Hh(this,e),Jd(this,"_audioStallTimer",void 0),Jd(this,"_preSample",void 0),Jd(this,"_isStallInPreCallbackEnd",!1),Jd(this,"_isStallInPreReportEnd",!1),Jd(this,"_stallList",[]),this._stream=t}var t,r;return jh(e,[{key:"start",value:function(t,r){this.stop(),cL.AUDIO_STALL&&e.interval>0&&"number"==typeof t&&"number"==typeof r&&(this._preSample={ts:AL(),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=Ug(Dg().mark((function t(){var r,n,i,o,a;return Dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={stats_count:Cy(r=this._stallList).call(r,(function(e){return!!e.get_stats_cost})).length,stall_list:iR(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=qz(this._stallList,2,this._isStallInPreReportEnd),this._isStallInPreReportEnd=i.isStallInEnd,o=cL.AUDIO_STALL_DATA/e.interval,a=qz(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=Ug(Dg().mark((function n(){return Dg().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=Ug(Dg().mark((function t(){var r,n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R;return Dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._preSample&&!(AL()-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=AL(),this._stallList.push({reason:u?Hg(d="virtual: ".concat(o,", virtualOccupy: ")).call(d,a):Hg(l="hasAudio: ".concat(n,", subAudio: ")).call(l,i)}),t.next=29;break;case 13:return h=AL(),p=0,t.prev=15,t.next=18,null===(_=this._stream.audioTransceiver)||void 0===_?void 0:_.receiver.getStats();case 18:null==(m=t.sent)||m.forEach((function(e){"inbound-rtp"===e.type&&(f=e),p++})),t.next=25;break;case 22:t.prev=22,t.t0=t.catch(15),v=t.t0.message||Xg(t.t0);case 25:g=AL(),y=AL(),S=y-this._preSample.ts,f?(E=(b=f).concealedSamples,k=b.totalSamplesReceived,T=E-this._preSample.concealedSamples,I=k-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=E,this._preSample.totalSamplesReceived=k,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:p?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}();Jd(Yz,"interval",100),Jd(Yz,"ratio",.6);var qz=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 l=o>=t,d=s+t-o-1;if(!l&&o>2){var h=0;dI(e).call(e,s+1,d+1).forEach((function(e){e.is_stall&&(h+=e.diff||0)})),(l=a+h>Yz.interval*t*Yz.ratio)&&(s=d,a+=h)}l&&(i.stall_count++,i.stall_duration+=a,i.list.push(a)),u&&(i.isStallInEnd=l),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},Jz=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(Jz||{}),Qz=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}(Qz||{}),Zz=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(Zz||{}),$z=function(){function e(t){Hh(this,e),Jd(this,"_plugins",new hT),this.id=t}var t;return jh(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(qC(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 lI(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=Ug(Dg().mark((function e(t){var r,n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.mediaTrack,i=by(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}(),eW=qe,tW=Lr,rW=jr,nW=function(e){for(var t=eW(this),r=rW(t),n=arguments.length,i=tW(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:tW(o,r);a>i;)t[i++]=e;return t};Cr({target:"Array",proto:!0},{fill:nW});var iW=qs("Array").fill,oW=se,aW=iW,sW=Array.prototype,cW=r((function(e){var t=e.fill;return e===sW||oW(sW,e)&&t===sW.fill?aW:t})),uW=new hD("InternalEventBus",1),lW=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}(lW||{}),dW=function(e){BA(r,e);var t=nC(r);function r(){return Hh(this,r),t.apply(this,arguments)}return jh(r,[{key:"emit",value:function(e){var t,n;uW.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=VA(UA(r.prototype),"emit",this)).call.apply(t,Hg(n=[this,e]).call(n,o))}}]),r}(_U.EventEmitter),hW=new dW,fW="data:application/javascript;base64,Y2xhc3MgRHVtcEF1ZGlvRGF0YSBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgcHJvY2VzcyhpbnB1dHMpIHsKICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgIGRhdGE6IGlucHV0c1swXSwKICAgICAgY2hhbm5lbENvdW50OiBpbnB1dHNbMF0ubGVuZ3RoLAogICAgICBzYW1wbGVSYXRlLAogICAgfSk7CiAgICByZXR1cm4gdHJ1ZTsKICB9Cn0KCnJlZ2lzdGVyUHJvY2Vzc29yKCdkdW1wLWF1ZGlvLWRhdGEnLCBEdW1wQXVkaW9EYXRhKTsK",vW=new hD("AudioContext",1),pW=function(){function e(){var t=this;Hh(this,e),Jd(this,"isWorkletReady",void 0),Jd(this,"_audioContextInstance",void 0),Jd(this,"_previousState",""),Jd(this,"_currentState",""),Jd(this,"_contextStuckAt",0);var r=0;pD()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,vW.info("currentTime resume")):e&&r===e&&(t._contextStuckAt=e,vW.warn("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),t._contextStuckAt),r=e}}),3e3)}return jh(e,[{key:"getAudioContextInstance",value:function(){var e=this;if(!this._audioContextInstance){var t=window.AudioContext||window.webkitAudioContext;this._audioContextInstance=nV?new t:new t({sampleRate:44100});try{this.isWorkletReady=this._audioContextInstance.audioWorklet.addModule(fW),this.isWorkletReady.catch((function(t){var r;BM("initial AudioWorklet error in promise",-1,Hg(r="".concat(t.name,"-")).call(r,t.message)),vW.error("isWorkletReady",t),e.isWorkletReady=null}))}catch(n){var r;BM("initial AudioWorklet error in catch",-1,Hg(r="".concat(n.name,"-")).call(r,n.message)),vW.error("isWorkletReady",n),this.isWorkletReady=null}this._audioContextInstance.onstatechange=function(){var t,r,n;vW.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(),(PD||wD)&&("running"===e._previousState&&"interrupted"===e._currentState&&hW.emit(lW.ON_IOS_INTERRUPTION_START),"interrupted"===e._previousState&&"running"===e._currentState&&hW.emit(lW.ON_IOS_INTERRUPTION_END))}}return this._audioContextInstance}}]),e}(),_W=function(){function e(t){Hh(this,e),Jd(this,"_ctx",void 0),Jd(this,"_analyserNode",void 0),Jd(this,"_audioSource",void 0),Jd(this,"currentTrackId",void 0),this.currentTrackId=t.id;var r=gW.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 jh(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=Ug(Dg().mark((function e(){var t;return Dg().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}(),mW=function(e){BA(r,e);var t=nC(r);function r(e,n){var i,o,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:gW.getAudioContextInstance(),s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:gW.isWorkletReady;(Hh(this,r),Jd(uA(i=t.call(this)),"_ctx",void 0),Jd(uA(i),"_worklet",void 0),Jd(uA(i),"_source",void 0),Jd(uA(i),"_buffers",[]),Jd(uA(i),"_bufferLength",0),Jd(uA(i),"_sampleRate",void 0),Jd(uA(i),"_channelCount",void 0),Jd(uA(i),"_frameSize",void 0),e instanceof MediaStreamTrack)?i._channelCount=null!==(o=e.getSettings().channelCount)&&void 0!==o?o:1:i._channelCount=e.channelCount;return i._ctx=a,i._frameSize=n,null==s||s.then((function(){i._worklet=new AudioWorkletNode(i._ctx,"dump-audio-data"),e instanceof MediaStreamTrack?i._source=i._ctx.createMediaStreamSource(new MediaStream([e])):i._source=e,i._source.connect(i._worklet),i._initWorkletEventListener(i._worklet)})).catch(),i}return jh(r,[{key:"_initWorkletEventListener",value:function(e){e.port.onmessage=this._handleWorkletMessage.bind(this)}},{key:"_handleWorkletMessage",value:function(e){var t=this,r=e.data,n=r.data,i=r.sampleRate;if(this._bufferLength>=this._frameSize||this._sampleRate!==i){var o,a;if(this._sampleRate){var s=1===this._channelCount||1===n.length?1:2;this.emit("data",{channels:iR(this._buffers),sampleRate:this._sampleRate,channelCount:s})}this._sampleRate=i,this._buffers=$g(o=cW(a=new Array(this._channelCount)).call(a,0)).call(o,(function(){return new Float32Array(t._frameSize)})),this._bufferLength=0}for(var c=0;c<this._channelCount;c++)this._buffers[c].set(n[c],this._bufferLength);this._bufferLength=this._bufferLength+n[0].length}},{key:"setFrameSize",value:function(e){this._frameSize=e}},{key:"destroy",value:function(){var e,t,r;this.removeAllListeners("data"),this._worklet&&(null===(e=this._source)||void 0===e||e.disconnect(this._worklet)),null===(t=this._worklet)||void 0===t||t.disconnect(),null===(r=this._worklet)||void 0===r||r.port.close(),this._buffers=[],delete this._source,delete this._worklet}}]),r}(_U.EventEmitter),gW=new pW,yW=new hD("VERTC",0),SW=function(){function e(){Hh(this,e),Jd(this,"_ac",void 0),Jd(this,"_sourceNode",void 0),Jd(this,"_gainNode",void 0),Jd(this,"_destNode",void 0),this._ac=gW.getAudioContextInstance(),this._gainNode=this._ac.createGain(),this._destNode=this._ac.createMediaStreamDestination(),this._gainNode.connect(this._destNode)}return jh(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!==BD&&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}(),bW=function(e){BA(n,e);var t,r=nC(n);function n(e,t,i){var o;return Hh(this,n),Jd(uA(o=r.call(this,e,t,Zd(Zd({},i),{},{mediaType:xU.AUDIO}))),"audioCaptureConfig",void 0),Jd(uA(o),"_ap",void 0),Jd(uA(o),"mixedAudioTrack",void 0),Jd(uA(o),"mixType",Lh.PLAYOUT_AND_PUBLISH),Jd(uA(o),"_audioFetchMap",new hT),Jd(uA(o),"_audioDataFetcher",void 0),Jd(uA(o),"notSupportedWebAudio",!1),o}return jh(n,[{key:"withWebAudio",get:function(){return!!this._ap}},{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!==Lh.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 _W(n),this._audioFetchMap.set(r,i));return i.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=Ug(Dg().mark((function e(){return Dg().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 yW.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:"setVolume",value:function(e){var t=!lL("SKIP_WEB_AUDIO_IN_TRACK")&&JU();t||(this.notSupportedWebAudio=!0);var r,n=!this.withWebAudio&&100!==e;try{t&&n&&(yW.print("Create AudioProcess"),this._ap=new SW,this._ap.updateInputTrack(this.originTrack),this.mediaTrack=this._ap.getOutputTrack())}catch(i){yW.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}},{key:"setUserId",value:function(e){this.trackInfo.streamUserId=e}},{key:"setDataFetcher",value:function(e,t){yW.info("setDataFetcher","frameSize %s",e),null!==gW.isWorkletReady?this._audioDataFetcher?this._audioDataFetcher.setFrameSize(e):(this._audioDataFetcher=new mW(this.preprocessingTrack,e),this._audioDataFetcher.on("data",t)):yW.info("setDataFetcher","audioContextManager.isWorkletReady is null")}},{key:"stopDataFetcher",value:function(){var e,t;null===(e=this._audioDataFetcher)||void 0===e||e.removeAllListeners("data"),null===(t=this._audioDataFetcher)||void 0===t||t.destroy(),this._audioDataFetcher=void 0}},{key:"destroy",value:function(){var e,t;this._audioFetchMap.forEach((function(e){return e.destroy()})),this._audioFetchMap.clear(),null===(e=this._ap)||void 0===e||e.destroy(),null===(t=this._audioDataFetcher)||void 0===t||t.destroy(),this._audioDataFetcher=void 0,VA(UA(n.prototype),"destroy",this).call(this)}}]),n}(PU),EW=function(e){BA(r,e);var t=nC(r);function r(e,n){var i;return Hh(this,r),Jd(uA(i=t.call(this,e,Zd(Zd({},n),{},{mediaType:xU.AUDIO}))),"_ap",void 0),Jd(uA(i),"_audioPlayer",void 0),Jd(uA(i),"_audioLevelFetcher",void 0),Jd(uA(i),"_audioDataFetcher",void 0),Jd(uA(i),"notSupportedWebAudio",!1),i}return jh(r,[{key:"withWebAudio",get:function(){return!!this._ap}},{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new _W(this.originTrack)),this._audioLevelFetcher.getAudioLevel()}},{key:"setVolume",value:function(e){var t=!lL("SKIP_WEB_AUDIO_IN_TRACK")&&JU();t||(this.notSupportedWebAudio=!0);var r,n,i=!this.withWebAudio&&100!==e;try{t&&i&&(yW.print("Create AudioProcess"),this._ap=new SW,this._ap.updateInputTrack(this.originTrack),this.mediaTrack=this._ap.getOutputTrack())}catch(o){yW.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._audioPlayer)||void 0===n||n.playAudio(this))}},{key:"getVolume",value:function(){return this.notSupportedWebAudio?100:this._ap?this._ap.getVolume():100}},{key:"dangerousGetPlayer",value:function(){return this._audioPlayer}},{key:"setPlaybackDevice",value:function(e){var t;return null===(t=this._audioPlayer)||void 0===t?void 0:t.setPlaybackDevice(e)}},{key:"setPlayer",value:function(e){this._audioPlayer=e}},{key:"pause",value:function(){var e;return null===(e=this._audioPlayer)||void 0===e?void 0:e.pause()}},{key:"play",value:function(){var e,t,r;return null!==(e=this._audioPlayer)&&void 0!==e&&e.played?null===(t=this._audioPlayer)||void 0===t?void 0:t.manuallyPlay():null===(r=this._audioPlayer)||void 0===r?void 0:r.playAudio(this)}},{key:"manuallyPause",value:function(){var e;return null===(e=this._audioPlayer)||void 0===e?void 0:e.manuallyPause()}},{key:"stop",value:function(){var e;return null===(e=this._audioPlayer)||void 0===e?void 0:e.stop()}},{key:"setDataFetcher",value:function(e,t){yW.info("setDataFetcher","frameSize %s",e),null!==gW.isWorkletReady?this._audioDataFetcher?this._audioDataFetcher.setFrameSize(e):(this._audioDataFetcher=new mW(this.originTrack,e),this._audioDataFetcher.on("data",t)):yW.info("setDataFetcher","audioContextManager.isWorkletReady is null")}},{key:"stopDataFetcher",value:function(){var e;yW.info("stopDataFetcher"),null===(e=this._audioDataFetcher)||void 0===e||e.destroy(),this._audioDataFetcher=void 0}},{key:"destroy",value:function(){var e,t,n;null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),null===(t=this._audioDataFetcher)||void 0===t||t.destroy(),this._audioDataFetcher=void 0,this._ap&&this._ap.destroy(),null===(n=this._audioPlayer)||void 0===n||n.destroy(),this._audioPlayer=void 0,VA(UA(r.prototype),"destroy",this).call(this)}}]),r}(MU),kW=r(Ad),TW=new hD("VideoSnapshot",1),IW=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},RW=function(){var e=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=document.createElement("canvas"),i=n.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(o=function(e,t,r){return t=t||e.width,r=r||e.height,n.width=t,n.height=r,i.setTransform(1,0,0,1,0,0),i.drawImage(e,0,0,t,r),i.getImageData(0,0,t,r)},a=Date.now(),!(s=IW(r))){e.next=16;break}return TW.info("takeSnapshot","VideoPlayer already set."),e.next=11,o(s,s.videoWidth,s.videoHeight);case 11:return c=e.sent,TW.info("takeSnapshot","success, cost ".concat(Date.now()-a,"ms")),e.abrupt("return",c);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(u=new window.ImageCapture(t)).track.readyState||!u.track.enabled||u.track.muted){e.next=29;break}return TW.info("takeSnapshot","use ImageCapture"),e.t0=o,e.next=23,u.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return l=e.sent,TW.info("takeSnapshot","success, cost ".concat(Date.now()-a,"ms")),e.abrupt("return",l);case 29:return TW.info("takeSnapshot","use temp video"),e.abrupt("return",new Gg((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=o(i,i.videoWidth,i.videoHeight);TW.info("takeSnapshot","success, cost ".concat(Date.now()-a,"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){return e.apply(this,arguments)}}(),AW=new hD("VERTC",0),CW=kW("default"),wW=function(e){return e.START_STALL_OBSERVE="start_stall_observe",e.STOP_STALL_OBSERVE="stop_stall_observe",e}(wW||{}),xW=function(e){BA(n,e);var t,r=nC(n);function n(e,t,i){var o;return Hh(this,n),Jd(uA(o=r.call(this,e,t,Zd(Zd({},i),{},{mediaType:xU.VIDEO}))),"resolution",void 0),Jd(uA(o),"videoPlayers",new hT),o.resolution={width:0,height:0},o}return jh(n,[{key:"intersection",value:function(){var e={};return this.videoPlayers.forEach((function(t,r){e[r.toString()]=t.isIntersecting})),e}},{key:"updateVideoCaptureConfig",value:(t=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return AW.info("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=Zd({},t)).contentHint,yD&&this.trackInfo.streamIndex===OU.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:"setContentHint",value:function(e){var t;"contentHint"in this.originTrack&&Qy(t=["text","motion","detail"]).call(t,e)&&(this.originTrack.contentHint=e)}},{key:"setTrack",value:function(e,t,r){this._originTrack=e,this.extensionManager=t,this.trackInfo=Zd(Zd({},this.trackInfo),r),this.isTrackReady=this.generatePreProcessingTrack()}},{key:"setPlayer",value:function(e,t,r,n,i){var o,a=null!==(o=t.playerId)&&void 0!==o?o:CW,s=this.videoPlayers.get(a);return t.player!==s&&(s=t.player,this.videoPlayers.set(a,s),i(s,this.isPublic,this.streamIndex)),this.mirror(!!r),this.dummy||n===Rh.PLAY_MANUALLY||this.play(a),s.domElement}},{key:"setUserId",value:function(e){this.trackInfo.streamUserId=e,this.videoPlayers.forEach((function(t){t.userId=e}))}},{key:"snapshot",value:function(){var e,t,r,n=by($w(e=this.videoPlayers).call(e));try{for(n.s();!(r=n.n()).done;){var i=r.value;if(i.played){t=i;break}}}catch(XJ){n.e(XJ)}finally{n.f()}return RW(this.preprocessingTrack,t)}},{key:"setRenderMode",value:function(e,t){var r;return null===(r=this.videoPlayers.get(e))||void 0===r?void 0:r.setRenderMode(t)}},{key:"mirror",value:function(e){this.videoPlayers.forEach((function(t){t.mirror(e)}))}},{key:"removePlayerTrack",value:function(){var e=this;this.videoPlayers.forEach((function(t,r){var n;null===(n=e.videoPlayers.get(r))||void 0===n||n.removeTrack()}))}},{key:"play",value:function(e){var t=this.videoPlayers.get(e);return null!=t&&t.played?t.manuallyPlay():null==t?void 0:t.playVideo(this)}},{key:"playAll",value:function(){var e=this;this.videoPlayers.forEach((function(t,r){e.play(r)}))}},{key:"manuallyPlay",value:function(e){var t;return null===(t=this.videoPlayers.get(e))||void 0===t?void 0:t.manuallyPlay()}},{key:"pause",value:function(e){var t;null===(t=this.videoPlayers.get(e))||void 0===t||t.manuallyPause()}},{key:"stop",value:function(e){var t;return null===(t=this.videoPlayers.get(e))||void 0===t?void 0:t.stop()}},{key:"stopAll",value:function(){var e=this;return this.videoPlayers.forEach((function(t,r){e.stop(r)}))}},{key:"destroy",value:function(){var e=this;this.videoPlayers.forEach((function(t,r){e.stop(r),t.removeAllListeners(),e.videoPlayers.delete(r)})),VA(UA(n.prototype),"destroy",this).call(this)}}]),n}(PU),OW=function(e){BA(r,e);var t=nC(r);function r(e,n,i,o){var a;return Hh(this,r),Jd(uA(a=t.call(this,e,Zd(Zd({},i),{},{mediaType:xU.VIDEO}))),"videoPlayers",new hT),Jd(uA(a),"_stream",void 0),Jd(uA(a),"_observingPlayer",void 0),a._ctx=o,a._stream=n,a}return jh(r,[{key:"observingPlayerId",get:function(){var e;return null===(e=this._observingPlayer)||void 0===e?void 0:e.playerId}},{key:"getSizeByPlayer",value:function(){var e=0,t=0;return this.videoPlayers.forEach((function(r){var n;null!==(n=r.domElement)&&void 0!==n&&n.videoWidth&&r.domElement.videoHeight&&(e=r.domElement.videoWidth,t=r.domElement.videoHeight)})),{width:e,height:t}}},{key:"intersection",value:function(){var e={};return this.videoPlayers.forEach((function(t,r){e[r.toString()]=t.isIntersecting})),e}},{key:"setPlayer",value:function(e,t,r,n){var i,o,a=null!==(i=t.playerId)&&void 0!==i?i:CW,s=this.videoPlayers.get(a);if(t.player!==s){var c;if(s=t.player,!HL(this.streamIndex))s.mirror(this._ctx.getRemoteMirrorType(null!==(c=this.trackInfo.streamUserId)&&void 0!==c?c:"",this.streamIndex));this.videoPlayers.set(a,s),this._handlePlayerStallEvent(s),n(s,this.isPublic,this.streamIndex)}return this.dummy||r===Rh.PLAY_MANUALLY||this.play(a),null===(o=s)||void 0===o?void 0:o.domElement}},{key:"mirror",value:function(e){this.videoPlayers.forEach((function(t){t.mirror(e)}))}},{key:"dangerousGetPlayer",value:function(e){return this.videoPlayers.get(e)}},{key:"snapshot",value:function(){var e,t,r,n=by($w(e=this.videoPlayers).call(e));try{for(n.s();!(r=n.n()).done;){var i=r.value;if(i.played){t=i;break}}}catch(XJ){n.e(XJ)}finally{n.f()}return RW(this.preprocessingTrack,t)}},{key:"stop",value:function(e){var t;null===(t=this.videoPlayers.get(e))||void 0===t||t.stop()}},{key:"stopAll",value:function(){var e=this;this.videoPlayers.forEach((function(t,r){e.stop(r)}))}},{key:"play",value:function(e){var t=this.videoPlayers.get(e);return null!=t&&t.played?t.manuallyPlay():null==t?void 0:t.playVideo(this)}},{key:"pause",value:function(e){var t;return null===(t=this.videoPlayers.get(e))||void 0===t?void 0:t.manuallyPause()}},{key:"_handlePlayerStallEvent",value:function(e){var t=this;e.on("start_stall_observe",(function(){!t._observingPlayer&&e&&(t._observingPlayer=e,t._stream.startVideoStallObserve(t._observingPlayer))})),e.on("stop_stall_observe",(function(){t._observingPlayer===e&&(t._stream.stopVideoStallObserve(),t._observingPlayer=void 0,t.videoPlayers.forEach((function(e){!t._observingPlayer&&e.played&&(t._observingPlayer=e,t._stream.startVideoStallObserve(e))})))}))}},{key:"destroy",value:function(){var e=this;this.videoPlayers.forEach((function(t,r){e.stop(r),t.removeAllListeners(),e.videoPlayers.delete(r)})),VA(UA(r.prototype),"destroy",this).call(this)}}]),r}(MU),NW=function(e){BA(v,e);var t,r,n,i,o,a,s,c,u,l,d,h,f=nC(v);function v(){var e,t,r;return Hh(this,v),Jd(uA(r=f.call(this)),"deviceMap",{audioinput:new hT,audiooutput:new hT,videoinput:new hT}),Jd(uA(r),"checkDeviceChangeTimer",null),Jd(uA(r),"isSupportedPermissionsQuery",!1),Jd(uA(r),"isGrantedMicrophonePermission",!1),Jd(uA(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!pD()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(uA(r)),!pD()&&r.initListener().then((function(){r.updateDeviceListInSilent()})),r}return jh(v,[{key:"refreshDevices",value:(h=Ug(Dg().mark((function e(){var t,r,n,i=this,o=arguments;return Dg().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,!yD){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:(d=Ug(Dg().mark((function e(){var t,r,n,i,o=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.ondevicechange)&&"function"==typeof(null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)?navigator.mediaDevices.addEventListener("devicechange",(function(){o._handleDeviceChange(),setTimeout((function(){o._handleDeviceChange()}),300)})):this.checkDeviceChangeTimer=window.setInterval((function(){o._handleDeviceChange()}),3e3),!this.isSupportedPermissionsQuery){e.next=22;break}return e.prev=2,e.next=5,navigator.permissions.query({name:"microphone"});case 5:n=e.sent,this.isGrantedMicrophonePermission="granted"===n.state,n.addEventListener("change",(function(){o.isGrantedMicrophonePermission="granted"===n.state})),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.prev=12,e.next=15,navigator.permissions.query({name:"camera"});case 15:i=e.sent,this.isGrantedCameraPermission="granted"===i.state,i.addEventListener("change",(function(){o.isGrantedCameraPermission="granted"===i.state})),e.next=22;break;case 20:e.prev=20,e.t1=e.catch(12);case 22:case"end":return e.stop()}}),e,this,[[2,10],[12,20]])}))),function(){return d.apply(this,arguments)})},{key:"_handleDeviceChange",value:(l=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c=this;return Dg().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,!yD){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=Cy(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=Fw(Hg(t=[]).call(t,iR($w(r=this.deviceMap.audioinput).call(r)),iR($w(n=this.deviceMap.videoinput).call(n)),iR($w(i=this.deviceMap.audiooutput).call(i)))),(ND||wD)&&!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||(Qy(t=e.kind).call(t,"video")?c.emit(Fh.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):Qy(r=e.kind).call(r,"audio")&&c.emit(Fh.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;lI(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),Qy(t=e.kind).call(t,"video")?c.emit(Fh.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):Qy(r=e.kind).call(r,"audio")&&c.emit(Fh.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 16:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getUserMedia",value:(u=Ug(Dg().mark((function e(t){var r;return Dg().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=Ug(Dg().mark((function e(){var t,r;return Dg().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=Cy(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=Cy(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=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c,u,l,d=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=(r=d.length>0&&void 0!==d[0]?d[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=l=e.sent,e.t5=null===e.t6,e.t5){e.next=63;break}e.t5=void 0===l;case 63:if(!e.t5){e.next=67;break}e.t7=void 0,e.next=68;break;case 67:e.t7=l.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=Ug(Dg().mark((function e(){return Dg().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=Ug(Dg().mark((function e(){var t,r,n,i;return Dg().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",Fw(Hg(t=[]).call(t,iR($w(r=this.deviceMap.audioinput).call(r)),iR($w(n=this.deviceMap.videoinput).call(n)),iR($w(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=Ug(Dg().mark((function e(){var t;return Dg().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",Fw($w(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=Ug(Dg().mark((function e(){var t;return Dg().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",Fw($w(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=Ug(Dg().mark((function e(){var t;return Dg().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",Fw($w(t=this.deviceMap.audiooutput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getAudioPlaybackDeviceById",value:(t=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateAudioPlaybackDevices();case 2:return r=e.sent,e.abrupt("return",lI(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}(yU),PW=new NW;!pD()&&(window.__rtc_dd__=PW);var MW=new hD("VERTC",0);function DW(e,t){return LW.apply(this,arguments)}function LW(){return(LW=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new xW(t,r,{streamIndex:OU.MAIN,sourceType:wU.INTERNAL,isDummy:!0}),e.next=3,n.isTrackReady;case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function UW(e,t){return VW.apply(this,arguments)}function VW(){return(VW=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new xW(t,r,{isDummy:!0,streamIndex:OU.SCREEN,sourceType:wU.INTERNAL}),e.next=3,n.isTrackReady;case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function FW(e,t){return BW.apply(this,arguments)}function BW(){return(BW=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,h;return Dg().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=HM(r.id),s=_x(),e.prev=3,MW.info("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o,capture_session_id:s}),u=AL(),yD&&(t.frameRate={ideal:30,max:30}),e.next=10,PW.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:AL()-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 _w(dw.GET_VIDEO_TRACK_FAILED,Hg(l="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(l,e.t0.message||"unknown message","."),e.t0);case 18:return d=i.getVideoTracks()[0],h=new xW(d,r,{streamIndex:OU.MAIN,sourceType:wU.INTERNAL,captureSessionId:s}),e.next=22,h.isTrackReady;case 22:return e.abrupt("return",h);case 23:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function jW(e,t){return HW.apply(this,arguments)}function HW(){return(HW=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,h,f;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MW.info("createMicrophoneAudioTrack","constraints:",t),o=(null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=HM(r.id),s=_x(),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=AL(),(l=r.getPluginByName(Qz.PRE_PROCESSING,"RTCAIAnsExtension"))&&(l.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=11,PW.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:AL()-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 _w(dw.GET_AUDIO_TRACK_FAILED,Hg(d="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(d,e.t0.message||"unknown message","."),e.t0);case 19:return h=i.getAudioTracks()[0],f=new bW(h,r,{streamIndex:OU.MAIN,sourceType:wU.INTERNAL,captureSessionId:s}),e.next=23,f.isTrackReady;case 23:return e.abrupt("return",f);case 24:case"end":return e.stop()}}),e,null,[[4,15]])})))).apply(this,arguments)}function GW(e,t,r){return zW.apply(this,arguments)}function zW(){return(zW=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MW.print("createCameraAndMicrophoneTrack","audioConstraints:",t,"videoConstraints:",r),a=HM(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",l=_x(),d=_x(),e.prev=6,null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:u,capture_session_id:l}),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_begin",media_device_id:c,event_session_id:d}),v=AL(),yD&&(r.frameRate={ideal:30,max:30}),(p=n.getPluginByName(Qz.PRE_PROCESSING,"RTCAIAnsExtension"))&&(p.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=15,PW.getUserMedia({audio:t,video:r});case 15: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:AL()-v,capture_session_id:l}),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_result",media_device_id:c,media_device_name:(null===(f=s.getAudioTracks()[0])||void 0===f?void 0:f.label)||"",reason:"success",elapse:AL()-v,event_session_id:d}),e.next=25;break;case 20:throw e.prev=20,e.t0=e.catch(6),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:l}),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:d}),new _w(dw.GET_VIDEO_TRACK_FAILED,Hg(_="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(_,e.t0.message||"unknown message","."),e.t0);case 25:return m=s.getVideoTracks()[0],g=new xW(m,n,{streamIndex:OU.MAIN,sourceType:wU.INTERNAL,captureSessionId:l}),y=s.getAudioTracks()[0],S=new bW(y,n,{streamIndex:OU.MAIN,sourceType:wU.INTERNAL,captureSessionId:d}),e.next=31,Gg.all([g.isTrackReady,S.isTrackReady]);case 31:return e.abrupt("return",{videoTrack:g,audioTrack:S});case 32:case"end":return e.stop()}}),e,null,[[6,20]])})))).apply(this,arguments)}function WW(e,t,r){return KW.apply(this,arguments)}function KW(){return(KW=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MW.info("createScreenTracks","screenConfig: %o, constraints: %o",t,n),u=HM(r.id),l=_x(),d=t.enableAudio,h=void 0!==d&&d,f=t.displaySurface,v=t.systemAudio,p=t.surfaceSwitching,_=t.selfBrowserSurface,m={},Qy(i=["monitor","browser","window"]).call(i,f)&&(n?n.displaySurface=f:n={displaySurface:f}),Qy(o=["include","exclude"]).call(o,v)&&(m.systemAudio=v),Qy(a=["include","exclude"]).call(a,p)&&(m.surfaceSwitching=p),Qy(s=["include","exclude"]).call(s,_)&&(m.selfBrowserSurface=_),e.prev=9,null==u||u.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen",capture_session_id:l}),b=AL(),e.next=14,navigator.mediaDevices.getDisplayMedia(Zd({video:!(n&&(!SD||"16.1"!==HD))||n,audio:!!h&&{channelCount:2,noiseSuppression:!1,echoCancellation:!0,autoGainControl:!1}},m));case 14:c=e.sent,null==u||u.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",media_device_name:Hg(g="".concat((null===(y=c.getVideoTracks()[0])||void 0===y?void 0:y.label)||"",", ")).call(g,(null===(S=c.getAudioTracks()[0])||void 0===S?void 0:S.label)||""),reason:"success",elapse:AL()-b,capture_session_id:l}),e.next=22;break;case 18:throw e.prev=18,e.t0=e.catch(9),null==u||u.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:l}),new _w(dw.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 22:if(E=c.getVideoTracks()[0],k=new xW(E,r,{streamIndex:OU.SCREEN,sourceType:wU.INTERNAL,captureSessionId:l}),T=c.getAudioTracks()[0],!c.getAudioTracks().length){e.next=30;break}return I=new bW(T,r,{streamIndex:OU.SCREEN,sourceType:wU.INTERNAL,captureSessionId:l}),e.next=29,Gg.all([k.isTrackReady,I.isTrackReady]);case 29:return e.abrupt("return",[k,I]);case 30:return e.next=32,k.isTrackReady;case 32:return e.abrupt("return",[k,void 0]);case 33:case"end":return e.stop()}}),e,null,[[9,18]])})))).apply(this,arguments)}function XW(e,t){return new EW(e,Zd({},t))}function YW(e,t){return qW.apply(this,arguments)}function qW(){return(qW=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new xW(t,r,{streamIndex:OU.MAIN,sourceType:wU.EXTERNAL}),e.next=3,n.isTrackReady;case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function JW(e,t){return QW.apply(this,arguments)}function QW(){return(QW=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new bW(t,r,{streamIndex:OU.MAIN,sourceType:wU.EXTERNAL}),e.next=3,n.isTrackReady;case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ZW(e,t){return $W.apply(this,arguments)}function $W(){return($W=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new xW(t,r,{sourceType:wU.EXTERNAL,streamIndex:OU.SCREEN}),e.next=3,n.isTrackReady;case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function eK(e,t){return tK.apply(this,arguments)}function tK(){return(tK=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new bW(t,r,{sourceType:wU.EXTERNAL,streamIndex:OU.SCREEN}),e.next=3,n.isTrackReady;case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var rK,nK=function(e){BA(r,e);var t=nC(r);function r(e){var n;return Hh(this,r),Jd(uA(n=t.call(this)),"isScreen",!1),Jd(uA(n),"audioMid",void 0),Jd(uA(n),"videoMid",void 0),Jd(uA(n),"videoTransceiver",void 0),Jd(uA(n),"audioTransceiver",void 0),Jd(uA(n),"vendorHandler",void 0),Jd(uA(n),"vendorCode",0),Jd(uA(n),"engineId",void 0),Jd(uA(n),"logger",void 0),n._ctx=e,n.engineId=e.id,n.logger=new hD("Stream",0,e.id),n}return jh(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}(yU),iK=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(iK||{}),oK=function(e){BA(r,e);var t=nC(r);function r(e){var n;Hh(this,r),Jd(uA(n=t.call(this,e)),"id",void 0),Jd(uA(n),"stream",void 0),Jd(uA(n),"streamId",void 0),Jd(uA(n),"seiList",[]),Jd(uA(n),"videoTrack",void 0),Jd(uA(n),"audioTrack",void 0),Jd(uA(n),"videoEncodeConfig",[pL]),Jd(uA(n),"subVideoDescriptions",[]),Jd(uA(n),"enableSimulcast",!1),Jd(uA(n),"observer",void 0),Jd(uA(n),"statsReport",void 0),Jd(uA(n),"prevBitrate",0),Jd(uA(n),"pubAudio",!1),Jd(uA(n),"pubVideo",!1),Jd(uA(n),"blackFrameRenderInterval",void 0),Jd(uA(n),"blackFrameLifetimeInterval",void 0),Jd(uA(n),"pubAttributes",void 0),Jd(uA(n),"pcSessionId",void 0),Jd(uA(n),"maxSeiCount",1),Jd(uA(n),"preReports",{audio:{},video:{}}),Jd(uA(n),"transformer",(function(e,t){var r;if(n.seiList.length){var i,o=[],a=0,s=by(n.seiList);try{for(s.s();!(i=s.n()).done;){var c=i.value;if(o.length>=n.maxSeiCount)break;var u=hV.generateSEI(c.content);a+=u.byteLength,c.repeatCount--,o.push(u)}}catch(XJ){s.e(XJ)}finally{s.f()}n.seiList=Cy(r=n.seiList).call(r,(function(e){return e.repeatCount>0}));var l=new Uint8Array(a+e.data.byteLength);l.set(new Uint8Array(e.data));var d=e.data.byteLength;o.forEach((function(e){l.set(e,d),d+=e.byteLength})),e.data=l.buffer,t.enqueue(e)}else t.enqueue(e)})),n.stream=new MediaStream,n.id=_x(),n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1,videoDescriptions:[],videoType:CU.NORMAL},n.statsReport=new Wz(e,uA(n));var i=lL("SEI_COUNT_FPS");return"number"==typeof i&&i<=10&&(n.maxSeiCount=i),n}return jh(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:"getLocalStreamStats",value:function(){return this.statsReport.getLocalStats()}},{key:"initVideoEncodedTransform",value:function(){if(this.videoTransceiver&&this.videoTransceiver.sender){var e=this.videoTransceiver.sender;if(qU()){var t=e.createEncodedStreams(),r=t.readable,n=t.writable,i=new TransformStream({transform:this.transformer});r.pipeThrough(i).pipeTo(n)}}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(){this.engineId,"".concat((new Error).stack),this.streamId,VA(UA(r.prototype),"destroy",this).call(this),this.prevBitrate=0,this.subVideoDescriptions=[],clearTimeout(this.blackFrameLifetimeInterval),clearInterval(this.blackFrameRenderInterval)}},{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}},{key:"genBlackFrame",value:function(){var e,t;this.logger.info("genBlackFrame()");var r=null!==(e=this.videoEncodeConfig[0])&&void 0!==e&&e.frameRate?WL(null===(t=this.videoEncodeConfig[0])||void 0===t?void 0:t.frameRate):15,n=Math.ceil(1e3/r),i=document.createElement("canvas"),o=i.getContext("2d");i.width=16,i.height=16;var a=function(e){e.fillRect(0,0,16,16)};return o&&(o.fillStyle="#000",a(o),this.blackFrameRenderInterval=window.setInterval((function(){a(o)}),n),this.refreshBlackFrameLifetime()),i.captureStream(r).getVideoTracks()[0]}},{key:"stopBlackFrame",value:function(){this.logger.info("stopBlackFrame()"),clearTimeout(this.blackFrameLifetimeInterval),clearInterval(this.blackFrameRenderInterval),delete this.blackFrameRenderInterval}},{key:"refreshBlackFrameLifetime",value:function(){var e=this;this.logger.info("refreshBlackFrameLifetime()"),this.blackFrameRenderInterval&&(clearTimeout(this.blackFrameLifetimeInterval),this.blackFrameLifetimeInterval=setTimeout((function(){clearInterval(e.blackFrameRenderInterval),delete e.blackFrameRenderInterval,e.emit("black-frame-ended")}),cL.BLACK_FRAME_LIFETIME))}}]),r}(nK),aK=function(e){BA(n,e);var t,r=nC(n);function n(e,t,i,o,a,s){var c;return Hh(this,n),Jd(uA(c=r.call(this,e)),"streamId",void 0),Jd(uA(c),"userId",void 0),Jd(uA(c),"isPublic",void 0),Jd(uA(c),"hasVideo",void 0),Jd(uA(c),"hasAudio",void 0),Jd(uA(c),"_attributes",void 0),Jd(uA(c),"streamState",void 0),Jd(uA(c),"removeTrack",!1),Jd(uA(c),"observer",void 0),Jd(uA(c),"statsReport",void 0),Jd(uA(c),"subVideo",void 0),Jd(uA(c),"subAudio",void 0),Jd(uA(c),"subMediaType",void 0),Jd(uA(c),"subLayer",void 0),Jd(uA(c),"_sequenceId",void 0),Jd(uA(c),"stream",void 0),Jd(uA(c),"videoTrack",void 0),Jd(uA(c),"audioTrack",void 0),Jd(uA(c),"recordedVideoFrames",void 0),Jd(uA(c),"stillExist",void 0),Jd(uA(c),"originalMediaType",void 0),Jd(uA(c),"priority",void 0),Jd(uA(c),"remoteSessionId",""),Jd(uA(c),"originalStreamIndex",0),Jd(uA(c),"virtual",void 0),Jd(uA(c),"pcSessionId",void 0),Jd(uA(c),"_virtualOccupy",void 0),Jd(uA(c),"_videoStallObserver",void 0),Jd(uA(c),"_audioStallObserver",void 0),Jd(uA(c),"preReports",{audio:{},video:{}}),Jd(uA(c),"_installInfo",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=iV.NONE,c.subLayer={spatialLayer:0,spatialSubLayer:-1},c.streamState=0,c.statsReport=new Kz(e,uA(c)),c.enableVendorMode&&(c.pcSessionId=_x()),c}return jh(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)}},{key:"getRemoteStreamStats",value:function(){return this.statsReport.getRemoteStreamStats()}},{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){oV.getNalunits(new aV(t.data)).forEach((function(t){if(t.sei){var r=hV.decodeSeiBody(t.body);r&&r.type!==sV.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(){if(this.audioTransceiver&&this.audioTransceiver.receiver){var e=this.audioTransceiver.receiver.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){e.data.byteLength<=1e3&&t.enqueue(e)}})).pipeTo(r)}else this.logger.warn("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n;try{var i;this.engineId,Xg({uid:this.userId,streamId:this.streamId,streams:uS(i=e.streams).call(i,(function(e,t){return e+yx(t)}),""),transceiver:Ex(e.transceiver),track:gx(e.track)}),this.streamId}catch(KJ){}if(this.enableVendorMode||null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&Qy(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",e.playerId),this._videoStallObserver||(this._videoStallObserver=new Xz(this.isScreen,this.engineId)),this._videoStallObserver.start(e)}},{key:"stopVideoStallObserve",value:function(){var e;this.logger.info("stopVideoStallObserve","invoke"),null===(e=this._videoStallObserver)||void 0===e||e.stop()}},{key:"updateVideoStallInfo",value:function(e,t,r){var n,i;r?(n=null===(i=this._videoStallObserver)||void 0===i?void 0:i.getStallInfo({interval:e.stats_interval||0,bitrate:e.bitrate,frameRateDecoded:e.frame_rate_decoded,frameRateReceived:e.frame_rate_received}),this._installInfo=n):n=this._installInfo;if(n){var o=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=o:e.stall_duration=o,e.pause_duration=Math.min(o,n.pauseDuration),t.stallCount=n.callback.stallCount,t.stallDuration=n.callback.stallDuration,n.stall100ms){var a=Math.min(n.stall100ms.duration,e.stats_interval||0);e.stall_duration_100ms=a,e.stall_count_100ms=n.stall100ms.count,t.stallDuration100MS=a,t.stallCount100MS=n.stall100ms.count}0!==n.report.stallCount||n.report.stallDuration}}},{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=Ug(Dg().mark((function e(t,r,n){var i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._audioStallObserver){e.next=5;break}this._audioStallObserver=new Yz(this),this._audioStallObserver.start(n.concealedSamples,n.totalSamplesReceived),e.next=11;break;case 5:return e.next=7,this._audioStallObserver.getAudioStallInfo();case 7: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||i.report.stall_duration,e.abrupt("return",i.extra);case 11:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"clean",value:function(){var e,t,r;this.logger.info("clean",Hg(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),this.engineId,"".concat((new Error).stack),this.streamId,VA(UA(n.prototype),"destroy",this).call(this),this.subAudio=!1,this.subVideo=!1,this.sequenceId=0,null===(t=this.videoTrack)||void 0===t||t.destroy(),this.videoTrack=void 0,null===(r=this.audioTrack)||void 0===r||r.destroy(),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,n=this;if((null===(t=this.audioTrack)||void 0===t||null===(r=t.preprocessingTrack)||void 0===r?void 0:r.id)!==e.id){this.audioTrack=XW(e,{streamIndex:this.isPublic?OU.PUBLIC:this.virtual?OU.VIRTUAL:this.isScreen?OU.SCREEN:OU.MAIN,streamUserId:this.userId});var i,o=this._ctx._remoteAudioTrackDumpConfig[this.isScreen?Zz.STREAM_INDEX_SCREEN:Zz.STREAM_INDEX_MAIN].get(this.userId);if(null!=o&&o.callback&&null!=o&&o.frameSize)null===(i=this.audioTrack)||void 0===i||i.setDataFetcher(o.frameSize,(function(e){var t;n.audioHasCapture&&n.audioHasPublish&&(null===(t=o.callback)||void 0===t||t.call(o,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,t,r,n){return new OW(e,t,Zd({},r),n)}(e,this,{streamIndex:this.isPublic?OU.PUBLIC:this.virtual?OU.VIRTUAL:this.isScreen?OU.SCREEN:OU.MAIN,streamUserId:this.userId},this._ctx),this.emit("ontrack",this.videoTrack))}}]),n}(nK),sK=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.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.PUB_RETRY="PUB_RETRY",e.SUB_RETRY="SUB_RETRY",e.VIDEO_TYPE_CHANGE="VIDEO_TYPE_CHANGE",e.JOIN_SUCCESS="JOIN_SUCCESS",e}(sK||{}),cK=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}(cK||{}),uK=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(uK||{}),lK=function(){var e=Ug(Dg().mark((function e(t,r,n,i){var o,a,s,c,u,l,d,h,f,v,p,_,m,g,y;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,u="video"===r?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,l="video"===r?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.next=8,null===(d=t.peerConnection)||void 0===d?void 0:d.getStatsWithLowFrequency(u,!0,l);case 8:return v=e.sent,p=lI(h=v||[]).call(h,(function(e){return"inbound-rtp"===e.type})),e.next=12,null==l?void 0:l.getStats();case 12:if(_=e.sent,m=[],null==_||_.forEach((function(e){return m.push(e.type)})),0!==(null==v?void 0:v.length)||0===m.length){e.next=19;break}return e.next=18,null===(y=t.peerConnection)||void 0===y?void 0:y.getStatsWithLowFrequency(void 0,void 0,l);case 18:g=e.sent;case 19:Xg({type:r,reports:$g(v).call(v,(function(e){return e.type})),reports2:m,pc:(null===(f=t.peerConnection)||void 0===f?void 0:f.getOriginRTCPeerConnection())||null,track:(null==u?void 0:u.id)||null,bytes:null==p?void 0:p.bytesReceived,framesReceived:null==p?void 0:p.framesReceived,packetsReceived:null==p?void 0:p.packetsReceived,allReports:g}),e.next=26;break;case 22:e.prev=22,e.t0=e.catch(5),e.t0.mseeage||Xg(e.t0);case 26:e.next=30;break;case 28:e.prev=28,e.t1=e.catch(0);case 30:case"end":return e.stop()}}),e,null,[[0,28],[5,22]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),dK=function(){var e=Ug(Dg().mark((function e(t,r,n,i){var o,a,s,c,u,l,d,h,f,v,p,_,m,g,y;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,u="video"===r?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,l="video"===r?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.next=8,null===(d=t.peerConnection)||void 0===d?void 0:d.getStatsWithLowFrequency(u,!0,l);case 8:return v=e.sent,p=lI(h=v||[]).call(h,(function(e){return"outbound-rtp"===e.type})),e.next=12,null==l?void 0:l.getStats();case 12:if(_=e.sent,m=[],null==_||_.forEach((function(e){return m.push(e.type)})),0!==v.length||0===m.length){e.next=19;break}return e.next=18,null===(y=t.peerConnection)||void 0===y?void 0:y.getStatsWithLowFrequency(void 0,void 0,l);case 18:g=e.sent;case 19:Xg({type:r,reports:$g(v).call(v,(function(e){return e.type})),reports2:m,pc:(null===(f=t.peerConnection)||void 0===f?void 0:f.getOriginRTCPeerConnection())||null,track:(null==u?void 0:u.id)||null,bytes:null==p?void 0:p.bytesSent,framesSent:null==p?void 0:p.framesSent,packetsSent:null==p?void 0:p.packetsSent,allReports:g}),e.next=26;break;case 22:e.prev=22,e.t0=e.catch(5),e.t0.mseeage||Xg(e.t0);case 26:e.next=30;break;case 28:e.prev=28,e.t1=e.catch(0);case 30:case"end":return e.stop()}}),e,null,[[0,28],[5,22]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),hK=function(e){BA(a,e);var t,r,n,i,o=nC(a);function a(e,t){var r;return Hh(this,a),Jd(uA(r=o.call(this)),"_audioEventSessionId",PL()),Jd(uA(r),"_videoEventSessionId",PL()),Jd(uA(r),"_stream",void 0),Jd(uA(r),"_firstAudioFrameTimer",void 0),Jd(uA(r),"_firstVideoFrameTimer",void 0),Jd(uA(r),"_transportDelayInterval",void 0),Jd(uA(r),"_transportDelay",void 0),Jd(uA(r),"_firstVideoFrameInterval",void 0),Jd(uA(r),"_firstAudioFrameInterval",void 0),Jd(uA(r),"_isScreen",!1),Jd(uA(r),"_audioFirstFrameState",0),Jd(uA(r),"_videoFirstFrameState",0),Jd(uA(r),"_timeout",1e4),Jd(uA(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(uA(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(uA(r),"_login",!1),Jd(uA(r),"_unMuteAudio",!1),Jd(uA(r),"_enableAudio",!1),Jd(uA(r),"_unMuteVideo",!1),Jd(uA(r),"_enableVideo",!1),Jd(uA(r),"_remoteUnmuteAudio",!1),Jd(uA(r),"_remoteUnmuteVideo",!1),Jd(uA(r),"_audioExternal",!1),Jd(uA(r),"_pushAudio",!1),Jd(uA(r),"_videoExternal",!1),Jd(uA(r),"_pushVideo",!1),Jd(uA(r),"_autoSubscribeVideo",!1),Jd(uA(r),"_autoSubscribeAudio",!1),Jd(uA(r),"_autoSubscribe",!1),Jd(uA(r),"_publishVideo",!1),Jd(uA(r),"_publishAudio",!1),Jd(uA(r),"_subscribeAudio",!1),Jd(uA(r),"_subscribeVideo",!1),Jd(uA(r),"_subscribe",!1),Jd(uA(r),"_pushTrack",!1),Jd(uA(r),"_multiChatMode",!1),Jd(uA(r),"_monitor",void 0),Jd(uA(r),"logger",void 0),r._ctx=e,r._stream=t,r.getTransportDelay(),r._monitor=HM(t.engineId),r.logger=new hD("RecvFrameObserver",0,t.engineId),r}return jh(a,[{key:"beginRecvFrame",value:(i=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,kI(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},f={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===(l=this._stream)||void 0===l?void 0:l.pcSessionId)||(null===(d=this._ctx.peerConnection)||void 0===d?void 0:d.getConnectionId()),remote_rtc_session_id:null===(h=this._stream)||void 0===h?void 0:h.remoteSessionId},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){lK(E._ctx,"audio",E._stream,E._monitor),E.stopRecvFrame("audio","timeout"),E._firstAudioFrameInterval&&window.clearInterval(E._firstAudioFrameInterval)}),this._timeout),this.logger.info("rtcFirstFrameRecv",Xg(f)),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===(p=this._currentVideoRecv)||void 0===p?void 0:p.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,transport_delay:i,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(g=this._stream)||void 0===g?void 0:g.pcSessionId)||(null===(y=this._ctx.peerConnection)||void 0===y?void 0:y.getConnectionId()),remote_rtc_session_id:null===(S=this._stream)||void 0===S?void 0:S.remoteSessionId},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){lK(E._ctx,"video",E._stream,E._monitor),E.stopRecvFrame("video","timeout"),E._firstVideoFrameInterval&&window.clearInterval(E._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),this.logger.info("rtcFirstFrameRecv",Xg(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 l={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._ctx.peerConnection)||void 0===c?void 0:c.getConnectionId()),remote_rtc_session_id:null===(u=this._stream)||void 0===u?void 0:u.remoteSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,this.logger.info("rtcFirstFrameRecv",Xg(l)),this._audioFirstFrameState=2}else if("video"===e){var d,h,f,v,p,_,m,g;if(1!==this._videoFirstFrameState)return;var y={event_type:"recv_end",media_type:e,is_screen:!(null===(d=this._stream)||void 0===d||!d.isScreen),start:null===(h=this._currentVideoRecv)||void 0===h?void 0:h.startTime,reason:t,result:!1,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,event_session_id:this._videoEventSessionId,type:null===(v=this._currentVideoRecv)||void 0===v?void 0:v.type,vendor_mode:(null===(p=this._stream)||void 0===p?void 0:p.vendorCode)||0,pc_session_id:(null===(_=this._stream)||void 0===_?void 0:_.pcSessionId)||(null===(m=this._ctx.peerConnection)||void 0===m?void 0:m.getConnectionId()),remote_rtc_session_id:null===(g=this._stream)||void 0===g?void 0:g.remoteSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,this.logger.info("rtcFirstFrameRecv",Xg(y)),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T;return Dg().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=18;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:l=this._currentAudioRecv,d=l.type,h=l.startTime,kI(n=["login","unmute","subscribe","push_track"]).call(n,d)>=0&&(r=0),f={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:d,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._ctx.peerConnection)||void 0===c?void 0:c.getConnectionId()),remote_rtc_session_id:null===(u=this._stream)||void 0===u?void 0:u.remoteSessionId},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this.logger.info("rtcFirstFrameRecv",Xg(f)),this.emit("recvAudioFirstFrame"),this._audioFirstFrameState=3,e.next=31;break;case 18:if("video"!==t){e.next=31;break}if(1===this._videoFirstFrameState){e.next=21;break}return e.abrupt("return");case 21:if(this._currentVideoRecv){e.next=23;break}return e.abrupt("return");case 23:b=this._currentVideoRecv,E=b.type,k=b.startTime,kI(v=["login","unmute","subscribe","push_track"]).call(v,E)>=0&&(r=0),T={event_type:"recv_end",media_type:t,is_screen:!(null===(p=this._stream)||void 0===p||!p.isScreen),start:k,result:!0,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,event_session_id:this._videoEventSessionId,type:E,transport_delay:r,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(g=this._stream)||void 0===g?void 0:g.pcSessionId)||(null===(y=this._ctx.peerConnection)||void 0===y?void 0:y.getConnectionId()),remote_rtc_session_id:null===(S=this._stream)||void 0===S?void 0:S.remoteSessionId},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this.logger.info("rtcFirstFrameRecv",Xg(T)),this.emit("recvVideoFirstFrame"),this._videoFirstFrameState=3;case 31: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:"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);var n=this._ctx.peerConnection;this._firstVideoFrameInterval=window.setInterval(Ug(Dg().mark((function i(){var o,a,s,c,u,l,d,h;return Dg().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!n||null===(o=e._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a||!a.preprocessingTrack){i.next=13;break}return l=null===(s=e._stream.videoTransceiver)||void 0===s?void 0:s.receiver,i.next=4,n.getStatsWithLowFrequency(null===(c=e._stream)||void 0===c||null===(u=c.videoTrack)||void 0===u?void 0:u.preprocessingTrack,!0,l);case 4:if(d=i.sent,!(h=lI(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(h.framesReceived>t||h.packetsReceived>r)){i.next=13;break}if(-1!==t||-1!==r){i.next=11;break}return t=h.framesReceived,r=h.packetsReceived,i.abrupt("return");case 11:e.recvFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 13:case"end":return i.stop()}}),i)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval);var n=this._ctx.peerConnection;this._firstAudioFrameInterval=window.setInterval(Ug(Dg().mark((function i(){var o,a,s,c,u,l;return Dg().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!n||null===(o=e._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a||!a.originTrack){i.next=12;break}return i.next=3,n.getStatsWithLowFrequency(null===(s=e._stream)||void 0===s||null===(c=s.audioTrack)||void 0===c?void 0:c.originTrack);case 3:if(u=i.sent,!(l=lI(u).call(u,(function(e){return"inbound-rtp"===e.type})))||!(l.totalSamplesReceived>t||l.packetsReceived>r)){i.next=12;break}if(-1!==t||-1!==r){i.next=10;break}return t=l.totalSamplesReceived,r=l.packetsReceived,i.abrupt("return");case 10:e.recvFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return i.stop()}}),i)}))),200)}},{key:"getTransportDelay",value:(r=Ug(Dg().mark((function e(){var t=this;return Dg().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(Ug(Dg().mark((function e(){return Dg().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=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t=this._ctx.peerConnection)){e.next=9;break}return i=null===(r=this._stream)||void 0===r||null===(n=r.videoTransceiver)||void 0===n?void 0:n.receiver,e.next=5,t.getStatsWithLowFrequency(void 0,!0,i);case 5:o=e.sent,a=lI(o).call(o,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(s=lI(o).call(o,(function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==a?void 0:a.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*s.currentRoundTripTime/2));case 9: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}(_U.EventEmitter),fK=function(){function e(t,r){Hh(this,e),Jd(this,"_audioEventSessionId",PL()),Jd(this,"_videoEventSessionId",PL()),Jd(this,"_pcSessionId",void 0),Jd(this,"_firstAudioFrameTimer",void 0),Jd(this,"_firstVideoFrameTimer",void 0),Jd(this,"_stream",void 0),Jd(this,"_firstVideoFrameInterval",void 0),Jd(this,"_firstAudioFrameInterval",void 0),Jd(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_login",!1),Jd(this,"_publisher",!1),Jd(this,"_unMuteAudio",!1),Jd(this,"_enableAudio",!1),Jd(this,"_unMuteVideo",!1),Jd(this,"_enableVideo",!1),Jd(this,"_audioExternal",!1),Jd(this,"_pushAudio",!1),Jd(this,"_videoExternal",!1),Jd(this,"_pushVideo",!1),Jd(this,"_autoPublish",!1),Jd(this,"_publish",!1),Jd(this,"_timeout",1e4),Jd(this,"_audioFirstFrameState",0),Jd(this,"_videoFirstFrameState",0),Jd(this,"_monitor",void 0),Jd(this,"logger",void 0),this._ctx=t,this._stream=r,this._monitor=HM(r.engineId),this.logger=new hD("SendFrameObserver",0,r.engineId)}var t,r;return jh(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if("audio"===e){var n,i,o,a,s,c;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var u={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._ctx.peerConnection)||void 0===a?void 0:a.getConnectionId()),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(){dK(r._ctx,"audio",r._stream,r._monitor),r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),this.logger.info("rtcFirstFrameSend",Xg(u)),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,d,h,f,v,p;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var _={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===(d=this._stream)||void 0===d?void 0:d.vendorCode)||0,pc_session_id:(null===(h=this._stream)||void 0===h?void 0:h.pcSessionId)||(null===(f=this._ctx.peerConnection)||void 0===f?void 0:f.getConnectionId()),capture_session_id:null===(v=this._stream)||void 0===v||null===(p=v.videoTrack)||void 0===p?void 0:p.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){dK(r._ctx,"video",r._stream,r._monitor),r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),this.logger.info("rtcFirstFrameSend",Xg(_)),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;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._ctx.peerConnection)||void 0===s?void 0:s.getConnectionId()),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",Xg(l)),this._audioFirstFrameState=2}else if("video"===e){var d,h,f,v,p,_,m,g;if(1!==this._videoFirstFrameState)return;var y={event_type:"sent_end",media_type:e,start:null===(d=this._currentVideoSend)||void 0===d?void 0:d.startTime,is_screen:!(null===(h=this._stream)||void 0===h||!h.isScreen),reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(f=this._currentVideoSend)||void 0===f?void 0:f.type,vendor_mode:(null===(v=this._stream)||void 0===v?void 0:v.vendorCode)||0,pc_session_id:(null===(p=this._stream)||void 0===p?void 0:p.pcSessionId)||(null===(_=this._ctx.peerConnection)||void 0===_?void 0:_.getConnectionId()),capture_session_id:null===(m=this._stream)||void 0===m||null===(g=m.videoTrack)||void 0===g?void 0:g.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,this.logger.info("rtcFirstFrameSend",Xg(y)),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if("audio"===e){var t,r,n,i,o,a;if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var s=this._currentAudioSend,c=s.type,u=s.startTime,l={event_type:"sent_end",media_type:e,is_screen:!(null===(t=this._stream)||void 0===t||!t.isScreen),start:u,result:!0,event_session_id:this._audioEventSessionId,type:c,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._ctx.peerConnection)||void 0===i?void 0:i.getConnectionId()),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",Xg(l)),this._audioFirstFrameState=3}else if("video"===e){var d,h,f,v,p,_;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var m=this._currentVideoSend,g=m.type,y=m.startTime,S={event_type:"sent_end",media_type:e,is_screen:!(null===(d=this._stream)||void 0===d||!d.isScreen),start:y,result:!0,event_session_id:this._videoEventSessionId,type:g,vendor_mode:(null===(h=this._stream)||void 0===h?void 0:h.vendorCode)||0,pc_session_id:(null===(f=this._stream)||void 0===f?void 0:f.pcSessionId)||(null===(v=this._ctx.peerConnection)||void 0===v?void 0:v.getConnectionId()),capture_session_id:null===(p=this._stream)||void 0===p||null===(_=p.videoTrack)||void 0===_?void 0:_.captureSessionId};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this.logger.info("rtcFirstFrameSend",Xg(S)),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:"_getFirstVideoFrameStats",value:(r=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null===(t=this._stream)||void 0===t||null===(r=t.videoTrack)||void 0===r?void 0:r.preprocessingTrack,a=null===(n=this._stream)||void 0===n||null===(i=n.videoTransceiver)||void 0===i?void 0:i.sender,!this._ctx.peerConnection||!o){e.next=8;break}return e.next=5,this._ctx.peerConnection.getStatsWithLowFrequency(o,!0,a);case 5:return s=e.sent,c=Cy(s).call(s,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null===(t=this._stream)||void 0===t||null===(r=t.audioTrack)||void 0===r?void 0:r.preprocessingTrack,a=null===(n=this._stream)||void 0===n||null===(i=n.audioTransceiver)||void 0===i?void 0:i.sender,!this._ctx.peerConnection||!o){e.next=7;break}return e.next=5,this._ctx.peerConnection.getStatsWithLowFrequency(o,!0,a);case 5:return s=e.sent,e.abrupt("return",lI(s).call(s,(function(e){return"outbound-rtp"===e.type})));case 7: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(Ug(Dg().mark((function n(){var i,o,a;return Dg().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||$g(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(Ug(Dg().mark((function r(){var n;return Dg().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}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),vK=(Jd(rK={},"audio",{delay:1200,stallRadio:.3}),Jd(rK,"video",{delay:1200,stallRadio:.6}),Jd(rK,"screen_audio",{delay:1600,stallRadio:.8}),Jd(rK,"screen_video",{delay:1600,stallRadio:.8}),rK),pK=function(){function e(t){Hh(this,e),Jd(this,"_preUplinkStats",new hT),Jd(this,"_preDownlinkStats",new hT),Jd(this,"_timer",void 0),Jd(this,"_delayTimer",void 0),Jd(this,"reportor",void 0),this._ctx=t}return jh(e,[{key:"updateUplinkStats",value:function(e,t){var r=e.audioStats,n=e.videoStats,i=e.isScreen;if(r.sendKBitrate>0&&r.rtt){var o,a,s=i?"screen_audio":"audio",c=r.rtt,u=r._fractionLost,l=r._retransmittedRate,d=this._getQosLevel(c,u||0,l||0),h=this._preUplinkStats.get(s)||[d];this._preUplinkStats.set(s,dI(o=Hg(a=[]).call(a,iR(h),[d])).call(o,-2))}if(n.sentKBitrate>0&&n.rtt){var f,v,p=i?"screen_video":"video",_=n._fractionLost,m=n.rtt,g=n._sendBandWidth,y=n._retransmittedRate;0===g&&(_=Math.max(.65,_));var S=this._getQosLevel(m,_||0,y||0),b=this._getUplinkVideoQoE(e,t),E=this._getVideoUplinkNetworkQuality(S,b),k=this._preUplinkStats.get(p)||[E];this._preUplinkStats.set(p,dI(f=Hg(v=[]).call(v,iR(k),[E])).call(f,-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,l=e.isScreen,d=e.userId,h=!0,f=!0;if(a)if(0===c.receivedKBitrate)h=!1;else{var v=c.rtt,p=c.audioLossRate,_=c.stallDuration,m=c.statsInterval,g=c.e2eDelay,y=_/m,S=l?"screen_audio":"audio",b=this._getQosLevel(v,p||0,u._retransmittedRate||0),E=this._getDownlinkQoE(S,y,g);n=this._getNetworkQuality(b,E)}if(s)if(0===u.receivedKBitrate||0===u.rtt)f=!1;else{var k=u.rtt,T=u.videoLossRate,I=u.stallDuration,R=u.statsInterval,A=u.e2eDelay,C=u._retransmittedRate,w=I/R,x=l?"screen_video":"video",O=this._getQosLevel(k,T||0,C||0),N=this._getDownlinkQoE(x,w,A);i=this._getNetworkQuality(O,N)}var P=Hg(r="".concat(d)).call(r,l?"_screen":"");if(h||f){var M=n&&i?Math.ceil((n+i)/2):n||i;if(M){var D,L,U=this._preDownlinkStats.get(P)||[M];this._preDownlinkStats.set(P,dI(D=Hg(L=[]).call(L,iR(U),[M])).call(D,-2)),this._startNetworkQualityReport()}}else this._preDownlinkStats.delete(P)}}},{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=this;if(Qy(e=["connected","connecting"]).call(e,null===(t=this._ctx.handler)||void 0===t?void 0:t.getConnectionState())){var o,a,s,c=this._getBetterQualityAndRemoveOldest("audio","up"),u=this._getBetterQualityAndRemoveOldest("video","up");r=c&&u?Math.ceil((c+u)/2):c||u||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||Eh.EXCELLENT;var l=Cy(o=$g(a=Fw(sx(s=this._preDownlinkStats).call(s))).call(a,(function(e){return i._getBetterQualityAndRemoveOldest(e,"down")}))).call(o,(function(e){return e}));n=Math.ceil(uS(l).call(l,(function(e,t){return t+e}),0)/l.length)||Eh.UNKNOWN}else r=n=Eh.DOWN;navigator.onLine||(r=Eh.DOWN,n=Eh.DOWN),"function"==typeof this.reportor&&this.reportor(r,n)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getVideoUplinkNetworkQuality",value:function(e,t){return 1===t||0===t?e:2===t?Math.min(e+1,5):Math.min(e+2,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:"_getUplinkVideoQoE",value:function(e,t){var r,n=(null==e||null===(r=e.videoStats)||void 0===r?void 0:r.rid)||"0";if(!t)return 0;var i=t.pubAttributes.videoDescriptions[n],o=e.videoStats,a=o.encodedFrameWidth*o.encodedFrameHeight/(i.width*i.height),s=o.sentFrameRate/i.framerate,c=0,u=0;return"number"!=typeof a||Number.isNaN(a)||(c=a>=.9?1:a<.9&&a>=.8?2:3),"number"!=typeof s||Number.isNaN(s)||(u=s>=.8?1:s<.8&&s>=.6?2:3),Math.max(0,c,u)}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=vK[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=Eh.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=Cy(i).call(i,(function(e){return e}));o.length>0&&(r=Math.min.apply(Math,iR(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&&VL(t)&&r.localaudio&&r.audiostream,videoActive:n&&FL(t)&&r.localvideo&&r.videostream}}}]),e}(),_K=function(){function e(t){Hh(this,e),Jd(this,"_timer",void 0),Jd(this,"_remoteVideoSizeCache",{}),Jd(this,"_remoteScreenSizeCache",{}),Jd(this,"onchange",void 0),this._room=t,this._start()}return jh(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,l=void 0===u?0:u,d=c.height,h=void 0===d?0:d,f=0,v=0;if(yD){var p,_,m=null!==(p=null==n||null===(_=n.videoTrack)||void 0===_?void 0:_.getSizeByPlayer())&&void 0!==p?p:{width:0,height:0};f=m.width,v=m.height}else{var g=a.getSettings();f=g.width||0,v=g.height||0}h===v&&l===f||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,f,v),delete s[i],(n.isScreen?r:t)[i]={width:f,height:v}}}))})),FS(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),FS(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),mK=Fw((new TextEncoder).encode("subt")),gK={1:dw.SUBTITLE_ERR_POSTPROCESS,2:dw.SUBTITLE_ERR_CONNECTION_ERROR,3:dw.SUBTITLE_ERR_PROCESS_ERROR},yK=new hD("SubtitleTool",1),SK=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&kI(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))||"";kI(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=Xg({source_language:o}))}},bK=function(){function e(t,r){Hh(this,e),Jd(this,"_taskId",void 0),Jd(this,"_sourceLanguage","zh"),Jd(this,"_updating",!1),Jd(this,"onEvent",void 0),Jd(this,"onMessage",void 0),Jd(this,"_preConfig",void 0),Jd(this,"_timer",void 0),this._ctx=t,this._roomConf=r;var n=r.userInfo.extraInfo;if(n)try{var i=JSON.parse(n);i.source_language&&(this._sourceLanguage=i.source_language)}catch(o){}}var t,r,n,i;return jh(e,[{key:"start",value:(i=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yK.info("start","Invoke config: %o",t),QL(t.mode,"mode",[wh.ASR_ONLY,wh.ASR_AND_TRANSLATION]),r=Array.isArray(t.targetLanguage)?t.targetLanguage:[t.targetLanguage||""],!(t.mode===wh.ASR_AND_TRANSLATION&&qC(r).call(r,(function(e){return-1===kI(kK).call(kK,e)}))>-1)){e.next=5;break}throw new _w(dw.INVALID_PARAMS,"Invalid targetLanguage.");case 5:if(!this._taskId){e.next=7;break}throw new _w(dw.SUBTITLE_ALREADY_ON,"Already turned on subtitle");case 7:return this._preConfig={targetLanguage:r,mode:t.mode},this._taskId=(Date.now().toString()+this._roomConf.roomId+this._roomConf.userId).substring(0,20),e.next=11,this._sendSubtitleSignalingWithRetry(t,this._taskId);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"update",value:(n=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yK.info("update","Invoke config: %o",t),this._taskId){e.next=3;break}throw new _w(dw.SUBTITLE_NOT_TURNED_ON,"Start subtitle first.");case 3:return this._sourceLanguage=t.sourceLanguage,this._updating=!0,e.prev=5,e.next=8,this._ctx.signalingManager.sendSignaling("controlMessage",this._genChangeSubtitleLanguageSignaling(t,this._taskId));case 8:e.next=14;break;case 10:throw e.prev=10,e.t0=e.catch(5),this._updating=!1,e.t0;case 14:case"end":return e.stop()}}),e,this,[[5,10]])}))),function(e){return n.apply(this,arguments)})},{key:"stop",value:function(){var e=this;yK.info("stop","Invoke"),this._taskId&&this._ctx.signalingManager.sendSignaling("controlMessage",{type:"subtitle",action:"stopped",appId:this._ctx.appId,roomId:this._roomConf.roomId,userId:this._roomConf.userId,taskId:this._taskId}).finally((function(){var t;delete e._taskId,null===(t=e.onEvent)||void 0===t||t.call(e,{event:xh.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(r=Ug(Dg().mark((function e(){return Dg().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._ctx.signalingManager.sendSignaling("controlMessage",{type:"subtitle",action:"stopped",appId:this._ctx.appId,roomId:this._roomConf.roomId,userId:this._roomConf.userId,taskId:this._taskId});case 3:delete this._taskId,this.start(this._preConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getConfig",value:function(){return this._preConfig}},{key:"destroy",value:function(){yK.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 _w(gK[r]||dw.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:xh.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:xh.STARTED}),this._clearTimer()}else if(this._updating&&"LanguageChanged"===i){var c;this._updating=!1,null===(c=this.onEvent)||void 0===c||c.call(this,{event:xh.UPDATED})}}},{key:"onMessageRecv",value:function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]||this._taskId&&this._preConfig){var t=EK(e);if(!t||0===t.length)return!1;if(this._taskId&&this._preConfig){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){if(i===wh.ASR_ONLY)e.mode===i&&a.push(e);else{var t=Qy(o).call(o,e.language);(t||e.mode===wh.ASR_ONLY)&&a.push(e),e.mode===wh.ASR_ONLY&&t&&a.push(Zd(Zd({},e),{},{mode:wh.ASR_AND_TRANSLATION}))}})),a.length>0)null===(r=this.onMessage)||void 0===r||r.call(this,a)}return!0}return!1}},{key:"_sendSubtitleSignalingWithRetry",value:(t=Ug(Dg().mark((function t(r,n){var i,o=this,a=arguments;return Dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=a.length>2&&void 0!==a[2]?a[2]:0,t.next=3,this._ctx.signalingManager.sendSignaling("controlMessage",this._genSubtitleSignaling(r,n));case 3:this._timer=self.setTimeout((function(){var e;2===i?(null===(e=o.onEvent)||void 0===e||e.call(o,{event:xh.ERROR,errorCode:dw.TIME_OUT,errorMessage:"start subtitle timeout."}),delete o._timer,o.stop()):o._sendSubtitleSignalingWithRetry(r,n,i+1)}),e.retryIntervel);case 4:case"end":return t.stop()}}),t,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"_genSubtitleSignaling",value:function(e,t){return{taskId:t,type:"subtitle",action:"started",roomId:this._roomConf.roomId,appId:this._ctx.appId,userId:this._roomConf.userId,subtitleMeta:{subtitleConfig:{mode:e.mode,usersConfig:[{userId:this._roomConf.userId,targetLanguages:Array.isArray(e.targetLanguage)?e.targetLanguage:[e.targetLanguage||""]}]},vendorConfig:{type:0}}}}},{key:"_genChangeSubtitleLanguageSignaling",value:function(e,t){return{taskId:t,type:"subtitle",action:"subtitleUpdated",roomId:this._roomConf.roomId,appId:this._ctx.appId,userId:this._roomConf.userId,subtitleMeta:{protocol:1,languageConfig:{sourceLanguages:[{userId:this._roomConf.userId,languageCode:[e.sourceLanguage]}]}}}}},{key:"_clearTimer",value:function(){this._timer&&(self.clearTimeout(this._timer),delete this._timer)}}]),e}();Jd(bK,"retryIntervel",3e4);var EK=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(mK.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=wL.ab2str(dI(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(c){}return!1},kK=["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"],TK=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[e.DUPLICATE_DOM=-1005]="DUPLICATE_DOM",e}(TK||{});function IK(e,t){return Zd(Zd({},e),t)}function RK(e){var t={};return FS(e).forEach((function(r){var n=e[r];try{Array.isArray(n)?t[r]=$g(n).call(n,(function(e){return null!==e&&"object"===Xd(e)?RK(e):e})):null!==n&&"object"===Xd(n)?t[r]=RK(n):t[r]=n}catch(i){}})),t}function AK(e){var t;return null===e?[]:$g(t=FS(e)).call(t,(function(t){return e[t]}))}var CK=function(){function e(t,r){Hh(this,e),Jd(this,"roomId",void 0),Jd(this,"userInfo",void 0),Jd(this,"userId",void 0),Jd(this,"sessionId",_x()),Jd(this,"token",void 0),Jd(this,"rtcVid",void 0),Jd(this,"joinPromise",void 0),Jd(this,"startJoinTimestamp",void 0),Jd(this,"_liveControlMessage",void 0),Jd(this,"_userStreamMap",new hT),Jd(this,"_roomConfig",{isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:Th.communication}),Jd(this,"_vendorConfig",{enableMultiVendor:!1,vendorCode:0}),Jd(this,"_roomAttr",{multiChatMode:!1,bigRoomMode:!1}),Jd(this,"_tokenPublishPrivilegeExpired",!1),Jd(this,"_tokenSubscribePrivilegeExpired",!1),Jd(this,"_monitor",void 0),this._ctx=r,this.roomId=t.roomId,this.userInfo=t.userInfo,this.userId=t.userInfo.userId,this.token=t.token,this._monitor=HM(r.id)}var t;return jh(e,[{key:"checkJoinRoom",value:(t=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.joinPromise;case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"vendorConfig",get:function(){return this._vendorConfig}},{key:"setVendorConfig",value:function(e){this._vendorConfig=e}},{key:"updateRoomAttributes",value:function(e){this._roomAttr=Zd(Zd({},this._roomAttr),e)}},{key:"setLiveControlMessage",value:function(e){this._liveControlMessage=e}},{key:"getLiveControlMessage",value:function(){return this._liveControlMessage}},{key:"isMultiChatMode",value:function(){return this._roomAttr.multiChatMode}},{key:"updateRoomConfig",value:function(e){return this._roomConfig=IK(this._roomConfig,e),this._roomConfig}},{key:"isAutoPublish",get:function(){return this._roomConfig.isAutoPublish}},{key:"isAutoSubscribeAudio",get:function(){return this._roomConfig.isAutoSubscribeAudio}},{key:"isAutoSubscribeVideo",get:function(){return this._roomConfig.isAutoSubscribeVideo}},{key:"remoteVideoConfig",get:function(){return this._roomConfig.remoteVideoConfig}},{key:"roomProfileType",get:function(){return this._roomConfig.roomProfileType||Th.communication}},{key:"updateUserPubInfo",value:function(e){var t=this._userStreamMap.get(e.clientId)||{};e.screen?(t.screenAudio=e.attributes.audiostream,t.screenVideo=e.attributes.videostream):(t.audio=e.attributes.audiostream,t.video=e.attributes.videostream),this._userStreamMap.set(e.clientId,t)}},{key:"getUserPubInfo",value:function(e){return Zd({audio:!1,video:!1,screenAudio:!1,screenVideo:!1},this._userStreamMap.get(e)||{})}},{key:"resetUserPubInfo",value:function(){this._userStreamMap.clear()}},{key:"tokenPublishPrivilegeExpired",get:function(){return this._tokenPublishPrivilegeExpired}},{key:"tokenSubscribePrivilegeExpired",get:function(){return this._tokenSubscribePrivilegeExpired}},{key:"setTokenPublishPrivilegeExpired",value:function(e){this._tokenPublishPrivilegeExpired=e}},{key:"setTokenSubscribePrivilegeExpired",value:function(e){this._tokenSubscribePrivilegeExpired=e}},{key:"getStayRoomDuration",value:function(){return this.startJoinTimestamp?AL()-this.startJoinTimestamp:0}},{key:"report",value:function(e,t,r){}}]),e}(),wK=6e4,xK=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)};function OK(e,t,r){var n=r.value;return r.value=Ug(Dg().mark((function e(){var r,i,o,a=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._ctx.signalingManager.isConnected()){e.next=2;break}throw new _w(dw.NOT_CONNECTED_YET,"error in ".concat(t,": try again after connect"));case 2:return e.prev=2,e.next=5,(this._roomConf||this.config).checkJoinRoom();case 5:e.next=10;break;case 7:throw e.prev=7,e.t0=e.catch(2),new _w(dw.JOIN_ROOM_FAILED,"error in ".concat(t,": try again after joined"));case 10:for(r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.abrupt("return",n.apply(this,i));case 12:case"end":return e.stop()}}),e,this,[[2,7]])}))),r}var NK=fT,PK=WI,MK=function(e,t,r,n){for(var i,o=n>1?void 0:n?PK(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&&NK(t,r,o),o},DK=function(e){BA(c,e);var t,r,n,i,o,a,s=nC(c);function c(e,t){var r;return Hh(this,c),Jd(uA(r=s.call(this)),"_forwardDstRooms",new hT),Jd(uA(r),"forwardStreamState","stopped"),r._ctx=e,r._roomConf=t,r}return jh(c,[{key:"startForwardStream2Rooms",value:(a=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!==this.forwardStreamState&&"paused"!==this.forwardStreamState){e.next=2;break}throw new _w(dw.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke startForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("start",this._roomConf.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=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new _w(dw.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._roomConf.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=Ug(Dg().mark((function e(){var t,r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new _w(dw.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._roomConf.roomId);case 6:r=e.sent;case 7:if(this._updateDstRooms([],r),!(iR(sx(t=this._forwardDstRooms).call(t)).length>0)){e.next=10;break}throw new _w(dw.UNEXPECTED_ERROR,"stopforwardstream failed: ".concat(Xg(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=Ug(Dg().mark((function e(){var t,r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("paused"!==this.forwardStreamState&&"stopped"!==this.forwardStreamState){e.next=2;break}throw new _w(dw.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke pauseForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("stop",this._roomConf.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=Ug(Dg().mark((function e(){var t,r,n,i,o=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o.length>0&&void 0!==o[0]&&o[0]||!Qy(t=["running","stopped"]).call(t,this.forwardStreamState)){e.next=3;break}throw new _w(dw.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._roomConf.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===Oh.FORWARD_STREAM_STATE_FAILURE&&e.safeEmit(sK.ON_FORWARD_STREAM_ERROR,t)}))}))}},{key:"onForwardDstRoomUserKick",value:function(e){var t=[{dstRoomId:e.dstRoomId,code:200,forwardStreamType:"stop"}];this._updateDstRooms([],t),this.safeEmit(sK.ON_FORWARD_STREAM_ERROR,{roomId:e.dstRoomId,state:Oh.FORWARD_STREAM_STATE_FAILURE,error:Nh.FORWARD_STREAM_ERROR_REMOTE_KICKED})}},{key:"destoy",value:function(){VA(UA(c.prototype),"removeAllListeners",this).call(this),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=qC(r).call(r,(function(t){return t.dstRoomId===e.roomId}));-1===n?r.push({dstRoomId:e.roomId,forwardStreamType:"start",code:e.roomId===t._roomConf.roomId?400:200}):r[n].forwardStreamType="update"})),r}},{key:"_transformForwardStreamResult",value:function(e){e||(e=[]);var t,r=[],n=by(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=i.dstRoomId,a=i.code,s={roomId:o,state:Oh.FORWARD_STREAM_STATE_SUCCESS,error:Nh.FORWARD_STREAM_ERROR_OK};200===a||(400===a?(s.state=Oh.FORWARD_STREAM_STATE_FAILURE,s.error=Nh.FORWARD_STREAM_ERROR_REMOTE_KICKED):a>=700&&a<800?(s.state=Oh.FORWARD_STREAM_STATE_FAILURE,s.error=Nh.FORWARD_STREAM_ERROR_INVALID_TOKEN):(s.state=Oh.FORWARD_STREAM_STATE_FAILURE,s.error=Nh.FORWARD_STREAM_ERROR_RESPONSE)),r.push(s)}}catch(XJ){n.e(XJ)}finally{n.f()}return r}},{key:"_updateDstRooms",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];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=lI(e).call(e,(function(e){return e.roomId===n}));if(!s&&!t._forwardDstRooms.has(n))throw new _w(dw.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=CT(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=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stop"!==t&&$g(n).call(n,(function(e){return e.roomId})),i={forwardStreamType:t,roomId:r},("start"===t||"update"===t)&&(i.dstRoomInfos=null==n?void 0:$g(n).call(n,(function(e){return{dstRoomId:e.roomId,dstToken:wL.token2auth(u._ctx.appId,e.roomId,u._roomConf.userId,e.token)}}))),e.next=7,this._ctx.signalingManager.sendSignaling("forwardStream",i);case 7:if(o=e.sent,a=[],200===(null==o?void 0:o.code)){e.next=12;break}throw"stop"!==t&&(null==n||n.forEach((function(e){a.push({dst_room_id:e.roomId,result:"server error ".concat(null==o?void 0:o.code)})}))),new _w(dw.UNEXPECTED_ERROR,"server side internal error, error code: ".concat(o));case 12:return"stop"!==t&&(null===(s=o.forwardStreamResults)||void 0===s||s.forEach((function(e){a.push({dst_room_id:e.dstRoomId,result:"dst room lost"})})),null===(c=o.forwardStreamResults)||void 0===c||c.forEach((function(e){var t=lI(a).call(a,(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))}))),e.abrupt("return",o.forwardStreamResults);case 14:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})}]),c}(yU);MK([OK],DK.prototype,"startForwardStream2Rooms",1),MK([OK],DK.prototype,"updateForwardStream2Rooms",1),MK([OK],DK.prototype,"stopForwardStream2Rooms",1),MK([OK],DK.prototype,"pauseForwardStream2AllRooms",1),MK([OK],DK.prototype,"resumeForwardStream2AllRooms",1);var LK=[{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}];function UK(e,t,r){var n,i=e?null===(n=lI(r).call(r,(function(t){return t.rid===e})))||void 0===n?void 0:n.maxkbps:r[0].maxkbps;return Math.min(null!=i?i:Number.POSITIVE_INFINITY,t)}var VK=r(gA),FK=N,BK=rr,jK=ee,HK=dA,GK=Qt,zK=C,WK=Kc,KK=F;Cr({target:"Reflect",stat:!0,forced:o((function(){var e=function(){},t=GK.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=zK.f(BK(t),r);if(!c){if(jK(o=WK(t)))return e(o,r,n,s);c=KK(0)}if(HK(c)){if(!1===c.writable||!jK(s))return!1;if(i=zK.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,GK.f(s,r,i)}else GK.f(s,r,KK(0,n))}else{if(void 0===(a=c.set))return!1;FK(a,s,n)}return!0}});var XK=r(te.Reflect.set),YK=function(){function e(t){Hh(this,e),Jd(this,"_roomId",void 0),Jd(this,"_constraints",{}),Jd(this,"_profile",void 0),Jd(this,"_customMaxBitrate",0),this._appId=t}return jh(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=tL.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=tL.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=Ey(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 l=(null==r?void 0:r.enc_sample_rate)||a;l&&(c["sprop-maxcapturerate"]=l);var d=(null==r?void 0:r.playback_rate)||a;return d&&(c.maxplaybackrate=d),(s&&s>1||null!=r&&r.stereo)&&(c["sprop-stereo"]=1,c.stereo=1),null!=r&&r.dtx&&(c.usedtx=1),$g(e=FS(c)).call(e,(function(e){var t;return Hg(t="".concat(e,"=")).call(t,c[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=Zd(Zd({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=Zd({},this._constraints),t=tL.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;HL(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),HL(null==t?void 0:t.channel)||(e.channelCount=t.channel),HL(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),HL(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),HL(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return HL(e.sampleRate)&&!HL(n)&&(e.sampleRate=n),HL(e.channelCount)&&!HL(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case Ih.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case Ih.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case Ih.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case Ih.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case Ih.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),qK={start_interval:100,multiplier:2,max_interval:3e4},JK=function(){function e(){Hh(this,e),Jd(this,"_times",0),Jd(this,"_config",qK),Jd(this,"initTs",AL())}return jh(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}(),QK=function(){function e(t){var r=this;Hh(this,e),Jd(this,"_reconnectTimer",void 0),Jd(this,"_retryFunc",void 0),Jd(this,"_abortControllers",[]),Jd(this,"_monitor",void 0),Jd(this,"logger",void 0),Jd(this,"_groupConfigId",RL()),Jd(this,"_retryLimiter",new JK),Jd(this,"_timer",void 0),Jd(this,"_destroyed",!1),Jd(this,"_onlineListener",(function(){r._reconnectTimer&&r._retryFunc&&(clearTimeout(r._reconnectTimer),r._retryFunc())})),this._ctx=t,this._monitor=HM(t.id),this.logger=new hD("ICERequest",4,t.id),window.addEventListener("online",this._onlineListener)}var t,r,n,i,o;return jh(e,[{key:"getICENode",value:(o=Ug(Dg().mark((function e(t){var r;return Dg().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 _w(dw.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 o.apply(this,arguments)})},{key:"_getAccessWithRetry",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 0!==r&&this.logger.info("_getAccessWithRetry()","invoke feedbackInfo: %o, 201count: %o",e,r),new Gg((function(n,i){t._getAccessNode(e).then((function(e){t._retryLimiter.reset(),n(e)})).catch((function(o){if(!t._destroyed){if(Array.isArray(o)&&o.length>0){if(qC(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._retryFunc=function(){t._getAccessWithRetry(e,r).then(n).catch(i)},t._reconnectTimer=self.setTimeout(t._retryFunc,a)}}))}))}},{key:"_getAccessNode",value:(i=Ug(Dg().mark((function e(t){var r=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Gg((function(e,n){var i=tL.getAccessNode(r._ctx.appId);if(i){var o,a=$g(o=Array.isArray(i)?i:[i]).call(o,(function(e){return e.cache_status=!0,e}));r.logger.info("getAccessNode","use cache node."),e(a),r._timer=window.setTimeout((function(){r._getAccessNodeFromServer(t),r._reportRtcInvokeStatus("es.R.node.cache",i),delete r._timer}),0)}else r._getAccessNodeFromServer(t).then(e).catch(n)})));case 1:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"_getAccessNodeFromServer",value:(n=Ug(Dg().mark((function e(t){var r,n,i,o=this;return Dg().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&&(null==t?void 0:t.length)>0&&tL.setAccessNode(o._ctx.appId,t,e.ttl||11200),e.dispatchDomains&&!o._ctx.useCloudProxy&&tL.setAccessUrls(e.dispatchDomains),t})).catch((function(e){if(i)return o._reportRtcInvokeStatus("es.R.req.fallback",""),tL.clearAccessUrls(),o._getAccessNodeFromServer(t);throw e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_getAccessUrls",value:function(){var e=tL.getAccessUrls()||[],t=!0;return this._reportRtcInvokeStatus("es.R.req.cache.urls",e),0===e.length&&(e=cL.ICE_CONFIG_REQUEST_URLS,t=!1,this._reportRtcInvokeStatus("es.R.req.external.urls",e)),0===e.length&&(e=cL.ICE_CONFIG_REQUEST_URLS_INTERNAL,t=!1,this._reportRtcInvokeStatus("es.R.req.internal.urls",e)),{urls:e,needFallback:t}}},{key:"getICEConfigFromServer",value:(r=Ug(Dg().mark((function e(t,r){var n,i,o,a,s=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={appID:this._ctx.appId,deviceID:tL.getDeviceId(),os:"web",sdkVersion:cL.VERSION,isOversea:cL.OVERSEA,expectedAddr:lL("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC},r&&(n.feedbackInfo=r,"ICE_FAILED"!==(null===(i=r[0])||void 0===i||null===(o=i.feedbackReason)||void 0===o?void 0:o.type)&&delete n.expectedAddr),a=$g(t).call(t,(function(e){return s._httpRequest(e,n)})),e.abrupt("return",LL(a));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_httpRequest",value:(t=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,h;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=RL(),r.connectSessionID=i,o=Date.now(),null===(n=this._monitor)||void 0===n||n.report("rtc_get_access",{error_code:0,message:Xg(r),elapse:0,type:"request",host:t,config_id:i,group_config_id:this._groupConfigId}),a=new AbortController,this._abortControllers.push(a),e.prev=6,e.prev=7,e.next=10,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:Xg(r),signal:a.signal});case 10:s=e.sent,e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),f=fetch,v=void 0,Qy(v=Function.prototype.toString.call(f)).call(v,"[native code]")||null===(l=this._monitor)||void 0===l||l.report("rtc_error",{error_code:TK.Fetch_MODIFY,message:"get access failed, possibly due to modifying the browser's Fetch API."},{origin_error:e.t0}),e.t0;case 17:if(this._abortControllers=Cy(c=this._abortControllers).call(c,(function(e){return e!==a})),200===s.status){e.next=20;break}throw{message:s.statusText,code:s.status};case 20:return e.next=22,s.json();case 22:if(200===(d=e.sent).code){e.next=25;break}throw d;case 25:return null===(u=this._monitor)||void 0===u||u.report("rtc_get_access",{error_code:200,message:Xg(d),elapse:Date.now()-o,type:"response",host:t,config_id:i,group_config_id:this._groupConfigId}),e.abrupt("return",d);case 29:throw e.prev=29,e.t1=e.catch(6),null===(h=this._monitor)||void 0===h||h.report("rtc_get_access",{error_code:Number((null===e.t1||void 0===e.t1?void 0:e.t1.code)||(null===e.t1||void 0===e.t1?void 0:e.t1.server_code)),message:null===e.t1||void 0===e.t1?void 0:e.t1.message,elapse:Date.now()-o,type:"response",host:t,config_id:i,group_config_id:this._groupConfigId},{error:Xg(e.t1)}),e.t1;case 33:case"end":return e.stop()}var f,v}),e,this,[[6,29],[7,13]])}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._destroyed=!0,window.removeEventListener("online",this._onlineListener),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}(),ZK={},$K={},eX={exports:{}},tX=eX.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"]}]};FS(tX).forEach((function(e){tX[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}));var rX=eX.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=rX,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t,o={},a=[],s=o;return Cy(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=dI(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 uS(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return $g(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=$g(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 $g(t=e.split(" ")).call(t,(function(e){var t;return uS(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return $g(r=e.split(";")).call(r,(function(e){var r;return $g(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}}))}))}}($K);var nX=rX,iX=/%[sdv%]/g,oX=function(e){var t=1,r=arguments,n=r.length;return e.replace(iX,(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""}}))},aX=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 oX.apply(null,n)},sX=["v","o","s","i","u","e","p","c","b","t","r","z","a"],cX=["i","c","b","a"],uX=$K,lX=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||sX,n=t.innerOrder||cX,i=[];return r.forEach((function(t){nX[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(aX(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(aX(t,r,e))}))}))})),e.media.forEach((function(e){i.push(aX("m",nX.m[0],e)),n.forEach((function(t){nX[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(aX(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(aX(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};ZK.write=lX,ZK.parse=uX.parse,ZK.parseParams=uX.parseParams,ZK.parseFmtpConfig=uX.parseFmtpConfig,ZK.parsePayloads=uX.parsePayloads,ZK.parseRemoteCandidates=uX.parseRemoteCandidates,ZK.parseImageAttributes=uX.parseImageAttributes,ZK.parseSimulcastStreamList=uX.parseSimulcastStreamList;var dX=new hD("FirefoxHandler",3),hX=Math.pow(2,32),fX="kp34Za0H+aVf862l";function vX(e){return e>hX-18?(dX.warn("generateAllSsrc","reset start id",e),vX(e=e-hX+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var pX=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:Hg(n=Hg(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Hg(o="".concat(e,"-")).call(o,t)}]},_X=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 l,d=uS(s).call(s,(function(t,r){return Hg(t).call(t,pX(e,"video",r,c))}),[]),h=[{semantics:"FID",ssrcs:Hg(r="".concat(i," ")).call(r,o)}];u&&h.push({semantics:"FEC-FR",ssrcs:Hg(l="".concat(i," ")).call(l,a)});return{ssrcs:d,ssrcGroups:h}};function mX(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 gX=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=Zd(Zd({},e),{},{media:[]});return n&&(i.invalid=[{value:"realx-exts:rscp"}]),t&&i.media.push(t),r&&i.media.push(r),delete i.groups,delete i.msidSemantic,ZK.write(i)};function yX(e){return SX.apply(this,arguments)}function SX(){return(SX=Ug(Dg().mark((function e(t){var r,n,i,o,a;return Dg().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,kX(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=bX(n,a),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function bX(e,t){if(!Array.isArray(e))return[];var r=0,n=2130706431,i=[];return e.forEach((function(e){var o={component:1,ip:e.ip,type:"host",generation:e.generation};e.udpPorts&&!t.tcpOnly&&e.udpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var EX,kX=function(){var e=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c;return Dg().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,wL.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=CL(Uint8Array,n,i,o,a),e.next=15,wL.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)}}(),TX=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=by(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(Qy(o=c.config).call(o,"level-asymmetry-allowed=1")&&Qy(a=c.config).call(a,"packetization-mode=1")&&Qy(s=c.config).call(s,"profile-level-id=42e0")){r=c.payload;break}}}catch(XJ){i.e(XJ)}finally{i.f()}for(var u=0;u<e.rtp.length;u++){var l=e.rtp[u];if("H264"===t){if(l.payload===r){var d;e.rtp.unshift(zI(d=e.rtp).call(d,u,1)[0]);break}}else if(l.codec===t){var h;e.rtp.unshift(zI(h=e.rtp).call(h,u,1)[0]);break}}var f=[];e.rtp.forEach((function(e){return f.push(e.payload)})),e.payloads=f.join(" ")}},IX=function(e){var t,r=ZK.parse(e);return r.media=$g(t=r.media).call(t,(function(e){return"audio"===e.type?CX(e,r):AX(e,["H264","VP8"],r)})),ZK.write(r)},RX=function(e){e.media.forEach((function(e){"audio"!==e.type&&"video"!==e.type||e.rtp.forEach((function(t){var r;e.rtcpFb||(e.rtcpFb=[]),lI(r=e.rtcpFb).call(r,(function(e){return e.payload===t.payload&&"rrtr"===e.type}))||e.rtcpFb.push({payload:t.payload,type:"rrtr"})}))}))},AX=function(e,t,r){var n,i,o,a,s,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{rrtr:!1},u={},l={},d=-1,h=[];(Array.isArray(e.fmtp)&&e.fmtp.forEach((function(e){var t=e.payload,r=e.config;if(lw(r).call(r,"apt=")){var n=dI(r).call(r,4);u[t]=n}else Qy(r).call(r,"42e0")&&Qy(r).call(r,"packetization-mode=1")&&(d=t)})),Array.isArray(e.rtp))&&(e.rtp=Cy(n=e.rtp).call(n,(function(e){var r,n=e.codec,i=e.payload;switch(n){case"H264":return r=!1,$g(t).call(t,(function(e){"H264"===e&&i===d&&(l[i]=i,h.push(i),r=!0)})),r;case"rtx":return!!l[u[i]]&&(l[i]=i,!0);case"red":case"ulpfec":case"flexfec-03":return l[i]=i,!0;default:return r=!1,$g(t).call(t,(function(e){e===n&&(l[i]=i,h.push(i),r=!0)})),r}})));Array.isArray(e.fmtp)&&(e.fmtp=Cy(i=e.fmtp).call(i,(function(e){return l[e.payload]})));Array.isArray(e.rtcpFb)?e.rtcpFb=Cy(o=e.rtcpFb).call(o,(function(e){return l[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"})})),wX(e,r),Array.isArray(e.ext))&&(e.ext=Cy(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=Cy(s=e.payloads.split(" ")).call(s,(function(e){return l[e]})).join(" "));return e},CX=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{rrtr:!1},i={};Array.isArray(e.rtp)&&(e.rtp=Cy(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&&FS(i).forEach((function(t){var r;null===(r=e.rtcpFb)||void 0===r||r.push({payload:Number(t),type:"rrtr"})})),wX(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},wX=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)},xX={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!qU()||void 0},OX=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}(OX||{}),NX=0,PX=function(e){BA(c,e);var t,r,n,i,o,a,s=nC(c);function c(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return Hh(this,c),Jd(uA(r=s.call(this)),"uuid",(NX++).toString()),Jd(uA(r),"_peerConnectionId",""),Jd(uA(r),"audioTrack4ff",void 0),Jd(uA(r),"_pc",void 0),Jd(uA(r),"_dc",void 0),Jd(uA(r),"_iceNode",void 0),Jd(uA(r),"_initSctpEvents",!1),Jd(uA(r),"_monitor",void 0),Jd(uA(r),"_offerIce",{}),Jd(uA(r),"_answerIce",{}),Jd(uA(r),"_offerSession",void 0),Jd(uA(r),"_answerSession",void 0),Jd(uA(r),"_offerMlines",[]),Jd(uA(r),"_answerMlines",[]),Jd(uA(r),"_connectReject",void 0),Jd(uA(r),"_logger",void 0),Jd(uA(r),"_destroyed",!1),Jd(uA(r),"_reportTimer",void 0),Jd(uA(r),"_clearPeerListeners",void 0),Jd(uA(r),"_iceStartTs",0),Jd(uA(r),"_icePreStepTs",0),r._ctx=e,r._groupConnectionId=t,r._isReconnect=n,r._monitor=HM(e.id),r._logger=new hD("PeerConnection_".concat(r.uuid),4,e.id),r._pc=new RTCPeerConnection(xX),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",Hg(i=Hg(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",Hg(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",HX.ICE_FAILED)},r._pc.oniceconnectionstatechange=function(){var e=r._pc.iceConnectionState;r.emit("ice_state",e)},r}return jh(c,[{key:"getOriginRTCPeerConnection",value:function(){return this._pc}},{key:"getConnectionId",value:function(){return this._peerConnectionId}},{key:"getGroupConnectionId",value:function(){return this._groupConnectionId}},{key:"getIceConnectionState",value:function(){return this._pc.iceConnectionState}},{key:"startIceConnect",value:(a=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,h,f=this;return Dg().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||"",this.reportRtcPreIce("ice_start"),yD&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=17,this._pc.createOffer();case 17:if((a=e.sent).sdp){e.next=20;break}throw new _w(dw.NOT_SUPPORTED,"create offer sdp failed.");case 20:if(s=ZK.parse(a.sdp),c=Ey(s.media,1),u=c[0],this._offerIce.fingerprint=s.fingerprint||u.fingerprint,!yD){e.next=36;break}return s.media=$g(l=s.media).call(l,(function(e){var t,r,n,i,o=Zd(Zd({},e),f._offerIce);return"video"===o.type&&(ZU?(o.ext=null===(t=o.ext)||void 0===t?void 0:Cy(t).call(t,(function(e){var t;return-1===kI(t=e.uri).call(t,"abs-send-time")})),o.rtcpFb=null===(r=o.rtcpFb)||void 0===r?void 0:Cy(r).call(r,(function(e){return"goog-remb"!==e.type}))):(o.rtcpFb=null===(n=o.rtcpFb)||void 0===n?void 0:Cy(n).call(n,(function(e){return"transport-cc"!==e.type})),o.ext=null===(i=o.ext)||void 0===i?void 0:Cy(i).call(i,(function(e){var t;return-1===kI(t=e.uri).call(t,"transport")})))),o})),$U&&RX(s),(h=Zd({},s)).fingerprint=this._answerIce.fingerprint,h.media=$g(d=h.media).call(d,(function(e){return delete(e=Zd(Zd({},e),f._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})),$U&&RX(h),e.next=32,this.setLocalDescription(ZK.write(s));case 32:return e.next=34,this.setRemoteDescription(ZK.write(h));case 34:e.next=44;break;case 36:delete s.media,this._offerSession=Zd({},s),this._answerSession=Zd({},s),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),this._offerMlines=[Zd(Zd(Zd({},u),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[Zd(Zd(Zd({},u),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription();case 44:return this._reportTransportStats(),e.next=47,new Gg((function(e,t){f._connectReject=t;var n=setTimeout((function(){var e;f.reportRtcPreIce("timeout"),null===(e=f._connectReject)||void 0===e||e.call(f,{code:4,message:"connect timeout"}),delete f._connectReject}),8e3),i=function(){f._print("connect","dataChannel open"),f._reportRtcInvokeStatus("es.dc.open",""),f.reportRtcPreIce("datachannel_opened"),clearTimeout(n),e(""),delete f._connectReject},o=function(e){var t,r,i,o;f._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"}),f._reportRtcInvokeStatus("es.dc.error",""),null===(i=f._connectReject)||void 0===i||i.call(f,{message:"dc.onerror, ".concat(null===(o=e.error)||void 0===o?void 0:o.errorDetail),code:0}),f.emit("disconnect",HX.DC_ERROR),delete f._connectReject,clearTimeout(n)},a=function(){var e;f._reportRtcInvokeStatus("es.dc.close",""),null===(e=f._connectReject)||void 0===e||e.call(f,{message:"dc.onclose",code:1}),f.reportRtcPreIce("datachannel_closed"),f.emit("disconnect",HX.DC_CLOSE),delete f._connectReject,clearTimeout(n)},s=function(){"connected"===f._pc.iceConnectionState?f.reportRtcPreIce("ice_connected"):"failed"!==f._pc.iceConnectionState&&"closed"!==f._pc.iceConnectionState||f.reportRtcPreIce("ice_failed")},c=function(){var e,t;"failed"!==f._pc.iceConnectionState&&"closed"!==f._pc.iceConnectionState&&"failed"!==f._pc.connectionState||(null===(e=f._connectReject)||void 0===e||e.call(f,{message:Hg(t="pc.connectionstatechange -> ".concat(f._pc.connectionState,", ice -> ")).call(t,f._pc.iceConnectionState),code:2}),delete f._connectReject,clearTimeout(n))};r.addEventListener("open",i),r.addEventListener("error",o),r.addEventListener("close",a),f._pc.addEventListener("iceconnectionstatechange",s),f._pc.addEventListener("connectionstatechange",c),f._clearPeerListeners=function(){r.removeEventListener("open",i),r.removeEventListener("error",o),r.removeEventListener("close",a),f._pc.removeEventListener("iceconnectionstatechange",s),f._pc.removeEventListener("connectionstatechange",c)}}));case 47:return this._print("connect","dataChannel establish success"),e.abrupt("return",r);case 49:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"setDescription",value:(o=Ug(Dg().mark((function e(t){var r,n;return Dg().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=AL(),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:AL()-n}),e.next=13,this.setLocalDescription(ZK.write(this._offerSession),t);case 13:return e.next=15,this.setRemoteDescription(ZK.write(this._answerSession),t);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setLocalDescription",value:(i=Ug(Dg().mark((function e(t,r){var n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=AL(),e.prev=1,e.next=4,this._pc.setLocalDescription({type:"offer",sdp:t});case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:AL()-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=13;break;case 8:throw 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:AL()-n},{type:"offer"}),e.t0;case 13:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return i.apply(this,arguments)})},{key:"setRemoteDescription",value:(n=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=AL(),e.prev=1,e.next=4,this._pc.setRemoteDescription({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:AL()-n},{type:"answer"}),e.next=12;break;case 7:throw 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:AL()-n},{type:"answer"}),e.t0;case 12:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return n.apply(this,arguments)})},{key:"closeIceConnect",value:function(){var e,t,r,n;null===(e=this._connectReject)||void 0===e||e.call(this,{code:3,message:"invoke destroy()"}),delete this._connectReject,this._pc&&this._pc.close(),null===(t=this._dc)||void 0===t||t.close(),delete this._dc,this._pc.ontrack=null,this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,n=this._pc,Fz.has(n)&&Fz.delete(n),null===(r=this._clearPeerListeners)||void 0===r||r.call(this),delete this._clearPeerListeners}},{key:"reportRtcPreIce",value:function(e){var t=AL();"ice_start"===e&&(this._iceStartTs=t,this._icePreStepTs=t),this._icePreStepTs=t}},{key:"getStatsWithLowFrequency",value:function(e,t,r){return Gz(this._pc,e,t,r)}},{key:"destroy",value:function(){this._print("destroy",this._peerConnectionId),VA(UA(c.prototype),"removeAllListeners",this).call(this),this.closeIceConnect(),this._destroyed=!0,this._reportTimer&&(clearTimeout(this._reportTimer),delete this._reportTimer),delete this._pc}},{key:"_genIceInfo",value:(r=Ug(Dg().mark((function e(t){var r,n,i,o;return Dg().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,yX(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 r.apply(this,arguments)})},{key:"_reportTransportStats",value:(t=Ug(Dg().mark((function e(){var t,r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getStatsWithLowFrequency();case 2:t=e.sent,r={},t.forEach((function(e){if("transport"===e.type)r.dtls_state=e.dtlsState,r.bytes_received=e.bytesReceived,r.bytes_sent=e.bytesSent,r.ice_state=e.iceState,r.packets_received=e.packetsReceived,r.packets_sent=e.packetsSent,r.selected_candidate_pair_changes=e.selectedCandidatePairChanges;else if("local-candidate"===e.type||"remote-candidate"===e.type){var t;r.candidates_info=Hg(t=[]).call(t,iR(r.candidates_info||[]),[{id:e.id,is_remote:e.isRemote,port:e.port,protocol:e.protocol,candidate_type:e.candidateType,priority:e.priority,network_type:e.networkType,candidate_ip:e.ip}])}else"candidate-pair"===e.type&&(r.candidatePairsInfo={},r.candidatePairsInfo.candidate_state=e.state,r.candidatePairsInfo.writable_state=e.writable,r.candidatePairsInfo.sent_ping_requests_total=e.requestsSent,r.candidatePairsInfo.recv_ping_requests=e.requestsReceived,r.candidatePairsInfo.sent_ping_responses=e.responsesSent,r.candidatePairsInfo.recv_ping_responses=e.responsesReceived,r.candidatePairsInfo.current_rtt=e.currentRoundTripTime,r.candidatePairsInfo.total_rtt=e.totalRoundTripTime,["localCandidateId","remoteCandidateId","bytesSent","bytesReceived","availableOutgoingBitrate","availableIncomingBitrate","bytesDiscardedOnSend","consentRequestsSent","packetsDiscardedOnSend","lastPacketReceivedTimestamp","lastPacketSentTimestamp"].forEach((function(t){var n;void 0!==e[t]&&(r.candidatePairsInfo[(n=t,n.replace(/[A-Z]/g,(function(e){return"_".concat(e.toLowerCase())})))]=e[t])})))})),FS(r).length,this._destroyed||"connected"===this._pc.iceConnectionState&&this._pc.connectionState;case 7:case"end":return e.stop()}}),e,this)}))),function(){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,Hg(r=["".concat(e)]).call(r,i))}},{key:"_report",value:function(e,t,r){var n,i,o,a;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this._peerConnectionId,group_connection_id:this._groupConnectionId}),Zd(Zd({},r),{},{tcp_only:null===(i=this._iceNode)||void 0===i?void 0:i.iceConfig.tcpOnly,ms_addr:Xg((null===(o=this._iceNode)||void 0===o?void 0:$g(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 _w(dw.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 _w(dw.NOT_SUPPORTED,"missing peer.".concat(e," API."))}))}}]),c}(yU),MX=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(MX||{}),DX=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}(DX||{}),LX=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}(LX||{}),UX=(Jd(EX={},0,[0,"success"]),Jd(EX,1,[dw.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),Jd(EX,2,[dw.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),Jd(EX,3,[dw.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),Jd(EX,4,[dw.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),Jd(EX,5,[dw.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),Jd(EX,17,[dw.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),Jd(EX,18,[dw.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),Jd(EX,100,[dw.USER_MESSAGE_NOT_JOIN,"not join room"]),Jd(EX,105,[dw.USER_MESSAGE_NOT_LOGIN,"not login."]),Jd(EX,106,[dw.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),Jd(EX,1e3,[dw.USER_MESSAGE_UNKNOWN,"unknown."]),EX),VX=["msg"],FX=[],BX=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}(BX||{}),jX=function(e){BA(a,e);var t,r,n,i,o=nC(a);function a(e,t,r){var n;return Hh(this,a),Jd(uA(n=o.call(this)),"_singlingCache",new hT),Jd(uA(n),"_p2pCache",new hT),Jd(uA(n),"_rttIds",{}),Jd(uA(n),"_p2pMessageId",new KL),Jd(uA(n),"_clearDataChannelListener",void 0),Jd(uA(n),"_monitor",void 0),Jd(uA(n),"logger",void 0),n.id=e,n._dataChannel=t,n.connectionIds=r,n._clearDataChannelListener=n._handleHandler(),n._monitor=HM(e),n.logger=new hD("DataChannelSignaling",3,e),n}return jh(a,[{key:"destroy",value:function(){var e=this;this._clearDataChannelListener(),delete this._dataChannel,this._singlingCache.forEach((function(t,r){t.error(new _w(dw.OPERATION_CANCEL,"disconnect")),e._singlingCache.delete(r)})),this._singlingCache.clear(),this._p2pCache.clear(),this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:6e4;return new Gg((function(o,a){var s,c=n._genHeader(r);c.id=OL();var u=c.id.join("-"),l="customMessage"===e;l&&LM.samplingOne2ManyMsg(n.id,Number(c.id.join("")),t);var d=setTimeout((function(){n._singlingCache.delete(u),a(new _w(dw.TIME_OUT,"".concat(e," message time out"))),l&&LM.updateOne2ManyMsgAck(n.id,t,999)}),i);n._singlingCache.set(u,{start:AL(),signalingType:e,success:function(e){clearTimeout(d),o(e),l&&LM.updateOne2ManyMsgAck(n.id,t,0)},error:function(e){clearTimeout(d),a(e),l&&LM.updateOne2ManyMsgAck(n.id,t,e.code)}}),n.logger.info("Signal",Hg(s=">>>>>> [".concat(e,"][")).call(s,u,"]"),t),n._sendMessage(e,c,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=Ug(Dg().mark((function e(t,r){var n,i,o;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=bM(t,VX),o=n instanceof ArrayBuffer,e.t0=this,e.t1=LM,e.t2=this.id,e.t3=Zd,e.t4=Zd({ver:1,id:this._p2pMessageId.getMessageId(),time:Date.now(),dir:MX.SEND,type:DX.P2P,err:LX.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,wL.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 ML(e.msg)?this._rttIds[e.id]=e.id:e.dir===MX.SEND&&this.logger.info("_sendP2PMessage [DC Signaling p2p >>]",Xg(e)),new Gg((function(n,i){var o=t._genHeader(Zd(Zd({needAck:!0,functionType:1},r),{},{id:OL()}));if(e.dir===MX.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new _w(dw.USER_MESSAGE_TIMEOUT,"P2P message timeout")),LM.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),LM.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),LM.updateP2PMsgAck(t.id,e,r.err);var o=Ey(UX[r.err]||[dw.USER_MESSAGE_UNKNOWN,Hg(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===dw.NOT_CONNECTED_YET&&(s.code=dw.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new _w(dw.NOT_CONNECTED_YET,"DataChannel not open");var i=lL("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=wL.str2ab(Xg([e,r])),c=CL(Uint8Array,Hg(n=[o,a]).call(n,iR(t.id||[])),i||t.zip?pM.deflate(new Uint8Array(s)):new Uint8Array(s));try{this._dataChannel.send(c.buffer)}catch(l){var u;throw null===(u=this._monitor)||void 0===u||u.report("rtc_error",{message:"datachannel send error: ".concat(l.message),error_code:TK.DC_SEND_ERROR}),l}"p2p"===e?LM.updateP2PMsgReq(this.id,r,c.buffer.byteLength):"customMessage"===e&&LM.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=Fw(dI(t).call(t,2,r))}return{header:o,data:dI(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:$g(n=e.split("-")).call(n,(function(e){return Number(e)}))});Qy(FX).call(FX,t)||this.logger.info("Signal",Hg(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,l;return Dg().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 pM.Inflate).push(o,!0),o=s.result),c=wL.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===(l=this._monitor)||void 0===l||l.report("rtc_signaling_msg_error",Zd({error_code:-1,message:e.t0.message,reason:"message parse failed"},this.connectionIds))),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=Ug(Dg().mark((function e(t,r,n,i,o){var a,s,c,u;return Dg().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=17;break;case 5:if(!Array.isArray(r)){e.next=17;break}if(c=r[0],r=r[1],Qy(FX).call(FX,c)||this.logger.info("Signal","<<<<<< ".concat(c),r,s),this._feedbackSignaling(s,c,c===kU.ON_CUSTOM_MESSAGE?Zd(Zd({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,wL.b64str2ab(r.message,this._monitor);case 13:r.message=e.sent;case 14:u=Date.now(),this.emit(c,Zd({},r)),c===kU.ON_CUSTOM_MESSAGE&&LM.reportOne2ManyMsgRecv(this.id,r,{msg_size:i,recv_msg_ts:o,fwd_msg_ts:u});case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"C2C",value:(t=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,h,f,v,p,_;return Dg().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)===MX.FEEDBACK||ML(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===MX.SEND?6:e.t0===MX.FEEDBACK?46:48;break;case 6:if(u=Date.now(),ML(null===(s=t)||void 0===s?void 0:s.msg)){e.next=43;break}if(d=(l=t).binary,h=l.msg,f=l.room,v=l.to,p=l.from,_=""===f?d?kU.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:kU.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:d?kU.USER_BINARY_MESSAGE_RECEIVED:kU.USER_MESSAGE_RECEIVED,v){e.next=27;break}if(e.t1=this,e.t2=kU.ON_CUSTOM_MESSAGE,e.t3=p,e.t4=d,!d){e.next=21;break}return e.next=18,wL.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=_,e.t10=Zd,e.t11=Zd({},t),e.t12={},!d){e.next=38;break}return e.next=35,wL.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(Zd(Zd({},t),{},{dir:MX.FEEDBACK,msg:""})),LM.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=Ey(t,2),a=o[0],s=o[1],c=void 0===s?{}:s;if("RXMediaMsg"===a){var u=c.type,l=c.data;switch(u){case"RSCP":try{var d=JSON.parse(l);Array.isArray(d)&&this.emit(u,d)}catch(v){}break;case"RTT":try{var h=JSON.parse(l);h.length&&this.emit(u,h[0])}catch(v){}break;case"SSC":try{var f=JSON.parse(l);f.length&&this.emit(u,f[0])}catch(v){}}}}}},{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(){var i=e._dataChannel;null==i||i.removeEventListener("close",t),null==i||i.removeEventListener("error",r),null==i||i.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){return Zd({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=this._singlingCache.get(e);i&&(this._singlingCache.delete(e),200===t.code?i.success(t):i.error(t),this.logger.info("Signal",Hg(n="<<<<<< [".concat(i.signalingType,"-ack] ")).call(n,e),t))}},{key:"_handleP2PMsgFeedback",value:function(e){var t=this._p2pCache.get(e.id);t&&(this._p2pCache.delete(e.id),e.err===LX.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(_U.EventEmitter),HX=function(e){return e.ICE_FAILED="ice failed",e.DC_ERROR="datachannel onerror",e.DC_CLOSE="datachannel onclose",e.NODE_CHANGE="recv nodeChange signaling",e.NOTIFY_RECONNECT="recv notifyReconnect signaling",e.JOIN_TIMEOUT="joinRoom timeout, retry with tcp only",e}(HX||{}),GX=function(e){BA(o,e);var t,r,n,i=nC(o);function o(e){var t;return Hh(this,o),Jd(uA(t=i.call(this)),"id",void 0),Jd(uA(t),"_monitor",void 0),Jd(uA(t),"logger",void 0),Jd(uA(t),"_getAccessManager",void 0),Jd(uA(t),"_connectionPool",new hT),Jd(uA(t),"_curConnection",void 0),Jd(uA(t),"_hasReportBrowerWarning",!1),Jd(uA(t),"_reconnectTimer",void 0),Jd(uA(t),"_connecting",!1),Jd(uA(t),"_isFirstTimeConnected",!0),Jd(uA(t),"_feedbackNodes",[]),Jd(uA(t),"_preIceStartTime",-1),Jd(uA(t),"_tcpOnlyTimer",void 0),Jd(uA(t),"_destroyed",!1),t._ctx=e,t.id=e.id,t._monitor=HM(t.id),t.logger=new hD("ConnectionManager",3,t.id),t.logger.info("constructor","invoke"),t._getAccessManager=new QK(e),t}return jh(o,[{key:"startup",value:function(){var e=this;this.logger.info("connect","invoke");try{PX.checkSupported()}catch(t){this.asyncEmit("disconnected",t)}this._connecting||(this._onConnectStart(),Gg.resolve().then((function(){return e.emit("__onGetIceConfigHook")})),this._getAccess())}},{key:"reconnectByNodeChange",value:(n=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.info("reconnectByNodeChange","invoke %o",t),a=t.nodes,s=t.reason,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:Xg(t),reason:Xg(s)}),tL.clearAccessNode(this._ctx.appId),null===(n=this._curConnection)||void 0===n||n.pc.reportRtcPreIce("node_change"),c=(null===(i=this._curConnection)||void 0===i||null===(o=i.node.publicIPs[0])||void 0===o?void 0:o.ip)||"",this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart("recv nodeChange signaling"),Array.isArray(a)&&a.length>0?this._startIceConnect(a):this._getAccess([{feedbackIP:c,feedbackReason:{type:"NODE_CHANGED",reason:s}}]);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"reconnect",value:(r=Ug(Dg().mark((function e(t){var r,n=arguments;return Dg().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:"shotdown",value:function(){var e=this;this.logger.info("destroy","invoke"),this._destroyed=!0,this.asyncEmit("disconnected",new _w(dw.OPERATION_CANCEL,"destroy")).then((function(){VA(UA(o.prototype),"removeAllListeners",e).call(e)})),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.asyncEmit("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=_x();this._preIceStartTime=AL();var i=this._ctx.joinRoomConfig.useTcpJoin,o=this._ctx.joinRoomConfig.useTcpJoinDelay,a=function(){var i=Ug(Dg().mark((function i(o){var a,s,c,u;return Dg().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return r&&((o=RK(o)).iceConfig.tcpOnly=!0),a={node:o},i.prev=2,s=new PX(t._ctx,n,!t._isFirstTimeConnected),a.pc=s,t._connectionPool.set(s.uuid,a),i.next=8,s.startIceConnect(o);case 8:return c=i.sent,u=new jX(t.id,c,{connection_id:s.getConnectionId(),group_connection_id:n}),a.signaling=u,s.reportRtcPreIce("datachannel_send_ping"),i.next=14,u.sendPingSignaling();case 14:s.reportRtcPreIce("datachannel_recv_pong"),t._onConnectSuccess({node:o,pc:s,signaling:u,dc:c}),t.safeEmit("__onConnectSuccessHook",e.length),i.next=22;break;case 19:i.prev=19,i.t0=i.catch(2),t._onConnectionFailed(a,i.t0);case 22:case"end":return i.stop()}}),i,null,[[2,19]])})));return function(e){return i.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=RK(e)).iceConfig.tcpOnly=!0,a(e)})),delete t._tcpOnlyTimer}),o))}}},{key:"_onConnectSuccess",value:function(e){var t,r=this;(this.logger.info("connect","peer_%s connect success.",e.pc.uuid),this.emit("__onIceConnectSuccessHook",e),this._curConnection)?(e.pc.destroy(),e.signaling.destroy(),this._connectionPool.delete(e.pc.uuid)):(this._curConnection=e,this._addConnectionHandler(e.pc),null===(t=this._monitor)||void 0===t||t.set({connection_id:e.pc.getConnectionId()}),this._connectionPool.delete(e.pc.uuid),this._feedbackNodes.forEach((function(e){return r._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!==OX.DESTROY&&t.code!==dw.OPERATION_CANCEL)&&(this._curConnection?this._feedbackBySignaling(e.node):this._feedbackNodes.push(e.node),this.logger.info("connect","remove cache node"),tL.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(),AL()-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=Ug(Dg().mark((function e(t){return Dg().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($g(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:TK.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||"init")),this._connecting=!0,e?this.asyncEmit("reconnecting",e):this.asyncEmit("connecting");var r,n=_x();(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.asyncEmit("connected",e),e.node.iceConfig.tcpOnly&&(this.logger.info("_onConnectEnded","use tcp only"),this._ctx.id,Xg(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.signaling)||void 0===n||n.destroy(),null===(i=t.pc)||void 0===i||i.destroy(),e._connectionPool.delete(r)}))}},{key:"_clearReconnectTimer",value:function(){this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer)}}]),o}(yU),zX=r(mi.f("asyncIterator"));function WX(e){var t,r,n,i=2;for(void 0!==Cd&&(r=zX,n=Kd);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new KX(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function KX(e){function t(e){if(Object(e)!==e)return ig.reject(new TypeError(e+" is not an object."));var t=e.done;return ig.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(KX=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?ig.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?ig.reject(e):t(r.apply(this.s,arguments))}},new KX(e)}var XX,YX,qX,JX=function(e){BA(n,e);var t,r=nC(n);function n(e,t){var i;return Hh(this,n),Jd(uA(i=r.call(this)),"_context",void 0),Jd(uA(i),"peerConnectionMode",0),Jd(uA(i),"id",void 0),Jd(uA(i),"_monitor",void 0),Jd(uA(i),"logger",void 0),Jd(uA(i),"_nextSsrc",Math.floor(Math.random()*hX+1e4)),Jd(uA(i),"_aSendonlyAnswerTpl",void 0),Jd(uA(i),"_vSendonlyAnswerTpl",void 0),Jd(uA(i),"_enableSubFlexfec",!1),Jd(uA(i),"audioTrack4ff",void 0),Jd(uA(i),"setLocalDescription",void 0),Jd(uA(i),"setRemoteDescription",void 0),i.peer=t,i.id=e.id,i._monitor=HM(i.id),i.logger=new hD("BasicHandler",3,e.id),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 jh(n,[{key:"destroy",value:function(){this.logger.info("destroy",this.peerConnectionId||""),VA(UA(n.prototype),"removeAllListeners",this).call(this)}},{key:"_peerConnection",get:function(){return this.peer.getOriginRTCPeerConnection()}},{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=$g(o=dI(a=dI(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=WL(e.width),i=t.width/n;return{width:n,height:Math.floor(t.height/i),scaleResolutionDownBy:i,frameRate:WL(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,r,n=e.stream,i=e.videoTrack,o=e.audioTrack,a=e.enableSimulcast,s=e.pubAudio,c=e.pubVideo,u={direction:"sendonly",streams:[n]},l={direction:"sendonly",streams:[n]},d=[],h=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var f,v,p=null==i?void 0:i.preprocessingTrack,_=Zd({},pL);if(p){var m=null==p?void 0:p.getSettings();_={width:Math.floor(m.width),height:Math.floor(m.height),frameRate:Math.floor(m.frameRate)}}"number"!=typeof _.frameRate&&(_.frameRate=30);var g=null==e?void 0:e.videoEncodeConfig[0],y={maxBitrate:1e3*g.maxKbps,rid:"0"};if(e.prevBitrate=g.maxKbps,l.sendEncodings=[y],d.push({width:_.width,height:_.height,framerate:_.frameRate,maxkbps:g.maxKbps,rid:"0"}),a&&(!yD||"VP8"===(null===(f=this._context)||void 0===f||null===(v=f.serverConfig)||void 0===v?void 0:v.videoCodec))){var S,b,E=function(e){for(var t=0,r=e.width*e.height,n=0;n<LK.length;n++)if(r>=LK[n].totalPixels){t=n;break}if(0===t)return LK[t].maxLayers;var i=LK[t-1].totalPixels;return(i-r)/(i-LK[t].totalPixels)<.1?LK[t-1].maxLayers:LK[t].maxLayers}(_);if(this.logger.info("simulcast() ","maxLayers: %o",E),E>1)this._simulcast(e,Zd(Zd({},_),{},{maxKbps:g.maxKbps}),l,d,E),null!==(S=this._context)&&void 0!==S&&null!==(b=S.serverConfig)&&void 0!==b&&b.simulcastOnDemand&&(h=$g(d).call(d,(function(e,t){return Zd(Zd({},e),{},{video_index:t,sub_index:t})})))}}null!==(t=this._context)&&void 0!==t&&null!==(r=t.serverConfig)&&void 0!==r&&r.e2eFeedback&&(h=$g(d).call(d,(function(e,t){return Zd(Zd({},e),{},{video_index:t,sub_index:t})}))),this.logger.info("publish videoTransceiverInit videoDescriptions","",l,d);var k=null==o?void 0:o.preprocessingTrack;(null==o?void 0:o.mixType)!==Lh.PLAYOUT&&null!=o&&o.mixedAudioTrack&&(k=null==o?void 0:o.mixedAudioTrack),k=s&&k?k:"audio";var T=null==i?void 0:i.preprocessingTrack;T=c&&T?T:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",Xg({aTrack:gx(k),vTrack:gx(T),audioTransceiverInit:u,videoTransceiverInit:l}))}catch(KJ){}return{semantics:"unified-plan",videoDescriptions:d,subVideoDescriptions:h,audioTransceiverInit:{track:k,init:u},videoTransceiverInit:{track:T,init:l}}}},{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:$g(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",Xg(c.encodings))}catch(KJ){}}}else this.logger.warn("updateMaxBitrate()","no pub")}},{key:"setCurrentDescription",value:(t=Ug(Dg().mark((function e(){return Dg().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=ZK.parse(e);r.media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:lI(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:lI(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&&Qy(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))})),$U&&RX(r)}},{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(Qy(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=lI(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=Hg(s=[]).call(s,iR(c.config.split(";")),["x-google-min-bitrate=100","x-google-start-bitrate=".concat(t)]).join(";");else e.fmtp.push({payload:o,config:"x-google-min-bitrate=100;x-google-start-bitrate=".concat(t)})}}))}},{key:"_report",value:function(e,t,r){var n;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this.peer.getConnectionId(),group_connection_id:this.peer.getGroupConnectionId()}),r)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}]),n}(_U.EventEmitter),QX=new hD("queue",4),ZX=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(ZX||{}),$X=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}($X||{}),eY=(Jd(XX={},"publish","unpublish"),Jd(XX,"subscribe","unsubscribe"),Jd(XX,"pushtrack","removetrack"),XX),tY=(Jd(YX={},"publish",0),Jd(YX,"subscribe",0),Jd(YX,"pushtrack",0),Jd(YX,"unpublish",1),Jd(YX,"unsubscribe",1),Jd(YX,"removetrack",1),YX),rY=function(e){BA(r,e);var t=nC(r);function r(){var e;return Hh(this,r),Jd(uA(e=t.call(this)),"_queue",void 0),e._queue=[],e}return jh(r,[{key:"queue",get:function(){return this._queue}},{key:"destroy",value:function(){this._queue=[]}},{key:"enqueue",value:function(e){var t,r=this._queue.length,n="";return this._queue=Cy(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==eY[t.action]||(n=t.streamId,QX.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;bD&&KD>=86&&KD<=92&&(t=Math.min(this._queue.length,5));for(var r=tY[this._queue[0].action],n=1;n<t;n++){var i;if(tY[this._queue[n].action]!==r)return{sdpStrategy:r,items:zI(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:zI(e=this._queue).call(e,0,t)}}}]),r}(mU),nY=qU(),iY=function(e){BA(c,e);var t,r,n,i,o,a,s=nC(c);function c(e,t){var r;return Hh(this,c),Jd(uA(r=s.call(this,e,t)),"name","chrome"),Jd(uA(r),"_queueBusy",!1),Jd(uA(r),"_sdpQueue",void 0),Jd(uA(r),"_aSendonlyOfferTpl",void 0),Jd(uA(r),"_vSendonlyOfferTpl",void 0),Jd(uA(r),"_aRecvonlyOfferTpl",void 0),Jd(uA(r),"_vRecvonlyOfferTpl",void 0),Jd(uA(r),"_mid",10),Jd(uA(r),"_inactiveMlineIndex",[]),Jd(uA(r),"_mlinesCache",{}),Jd(uA(r),"setDescription",void 0),r.logger=new hD("ChromeHandler",3,e.id),r.setDescription=t.setDescription.bind(t),r._sdpQueue=new rY,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(r.logger.info("dequeue start"),r.dequeue())})),r}return jh(c,[{key:"destroy",value:function(){VA(UA(c.prototype),"destroy",this).call(this),this._sdpQueue.destroy(),this._mlinesCache={}}},{key:"publish",value:(a=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R,A,C,w,x,O,N,P,M,D,L,U,V,F,B;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=t.stream,d=t.enableSimulcast,h=VA(UA(c.prototype),"internalPublish",this).call(this,t),f=h.videoDescriptions,v=h.subVideoDescriptions,p=h.audioTransceiverInit,_=h.videoTransceiverInit,m=vX(this._nextSsrc),this._nextSsrc=m.next,g="".concat(this._mid++),y="".concat(this._mid++),S=Zd(Zd(Zd({},this._aSendonlyOfferTpl),this.peer._offerIce),{},{mid:g,msid:Hg(r="".concat(l.id," ")).call(r,l.id,"-audio"),ssrcs:pX(l.id,"audio",m.audio,fX)}),b=Zd(Zd(Zd({},this._vSendonlyOfferTpl),this.peer._offerIce),{},{mid:y,msid:Hg(n="".concat(l.id," ")).call(n,l.id,"-video")}),d?(this.logger.info("subVideoDesc","desc: %o ",v),delete b.ssrcGroups,delete b.ssrcs,E=[],b.rids=$g(f).call(f,(function(e){var t=e.rid;return E.unshift(t),{id:t,direction:"send"}})),b.simulcast={dir1:"send",list1:E.join(";")}):(k=_X(l.id,m,{cname:fX}),T=k.ssrcs,I=k.ssrcGroups,b.ssrcs=T,b.ssrcGroups=I),null!==(i=this._context)&&void 0!==i&&null!==(o=i.serverConfig)&&void 0!==o&&o.audioRed&&Array.isArray(S.rtp)&&(-1!==(A=qC(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(w=zI(C=S.rtp).call(C,A,1),x=Ey(w,1),O=x[0],S.rtp.unshift(O)),N=[],S.rtp.forEach((function(e){return N.push(e.payload)})),S.payloads=N.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&TX(b,null===(P=this._context)||void 0===P||null===(M=P.serverConfig)||void 0===M?void 0:M.videoCodec),Array.isArray(b.ext)&&(lL("IOS_SAFARI_ORIENTATION")||!SD&&!PD||(b.ext=Cy(L=b.ext).call(L,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&Qy(t).call(t,"video-orientation"))}))),b.ext=Cy(D=b.ext).call(D,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&Qy(t).call(t,"framemarking"))}))),(U=null==S?void 0:lI(u=S.rtp).call(u,(function(e){return"opus"===e.codec})))&&S.fmtp&&(B=lI(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)),d||SD||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:gX(this.peer._offerSession,S,b),audioMid:g,videoMid:y,type:"incroffer",semantics:"unified-plan",videoDescriptions:f,subVideoDescriptions:v,audioTransceiverInit:p,videoTransceiverInit:_,peerConnectionMode:this.peerConnectionMode});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"subscribe",value:(o=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R,A,C,w,x,O,N,P,M,D,L,U;return Dg().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,oY();case 6:return c=e.sent,e.next=9,this.createAVMlineOfferTpl(c);case 9:return u="",l="",d=!1,h=!1,f=void 0,v=void 0,this._mlinesCache[t.streamId]=[f,v],t.virtual?(u="".concat(this._mid++),d=!0):r.multiChatMode?(u="".concat(this._mid++),l="".concat(this._mid++),h=!0):(d=!0,h=!0,u="".concat(this._mid++),l="".concat(this._mid++)),u&&(f=Zd(Zd({},RK(this._aRecvonlyOfferTpl)),{},{mid:u})),d&&(this._mlinesCache[t.streamId][0]=f,p={track:"audio",init:{direction:"recvonly"}}),l&&(v=Zd(Zd({},RK(this._vRecvonlyOfferTpl)),{},{mid:l})),h&&(this._mlinesCache[t.streamId][1]=v,_={track:"video",init:{direction:"recvonly"}}),m=gX(this.peer._offerSession,f,v),g=void 0,y=void 0,t.enableVendorMode||r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl||(g=vX(this._nextSsrc),this._nextSsrc=g.next,A=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Hg(S=Hg(b="".concat(t.streamId)).call(b,null!==(E=this._context)&&void 0!==E&&E.avSync?"":"-audio"," ")).call(S,t.streamId,"-audio"),ssrcs:pX(t.streamId,"audio",g.audio)}),C=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:l,msid:Hg(k=Hg(T="".concat(t.streamId)).call(T,null!==(I=this._context)&&void 0!==I&&I.avSync?"":"-video"," ")).call(k,t.streamId,"-video")},_X(t.streamId,g,{flexfec:this._enableSubFlexfec})),y={sdp:ZK.write(Zd(Zd({},this.peer._answerSession),{},{media:[A,C]})),sequenceId:t.sequenceId?++t.sequenceId:0},null===(R=g)||void 0===R||delete R.next),(w=null===(n=f)||void 0===n?void 0:lI(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=f)&&void 0!==o&&o.fmtp&&(N=null===(x=f)||void 0===x?void 0:lI(O=x.fmtp).call(O,(function(e){return e.payload===w.payload})))&&this._context&&(N.config+=";stereo=1;sprop-stereo=1"),t.isPublic&&KD>=86&&null!=(L=null===(P=v)||void 0===P?void 0:Cy(M=P.rtp).call(M,(function(e){return"H264"===e.codec})))&&L.length&&null!==(D=v)&&void 0!==D&&D.fmtp&&(null===(U=v)||void 0===U||U.fmtp.forEach((function(e){lI(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:l,type:a,semantics:s,audioTransceiverInit:p,videoTransceiverInit:_,allSsrc:g,peerConnectionMode:this.peerConnectionMode,signalingAck:y});case 29:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"handleAck",value:(i=Ug(Dg().mark((function e(t){return Dg().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 i.apply(this,arguments)})},{key:"dequeue",value:(n=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c,u,l,d,h,f,v,p,_,m=this;return Dg().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!==ZX.ADD){e.next=16;break}return e.delegateYield(Dg().mark((function e(){var t,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=Zd({},m.peer._answerIce)).candidates,c=!1,u=!1,e.prev=4,d=WX(n);case 6:return e.next=8,d.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,l=i.videoTransceiverInit,d=i.signalingAck,h=i.stream,f=h instanceof aK;if(i.onSuccess&&s.push(i.onSuccess),i.onFail&&r.push(i.onFail),f&&(null==d?void 0:d.sequenceId)<h.sequenceId)return"break";var v,p={},_={},g=ZK.parse(d.sdp);Array.isArray(g.media)&&BC(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=Zd(Zd({},r),t)).type?(p=r).mid=e:(_=r).mid=n}));var y,S=h.streamId;if(c===$X.publish&&(S=null===(y=h.stream)||void 0===y?void 0:y.id),!m._mlinesCache[S])return"break";var b=Ey(m._mlinesCache[S],2),E=b[0],k=b[1];if(u&&E){h.audioTransceiver=m._peerConnection.addTransceiver(u.track,u.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",Xg({audioStreamTrack:gx(u.track)}));var T=m._inactiveMlineIndex.shift();T||(T=m.peer._offerMlines.length),m.peer._offerMlines[T]=Zd({},E),m.peer._answerMlines[T]=p,nY&&h.initAudioEncodedTransform()}if(l&&k){var I,R;h.videoTransceiver=m._peerConnection.addTransceiver(l.track,l.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",Xg({videoStreamTrack:gx(l.track)}));var A,C,w=m._inactiveMlineIndex.shift();w||(w=m.peer._offerMlines.length),m.peer._offerMlines[w]=Zd({},k),c===$X.publish&&null!==(I=m._context)&&void 0!==I&&null!==(R=I.serverConfig)&&void 0!==R&&R.videoCodec&&TX(_,null===(A=m._context)||void 0===A||null===(C=A.serverConfig)||void 0===C?void 0:C.videoCodec),m.peer._answerMlines[w]=_,nY&&h.initVideoEncodedTransform()}o.push(h.streamId||""),a.push(f?h.userId:"local"),f&&(h.sequenceId=null==d?void 0:d.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,l=e.t0;case 22:if(e.prev=22,e.prev=23,!c||null==d.return){e.next=27;break}return e.next=27,d.return();case 27:if(e.prev=27,!u){e.next=30;break}throw l;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:_={},n.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;_[t]=t,n!==$X.removetrack&&(_[r]=r),_[t]=t})),this.peer._offerMlines=$g(f=this.peer._offerMlines).call(f,(function(e,t){return _[e.mid]&&(e=mX(e),m._inactiveMlineIndex.push(t)),e})),BC(v=this._inactiveMlineIndex).call(v,(function(e,t){return e-t})),this.peer._answerMlines=$g(p=this.peer._answerMlines).call(p,(function(e){return _[e.mid]&&(e=mX(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(KJ){}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 n.apply(this,arguments)})},{key:"getDefaultSdp",value:(r=Ug(Dg().mark((function e(){var t,r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,oY();case 2:return r=e.sent,this.createAVMlineOfferTpl(r),n=ZK.parse(r),i=[],n.media=Cy(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=Cy(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"}],$U&&RX(n),e.abrupt("return",{sdp:ZK.write(n),semantics:"unified-plan",type:"incroffer"});case 10:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"rollback",value:(t=Ug(Dg().mark((function e(t){var r;return Dg().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 t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this,r=ZK.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=Cy(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=Cy(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}})),$U&&RX(r)}}]),c}(JX),oY=function(){var e=Ug(Dg().mark((function e(){var t,r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,DL(!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 _w(dw.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(){return e.apply(this,arguments)}}(),aY=function(e){BA(l,e);var t,r,n,i,o,a,s,c,u=nC(l);function l(e,t){var r;return Hh(this,l),Jd(uA(r=u.call(this,e,t)),"name","firefox"),Jd(uA(r),"_aRecvonlyOfferTpl",void 0),r.logger=new hD("FirefoxHandler",3,e.id),r}return jh(l,[{key:"destroy",value:function(){}},{key:"publish",value:(c=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,d,h,f,v,p,_,m,g=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=VA(UA(l.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=$g(u=c.init.sendEncodings).call(u,(function(e){return delete e.rid,e}))),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),d=AL(),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:AL()-d}),(f=ZK.parse(h.sdp)).media=null===(r=f.media)||void 0===r?void 0:$g(r).call(r,(function(e){return Zd(Zd({},e),g.peer._offerIce)})),RX(f),e.next=15,this.setLocalDescription(ZK.write(f));case 15:return v=t.audioTransceiver.mid,p=t.videoTransceiver.mid,_=null,m=null,f.media=null===(n=f.media)||void 0===n?void 0:$g(n).call(n,(function(e){if("".concat(e.mid)===v){var t,r,n=null===(t=_=e)||void 0===t?void 0:lI(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&_.fmtp){var i,o,a=lI(i=_.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)===p){var s,c,u,l;null!==(s=g._context)&&void 0!==s&&null!==(c=s.serverConfig)&&void 0!==c&&c.videoCodec&&TX(e,null===(u=g._context)||void 0===u||null===(l=u.serverConfig)||void 0===l?void 0:l.videoCodec),m=e}return e})),this.addBitrateLimit(m,t.videoEncodeConfig[0].maxKbps),e.next=23,this.setLocalDescription(ZK.write(f));case 23:return e.abrupt("return",{partialSdp:gX(f,_,m),audioMid:v,videoMid:p,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=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R,A,C=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("subscribe()"),c="",u="",l=!1,d=!1,h=void 0,f=void 0,t.virtual?l=!0:(r.multiChatMode||(l=!0),d=!0),l&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),d&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),v=AL(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return p=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:AL()-v}),(_=ZK.parse(p.sdp)).media=null===(n=_.media)||void 0===n?void 0:$g(n).call(n,(function(e){return Zd(Zd({},e),C.peer._offerIce)})),$g(i=_.media).call(i,(function(e){var t,r,n,i;"video"===e.type&&(ZU?(e.ext=null===(t=e.ext)||void 0===t?void 0:Cy(t).call(t,(function(e){var t;return-1===kI(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Cy(r).call(r,(function(e){return"goog-remb"!==e.type}))):(e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:Cy(n).call(n,(function(e){return"transport-cc"!==e.type})),e.ext=null===(i=e.ext)||void 0===i?void 0:Cy(i).call(i,(function(e){var t;return-1===kI(t=e.uri).call(t,"transport")}))))})),$U&&RX(_),e.next=22,this.setLocalDescription(ZK.write(_),{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=_.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===c?h=e:"".concat(e.mid)===u&&(f=e)})),c&&h||(c="audio_".concat(u),h=Zd(Zd({},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=vX(this._nextSsrc),this._nextSsrc=m.next,R=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:c,msid:Hg(y=Hg(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:pX(t.streamId,"audio",m.audio)}),A=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Hg(E=Hg(k="".concat(t.streamId)).call(k,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},_X(t.streamId,m,{flexfec:this._enableSubFlexfec})),g={sdp:ZK.write(Zd(Zd({},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:gX(_,h,f,!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=Ug(Dg().mark((function e(t){var r,n,i,o;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==$X.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==$X.unpublish&&i!==$X.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=ZK.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=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=ZK.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){if("audio"===(e=Zd(Zd({},e),d.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type){if(r instanceof oK&&jD<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=Cy(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=Cy(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=Cy(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=Cy(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=ZK.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),l=$g(o=u.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=l,$g(a=c.media).call(a,(function(e){var t,r,n,i;"video"===e.type&&(ZU?(e.ext=null===(t=e.ext)||void 0===t?void 0:Cy(t).call(t,(function(e){var t;return-1===kI(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Cy(r).call(r,(function(e){return"goog-remb"!==e.type}))):(e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:Cy(n).call(n,(function(e){return"transport-cc"!==e.type})),e.ext=null===(i=e.ext)||void 0===i?void 0:Cy(i).call(i,(function(e){var t;return-1===kI(t=e.uri).call(t,"transport")}))))})),$U&&RX(c),e.next=12,this.setRemoteDescription(ZK.write(c));case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Ug(Dg().mark((function e(){var t,r,n,i,o;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ZK.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=Cy(n=i.media).call(n,(function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,o.push("".concat(e.mid)),!0)})),$U&&RX(i),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:ZK.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=Ug(Dg().mark((function e(t){var r,n,i;return Dg().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=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,h,f,v,p=this;return Dg().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),l=[],e.next=9,this._peerConnection.createOffer();case 9:return d=e.sent,(h=ZK.parse(null==d?void 0:d.sdp)).media=$g(i=h.media).call(i,(function(e){return u[e.mid]&&(e=mX(e)),"inactive"!==e.direction&&l.push(e.mid),Zd(Zd({},e),p.peer._offerIce)})),f=ZK.parse(null===(o=this._peerConnection.remoteDescription)||void 0===o?void 0:o.sdp),v={},f.media.forEach((function(e){void 0!==e.mid&&(v[e.mid]=e)})),f.media=$g(a=h.media).call(a,(function(e){return"inactive"===e.direction?e:v[e.mid]})),h.groups&&f.groups&&(h.groups[0].mids=l.join(" "),f.groups[0].mids=l.join(" ")),e.next=19,this.setLocalDescription(ZK.write(h));case 19:return e.next=21,this.setRemoteDescription(ZK.write(f));case 21:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Ug(Dg().mark((function e(){return Dg().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=ZK.parse(e);r.media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)})),$U&&RX(r)}}]),l}(JX),sY=(Jd(qX={},HX.ICE_FAILED,hh.ICE_FAILED),Jd(qX,HX.DC_ERROR,hh.ICE_FAILED),Jd(qX,HX.DC_CLOSE,hh.ICE_FAILED),Jd(qX,HX.NODE_CHANGE,hh.NODE_CHANGE),Jd(qX,HX.NOTIFY_RECONNECT,hh.NOTIFY_RECONNECT),Jd(qX,HX.JOIN_TIMEOUT,hh.JOIN_TIMEOUT),qX),cY=function(e){BA(r,e);var t=nC(r);function r(e){var n;return Hh(this,r),Jd(uA(n=t.call(this)),"_connectionManager",void 0),Jd(uA(n),"_dataChannelSignal",void 0),Jd(uA(n),"_state",void 0),Jd(uA(n),"_connectionLostTimer",void 0),Jd(uA(n),"_isReconnecting",!1),Jd(uA(n),"logger",void 0),n._ctx=e,n.logger=new hD("SignalingManager",1,e.id),n.logger.info("constructor","invoke"),n._connectionManager=new GX(e),n._addConnectorHandler(),n}return jh(r,[{key:"connect",value:function(){var e=this;return this.isConnected()?Gg.resolve():new Gg((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.startup()}))}},{key:"reconnect",value:function(e,t){this._connectionManager.reconnect(e,t)}},{key:"sendSignaling",value:function(e,t,r,n){if(!this._dataChannelSignal)throw new _w(dw.NOT_CONNECTED_YET,"signaling channel is not connected");return this._dataChannelSignal.sendSignaling(e,t,r,n)}},{key:"sendP2PMessage",value:function(e){if(!this._dataChannelSignal)throw new _w(dw.NOT_CONNECTED_YET,"signaling channel is not connected");return this._dataChannelSignal.sendP2PMessage(e)}},{key:"destroy",value:function(){var e,t;this.logger.info("destroy()"),this._clearConnectionLostTimer(),this._connectionManager.shotdown(),null===(e=this._ctx.handler)||void 0===e||e.destroy(),this._ctx.handler=void 0,null===(t=this._dataChannelSignal)||void 0===t||t.destroy(),this._setState(dh.CONNECTION_STATE_DISCONNECTED),this.removeAllListeners()}},{key:"isConnected",value:function(){return this._state===dh.CONNECTION_STATE_CONNECTED||this._state===dh.CONNECTION_STATE_RECONNECTED}},{key:"isReconnecting",value:function(){return this._state===dh.CONNECTION_STATE_CONNECTING||this._state===dh.CONNECTION_STATE_RECONNECTING}},{key:"_setState",value:function(e,t){if(this._state!==e){this._state=e;var r={state:e};t&&(r.reason=sY[t]||hh.ICE_FAILED),this.safeEmit(IU.ON_CONNECTION_STATE_CHANGE,r)}}},{key:"_addConnectorHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n,i;e.logger.info("connectStateChange","connected"),e._clearConnectionLostTimer(),null===(r=e._dataChannelSignal)||void 0===r||r.destroy(),e._ctx.peerConnection=t.pc,e._ctx.handler=(n=e._ctx,i=t.pc,yD?new aY(n,i):new iY(n,i)),e._dataChannelSignal=t.signaling,e._addSignalEventHandler(),e._setState(e._isReconnecting?dh.CONNECTION_STATE_RECONNECTED:dh.CONNECTION_STATE_CONNECTED)})),this._connectionManager.on("disconnected",(function(t){e._clearConnectionLostTimer(),e._setState(dh.CONNECTION_STATE_DISCONNECTED),e.logger.error("connectStateChange","disconnected. %o",t.message),e._isReconnecting&&e.safeEmit(IU.ON_RECONNECT_FAILED)})),this._connectionManager.on("connecting",(function(){e._isReconnecting=!1,e._ctx.handler=void 0,e._setState(dh.CONNECTION_STATE_CONNECTING),e.logger.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(t){e._setState(dh.CONNECTION_STATE_DISCONNECTED,t),e._connectionLostTimer||(e._connectionLostTimer=window.setTimeout((function(){e.safeEmit(IU.ON_CONNECTION_STATE_CHANGE,{state:dh.CONNECTION_STATE_LOST})}),1e4)),e._isReconnecting=!0,e._ctx.handler=void 0,e._setState(dh.CONNECTION_STATE_RECONNECTING,t),e.logger.warn("connectStateChange","reconnecting")})),this._connectionManager.on("connectWidthTcp",(function(){e.safeEmit(IU.CONNECT_WITH_TCP)})),["__onGetIceConfigHook","__onIceConnectSuccessHook","__onConnectSuccessHook"].forEach((function(t){e._connectionManager.on(t,(function(){for(var r,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return e.emit.apply(e,Hg(r=[t]).call(r,i))}))}))}},{key:"_clearConnectionLostTimer",value:function(){this._connectionLostTimer&&(clearTimeout(this._connectionLostTimer),delete this._connectionLostTimer)}},{key:"_addSignalEventHandler",value:function(){var e,t,r=this;[kU.ON_ADD_STREAM,kU.ON_ADD_STREAM_LIST,kU.ON_REMOVE_STREAM,kU.ON_REMOVE_STREAM_LIST,kU.USER_CONNECTION,kU.USER_CONNECTION_LIST,kU.USER_DISCONNECTION,kU.USER_DISCONNECTION_LIST,kU.ON_UPDATE_STREAM_ATTRIBUTES,kU.ON_UPDATE_ROOM_ATTRIBUTES,kU.ON_PUSH_TRACK,kU.ON_REMOVE_TRACK,kU.ON_CUSTOM_MESSAGE,kU.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,kU.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,kU.USER_MESSAGE_RECEIVED,kU.USER_BINARY_MESSAGE_RECEIVED,kU.POST_PROCESSING_MESSAGE,kU.ON_USER_TOKEN_WILL_EXPIRE,kU.ON_TOKEN_PUBLISH_PRIVILEGE_WILL_EXPIRE,kU.ON_TOKEN_PUBLISH_PRIVILEGE_DID_EXPIRED,kU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_WILL_EXPIRE,kU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_DID_EXPIRED,kU.STREAM_CONTROL_MESSAGE,kU.ON_UPDATE_USER_ATTRIBUTES,kU.ON_SPEAKER_CHANGE,kU.ON_STREAM_FAILED,kU.ON_FORWARD_DST_ROOM_USER_KICK,TU.RSCP,TU.RTT,TU.SSC].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(kU.NODE_CHANGE,(function(e){r._connectionManager.reconnectByNodeChange(e)})),null===(t=this._dataChannelSignal)||void 0===t||t.on(kU.ON_NOTIFY_RECONNECT,(function(){r._connectionManager.reconnect(HX.NOTIFY_RECONNECT)}))}}]),r}(yU),uY=new hD("Locker",2),lY=1,dY=function(){function e(t){var r;Hh(this,e),Jd(this,"lockingPromise",Gg.resolve()),Jd(this,"locks",0),Jd(this,"name",""),Jd(this,"lockId",void 0),Jd(this,"closeReason",void 0),this.lockId=lY++,t&&(this.name=t),uY.info(Hg(r="lock-".concat(this.name,"-")).call(r,this.lockId),"is created.")}return jh(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r=this;this.locks+=1,uY.info(Hg(e="lock-".concat(this.name,"-")).call(e,this.lockId),"locked, current queue ".concat(this.locks,"."));var n=new Gg((function(e){t=function(){var t;r.locks-=1,uY.info(Hg(t="lock-".concat(r.name,"-")).call(t,r.lockId),"unlocked, current queue ".concat(r.locks,".")),e()}})),i=this.lockingPromise.then((function(){return t}));return this.lockingPromise=this.lockingPromise.then((function(){return n})),i}}]),e}(),hY=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(hY||{}),fY=function(e){return e.RECONNECT="ice-reconnect",e.LEAVE="leave_room",e}(fY||{}),vY=function(){function e(t,r,n){var i,o;Hh(this,e),Jd(this,"avSync",!0),Jd(this,"streamRTT",{}),Jd(this,"useCloudProxy",!1),Jd(this,"audioProfileManager",void 0),Jd(this,"userPriority",new hT),Jd(this,"expectedIDC",void 0),Jd(this,"joinRoomConfig",void 0),Jd(this,"signalingManager",void 0),Jd(this,"peerConnection",void 0),Jd(this,"pubSubLock",new dY("pubSubLock")),Jd(this,"visibility",!0),Jd(this,"serverConfig",void 0),Jd(this,"mediaParams",void 0),Jd(this,"activeSimStreams",void 0),Jd(this,"subscribeFallbackOption",void 0),Jd(this,"joinRoomParams",void 0),Jd(this,"isPreConnection",!1),Jd(this,"_handler",void 0),Jd(this,"_monitor",void 0),Jd(this,"_businessId",void 0),Jd(this,"_userStreamConfig",new hT),Jd(this,"_localAudioTrackDumpConfig",(Jd(i={},ch.STREAM_INDEX_MAIN,{callback:void 0,frameSize:void 0}),Jd(i,ch.STREAM_INDEX_SCREEN,{callback:void 0,frameSize:void 0}),i)),Jd(this,"_remoteAudioTrackDumpConfig",(Jd(o={},ch.STREAM_INDEX_MAIN,new hT),Jd(o,ch.STREAM_INDEX_SCREEN,new hT),o)),this.id=t,this.appId=r,this._monitor=HM(t),this.expectedIDC=null==n?void 0:n.expectedIDC,this.audioProfileManager=new YK(r),this.joinRoomConfig=new nL(t),this.signalingManager=new cY(this)}return jh(e,[{key:"businessId",get:function(){return this._businessId},set:function(e){var t;this._businessId=e,null===(t=this._monitor)||void 0===t||t.set({rtc_business_id:e})}},{key:"handler",get:function(){return this._handler},set:function(e){var t;e&&this.resetPubSubLock("ice-reconnect"),null===(t=this._handler)||void 0===t||t.destroy(),this._handler=e}},{key:"role",get:function(){return this.visibility?hY.NORMAL_USER:hY.SILENT_USER}},{key:"resetPubSubLock",value:function(e){this.pubSubLock.closeReason=e,this.pubSubLock=new dY("pubSubLock")}},{key:"setUserStreamConf",value:function(e,t,r){var n=this._userStreamConfig.get(e)||{},i=n[t]||{};n[t]=Zd(Zd({},i),r),this._userStreamConfig.set(e,n)}},{key:"getRemoteMirrorType",value:function(e,t){var r,n;return!(null===(r=this._userStreamConfig.get(e))||void 0===r||null===(n=r[t])||void 0===n||!n.mirrorType)}},{key:"destroy",value:function(){var e,t;this.signalingManager.destroy(),null===(e=this.handler)||void 0===e||e.destroy(),this.userPriority.clear(),this.avSync=!0,this._localAudioTrackDumpConfig=(Jd(t={},ch.STREAM_INDEX_MAIN,{callback:void 0,frameSize:void 0}),Jd(t,ch.STREAM_INDEX_SCREEN,{callback:void 0,frameSize:void 0}),t),this._remoteAudioTrackDumpConfig[ch.STREAM_INDEX_MAIN].clear(),this._remoteAudioTrackDumpConfig[ch.STREAM_INDEX_SCREEN].clear()}}]),e}();function pY(e,t,r){var n=r.value;return r.value=Ug(Dg().mark((function e(){var t,r,i,o,a,s,c,u=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ctx.pubSubLock.lock();case 2:if(r=e.sent,"chrome"===(null===(t=this._ctx.handler)||void 0===t?void 0:t.name)&&r(),e.prev=4,!(i=this._ctx.pubSubLock.closeReason)){e.next=8;break}throw new _w(dw.UNEXPECTED_ERROR,i);case 8:for(o=u.length,a=new Array(o),s=0;s<o;s++)a[s]=u[s];return e.next=11,n.apply(this,a);case 11:return e.abrupt("return",e.sent);case 12:return e.prev=12,"chrome"!==(null===(c=this._ctx.handler)||void 0===c?void 0:c.name)&&r(),e.finish(12);case 15:case"end":return e.stop()}}),e,this,[[4,,12,15]])}))),r}var _Y=qU(),mY=function(e){BA(s,e);var t,r,n,i,o,a=nC(s);function s(e,t){var r;return Hh(this,s),Jd(uA(r=a.call(this,e,t)),"_peerConnectionId",RL()),Jd(uA(r),"peerConnectionMode",1),Jd(uA(r),"name","vendor"),Jd(uA(r),"direction","up"),Jd(uA(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 jh(s,[{key:"publish",value:(o=Ug(Dg().mark((function e(t){var r,n,i,o,a,c,u,l,d,h,f=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.enableSimulcast=!1,this.stream=t,r=VA(UA(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),_Y&&(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=AL(),l=ZK.parse(c.sdp),Array.isArray(l.media)&&(l.media=$g(d=l.media).call(d,(function(e){var r,n,i,o,a;if("video"===e.type)null!==(r=f._context)&&void 0!==r&&null!==(n=r.serverConfig)&&void 0!==n&&n.videoCodec&&TX(e,null===(i=f._context)||void 0===i||null===(o=i.serverConfig)||void 0===o?void 0:o.videoCodec),(SD||PD)&&Array.isArray(e.ext)&&(e.ext=Cy(a=e.ext).call(a,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&Qy(t).call(t,"video-orientation"))}))),SD||f.addBitrateLimit(e,t.videoEncodeConfig[0].maxKbps);else if("audio"===e.type){var s,c=null==e?void 0:lI(s=e.rtp).call(s,(function(e){return"opus"===e.codec}));if(c&&e.fmtp){var u,l,d=lI(u=e.fmtp).call(u,(function(e){return e.payload===c.payload}));d&&null!==(l=f._context)&&void 0!==l&&l.audioProfileManager&&(d.config=f._context.audioProfileManager.getOpusConfigStr(d.config))}}return e}))),h={type:"offer",sdp:ZK.write(l)},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:AL()-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:AL()-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=Ug(Dg().mark((function e(t){var r,n,i,o,a,s=this;return Dg().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"}),_Y&&(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=AL(),i=ZK.parse(r.sdp),Array.isArray(i.media)&&(i.media=$g(o=i.media).call(o,(function(e){if("audio"===e.type){var t,r=null==e?void 0:lI(t=e.rtp).call(t,(function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n,i=null==e?void 0:lI(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={type:"offer",sdp:ZK.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:AL()-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:AL()-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=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.action!==$X.publish&&t.action!==$X.subscribe){e.next=16;break}return n={sdp:null===(r=t.signalingAck)||void 0===r?void 0:r.sdp,type:"answer"},i=AL(),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:AL()-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:AL()-i},{type:"offer"}),e.t0;case 13:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=17;break;case 16:t.action!==$X.unpublish&&t.action!==$X.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(),VA(UA(s.prototype),"destroy",this).call(this)}},{key:"getDefaultSdp",value:(r=Ug(Dg().mark((function e(){return Dg().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=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{this._peerConnection&&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}(JX),gY=fT,yY=WI,SY=function(e,t,r,n){for(var i,o=n>1?void 0:n?yY(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&&gY(t,r,o),o},bY=function(e){BA(c,e);var t,r,n,i,o,a,s=nC(c);function c(e,t){var r;return Hh(this,c),Jd(uA(r=s.call(this)),"_logger",void 0),Jd(uA(r),"_pubBackOff",new hT),r._ctx=e,r._roomConf=t,r._logger=new hD("RoomPublisher",2,e.id),r}return jh(c,[{key:"publish",value:(a=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R,A,C,w,x,O,N=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._logger.info("publish()","localStream: %o",t),p=t.videoTrack,_=t.audioTrack,m=AL(),g="",y="",S=this._ctx.handler,"H264"!==(null===(r=this._ctx.serverConfig)||void 0===r?void 0:r.videoCodec)){e.next=17;break}return e.next=10,WU();case 10:if(e.sent){e.next=17;break}if("VP8"!==lL("FALLBACK_ENCODE_CODEC")){e.next=16;break}this._ctx.serverConfig.videoCodec="VP8",e.next=17;break;case 16:throw new _w(dw.PUBLISH_FAILED,"h264 is not supported");case 17:if(!this._roomConf.vendorConfig.enableMultiVendor){e.next=26;break}return e.next=20,this._getVendorPubSdpInfo(t);case 20:E=e.sent,k=Ey(E,2),S=k[0],b=k[1],e.next=29;break;case 26:return e.next=28,this._ctx.handler.publish(t);case 28:b=e.sent;case 29:return this.emit("_test_pub_sdpInfo_",b),g=b.audioMid,y=b.videoMid,t.pubAttributes={localaudio:!!_,localvideo:!!p,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:(null==p?void 0:p.sourceType)===Jz.EXTERNAL,extaudio:(null==_?void 0:_.sourceType)===Jz.EXTERNAL,videoDescriptions:b.videoDescriptions,videoType:CU.NORMAL},T={attributes:Zd({},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:g,videoMid:y,sdpInfo:{msid:t.stream.id,type:b.type,sdp:b.partialSdp,semantics:b.semantics},peerConnectionMode:null===(n=b)||void 0===n?void 0:n.peerConnectionMode,supportMultiVendor:!0},((I=!this._roomConf.vendorConfig.enableMultiVendor&&t.enableSimulcast&&(null===(i=this._ctx.serverConfig)||void 0===i?void 0:i.simulcastOnDemand)&&(null===(o=b.subVideoDescriptions)||void 0===o?void 0:o.length))||null!==(a=this._ctx.serverConfig)&&void 0!==a&&a.e2eFeedback)&&(T.attributes.subVideoDescriptions=b.subVideoDescriptions),null!==(s=b)&&void 0!==s&&s.peerConnectionId&&(T.peerConnectionId=b.peerConnectionId),e.prev=37,this.emit("_test_pub_body_",T),e.next=41,this._ctx.signalingManager.sendSignaling("publish",T);case 41:R=e.sent,e.next=70;break;case 44:return e.prev=44,e.t0=e.catch(37),e.t0 instanceof Error?this._roomConf.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:m,message:Hg(C="".concat(e.t0.name,": ")).call(C,e.t0.message)}):e.t0 instanceof _w&&this._roomConf.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:m,message:Hg(w="".concat(e.t0.code,": ")).call(w,e.t0.message)}),e.next=49,null===(A=S)||void 0===A?void 0:A.rollback({msid:t.stream.id,stream:t,audioMid:g,videoMid:y});case 49:if(!(e.t0.code>=500&&e.t0.code<600)){e.next=67;break}if(this.emit("_test_pub_5xx_"),!((x=this._getPubBackOff(t.id)).retryDuration<6e4)){e.next=63;break}return this._logger.info("pubRetry",t.id,x.retryDuration),e.next=56,new Gg((function(e){return setTimeout(e,x.interval)}));case 56:return x.retryDuration+=x.interval,x.interval=x.interval>4e3?8e3:2*x.interval,t.resetStream(),this.emit(sK.PUB_RETRY,{screen:t.isScreen}),e.abrupt("return",this.publish(t));case 63:this._logger.info("pubRetry","end"),this._pubBackOff.delete(t.id);case 65:e.next=69;break;case 67:if(403!==e.t0.code){e.next=69;break}throw new _w(dw.TOKEN_NO_PUBLISH_PERMISSION,e.t0.message||"token no publish permission");case 69:throw e.t0;case 70:if(this._roomConf.report("rtc_recv_answer",{error_code:0,answer_type:null===(c=R)||void 0===c?void 0:c.relayMessage.type,sequence_id:(null===(u=R)||void 0===u||null===(l=u.relayMessage)||void 0===l?void 0:l.sequenceId)||0,message:null===(d=R)||void 0===d||null===(h=d.relayMessage)||void 0===h?void 0:h.sdp,direction:"up",stream_id:"",stream_user_id:"",pc_session_id:(null===(f=S)||void 0===f?void 0:f.peerConnectionId)||""}),O=new Gg((function(e,r){var n,i,o,a,s,c,u,l;null===(n=S)||void 0===n||n.handleAck({action:$X.publish,streamId:R.streamId,audioMid:g,videoMid:y,audioTransceiverInit:null===(i=b)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=b)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:{sdp:null===(a=R)||void 0===a||null===(s=a.relayMessage)||void 0===s?void 0:s.sdp,sequenceId:null===(c=R)||void 0===c||null===(u=c.relayMessage)||void 0===u?void 0:u.sequenceId},sdp:null===(l=b)||void 0===l?void 0:l.sdp,stream:t,onSuccess:function(){N._logger.info("publish()","publish success"),e(0)},onFail:function(e){N._logger.info("publish()","publish fail"),r(e)}})})),e.t1=!yD,!e.t1){e.next=76;break}return e.next=76,O;case 76:this.emit("___afterHandleAckInPub"),(I||null!==(v=this._ctx.serverConfig)&&void 0!==v&&v.e2eFeedback)&&this.emit(TU.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}],!0),t.streamId=R.streamId,t.videoMid=y,t.audioMid=g,t.subVideoDescriptions=b.subVideoDescriptions,this._roomConf.report("rtc_publish_stat",{result:"success",is_screen:"0",start:m,message:"unknown"});case 83:case"end":return e.stop()}}),e,this,[[37,44]])}))),function(e){return a.apply(this,arguments)})},{key:"updatePubTrack",value:(o=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R,A,C,w;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._logger.info("updatePubTrack()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,i=t.pubAudio,o=t.pubVideo,a=t.vendorHandler||this._ctx.handler,s=null==n?void 0:n.preprocessingTrack,c=null==r?void 0:r.preprocessingTrack,!o||!c){e.next=12;break}return t.stopBlackFrame(),e.next=9,null===(u=t.videoTransceiver)||void 0===u?void 0:u.sender.replaceTrack(c);case 9:this._updateVideoDescriptions(t),e.next=14;break;case 12:return e.next=14,null===(l=t.videoTransceiver)||void 0===l?void 0:l.sender.replaceTrack(null);case 14:if(null==a||a.updateMaxBitrate(t),!i||!s){e.next=22;break}return h=n.mixType,(f=n.mixedAudioTrack)&&h!==Lh.PLAYOUT&&s.enabled&&(s=f),e.next=20,null===(d=t.audioTransceiver)||void 0===d?void 0:d.sender.replaceTrack(s);case 20:e.next=25;break;case 22:return e.next=24,null===(v=t.audioTransceiver)||void 0===v?void 0:v.sender.replaceTrack(null);case 24:this._ctx.id;case 25:this.emit("___onAfterReplaceTrack");try{this._ctx.id,Xg({audioStreamTrack:gx(s),videoStreamTrack:gx(c)})}catch(KJ){}for(p={localaudio:!!n,localvideo:!!r,videostream:o,audiostream:i,extvideo:(null==r?void 0:r.sourceType)===Jz.EXTERNAL,extaudio:(null==n?void 0:n.sourceType)===Jz.EXTERNAL,videoType:r?CU.NORMAL:t.pubAttributes.videoType},_={},m=0,g=VS(p);m<g.length;m++)y=Ey(g[m],2),S=y[0],(b=y[1])!==VK(t.pubAttributes,S)&&XK(_,S,b);if(FS(_).length){e.next=32;break}return e.abrupt("return");case 32:return t.observer&&(E=t.observer,k=_.audiostream,T=_.videostream,I=_.localaudio,R=_.localvideo,A=_.extaudio,C=_.extvideo,void 0!==R?void 0!==C?E.setPushVideo(C):E.setEnableVideo(R):void 0!==T&&E.setUnmuteVideo(T),void 0!==I?void 0!==A?E.setPushAudio(A):E.setEnableAudio(I):void 0!==k&&E.setUnmuteAudio(k)),t.pubAttributes=Zd(Zd({},t.pubAttributes),p),t.pubAttributes.videostream||t.stopBlackFrame(),w={roomId:this._roomConf.roomId,streamId:t.streamId,attributes:_},e.next=38,this._ctx.signalingManager.sendSignaling("updateStreamAttributes",w);case 38:if(this.emit("___onAfterUpdateSignaling"),!yD){e.next=42;break}return e.next=42,null==a?void 0:a.setCurrentDescription();case 42:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"unpublish",value:(i=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._logger.info("unpublish()","localStream: %o",t),r={roomId:this._roomConf.roomId,initStreamId:t.initStreamId,streamId:t.streamId},this._ctx.signalingManager.sendSignaling("unpublish",r),n=t.vendorHandler||this._ctx.handler,t.stopBlackFrame(),e.next=7,null==n?void 0:n.handleAck({action:$X.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 7:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"updatePubBlackFrame",value:(n=Ug(Dg().mark((function e(t){var r,n,i,o=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=t.genBlackFrame()){e.next=3;break}return e.abrupt("return");case 3:null===(r=t.videoTransceiver)||void 0===r||null===(n=r.sender)||void 0===n||n.replaceTrack(i),t.pubAttributes.videoType=CU.BLACK,this._ctx.signalingManager.sendSignaling("updateStreamAttributes",{roomId:this._roomConf.roomId,streamId:t.streamId,attributes:{videoType:CU.BLACK}}),t.on("black-frame-ended",(function(){var e,r;null===(e=t.videoTransceiver)||void 0===e||null===(r=e.sender)||void 0===r||r.replaceTrack(null),t.pubAttributes.videoType=CU.NORMAL,o._ctx.signalingManager.sendSignaling("updateStreamAttributes",{roomId:o._roomConf.roomId,streamId:t.streamId,attributes:{videoType:CU.NORMAL}})}));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"destroy",value:function(e){var t=this;e.forEach((function(e){var r;e&&e.hasPublished&&(null===(r=t._ctx.handler)||void 0===r||r.handleAck({action:$X.unpublish,audioMid:e.audioMid,videoMid:e.videoMid,stream:e,streamId:e.streamId}))})),this._pubBackOff.clear(),VA(UA(c.prototype),"removeAllListeners",this).call(this)}},{key:"_updateVideoDescriptions",value:(r=Ug(Dg().mark((function e(t){var r,n,i,o;return Dg().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!=(i=null===(r=t.videoTrack)||void 0===r||null===(n=r.preprocessingTrack)||void 0===n?void 0:n.getSettings())&&i.width&&null!=i&&i.height&&null!=i&&i.frameRate){e.next=5;break}return e.abrupt("return");case 5:if(o=t.pubAttributes.videoDescriptions[0],i.width!==o.width||i.height!==o.height||i.frameRate!==o.framerate){e.next=8;break}return e.abrupt("return");case 8:o.width=i.width,o.height=i.height,o.framerate=i.frameRate,o.maxkbps=t.videoEncodeConfig[0].maxKbps||o.maxkbps,this._ctx.signalingManager.sendSignaling("updateStreamAttributes",{roomId:this._roomConf.roomId,streamId:t.streamId,attributes:{videoDescriptions:[o]}});case 13:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_getVendorPubSdpInfo",value:(t=Ug(Dg().mark((function e(t){var r,n,i,o=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new PX(this._ctx,""),t.vendorHandler=new mY(this._ctx,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(IU.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:dh.CONNECTION_STATE_CONNECTING,connected:dh.CONNECTION_STATE_CONNECTED,disconnected:dh.CONNECTION_STATE_RECONNECTING}[e],userId:o._roomConf.userId})})),i.once("disconnect",Ug(Dg().mark((function e(){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i.removeAllListeners(),"connected"===(null===(r=o._ctx.peerConnection)||void 0===r?void 0:r.getIceConnectionState())){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 t.apply(this,arguments)})},{key:"_getPubBackOff",value:function(e){return this._pubBackOff.has(e)||this._pubBackOff.set(e,{interval:1e3,retryDuration:0}),this._pubBackOff.get(e)}}]),c}(yU);SY([pY,OK],bY.prototype,"publish",1),SY([pY,OK],bY.prototype,"updatePubTrack",1),SY([pY,OK],bY.prototype,"unpublish",1),SY([OK],bY.prototype,"updatePubBlackFrame",1),SY([OK],bY.prototype,"_updateVideoDescriptions",1);var EY,kY=fT,TY=WI,IY=function(e,t,r,n){for(var i,o=n>1?void 0:n?TY(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&&kY(t,r,o),o},RY=function(e){BA(f,e);var t,r,n,i,o,a,s,c,u,l,d,h=nC(f);function f(e,t){var r;return Hh(this,f),Jd(uA(r=h.call(this)),"_logger",void 0),Jd(uA(r),"_subBackOff",new hT),Jd(uA(r),"_subResolves",{}),Jd(uA(r),"_ontrackCallbackMap",new hT),r._ctx=e,r._roomConf=t,r._logger=new hD("RoomSubscriber",2,e.id),r}return jh(f,[{key:"subscribe",value:(d=Ug(Dg().mark((function e(t,r,n){return Dg().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 d.apply(this,arguments)})},{key:"_subscribe",value:(l=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R,A,C,w,x,O,N,P,M,D,L,U,V,F,B,j,H,G,z,W,K,X,Y,q,J,Q=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._logger.info("subscribe()","mediaType: %o",r),xK("subscribe()",t,this._logger),t.streamState=iK.SUB_ING,k=!1,T=!1,VL(r)&&(T=!0),FL(r)&&(k=!0),k||!this._roomConf.isMultiChatMode()){e.next=9;break}return t.streamState=iK.INIT,e.abrupt("return");case 9:if(I=AL(),R=t.subVideo,A=[],this._subResolves[t.streamId]||(this._subResolves[t.streamId]=[]),A.push(new Gg((function(e,r){Q._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new _w(dw.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),wK);t.on("ontrack",(function r(i){"video"===i.mediaType&&(Q._logger.info("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),this._roomConf.isMultiChatMode()||A.push(new Gg((function(e,r){Q._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new _w(dw.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),wK);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(Q._logger.info("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),C=function(e){t.ontrack(e)},null===(i=this._ctx.handler)||void 0===i||i.on("ontrack",C),this._ontrackCallbackMap.set(t,C),w=this._ctx.handler,null!==(o=this._ctx.serverConfig)&&void 0!==o&&o.forceUniHandler||!t.enableVendorMode){e.next=28;break}return e.next=22,this._getVendorSubSdpInfo(t,C);case 22:O=e.sent,N=Ey(O,2),w=N[0],x=N[1],e.next=31;break;case 28:return e.next=30,this._ctx.handler.subscribe(t,{multiChatMode:this._roomConf.isMultiChatMode()});case 30:x=e.sent;case 31:if(M=(P=x).audioMid,D=P.videoMid,t.subVideo=k,L={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},U={audio:!this._roomConf.isMultiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:D,audioMid:M,sdpInfo:{sdp:null===(a=x)||void 0===a?void 0:a.partialSdp,semantics:null===(s=x)||void 0===s?void 0:s.semantics,type:null===(c=x)||void 0===c?void 0:c.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!this._roomConf.isMultiChatMode()||T,video:k},qualityLayer:L},extra:{enableSendRTT:!0},peerConnectionMode:null===(u=x)||void 0===u?void 0:u.peerConnectionMode,supportMultiVendor:!0},null!==(l=x)&&void 0!==l&&l.peerConnectionId&&(U.peerConnectionId=x.peerConnectionId),V=this._ctx,F=V.subscribeFallbackOption,B=V.userPriority,"number"==typeof F&&(U.config.fallbackOption=F),B.has(t.userId)&&(U.config.priority=B.get(t.userId)),null!==(d=x)&&void 0!==d&&d.allSsrc&&(U.extra.subscribeSSRC=x.allSsrc),null===(h=x)||void 0===h||!h.signalingAck){e.next=43;break}return e.next=43,new Gg((function(e,r){var n,i,o,a;null===(n=w)||void 0===n||n.handleAck({action:$X.subscribe,streamId:t.streamId,audioMid:M,videoMid:D,audioTransceiverInit:null===(i=x)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=x)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:null===(a=x)||void 0===a?void 0:a.signalingAck,stream:t,sdp:x.sdp,onSuccess:function(){Q._logger.info("ssrc","success"),e(0)},onFail:function(e){Q._logger.info("ssrc","fail",e),r(e)}})}));case 43:return e.prev=43,this.emit("_test_sub_body_",U),e.next=47,this._ctx.signalingManager.sendSignaling("subscribe",U);case 47:j=e.sent,e.next=81;break;case 50:if(e.prev=50,e.t0=e.catch(43),t.streamState=iK.INIT,e.t0 instanceof Error&&this._roomConf.report("rtc_subscribe_stat",{result:"fail",start:I,message:e.t0.message,stream_user_id:t.userId}),!(e.t0.code>=500&&e.t0.code<600)){e.next=71;break}if(this.emit("_test_sub_5xx_"),!((G=this._getSubBackOff(t.streamId)).retryDuration<6e4)){e.next=69;break}return this._logger.info("subRetry",t.streamId,G.retryDuration),e.next=61,new Gg((function(e){return setTimeout(e,G.interval)}));case 61:return G.retryDuration+=G.interval,G.interval=G.interval>4e3?8e3:2*G.interval,this.emit(sK.SUB_RETRY,{screen:t.isScreen,userId:t.userId}),e.next=66,null===(z=w)||void 0===z?void 0:z.handleAck({action:$X.unsubscribe,streamId:t.streamId,audioMid:M,videoMid:D,stream:t});case 66:return e.abrupt("return",this._subscribe(t,r,n));case 69:this._logger.info("subRetry","end",t.streamId),this._subBackOff.delete(t.streamId);case 71:return t.subVideo=R,e.next=74,null===(H=w)||void 0===H?void 0:H.rollback({msid:t.streamId,stream:t});case 74:return W={roomId:this._roomConf.roomId,streamId:t.streamId,userId:t.userId},e.next=77,this._ctx.signalingManager.sendSignaling("unsubscribe",W).catch((function(){}));case 77:if(t.streamState=iK.INIT,403!==e.t0.code){e.next=80;break}throw new _w(dw.TOKEN_NO_SUBSCRIBE_PERMISSION,e.t0.message||"token no subscribe permission");case 80:throw e.t0;case 81:if(j.relayMessage){e.next=84;break}throw this._roomConf.report("rtc_error",{error_code:-1009,message:"relayMessage is null"}),new _w(dw.UNEXPECTED_ERROR,"unable to subscribe");case 84:if(K=null!==(f=null===(v=j)||void 0===v?void 0:v.relayMessage)&&void 0!==f?f:{},X=K.audioMid,Y=K.videoMid,Jd(p={},M,X),Jd(p,D,Y),q=p,this._logger.info("sub midmap",t.userId,q),t.videoMid=D,t.audioMid=M,t.subMediaType=r,t.streamState=iK.SUB_ED,t.subLayer=L,this._roomConf.report("rtc_recv_answer",{error_code:0,answer_type:null===(_=j)||void 0===_||null===(m=_.relayMessage)||void 0===m?void 0:m.type,sequence_id:(null===(g=j)||void 0===g||null===(y=g.relayMessage)||void 0===y?void 0:y.sequenceId)||0,message:null===(S=j)||void 0===S||null===(b=S.relayMessage)||void 0===b?void 0:b.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:(null===(E=w)||void 0===E?void 0:E.peerConnectionId)||""}),e.prev=93,null!==(J=x)&&void 0!==J&&J.signalingAck){e.next=97;break}return e.next=97,new Gg((function(e,r){var n,i,o,a,s,c,u;null===(n=w)||void 0===n||n.handleAck({action:$X.subscribe,streamId:t.streamId,audioMid:M,videoMid:D,audioTransceiverInit:null===(i=x)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=x)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:{sdp:null===(a=j)||void 0===a||null===(s=a.relayMessage)||void 0===s?void 0:s.sdp,sequenceId:null===(c=j)||void 0===c||null===(u=c.relayMessage)||void 0===u?void 0:u.sequenceId},stream:t,sdp:x.sdp,onSuccess:function(){Q._logger.info("sub ack","success"),e(0)},onFail:function(e){Q._logger.info("sub ack","fail",e),r(e)}})}));case 97:return e.next=99,Gg.all(A);case 99:e.next=109;break;case 101:return e.prev=101,e.t1=e.catch(93),e.t1 instanceof Error&&this._roomConf.report("rtc_subscribe_stat",{result:"fail",start:I,message:e.t1.message,stream_user_id:t.userId}),W={roomId:this._roomConf.roomId,streamId:t.streamId,userId:t.userId},e.next=107,this._ctx.signalingManager.sendSignaling("unsubscribe",W).catch((function(){}));case 107:throw t.streamState=iK.INIT,e.t1;case 109:this._roomConf.isMultiChatMode()||(t.subAudio=T),this._roomConf.report("rtc_subscribe_stat",{result:"success",start:I,message:"unknown",stream_user_id:t.userId}),t.startReport((function(e){return Q.emit("onRemoteStreamStats",e)}),w);case 112:case"end":return e.stop()}}),e,this,[[43,50],[93,101]])}))),function(e,t,r){return l.apply(this,arguments)})},{key:"unsubscribe",value:(u=Ug(Dg().mark((function e(t){var r,n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return xK("unsubscribe()",t,this._logger),i={roomId:this._roomConf.roomId,streamId:t.streamId,userId:t.userId},o=t.vendorHandler||this._ctx.handler,this._ctx.signalingManager.sendSignaling("unsubscribe",i).catch((function(){})),t.streamState=iK.INIT,t.subVideo=!1,null===(r=t.observer)||void 0===r||r.setSubscribeVideo(!1),!this._roomConf.isMultiChatMode()&&(null===(n=t.observer)||void 0===n||n.setSubscribeAudio(!1)),e.next=10,null==o?void 0:o.handleAck({action:$X.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:a=e.sent,this._subResolves[a]&&this._subResolves[a].forEach((function(e){return e(0)})),this._logger.info("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),t.subMediaType=iV.NONE,this._removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(c=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,l;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(xK("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)&uh.AUDIO),l=!!(c&uh.VIDEO),e.next=10,null===(i=this._ctx.handler)||void 0===i?void 0:i.handleAck({action:$X.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(!l),t.subVideo=!l,t.subMediaType=t.subMediaType-(t.subMediaType&c),t.virtual&&(t.clean(),t.resetHasSubscribed(),t.statsReport.unsubscribe());case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return c.apply(this,arguments)})},{key:"handleRemoveStream",value:(s=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(xK("handleRemoveStream()",t,this._logger),t.subVideo=!1,t.streamState!==iK.INIT){e.next=4;break}return e.abrupt("return");case 4:return e.abrupt("return",this.unsubscribe(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"_removeOnTrackListener",value:function(e){var t=this._ontrackCallbackMap.get(e);if(t){var r=e.vendorHandler||this._ctx.handler;null==r||r.off("ontrack",t),this._ontrackCallbackMap.delete(e)}}},{key:"_getVendorSubSdpInfo",value:(a=Ug(Dg().mark((function e(t,r){var n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new PX(this._ctx,""),t.vendorHandler=new mY(this._ctx,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(IU.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",Ug(Dg().mark((function e(){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==i||i.removeAllListeners(),"connected"===(null===(r=a._ctx.peerConnection)||void 0===r?void 0:r.getIceConnectionState())){e.next=4;break}return a._logger.info("vendor ice failed",t.streamId),e.abrupt("return");case 4:return n=t.subMediaType,e.next=7,a.unsubscribe(t);case 7:return e.next=9,a.subscribe(t,n);case 9:t.vendorHandler&&t.statsReport.setVar(t.vendorHandler),a.emit(sK.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 a.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(o=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._logger.info("subscribe4pushTrack()","streamInfo: %o",r),xK("subscribe4pushTrack()",t,this._logger),t.subAudio=!0,e.next=5,null===(n=this._ctx.handler)||void 0===n?void 0:n.subscribe(t,{multiChatMode:this._roomConf.isMultiChatMode()});case 5:if(a=e.sent){e.next=8;break}throw new _w(dw.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 8:return s=a.audioMid,c=a.videoMid,(u=[]).push(new Gg((function(e,r){var n=setTimeout((function(){return r(new _w(dw.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),wK);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(d._logger.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),l=function(e){t.ontrack(e)},null===(i=this._ctx.handler)||void 0===i||i.on("ontrack",l),this._ontrackCallbackMap.set(t,l),e.next=17,null===(o=this._ctx.handler)||void 0===o?void 0:o.handleAck({action:$X.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,Gg.all(u);case 19:t.startReport((function(e){return d.emit("onRemoteStreamStats",e)}),this._ctx.handler);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"updateUserAttributes",value:(i=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._logger.info("updateUserAttributes()","attributes: %o",t),e.next=3,this._ctx.signalingManager.sendSignaling("updateUserAttributes",{roomId:this._roomConf.roomId,sessionId:this._roomConf.sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(n=Ug(Dg().mark((function e(t,r){var n;return Dg().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 n={roomId:this._roomConf.roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,this._ctx.signalingManager.sendSignaling("updateSubscribe",n);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 n.apply(this,arguments)})},{key:"updateSubPriority",value:(r=Ug(Dg().mark((function e(t,r){var n;return Dg().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 n={roomId:this._roomConf.roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{priority:r}},e.next=7,this._ctx.signalingManager.sendSignaling("updateSubscribe",n);case 7:return t.priority=r,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.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,l=Array.isArray(u)?u:c,d=-1,h=e.width*e.height,f=0;f<(null==l?void 0:l.length);f++){var v,p;if(h>=(null===(v=l[f])||void 0===v?void 0:v.width)*(null===(p=l[f])||void 0===p?void 0:p.height)){d=f;break}}var _=l[0];if(-1===d)_=l[d=l.length-1];else if(0!==d){var m=l[d-1].width*l[d-1].height,g=(m-h)/(m-l[d].width*l[d].height);_=g<.1?l[d-1]:l[d],d=g<.1?d-1:d}return a=null!==(r=null===(n=_)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=_)||void 0===o?void 0:o.video_index)&&void 0!==i?i:d,spatialSubLayer:a}}},{key:"updateSubMediaType",value:(t=Ug(Dg().mark((function e(t,r){var n,i,o,a,s;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=!1,o=!1,VL(r)&&(o=!0),FL(r)&&(i=!0),a={roomId:this._roomConf.roomId,streamList:[t.streamId],config:{enableMediaType:{video:i,audio:!!this._roomConf.isMultiChatMode()||o}}},e.next=6,this._ctx.signalingManager.sendSignaling("updateSubscribe",a);case 6:return this._roomConf.isMultiChatMode()||(null===(s=t.observer)||void 0===s||s.setUnmuteAudio(o),t.subAudio=o),null===(n=t.observer)||void 0===n||n.setUnmuteVideo(i),t.subVideo=i,t.subMediaType=r,e.abrupt("return",t);case 11:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(e){var t,r=this;e.forEach((function(e){e.forEach((function(e){if(e.hasSubscribed){var t=e.vendorHandler||r._ctx.handler;null==t||t.handleAck({action:$X.unsubscribe,streamId:e.streamId,audioMid:e.audioMid,videoMid:e.videoMid,stream:e})}}))})),this._subBackOff.clear(),this._ontrackCallbackMap.forEach((function(e,t){r._removeOnTrackListener(t),r._ontrackCallbackMap.delete(t)})),this._subResolves={},null===(t=this._ctx.handler)||void 0===t||t.removeAllListeners("ontrack"),VA(UA(f.prototype),"removeAllListeners",this).call(this)}},{key:"_getSubBackOff",value:function(e){return this._subBackOff.has(e)||this._subBackOff.set(e,{interval:1e3,retryDuration:0}),this._subBackOff.get(e)}}]),f}(yU);IY([pY,OK],RY.prototype,"subscribe",1),IY([pY,OK],RY.prototype,"unsubscribe",1),IY([pY,OK],RY.prototype,"unsubscribe4removeTrack",1),IY([OK],RY.prototype,"handleRemoveStream",1),IY([pY,OK],RY.prototype,"subscribe4pushTrack",1),IY([OK],RY.prototype,"updateUserAttributes",1),IY([OK],RY.prototype,"updateSubTrackLayer",1),IY([OK],RY.prototype,"updateSubPriority",1);var AY=(Jd(EY={},Th.communication,[0]),Jd(EY,Th.chat,[0]),Jd(EY,Th.chatRoom,[1,"IES_chatroom"]),Jd(EY,Th.coHost,[1,"IES_PK"]),Jd(EY,Th.meeting,[16]),Jd(EY,Th.classRoom,[0]),EY),CY=function(e){BA(a,e);var t,r,n,i,o=nC(a);function a(e,t){var r;return Hh(this,a),Jd(uA(r=o.call(this)),"_logger",void 0),Jd(uA(r),"_authorization",void 0),Jd(uA(r),"_joinRoom5xxTimer",void 0),Jd(uA(r),"_joinTask",void 0),Jd(uA(r),"_sdpInfo",void 0),r._ctx=e,r._roomConf=t,r._logger=new hD("RoomJoin",2,e.id),r._logger.info("constructor","invoke"),r}return jh(a,[{key:"join",value:function(){var e,t,r=this,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._logger.info("join()");var i=new Gg((function(i,o){e=i,t=o,r._callJoinRoom(n).catch((function(e){var t=Array.isArray(e)&&e.length>0?e[0]:e;r._joinRoomFailed(t.message)}))}));return this._joinTask&&n?this._joinTask.startTime=AL():(this._joinTask={startTime:AL(),success:e,fail:t},this._roomConf.joinPromise=i),this._reportJoinRoomStart(),i}},{key:"updateToken",value:(i=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._logger.info("updateToken()","newToken: %o",t),this._ctx.appId&&this._roomConf.userId&&this._roomConf.roomId){e.next=3;break}return e.abrupt("return");case 3:return r={roomId:this._roomConf.roomId,userId:this._roomConf.userId,appId:this._ctx.appId,token:"Bearer ".concat(t)},e.prev=4,e.next=7,this._ctx.signalingManager.sendSignaling("updateToken",r);case 7:e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(4),new _w(dw.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 12:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e){return i.apply(this,arguments)})},{key:"leave",value:(n=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._logger.info("leave()"),this._stopJoinRoom5xxRetry(),this._joinRoomFailed("leave_room"),t={Authorization:this._authorization,roomId:this._roomConf.roomId,sessionId:this._roomConf.sessionId},e.next=6,this._ready2join();case 6:if(!this._ctx.signalingManager.isConnected()){e.next=11;break}return e.next=9,this._ctx.signalingManager.sendSignaling("leaveRoom",t);case 9:e.next=12;break;case 11:return e.abrupt("return",Gg.reject(new _w(dw.NOT_CONNECTED_YET,"server not connected")));case 12:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"destroy",value:function(){this._logger.info("destroy()"),this._joinRoomFailed("leave_room"),this._authorization=void 0,this._stopJoinRoom5xxRetry(),this.removeAllListeners()}},{key:"_ready2join",value:(r=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ctx.signalingManager.connect();case 2:if(this._sdpInfo){e.next=6;break}return e.next=5,null===(t=this._ctx.handler)||void 0===t?void 0:t.getDefaultSdp();case 5:this._sdpInfo=e.sent;case 6:if(a.supportedCodecs){e.next=10;break}return e.next=9,VU();case 9:a.supportedCodecs=e.sent;case 10:return e.abrupt("return",{sdpInfo:this._sdpInfo,supportedCodecs:a.supportedCodecs});case 11:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_callJoinRoom",value:(t=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R,A,C,w,x,O,N,P=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._logger.info("_callJoinRoom","invoke"),delete this._sdpInfo,n=this._ctx,i=n.appId,o=n.role,a=n.businessId,s=n.useCloudProxy,c=n.joinRoomParams,u=n.mediaParams,e.next=5,this._ready2join();case 5:if(l=e.sent,d=l.sdpInfo,h=l.supportedCodecs,f={Authorization:wL.token2auth(i,this._roomConf.roomId,this._roomConf.userId,this._roomConf.token),sessionId:this._roomConf.sessionId,timestamp:Date.now(),controlMessage:this._roomConf.getLiveControlMessage(),userAttributes:{extra_info:this._roomConf.userInfo.extraInfo,role:o},sdpInfo:d,params:{supportedCodecs:h,deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:cL.VERSION,deviceId:tL.getDeviceId(),appId:i,roomId:this._roomConf.roomId,userId:this._roomConf.userId,businessId:a,enableCloudProxy:s,channelProfile:AY[this._roomConf.roomProfileType]?"".concat(AY[this._roomConf.roomProfileType][0]):"0"},options:{supportCheckTokenPrivilege:!0,supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0,supportMultiVendor:!0}},c)for(v=0,p=VS(c);v<p.length;v++)_=Ey(p[v],2),m=_[0],g=_[1],f.params[m]=g;return u&&(f.mediaParams=u),lL("SIGNAL_CROP_JOINROOM")&&null!==(r=f.sdpInfo)&&void 0!==r&&r.sdp&&(f.sdpInfo.sdp=IX(f.sdpInfo.sdp)),Gg.resolve().then((function(){return P.emit("onSendingJoinMessageHook")})),e.prev=14,R=t?"reconnected":"joinRoom",e.next=18,this._joinRoomWithRetry(R,f);case 18:A=e.sent,this._logger.success("join","send join message success"),C=A.config||{},w=C.engine_WEB,x=C._abtest_vid,this._authorization=f.Authorization,tL.setEngineWebConfig(this._ctx.appId,this._roomConf.roomId,w),this._ctx.serverConfig={videoCodec:(null==w?void 0:w.video_codec)||"H264",audioRed:!(null==w||!w.pub_audio_red),muteReplaceUnsub:!(null===(y=A.config)||void 0===y||!y.mute_replace_unsub),simulcastOnDemand:!(!1===(null===(S=A.config)||void 0===S||null===(b=S.engine_VPM)||void 0===b||null===(E=b.ondemand)||void 0===E?void 0:E.enable)),forceUniHandler:1===(null===(k=A.config)||void 0===k||null===(T=k.vendor_param)||void 0===T?void 0:T.vendor_stream_sub_mode),e2eFeedback:null==w?void 0:w.e2e_feedback},"boolean"==typeof(null==w?void 0:w.av_sync)&&(this._ctx.avSync=w.av_sync),this._roomConf.rtcVid=x,A.vendorConfig&&this._roomConf.setVendorConfig(A.vendorConfig),Yz.setAudioStallConfig(w),null!==(I=A.relayMessage)&&void 0!==I&&I.sdp&&(null===(O=this._ctx.handler)||void 0===O||O.createAVMlineAnswerTpl(A.relayMessage.sdp)),this.emit(sK.JOIN_SUCCESS,{joinRes:A,reconnect:t}),this._joinRoomSuccess(A),e.next=37;break;case 33:e.prev=33,e.t0=e.catch(14),N={461:dw.ROOM_FORBIDDEN,462:dw.USER_FORBIDDEN},(null===e.t0||void 0===e.t0?void 0:e.t0.code)>=700&&(null===e.t0||void 0===e.t0?void 0:e.t0.code)<800?this._joinRoomFailed("token_error",dw.INVALID_TOKEN):N[null===e.t0||void 0===e.t0?void 0:e.t0.code]?this._joinRoomFailed((null===e.t0||void 0===e.t0?void 0:e.t0.message)||N[null===e.t0||void 0===e.t0?void 0:e.t0.code],N[null===e.t0||void 0===e.t0?void 0:e.t0.code]):(null===e.t0||void 0===e.t0?void 0:e.t0.code)===dw.TIME_OUT&&this._ctx.joinRoomConfig.useTcpAfterJoinTimeout?(this._logger.error("join",HX.JOIN_TIMEOUT),this.safeEmit(sK.ON_REJOIN_WITH_TCP),this._ctx.signalingManager.reconnect(HX.JOIN_TIMEOUT,!0)):e.t0.code===dw.OPERATION_CANCEL&&this._ctx.signalingManager.isReconnecting()||this._joinRoomFailed((null===e.t0||void 0===e.t0?void 0:e.t0.message)||"signaling_error");case 37:case"end":return e.stop()}}),e,this,[[14,33]])}))),function(e){return t.apply(this,arguments)})},{key:"_joinRoomWithRetry",value:function(e,t,r){var n=this;return new Gg((function(i,o){n._ctx.signalingManager.sendSignaling(e,t,void 0,1e4).then((function(e){n.emit("onJoinRoomAck",e),i(e)})).catch((function(a){if(r=r||new JK,a.code>=500&&a.code<600&&AL()-r.initTs<6e4){var s,c=r.getRetryDelay();return n._logger.warn("_joinRoomWithRetry",Hg(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:"_reportJoinRoomStart",value:function(){this._joinTask&&this.emit("__joinRoomStartReport")}},{key:"_joinRoomSuccess",value:function(e){this._joinTask&&(this._joinTask.success(e),this.emit("__joinRoomSuccessReport"),this._roomConf.report("join_room",{type:"end",start:this._joinTask.startTime,result:!0,reason:""},{enable_cloud_proxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC}),this._roomConf.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:AL()-this._joinTask.startTime}),delete this._joinTask,delete this._roomConf.joinPromise)}},{key:"_joinRoomFailed",value:function(e,t){this._joinTask&&(this._joinTask.fail(new _w(t||dw.JOIN_ROOM_FAILED,e)),this.emit("__joinRoomFailedReport"),this._roomConf.report("join_room",{type:"end",start:this._joinTask.startTime,result:!1,reason:e},{enable_cloud_proxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC}),delete this._joinTask,delete this._roomConf.joinPromise)}}]),a}(yU);Jd(CY,"supportedCodecs",void 0);var wY=fT,xY=WI,OY=function(e,t,r,n){for(var i,o=n>1?void 0:n?xY(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&&wY(t,r,o),o},NY=function(){function e(t,r){Hh(this,e),Jd(this,"_logger",void 0),this._ctx=t,this._roomConf=r,this._logger=new hD("RoomMessage",2,t.id)}var t,r;return jh(e,[{key:"sendUserMessage",value:function(e,t){return this._ctx.signalingManager.sendP2PMessage({to:e,from:this._roomConf.userId,room:this._roomConf.roomId,app:this._ctx.appId,msg:t})}},{key:"sendRoomMessage",value:(r=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={clientId:this._roomConf.userId,binary:r,message:"",roomId:this._roomConf.roomId},!r){e.next=7;break}return e.next=4,wL.ab2b64str(t);case 4:n.message=e.sent,e.next=8;break;case 7:n.message=t;case 8:return e.abrupt("return",this._ctx.signalingManager.sendSignaling("customMessage",n));case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"controlMessage",value:(t=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._logger.info("controlMessage()","params: %o",t),r=t,"transcode"===t.type&&(r.roomId=this._roomConf.roomId),e.next=5,this._ctx.signalingManager.sendSignaling("controlMessage",r);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();OY([OK],NY.prototype,"sendUserMessage",1),OY([OK],NY.prototype,"sendRoomMessage",1),OY([OK],NY.prototype,"controlMessage",1);var PY=fT,MY=WI,DY=function(e,t,r,n){for(var i,o=n>1?void 0:n?MY(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&&PY(t,r,o),o},LY={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},UY=function(e){BA(N,e);var t,r,n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R,A,C,w,x,O=nC(N);function N(e,t){var r;return Hh(this,N),Jd(uA(r=O.call(this)),"_localStream",void 0),Jd(uA(r),"_localScreenStream",void 0),Jd(uA(r),"_remoteUsers",new hT),Jd(uA(r),"_remoteStreams",new hT),Jd(uA(r),"_remoteStreamStreamIdUserIdMap",{}),Jd(uA(r),"_virtualStreams",[]),Jd(uA(r),"_serverConfig",void 0),Jd(uA(r),"_userDuplicateLoginTimerMap",new hT),Jd(uA(r),"_networkQualityManager",void 0),Jd(uA(r),"_videoSizeObserver",void 0),Jd(uA(r),"_hasPublished",!1),Jd(uA(r),"_subtitleTool",void 0),Jd(uA(r),"_csrcUserIdMap",{}),Jd(uA(r),"_publishOnDemandItem",void 0),Jd(uA(r),"_onceTriggerBySignal",!1),Jd(uA(r),"_pubTransceiverReady",!1),Jd(uA(r),"_publishOnDemandBusy",!1),Jd(uA(r),"logger",void 0),Jd(uA(r),"_forwardStreamManager",void 0),Jd(uA(r),"_publisher",void 0),Jd(uA(r),"_subscriber",void 0),Jd(uA(r),"_roomJoin",void 0),Jd(uA(r),"_roomMessage",void 0),Jd(uA(r),"_clearSignalListeners",void 0),r.config=e,r._ctx=t,r.logger=new hD("Room",1,t.id),r.logger.info("constructor","invoke"),r._publisher=new bY(t,e),r._addPublisherListeners(),r._subscriber=new RY(t,e),r._addSubscriberListeners(),r._roomJoin=new CY(t,e),r._addJoinRoomHandler(),r._forwardStreamManager=new DK(t,e),r._addForwardStreamListeners(),r._roomMessage=new NY(t,e),r._networkQualityManager=new pK(t),r._networkQualityManager.reportor=r._reportNetworkQuality.bind(uA(r)),r._videoSizeObserver=new _K(uA(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(uA(r)),r._addSignalListeners(),r}return jh(N,[{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||!e.hasPublished)}},{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:"virtualStreams",get:function(){return this._virtualStreams}},{key:"_addSignalListeners",value:function(){var e,t=this,r=(Jd(e={},kU.ON_ADD_STREAM,this._onAddStream.bind(this)),Jd(e,kU.ON_ADD_STREAM_LIST,(function(e){e&&Array.isArray(e.streamList)&&e.streamList.forEach((function(e){return t._onAddStream(e)}))})),Jd(e,kU.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),Jd(e,kU.ON_REMOVE_STREAM_LIST,(function(e){e&&Array.isArray(e.streamList)&&e.streamList.forEach((function(e){return t._onRemoveStream(e)}))})),Jd(e,kU.USER_CONNECTION,this._onUserConnection.bind(this)),Jd(e,kU.USER_CONNECTION_LIST,(function(e){e&&Array.isArray(e.userList)&&e.userList.forEach((function(e){return t._onUserConnection(e)}))})),Jd(e,kU.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),Jd(e,kU.USER_DISCONNECTION_LIST,(function(e){e&&Array.isArray(e.userList)&&e.userList.forEach((function(e){return t._onUserDisconnection(e)}))})),Jd(e,kU.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),Jd(e,kU.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),Jd(e,kU.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),Jd(e,kU.ON_PUSH_TRACK,this._onPushTrack.bind(this)),Jd(e,kU.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),Jd(e,kU.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),Jd(e,kU.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),Jd(e,kU.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),Jd(e,kU.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),Jd(e,kU.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),Jd(e,kU.ON_TOKEN_PUBLISH_PRIVILEGE_WILL_EXPIRE,this._onUserTokePublishPrivilegeWillExpire.bind(this)),Jd(e,kU.ON_TOKEN_PUBLISH_PRIVILEGE_DID_EXPIRED,this._onUserTokenPublishPrivilegeDidExpire.bind(this)),Jd(e,kU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_WILL_EXPIRE,this._onUserTokeSubscribePrivilegeWillExpire.bind(this)),Jd(e,kU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_DID_EXPIRED,this._onUserTokenSubscribePrivilegeDidExpire.bind(this)),Jd(e,kU.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),Jd(e,kU.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),Jd(e,TU.RTT,this._onRTT.bind(this)),Jd(e,TU.SSC,this._onSSC.bind(this)),Jd(e,IU.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),Jd(e,kU.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),Jd(e,kU.ON_FORWARD_DST_ROOM_USER_KICK,this._forwardStreamManager.onForwardDstRoomUserKick.bind(this._forwardStreamManager)),Jd(e,TU.RSCP,this._onRSCP.bind(this)),e);FS(r).forEach((function(e){t._ctx.signalingManager.on(e,r[e])})),this._clearSignalListeners=function(){FS(r).forEach((function(e){t._ctx.signalingManager.off(e,r[e])}))}}},{key:"_addPublisherListeners",value:function(){var e=this;this._publisher.on(sK.PUB_RETRY,(function(t){e.emit(sK.PUB_RETRY,t)})),this._publisher.on(TU.RSCP,this._onRSCP.bind(this)),this._publisher.on(IU.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(t){return e.emit(IU.ON_VENDOR_CONNECTION_STATE_CHANGE,t)}))}},{key:"_addSubscriberListeners",value:function(){var e=this;this._subscriber.on(IU.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(t){return e.emit(IU.ON_VENDOR_CONNECTION_STATE_CHANGE,t)})),this._subscriber.on("onRemoteStreamStats",(function(t){e._networkQualityManager.updateDownlinkStats(t,e._findRemoteStreamByScreen(t.userId,t.isScreen)),lL("HIDDEN_STATS")||(t=BL(t)),e.emit(sK.ON_REMOTE_STREAM_STATS,t)})),this._subscriber.on(sK.RESUBSCRIBE,(function(t){e.emit(sK.RESUBSCRIBE,t)})),this._subscriber.on(sK.SUB_RETRY,(function(t){e.emit(sK.SUB_RETRY,t)}))}},{key:"_addJoinRoomHandler",value:function(){var e=this;this._roomJoin.on(sK.JOIN_SUCCESS,this._onJoinSucc.bind(this)),this._roomJoin.on(sK.ON_REJOIN_WITH_TCP,(function(){e.emit(sK.ON_REJOIN_WITH_TCP)}))}},{key:"_addForwardStreamListeners",value:function(){var e=this;this._forwardStreamManager.on(sK.ON_FORWARD_STREAM_ERROR,(function(t){e.safeEmit(sK.ON_FORWARD_STREAM_ERROR,t)}))}},{key:"_onLocalStreamStats",value:function(e){var t=e.isScreen?this._localScreenStream:this.localStream;this._networkQualityManager.updateUplinkStats(e,t),lL("HIDDEN_STATS")||(e=BL(e)),this.emit(sK.ON_LOCAL_STREAM_STATS,e)}},{key:"join",value:(x=Ug(Dg().mark((function e(){var t,r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("join()"),this.config.startJoinTimestamp=AL(),e.prev=2,e.next=5,this._roomJoin.join();case 5:return r=e.sent,null!==(t=r.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack(),this._initSubtitleTool(),e.abrupt("return",{users:r.clients,streams:r.streams});case 11:if(e.prev=11,e.t0=e.catch(2),e.t0.code===dw.OPERATION_CANCEL){e.next=15;break}throw e.t0;case 15:case"end":return e.stop()}}),e,this,[[2,11]])}))),function(){return x.apply(this,arguments)})},{key:"publishScreen",value:(w=Ug(Dg().mark((function e(t,r,n,i,o){var a,s,c,u,l,d,h,f,v;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishScreen()"),this._localScreenStream||(this._localScreenStream=new oK(this._ctx),this.config.vendorConfig.enableMultiVendor&&(this._localScreenStream.pcSessionId=_x()),this._localScreenStream.isScreen=!0,this._localScreenStream.observer=new fK(this._ctx,this._localScreenStream)),a=!1,s=!1,c=!1,u=!1,!this._localScreenStream.videoTrack&&r?(r.sourceType===wU.EXTERNAL&&(s=!0),a=!0):this._localScreenStream.videoTrack&&!r&&(a=!1),!this._localScreenStream.audioTrack&&n?(n.sourceType===wU.EXTERNAL&&(u=!0),c=!0):this._localScreenStream.audioTrack&&!n&&(c=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(VL(i)&&(this._localScreenStream.pubAudio=o===uK.PUB),FL(i)&&(this._localScreenStream.pubVideo=o===uK.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(!this._localScreenStream.hasPublished){e.next=17;break}return e.abrupt("return",this.unpublishScreen());case 17:return e.abrupt("return");case 18:if(this._localScreenStream.hasPublished){e.next=24;break}return null===(l=this._localScreenStream.observer)||void 0===l||l.setPublish(!0),e.next=22,this._publisher.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return s?null===(d=this._localScreenStream.observer)||void 0===d||d.setPushVideo(a):null===(h=this._localScreenStream.observer)||void 0===h||h.setEnableVideo(a),u?null===(f=this._localScreenStream.observer)||void 0===f||f.setPushAudio(c):null===(v=this._localScreenStream.observer)||void 0===v||v.setEnableAudio(c),e.next=28,this.updatePubScreenTrack();case 28:this._localScreenStream.pubAudio||this._localScreenStream.pubVideo?this._ctx.handler&&this._localScreenStream.startReport(this._onLocalStreamStats.bind(this),this._localScreenStream.vendorHandler||this._ctx.handler):this._localScreenStream.stopReport("unpublish screen");case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return w.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(C=Ug(Dg().mark((function e(){return Dg().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._publisher.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return C.apply(this,arguments)})},{key:"unpublishScreen",value:(A=Ug(Dg().mark((function e(){var t;return Dg().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._publisher.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 A.apply(this,arguments)})},{key:"liveControlMessage",value:(R=Ug(Dg().mark((function e(t){var r,n=this;return Dg().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){e.roomID=n.config.roomId})),e.next=4,this._roomMessage.controlMessage(t);case 4:this.config.setLiveControlMessage("stopped"===t.action?void 0:t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return R.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(I=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._roomMessage.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"getLocalStreamStats",value:(T=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this.localStream)||void 0===t?void 0:t.getLocalStreamStats();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return T.apply(this,arguments)})},{key:"updateUserAttributes",value:(k=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateUserAttributes","Invoke updateUserAttributes"),e.next=3,this._subscriber.updateUserAttributes({role:this._ctx.role});case 3:case"end":return e.stop()}}),e,this)}))),function(){return k.apply(this,arguments)})},{key:"publish",value:(E=Ug(Dg().mark((function e(t,r,n,i,o,a){var s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=T.length>6&&void 0!==T[6]&&T[6],this.logger.info("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new oK(this._ctx),this.config.vendorConfig.enableMultiVendor&&(this._localStream.pcSessionId=_x()),this._localStream.observer=new fK(this._ctx,this._localStream),c=!0,this._localStream.vendorCode=this.config.vendorConfig.vendorCode||0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,u=this._localStream,l=u.pubAudio,d=u.pubVideo,o&&(VL(o)&&(this._localStream.pubAudio=a===uK.PUB),FL(o)&&(this._localStream.pubVideo=a===uK.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===(h=this._localStream.observer)||void 0===h||h.setLogin(!0):c&&(p=!!this._localStream.videoTrack,_=!!this._localStream.audioTrack,m=(null===(f=this._localStream.videoTrack)||void 0===f?void 0:f.sourceType)===wU.EXTERNAL,g=(null===(v=this._localStream.audioTrack)||void 0===v?void 0:v.sourceType)===wU.EXTERNAL,this.config.isAutoPublish&&!this._hasPublished?(p&&(m?null===(y=this._localStream.observer)||void 0===y||y.setPushVideo(!0):null===(S=this._localStream.observer)||void 0===S||S.setEnableVideo(!0)),_&&(g?null===(b=this._localStream.observer)||void 0===b||b.setPushAudio(!0):null===(E=this._localStream.observer)||void 0===E||E.setEnableAudio(!0))):null===(k=this._localStream.observer)||void 0===k||k.setPublish(!0)),this.emit("___onMediaServerClientPublish"),e.next=18,this._publisher.publish(this._localStream);case 18:this._hasPublished=!0,this.emit(sK.ON_PUBLISH_RESULT,{isScreen:!1,state:oh.PUBLISH_SUCC}),e.next=27;break;case 22:throw e.prev=22,e.t0=e.catch(13),this.emit(sK.ON_PUBLISH_RESULT,{isScreen:!1,state:oh.PUBLISH_FAIL,errorCode:e.t0.code}),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=l,this._localStream.pubVideo=d,e.t1;case 40:this._localStream.pubAudio||this._localStream.pubVideo?this._ctx.handler&&this._localStream.startReport(this._onLocalStreamStats.bind(this),this._localStream.vendorHandler||this._ctx.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 E.apply(this,arguments)})},{key:"updatePubTrack",value:(b=Ug(Dg().mark((function e(){return Dg().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._publisher.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return b.apply(this,arguments)})},{key:"unpublish",value:(S=Ug(Dg().mark((function e(){return Dg().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._publisher.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 S.apply(this,arguments)})},{key:"subscribe",value:(y=Ug(Dg().mark((function e(t,r,n){var i,o;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("subscribe","remoteStream %o",t),t.streamState===iK.INIT){e.next=8;break}if((i=t.subMediaType|r)===t.subMediaType){e.next=7;break}return e.next=6,this._subscriber.updateSubMediaType(t,i);case 6:return e.abrupt("return",e.sent);case 7:return e.abrupt("return");case 8:return o=void 0,n&&(o=this._subscriber.getSubLayer(n,t)),e.next=12,this._subscriber.subscribe(t,r,o);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return y.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(g=Ug(Dg().mark((function e(t,r){var n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(o=this._findRemoteStreamByScreen(t,!1))&&o.hasSubscribed&&!((null===(n=o.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 a=this._subscriber.getSubLayer(r,o),o.originalStreamIndex=a.spatialLayer,e.abrupt("return",this._subscriber.updateSubTrackLayer(o,a));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return g.apply(this,arguments)})},{key:"unsubscribe",value:(m=Ug(Dg().mark((function e(t,r){var n,i;return Dg().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(i=t.subMediaType-(t.subMediaType&r),null!==(n=this._ctx.serverConfig)&&void 0!==n&&n.muteReplaceUnsub||!(i===iV.NONE||this.config.isMultiChatMode()&&i===uh.AUDIO)){e.next=8;break}return e.next=7,this._subscriber.unsubscribe(t);case 7:return e.abrupt("return",e.sent);case 8:return e.next=10,this._subscriber.updateSubMediaType(t,i);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"startSubtitle",value:(_=Ug(Dg().mark((function e(t){return Dg().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 _w(dw.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"updateSubtitleConfig",value:(p=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subtitleTool){e.next=5;break}return e.next=3,this._subtitleTool.update(t);case 3:e.next=6;break;case 5:throw new _w(dw.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:(v=Ug(Dg().mark((function e(){var t;return Dg().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 v.apply(this,arguments)})},{key:"startForwardStream2Rooms",value:(f=Ug(Dg().mark((function e(t){return Dg().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 f.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(h=Ug(Dg().mark((function e(t){return Dg().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 h.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(d=Ug(Dg().mark((function e(){return Dg().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 d.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(l=Ug(Dg().mark((function e(){return Dg().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 l.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(u=Ug(Dg().mark((function e(){return Dg().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 u.apply(this,arguments)})},{key:"updateMediaParams",value:(c=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._ctx.signalingManager.sendSignaling("updateMediaParams",{roomId:this.config.roomId,mediaParams:t}));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"leave",value:(s=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=c.length>0&&void 0!==c[0]&&c[0],this.logger.info("leave","Invoke leave"),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,e.prev=4,i=by($w(n=this._remoteStreams).call(n));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(XJ){i.e(XJ)}finally{i.f()}return this._localStream&&(null===(s=this._localStream.observer)||void 0===s||s.setLogin(!1)),e.next=10,this._roomJoin.leave().catch((function(){}));case 10:this.destroy(),this.config.report("rtc_leave_room",{error_code:0,message:"",elapse:this.config.getStayRoomDuration()}),e.next=22;break;case 14:if(e.prev=14,e.t0=e.catch(4),e.t0 instanceof Error&&this.config.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:this.config.getStayRoomDuration()}),!r){e.next=21;break}throw e.t0;case 21:this.destroy();case 22:case"end":return e.stop()}}),e,this,[[4,14]])}))),function(){return s.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._ctx.userPriority;t.hasSubscribed&&n.has(e)&&r._subscriber.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e,t;this.logger.info("destroy","Invoke destroy"),this._ctx.id,"".concat((new Error).stack),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._subscriber.destroy(this._remoteStreams),this._publisher.destroy([this.localStream,this.localScreenStream]),this._roomJoin.destroy(),null===(t=this._clearSignalListeners)||void 0===t||t.call(this),this._remoteUsers=new hT;var r,n=by(this._remoteStreams);try{for(n.s();!(r=n.n()).done;){var i=Ey(r.value,2)[1];Array.isArray(i)&&i.forEach((function(e){null==e||e.destroy()}))}}catch(XJ){n.e(XJ)}finally{n.f()}this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new hT,this._localStream&&(this._localStream.clean(),this._localStream=void 0),this._localScreenStream&&(this._localScreenStream.clean(),this._localScreenStream=void 0),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={},this._forwardStreamManager.destoy()}},{key:"updateToken",value:(a=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateToken","Invoke updateToken"),this.config.token=t,e.prev=2,e.next=5,this._roomJoin.updateToken(t);case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(2),this.safeEmit(sK.ON_ROOM_ERROR,{errorCode:dw.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return a.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){return this._roomMessage.sendUserMessage(e,t)}},{key:"sendRoomMessage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this._roomMessage.sendRoomMessage(e,t)}},{key:"maybeFillBackFrame2Stream",value:(o=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.refreshBlackFrameLifetime(),null!==(r=t.videoTransceiver)&&void 0!==r&&r.sender.track||this._publisher.updatePubBlackFrame(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.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.emit(sK.JOIN_SUCCESS,a),this._serverConfig=o.config,this.config.updateRoomAttributes(o.roomAttributes);var s=[],c=[],u=[],l=[],d=[];null===(t=o.clientsDetail)||void 0===t||t.forEach((function(e){if(e.attributes&&(e.attributes.serverMuteVideo&&i.safeEmit(sK.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&i.safeEmit(sK.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,f=by($w(r=this._remoteUsers).call(r));try{for(f.s();!(h=f.n()).done;){var v=h.value;v._stillExist||c.push({clientId:v.userId}),delete v._stillExist}}catch(XJ){f.e(XJ)}finally{f.f()}o.streams.forEach((function(e){var t=i._findRemoteStreamByScreen(e.clientId,e.screen);i.config.updateUserPubInfo(e),t?(t.stillExist=!0,t.streamId=e.streamId,d.push(e)):l.push(e)}));var p,_=by($w(n=this._remoteStreams).call(n));try{for(_.s();!(p=_.n()).done;){var m=p.value;Array.isArray(m)&&m.forEach((function(e){e.stillExist?delete e.stillExist:u.push({clientId:e.userId,streamId:e.streamId,message:bU.clientDisconnected})}))}}catch(XJ){_.e(XJ)}finally{_.f()}c.forEach((function(e){return i._onUserDisconnection(e)})),s.forEach((function(e){return i._onUserConnection(e)})),u.forEach((function(e){return i._onRemoveStream(e)})),l.forEach((function(e){return i._onAddStream(e,{fromSignal:!1})})),d.forEach((function(e){return i._onUpdateStreamAttributes(e)})),this.config.resetUserPubInfo(),a&&this._handleSendOrRecvStreamAfterReconnect(),this.emit("__joinSuccess")}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r,n,i=this;this._localStream&&(this._localStream.clean(),this._localStream.vendorCode=this.config.vendorConfig.vendorCode||0,null===(r=this._localStream.observer)||void 0===r||r.setLogin(!0),this._publisher.publish(this._localStream).then((function(){var e;i._ctx.handler&&(null===(e=i._localStream)||void 0===e||e.startReport(i._onLocalStreamStats.bind(i),i._localStream.vendorHandler||i._ctx.handler)),i.emit(sK.ON_PUBLISH_RESULT,{isScreen:!1,state:oh.PUBLISH_SUCC,retry:!0})})).catch((function(e){i.logger.error("failed repub error:".concat(e)),i.emit(sK.ON_PUBLISH_RESULT,{isScreen:!1,state:oh.PUBLISH_FAIL,errorCode:e.code,retry:!0})})));this._localScreenStream&&(this._localScreenStream.clean(),null===(n=this._localScreenStream.observer)||void 0===n||n.setLogin(!0),this._publisher.publish(this._localScreenStream).then((function(){var e;i._ctx.handler&&(null===(e=i._localScreenStream)||void 0===e||e.startReport(i._onLocalStreamStats.bind(i),i._localScreenStream.vendorHandler||i._ctx.handler)),i.emit(sK.ON_PUBLISH_RESULT,{isScreen:!0,state:oh.PUBLISH_SUCC,retry:!0})})).catch((function(e){i.logger.error("failed repub screen stream error:".concat(e)),i.emit(sK.ON_PUBLISH_RESULT,{isScreen:!0,state:oh.PUBLISH_FAIL,errorCode:e.code,retry:!0})})));var o,a=by($w(t=this._remoteStreams).call(t));try{for(a.s();!(o=a.n()).done;){var s=o.value;Array.isArray(s)&&s.forEach(function(){var e=Ug(Dg().mark((function e(t){var r,n,o,a,s,c;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=22;break}return t.resetHasSubscribed(),e.prev=2,i.logger.info(Hg(r="start resubscribe ".concat(t.userId," with ")).call(r,t.subMediaType)),FL(t.subMediaType)&&(null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!0)),VL(t.subMediaType)&&(null===(o=t.observer)||void 0===o||o.setSubscribeAudio(!0)),e.next=8,i._subscriber.subscribe(t,t.subMediaType);case 8:i.logger.info(Hg(a="success resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType)),i.safeEmit(sK.RESUBSCRIBE,{stream:t}),i.emit(sK.ON_SUBSCRIBE_RESULT,{state:ih.SUBSCRIBE_SUCC,userId:t.userId,isScreen:t.isScreen,retry:!0}),e.next=22;break;case 13:if(e.prev=13,e.t0=e.catch(2),i.emit(sK.ON_SUBSCRIBE_RESULT,{state:ih.SUBSCRIBE_FAIL,userId:t.userId,isScreen:t.isScreen,errorCode:e.t0.code,retry:!0}),i.logger.error(Hg(s=Hg(c="failed resubscribe ".concat(t.userId," with ")).call(c,t.subMediaType,", error:")).call(s,e.t0)),e.t0.code!==dw.NOT_CONNECTED_YET){e.next=20;break}return t.streamState=iK.SUB_ED,e.abrupt("return");case 20:t.clean(),t.resetHasSubscribed();case 22:case"end":return e.stop()}}),e,null,[[2,13]])})));return function(t){return e.apply(this,arguments)}}())}}catch(XJ){a.e(XJ)}finally{a.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect(),this._forwardStreamManager.resumeFromReconnect()}},{key:"_handleFFAudioTrack",value:function(){var e,t,r=null===(e=this._ctx.handler)||void 0===e?void 0:e.audioTrack4ff,n=null===(t=this._ctx.handler)||void 0===t?void 0:t.getTransceivers();if(r&&Array.isArray(n)){var i=lI(n).call(n,(function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===r}));if(i){var o=new aK(this._ctx,"ff-stream","ff-stream",!1,!1,LY);o.virtual=!0,o.audioTransceiver=i,o.audioMid="0",o.audioTrack=XW(r,{streamIndex:OU.VIRTUAL}),this._virtualStreams.push(o),this.safeEmit(sK.SUBSCRIBE_PUSH_TRACK,{stream:o})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?lI(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)?lI(r).call(r,(function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.needEmit,n=void 0===r||r,i=t.fromSignal,o=void 0===i||i,a=t.virtual,s=void 0!==a&&a;if(e.clientId!==this.config.userId){var c=this.config,u=c.isAutoSubscribeAudio,l=c.isAutoSubscribeVideo,d=this._findRemoteStreamByScreen(e.clientId,e.screen);if(d&&d.streamId!==e.streamId){var h,f=null===(h=this._remoteStreams.get(e.clientId))||void 0===h?void 0:Cy(h).call(h,(function(e){return e.streamId!==d.streamId}));d.clean(),this._remoteStreams.set(e.clientId,f||[])}var v=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,v)v.attributes=e.attributes;else if((v=new aK(this._ctx,e.clientId,e.streamId,e.screen,!1,e.attributes)).virtual=s,this._initStreamListeners(v),!s){var p=this._remoteStreams.get(e.clientId);p?p.push(v):this._remoteStreams.set(e.clientId,[v])}if(v.remoteSessionId=e.remoteSessionId||"",v.observer=new hK(this._ctx,v),!v.isScreen&&l&&(o&&v.hasVideo&&(v.attributes.extvideo?(v.observer.setExternalVideoSource(!0),v.observer.setPushVideo(!0)):(v.observer.setExternalVideoSource(!1),v.observer.setPublishVideo(!0))),o&&v.hasAudio&&u&&!this.config.isMultiChatMode()&&(v.attributes.extaudio?(v.observer.setExternalAudioSource(!0),v.observer.setPushAudio(!0)):(v.observer.setExternalAudioSource(!1),v.observer.setPublishAudio(!0))),n&&!o)){var _=this.config,m=_.isAutoSubscribeAudio,g=_.isAutoSubscribeVideo;v.observer.setLogin(!0,{audio:!!m&&!this.config.isMultiChatMode(),video:!!g})}return n&&this.safeEmit(kU.ON_ADD_STREAM,{stream:v}),v}}},{key:"_onUserConnection",value:function(e){if(e.clientId!==this.config.userId){var t=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof t)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(t);var r={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,Zd({},r)),this.safeEmit(kU.USER_CONNECTION,{userInfo:r,publishState:this.config.getUserPubInfo(r.userId)}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(sK.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(sK.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t=this,r=e.clientId,n=e.tag,i=e.code,o=e.forbiddenTime;if(r)if(r===this.config.userInfo.userId){var a=null;n===RU.kickedByAdmin?a=dw.KICKED_OUT:n===RU.onUserTokenDidExpire?a=dw.TOKEN_EXPIRED:n===RU.userDuplicateLogin&&(a=dw.DUPLICATE_LOGIN),i===AU.roomDismissByAdmin&&(a=dw.ROOM_DISMISS),a&&this.safeEmit(sK.ON_ROOM_ERROR,{errorCode:a,forbiddenTime:o})}else{var s=th.DROPPED;n===RU.userLeave?s=th.QUIT:n===RU.kickedByAdmin?s=th.KICKED_BY_ADMIN:n===RU.roleChanged&&(s=th.SWITCH_TO_INVISIBLE);var c=function(){var e;t._remoteUsers.delete(r);var n=[];null===(e=t._remoteStreams.get(r))||void 0===e||e.forEach((function(e){n.push(t._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:bU.clientDisconnected}))})),t._remoteStreams.delete(r),Gg.all(n).finally((function(){t.safeEmit(sK.ON_USER_LEAVE,{userInfo:{userId:r},reason:s})}))};if(n===RU.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(r);u&&self.clearTimeout(u);var l=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(r,l)}else c()}}},{key:"_onRemoveStream",value:(i=Ug(Dg().mark((function e(t){var r,n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.clientId!==this.config.userId){e.next=2;break}return e.abrupt("return");case 2:if(r=this._remoteStreams.get(t.clientId)){e.next=5;break}return e.abrupt("return");case 5:if(n=lI(r).call(r,(function(e){return e.streamId===t.streamId}))){e.next=8;break}return e.abrupt("return");case 8:return n.hasVideo&&(null===(i=n.observer)||void 0===i||i.setPublishVideo(!1)),n.hasAudio&&!this.config.isMultiChatMode()&&(null===(o=n.observer)||void 0===o||o.setPublishAudio(!1)),e.prev=10,e.next=13,this._subscriber.handleRemoveStream(n).then((function(){var e=a._remoteStreams.get(t.clientId);e&&(e=Cy(e).call(e,(function(e){return e.streamId!==t.streamId||(e.clean(),!1)})),a._remoteStreams.set(t.clientId,e))})).finally((function(){a.safeEmit(kU.ON_REMOVE_STREAM,{stream:n,reason:t.message,callback:function(){return n.destroy()}})}));case 13:e.next=18;break;case 15:e.prev=15,e.t0=e.catch(10),console.error(e.t0);case 18:case"end":return e.stop()}}),e,this,[[10,15]])}))),function(e){return i.apply(this,arguments)})},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(sK.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(sK.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&this.config.updateRoomAttributes(e.roomAttributes),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this.config,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,l=s.attributes,d=Zd(Zd({},l),a),h=!1,f=d.localaudio!==l.localaudio,v=!1,p=!1,_=d.localvideo!==l.localvideo,m=!1,g=iV.NONE,y=iV.NONE;if(d.audiostream!==l.audiostream&&(h=d.localaudio,v=!!d.audiostream,d.audiostream?g|=uh.AUDIO:y|=uh.AUDIO),d.videostream!==l.videostream&&(p=d.localvideo,m=!!d.videostream,d.videostream?g|=uh.VIDEO:y|=uh.VIDEO),g&&this.safeEmit(sK.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:uK.PUB,remoteStream:s}),y&&this.safeEmit(sK.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:uK.UNPUB,remoteStream:s}),s.remoteSessionId=e.remoteSessionId||"",s.attributes=d,d.localaudio!==l.localaudio)if(d.localaudio){var S,b,E,k;if((r||s.subAudio)&&d.audiostream)if(d.extaudio)null===(S=s.observer)||void 0===S||S.setExternalAudioSource(!0),null===(b=s.observer)||void 0===b||b.setPushAudio(!0);else null===(E=s.observer)||void 0===E||E.setExternalAudioSource(!1),null===(k=s.observer)||void 0===k||k.setEnableAudio(!0);this.safeEmit(sK.ON_USER_START_AUDIO_CAPTURE,{userId:i},s)}else{var T,I,R,A;if(d.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(sK.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(d.localvideo!==l.localvideo)if(d.localvideo){var C,w,x,O;if((n||s.subVideo)&&d.videostream)if(d.extvideo)null===(C=s.observer)||void 0===C||C.setExternalVideoSource(!0),null===(w=s.observer)||void 0===w||w.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(sK.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var N,P,M,D;if(d.extvideo)null===(N=s.observer)||void 0===N||N.setExternalVideoSource(!0),null===(P=s.observer)||void 0===P||P.setPushVideo(!1);else null===(M=s.observer)||void 0===M||M.setExternalVideoSource(!1),null===(D=s.observer)||void 0===D||D.setEnableVideo(!1);!s.isScreen&&this.safeEmit(sK.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!f&&r)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(v);if(p&&!_&&n)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteVideo(m);"number"==typeof d.videoType&&d.videoType!==l.videoType&&this.safeEmit(sK.VIDEO_TYPE_CHANGE,{userId:s.userId,isScreen:s.isScreen,type:d.videoType===CU.BLACK?SU.BLACK:SU.NORMAL})}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&lw(t).call(t,"audio_mux")){var n=this._onAddStream(Zd(Zd({},e),{},{attributes:LY}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._subscriber.subscribe4pushTrack(n,e).then((function(){r.safeEmit(sK.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){r.logger.error("subscribe","push track failed %o",e)}))}else{var i;this.config.report("rtc_error",{message:Hg(i="onPushTrack, userId: ".concat(e.clientId,", ")).call(i,e.streamId),error_code:TK.TRACK_ERROR})}}},{key:"_onRemoveTrack",value:function(e){var t=e.clientId,r=e.streamId,n=e.message,i=e.trackType;this.logger.info("_onRemoveTrack","remove track: %o",t);var o=this._findRemoteStream(t,r);o&&(o.removeTrack=!0,this._subscriber.unsubscribe4removeTrack(o,n,i),this.emit(sK.REMOVE_PUSH_TRACK,{stream:o,mediaType:i+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&&Qy(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=Ey(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&&BC(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,c=this,u=by($w(a=this._remoteStreams).call(a));try{for(u.s();!(s=u.n()).done;){var l=s.value;Array.isArray(l)&&l.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()}))}}catch(XJ){u.e(XJ)}finally{u.f()}this._virtualStreams.forEach((function(e){var t;c.emit(sK.REMOVE_PUSH_TRACK,{stream:e,mediaType:uh.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){e.state===dh.CONNECTION_STATE_RECONNECTING?this._onReconnecting():e.state===dh.CONNECTION_STATE_RECONNECTED&&this._roomJoin.join(!0)}},{key:"_initStreamListeners",value:function(e){var t=this;e.on("ontrack",(function(e){e.track})),e.on("onSEIMessage",(function(r){t.emit(sK.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:t.config.roomId,streamIndex:e.isScreen?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){var t;null!==(t=this._subtitleTool)&&void 0!==t&&t.onMessageRecv(e)||this.safeEmit(kU.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(kU.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(kU.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new bK(this._ctx,this.config),this._subtitleTool.onEvent=function(t){e.emit(sK.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(sK.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=cK.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=cK.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?cK.START_FAILED:cK.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?cK.STOP_FAILED:cK.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?cK.UPDATE_FAILED:cK.UPDATE_SUCCESS}this.safeEmit(kU.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(kU.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(kU.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onUserTokePublishPrivilegeWillExpire",value:function(){this.safeEmit(kU.ON_TOKEN_PUBLISH_PRIVILEGE_WILL_EXPIRE,null)}},{key:"_onUserTokenPublishPrivilegeDidExpire",value:function(){this.safeEmit(kU.ON_TOKEN_PUBLISH_PRIVILEGE_DID_EXPIRED,null)}},{key:"_onUserTokeSubscribePrivilegeWillExpire",value:function(){this.safeEmit(kU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_WILL_EXPIRE,null)}},{key:"_onUserTokenSubscribePrivilegeDidExpire",value:function(){this.safeEmit(kU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_DID_EXPIRED,null)}},{key:"_onStreamFailed",value:(n=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("publish"!==t.type){e.next=11;break}if(i=void 0,(null===(r=this.localStream)||void 0===r?void 0:r.streamId)===t.streamId?i=this.localStream:(null===(n=this.localScreenStream)||void 0===n?void 0:n.streamId)===t.streamId&&(i=this.localScreenStream),i){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,this._publisher.unpublish(i).catch((function(){}));case 7:i.clean(),this._publisher.publish(i).catch((function(){})),e.next=22;break;case 11:if("subscribe"!==t.type){e.next=22;break}if(o=this._remoteStreamStreamIdUserIdMap[t.streamId],!(a=this._findRemoteStream(o,t.streamId))){e.next=22;break}return s=a.subMediaType,c=a.subLayer,e.next=19,this._subscriber.unsubscribe(a);case 19:return e.next=21,this._subscriber.subscribe(a,s,c);case 21:this.safeEmit(sK.RESUBSCRIBE,{stream:a});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===EU.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=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c,u,l,d,h,f,v=this;return Dg().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.videoTransceiver){e.next=16;break}return this._publishOnDemandBusy=!0,a=this._publishOnDemandItem,this._publishOnDemandItem=void 0,s=[],c=this._localStream.stream.id,u=this._localStream.videoTransceiver.sender,l=u.getParameters(),Array.isArray(l.encodings)&&Array.isArray(a)&&(h={},this.logger.info("_onPublishOnDemand exec","usedDescriptions: %o",a),a.forEach((function(e){var t;if(null!==(t=e.StreamIds)&&void 0!==t&&Qy(t).call(t,c)){var r,n,i,o,a,s,u,l=null!==(r=null===(n=e.Metadata)||void 0===n?void 0:n.VideoIndex)&&void 0!==r?r:0,d=0;null!==(i=v._ctx.serverConfig)&&void 0!==i&&i.e2eFeedback&&(d=Math.max.apply(Math,Hg(o=iR($g(a=FS(null!==(s=null===(u=e.Metadata)||void 0===u?void 0:u.VideoKbpsHist)&&void 0!==s?s:{})).call(a,(function(e){return Number(e)})))).call(o,[0]))),h[l]={kbps:d}}})),f=iR(this._localStream.pubAttributes.videoDescriptions),l.encodings=$g(d=l.encodings).call(d,(function(e){if(e.rid){if(h[e.rid]){var t;e.active=!0;var r=null===(t=h[e.rid])||void 0===t?void 0:t.kbps;r&&(e.maxBitrate=1e3*UK(e.rid,r,f))}else e.active=!1;var n=Number(e.rid);s[n]=e.active}else{var i,o=null===(i=h[0])||void 0===i?void 0:i.kbps;o&&(e.maxBitrate=1e3*UK(void 0,o,f))}return e})),this.config.report("rtc_invoke_status",{sdk_api_name:"onPublishOnDemand",message:Xg(l.encodings),error_code:0,stream_id:c,elapse:0}),this._ctx.activeSimStreams=s),e.next=13,u.setParameters(l);case 13:this._publishOnDemandBusy=!1,e.next=18;break;case 16:if(null!==(o=this._localStream)&&void 0!==o&&o.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(null!=t&&t.length&&r){var n=t[0];this._ctx.streamRTT[n]={audio:r.audio_rtt,video:r.video_rtt}}}},{key:"_onRSCP",value:function(e,t){var r=this;!!lI(e).call(e,(function(e){var t,n,i;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:Qy(t).call(t,null===(n=r._localStream)||void 0===n||null===(i=n.stream)||void 0===i?void 0:i.id)}))&&(t?this._pubTransceiverReady=!0:this._onceTriggerBySignal=!0,t&&this._onceTriggerBySignal||(this._publishOnDemandItem=e),this._pubTransceiverReady&&this._onPublishOnDemand())}},{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(sK.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(sK.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){this.emit(sK.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:this.config.roomId,userId:e,streamIndex:t?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"setAudioEncodeMaxBitrate",value:(t=Ug(Dg().mark((function e(t,r){var n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(n=t===ch.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)})}]),N}(yU);DY([OK],UY.prototype,"publishScreen",1),DY([OK],UY.prototype,"updatePubScreenTrack",1),DY([OK],UY.prototype,"unpublishScreen",1),DY([OK],UY.prototype,"liveControlMessage",1),DY([OK],UY.prototype,"publicStreamControlMessage",1),DY([OK],UY.prototype,"updateUserAttributes",1),DY([OK],UY.prototype,"publish",1),DY([OK],UY.prototype,"updatePubTrack",1),DY([OK],UY.prototype,"unpublish",1),DY([OK],UY.prototype,"subscribe",1),DY([OK],UY.prototype,"updateSubVideoConfig",1),DY([OK],UY.prototype,"unsubscribe",1),DY([OK],UY.prototype,"startSubtitle",1),DY([OK],UY.prototype,"stopSubtitle",1),DY([OK],UY.prototype,"startForwardStream2Rooms",1),DY([OK],UY.prototype,"updateForwardStream2Rooms",1),DY([OK],UY.prototype,"stopForwardStream2Rooms",1),DY([OK],UY.prototype,"pauseForwardStream2AllRooms",1),DY([OK],UY.prototype,"resumeForwardStream2AllRooms",1),DY([OK],UY.prototype,"updateMediaParams",1),DY([OK],UY.prototype,"updateRemoteUserPriority",1),DY([OK],UY.prototype,"updateToken",1),DY([OK],UY.prototype,"sendUserMessage",1),DY([OK],UY.prototype,"sendRoomMessage",1),DY([OK],UY.prototype,"maybeFillBackFrame2Stream",1);var VY=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&&CT(r.style,t.style),t.attributes&&VS(t.attributes).forEach((function(e){var t=Ey(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},FY=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],BY={playsinline:"","webkit-playsinline":""},jY={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},HY=function(e){BA(n,e);var t,r=nC(n);function n(e,t,i){var o;Hh(this,n),Jd(uA(o=r.call(this)),"_containerDom",void 0),Jd(uA(o),"_videoDom",void 0),Jd(uA(o),"userId",void 0),Jd(uA(o),"renderMode",void 0),Jd(uA(o),"mirrorType",fh.MIRROR_TYPE_NONE),Jd(uA(o),"isScreen",void 0),Jd(uA(o),"isLocal",void 0),Jd(uA(o),"played",!1),Jd(uA(o),"_needLoad",!1),Jd(uA(o),"_emitPlayFailed",!1),Jd(uA(o),"_videoContainer",void 0),Jd(uA(o),"_safari15VideoTimer",void 0),Jd(uA(o),"_monitor",void 0),Jd(uA(o),"logger",void 0),Jd(uA(o),"_onLocalTrackMute",void 0),Jd(uA(o),"_onInterruptionEnd",void 0),Jd(uA(o),"_needResume",!1),Jd(uA(o),"_rotate",0),Jd(uA(o),"_rotateDom",void 0),Jd(uA(o),"_resizeObserver",void 0),Jd(uA(o),"_hasManuallyPaused",!1),Jd(uA(o),"isIntersecting",void 0),Jd(uA(o),"intersectionObserver",void 0),Jd(uA(o),"emitVideoEvent",(function(e){var t,r,n={type:"video",rawEvent:e,readyState:(null===(t=o._videoDom)||void 0===t?void 0:t.readyState)||0,userId:o.userId,eventName:e.type,currentTime:(null===(r=o._videoDom)||void 0===r?void 0:r.currentTime)||0,isScreen:o.isScreen};switch(o.emit("playback_event",n),e.type){case"canplay":o.refreshRenderSize("the video started playing."),o._internalPlay();break;case"loadeddata":o._internalPlay();break;case"playing":o.logger.info("VideoPlayerPlaying","[userId-".concat(o.userId,"] video element playing"));break;case"pause":o.logger.info("VideoPlayerPause","[userId-".concat(o.userId,"] video element pause")),o._needResume&&(o.logger.info("VideoPlayerPause","[userId-".concat(o.userId,"] video element resume")),o._internalPlay(),o._needResume=!1)}})),Jd(uA(o),"_internalPlay",(function(){var e,t;if(o.engineId,null===(e=o._videoDom)||void 0===e||e.paused,o._hasManuallyPaused,!o._hasManuallyPaused&&null!==(t=o._videoDom)&&void 0!==t&&t.paused){var r=o._videoDom.play();null!=r&&r.then&&r.then((function(){var e;o.isLocal&&ED&&!o._needLoad&&(null===(e=o._videoDom)||void 0===e||e.load(),o._needLoad=!0)})).catch((function(e){var t,r,n,i,a,s;o._emitPlayFailed||("AbortError"!==e.name?(o._emitPlayFailed=!0,null===(t=o._monitor)||void 0===t||t.report("rtc_error",{message:Hg(r="video autoplay failed, userId: ".concat(o.userId,", ")).call(r,e.name),error_code:TK.AUTOPLAY_FAILED}),o.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(n=o._videoDom)||void 0===n?void 0:n.readyState)||0,userId:o.userId,eventName:"autoplay-error",currentTime:(null===(i=o._videoDom)||void 0===i?void 0:i.currentTime)||0,isScreen:o.isScreen})):null===(a=o._monitor)||void 0===a||a.report("rtc_error",{message:Hg(s="video autoplay failed, userId: ".concat(o.userId,", ")).call(s,e.name),error_code:TK.AUTOPLAY_FAILED}))}))}})),o.engineId=e,o.playerId=t;var a=i.renderDom;o._monitor=HM(e),o.logger=new hD("Player",0,e);var s=i.userId,c=i.isScreen?sh.RENDER_MODE_FIT:sh.RENDER_MODE_HIDDEN;o.renderMode=void 0!==i.renderMode?i.renderMode:c,o._rotate=Number(i.rotation||0);var u="string"==typeof a?document.getElementById(a):a;if(!u)throw new _w(dw.CANT_FIND_DOM,"can't find dom");return o._videoContainer=document.createElement("div"),o._videoContainer.style.width="100%",o._videoContainer.style.height="100%",o._videoContainer.style.position="relative",o._videoContainer.style.overflow="hidden",o._containerDom=u,o.userId=s,o.isLocal=!!i.isLocal,o.isScreen=!!i.isScreen,o._initVideo(),!o.isLocal||15!==(null==GD?void 0:GD[0])&&15!==BD||(o._safari15VideoTimer=window.setTimeout((function(){try{o._videoContainer.style.display="block",setTimeout((function(){o._videoContainer.style.display="flex"}),500)}catch(KJ){}}),1e3)),o}return jh(n,[{key:"_initVideo",value:function(){var e,t,r=this;this._videoDom||(this._videoDom=VY("video",{style:{width:"100%",height:"100%"},attributes:jY}),this._videoDom.id=Hg(t="".concat(this.userId,"_")).call(t,RL()),this.setRenderMode(this.renderMode),this.mirror(this.mirrorType===fh.MIRROR_TYPE_RENDER));this._containerDom.appendChild(this._videoContainer),kI(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._initInterSectionObserver(),this._initListeners(),this._onLocalTrackMute=function(){r._needResume=!0},this._onInterruptionEnd=function(){r.logger.warn("resume player after iOS interruption"),r._internalPlay()},hW.on(lW.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),hW.on(lW.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),hW.on(lW.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd)}},{key:"_initInterSectionObserver",value:function(){var e=this;!this.intersectionObserver&&"undefined"!=typeof IntersectionObserver&&this._videoDom&&(this.intersectionObserver=new IntersectionObserver((function(t){t[0]&&(e.isIntersecting=t[0].isIntersecting)}),{}),this.intersectionObserver.observe(this._videoDom))}},{key:"_closeIntersectionObserver",value:function(){this.intersectionObserver&&this._videoDom&&(this.intersectionObserver.disconnect(),this.intersectionObserver.unobserve(this._videoDom),delete this.intersectionObserver)}},{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,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===sh.RENDER_MODE_FILL)s=i,c=n;else{var u=this.renderMode===sh.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&&FY.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&&FY.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===sh.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this.renderMode===sh.RENDER_MODE_FILL?this._videoDom.style.objectFit="fill":this._videoDom.style.objectFit="cover")}},{key:"playVideo",value:(t=Ug(Dg().mark((function e(t){var r,n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=this._videoDom,this.logger.info("playVideo","play video track: ".concat(this.userId)),!(i&&i.srcObject instanceof MediaStream&&i.srcObject.getTrackById(null===(r=t.preprocessingTrack)||void 0===r?void 0:r.id))){e.next=5;break}try{this.engineId,this.userId}catch(KJ){}return e.abrupt("return");case 5:i||(this._initVideo(),i=this._videoDom),this.logger.info("playVideo","play video by dom: ".concat(null===(n=i)||void 0===n?void 0:n.id)),(o=new MediaStream).addTrack(t.preprocessingTrack),i.srcObject=o,i&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),i&&!this._videoContainer.contains(i)&&this._videoContainer.appendChild(i),setTimeout((function(){return a._internalPlay()})),cL.VIDEO_STALL&&this.emit(wW.START_STALL_OBSERVE),this.played=!0;case 15:case"end":return e.stop()}}),e,this)}))),function(e){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 _w(dw.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||OD?this._videoDom.play():Gg.resolve()}},{key:"manuallyPause",value:function(){if(this.played){if(this._hasManuallyPaused=!0,!this._videoDom)throw new _w(dw.INVALID_PARAMS,"Player not found");return this._videoDom.pause()}}},{key:"mirror",value:function(e){var t;this.logger.info("mirror",Hg(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?fh.MIRROR_TYPE_RENDER:fh.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",Hg(e="stop video track: ".concat(this.userId," ")).call(e,this.playerId.toString())),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,cL.VIDEO_STALL&&this.emit(wW.STOP_STALL_OBSERVE),this._closeIntersectionObserver()}},{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(),VA(UA(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),hW.off(lW.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),hW.off(lW.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),hW.off(lW.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}(_U.EventEmitter),GY=function(e){BA(i,e);var t,r,n=nC(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(Hh(this,i),Jd(uA(r=n.call(this)),"_containerDom",void 0),Jd(uA(r),"_audioDom",void 0),Jd(uA(r),"_fakeAudioDom",void 0),Jd(uA(r),"userId",void 0),Jd(uA(r),"muted",!1),Jd(uA(r),"_emitPlayFailed",!1),Jd(uA(r),"played",!1),Jd(uA(r),"isScreen",void 0),Jd(uA(r),"_wechatTimer",void 0),Jd(uA(r),"_edgeTimer",void 0),Jd(uA(r),"_monitor",void 0),Jd(uA(r),"logger",void 0),Jd(uA(r),"_pasued",!0),Jd(uA(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());MD&&OD&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),ND&&RD&&"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)})),Jd(uA(r),"_internalPlay",(function(){var e,t;if(r.engineId,null===(e=r._audioDom)||void 0===e||e.paused,r.userId,r.isScreen,null!==(t=r._audioDom)&&void 0!==t&&t.paused)try{var n,i=r._audioDom.play(),o=gW.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:TK.AUTOPLAY_FAILED}));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:Hg(n=Hg(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:TK.AUTOPLAY_FAILED})})).finally((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(MD&&ND&&(i=i.then((function(){return new Gg((function(e){setTimeout(Ug(Dg().mark((function t(){var n;return Dg().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(){r.engineId,r.userId,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:Hg(n=Hg(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:TK.AUTOPLAY_FAILED})})))}catch(d){var c,u,l;r._autoPlayError(d),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:Hg(u=Hg(l="audio autoplay failed, userId: ".concat(r.userId,": ")).call(l,d.message," ")).call(u,d.name),error_code:TK.AUTOPLAY_FAILED})}})),r.engineId=e,a){var u=document.getElementById(a);if(!u)throw new _w(dw.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=HM(e),r.logger=new hD("Player",0,e),r._initAudio(),r}return jh(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=VY("audio",{style:{display:"none"},attributes:BY}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Hg(e="".concat(this.userId,"_")).call(e,RL()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&FY.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&&(FY.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=Ug(Dg().mark((function e(t){var r,n,i,o,a,s=this;return Dg().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 EW?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.originTrack]),a.addTrack(t.preprocessingTrack)):a.addTrack(t.preprocessingTrack),MD&&ND&&(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 _w(dw.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 _w(dw.INVALID_PARAMS,"Player not found");if(!this.played)return Gg.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=gW.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?Gg.all(r):Gg.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,PW.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=$g(r).call(r,(function(e){return e.deviceId})),Qy(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(),VA(UA(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom),this._edgeTimer&&clearTimeout(this._edgeTimer)}}]),i}(_U.EventEmitter),zY=function(){var e=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(Gj.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)}}(),WY=fT,KY=WI,XY=function(e,t,r,n){for(var i,o=n>1?void 0:n?KY(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&&WY(t,r,o),o},YY=function(){function e(t,r){var n=this;Hh(this,e),Jd(this,"_sharedAudioContext",new AudioContext),Jd(this,"_workletReady",void 0),Jd(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),Jd(this,"_localGainNode",this._sharedAudioContext.createGain()),Jd(this,"_bufferGainNode",this._sharedAudioContext.createGain()),Jd(this,"_audioBufferSource",void 0),Jd(this,"_localSource",void 0),Jd(this,"_context",void 0),Jd(this,"_failedAudioList",[]),Jd(this,"_startingIds",new hT),Jd(this,"_revokeURLs",new Uz),Jd(this,"_audioFetchMap",new hT),Jd(this,"_audioFetchConfig",new hT),Jd(this,"mixingMap",new hT),Jd(this,"resourcesCache",new hT),Jd(this,"volumeConfig",new hT),Jd(this,"cachedBuffer",[]),Jd(this,"id","AudioMixingManager"),this.engineId=r,this._context=t;try{var i,o;this._workletReady=null===(i=this._sharedAudioContext.audioWorklet)||void 0===i||null===(o=i.addModule)||void 0===o?void 0:o.call(i,fW),this._workletReady.catch((function(){n._workletReady=null}))}catch(a){this._workletReady=null}this._localGainNode.gain.value=1}var t,r,n;return jh(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=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,h,f,v,p,_,m=this;return Dg().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,QL(o=n.type,"mixingType",AK(Lh)),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:Uh.AUDIO_MIXING_STATE_STOPPED,error:hw.AUDIO_MIXING_ERROR_OK});try{c.gainNode.disconnect(this._audioDestination),c.audioSource.disconnect(c.gainNode)}catch(g){}}if(!(l=this.resourcesCache.get(t))||l.filePath!==r){e.next=19;break}u=l.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:Uh.AUDIO_MIXING_STATE_FAILED,error:hw.AUDIO_MIXING_ERROR_START_FAILED}),new _w(dw.LOAD_RESOURCES_FAILED,e.statusText)}));case 21:return d=e.sent,GT(r).call(r,"mp3")?h={type:"audio/mpeg"}:GT(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=25,zY(d,h);case 25:if(e.sent){e.next=29;break}throw this._context.emitMessage({mixId:t,state:Uh.AUDIO_MIXING_STATE_FAILED,error:hw.AUDIO_MIXING_ERROR_START_FAILED}),new _w(dw.LOAD_RESOURCES_FAILED,"invalid audio resource");case 29:(u=new Audio).crossOrigin="anonymous",u.src=Gj.createObjectURL(new Blob([d],h));case 32:return i<=0?u.loop=!0:i>0&&(f=i,u.onended=function(){--f>0?u.play():(m.mixingMap.delete(t),m._context.emitMessage({mixId:t,state:Uh.AUDIO_MIXING_STATE_FINISHED,error:hw.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:ch.STREAM_INDEX_MAIN,mediaType:uh.AUDIO});case 43:if(this._startingIds.delete(t),v=this._sharedAudioContext.createMediaElementSource(u),p=this._sharedAudioContext.createGain(),_=this.volumeConfig.get(t),p.gain.value=_?_/100:1,v.connect(p).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:v,audioNode:u,gainNode:p,type:"file"}),o===Lh.PUBLISH)try{p.disconnect(this._sharedAudioContext.destination)}catch(g){}else p.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:Uh.AUDIO_MIXING_STATE_PLAYING,error:hw.AUDIO_MIXING_ERROR_OK}),this.updateFetcher(t);case 54: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.updateFetcher(e),this._context.emitMessage({mixId:e,state:Uh.AUDIO_MIXING_STATE_STOPPED,error:hw.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Uh.AUDIO_MIXING_STATE_PAUSED,error:hw.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:Uh.AUDIO_MIXING_STATE_PLAYING,error:hw.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=Ug(Dg().mark((function e(t,r){var n,i,o=this;return Dg().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 _w(dw.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Uh.AUDIO_MIXING_STATE_FAILED,error:hw.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof _w)throw e;throw new _w(dw.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,GT(r).call(r,"mp3")?i={type:"audio/mpeg"}:GT(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,zY(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Uh.AUDIO_MIXING_STATE_FAILED,error:hw.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new _w(dw.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Uh.AUDIO_MIXING_STATE_PRELOADED,error:hw.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=Gj.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new Gg((function(e){var r=Gj.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)),Gj.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:"setAudioFrameCallback",value:function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4096;if(QL(n,"frameSize",[256,512,1024,2048,4096,8192,16384]),n=null!==(r=n)&&void 0!==r?r:4096,null===this._workletReady)throw new _w(dw.NOT_SUPPORTED,"Not support AudioWorklet");t?this._audioFetchConfig.set(e,{callback:t,frameSize:n}):this._audioFetchConfig.delete(e),this.updateFetcher(e)}},{key:"updateFetcher",value:function(e){var t,r,n=null!==(t=this._audioFetchConfig.get(e))&&void 0!==t?t:{},i=n.callback,o=n.frameSize,a=null===(r=this.mixingMap.get(e))||void 0===r?void 0:r.gainNode;if(console.log("updateFetcher",a,o,i),a&&i&&o){var s=this._audioFetchMap.get(e);s?s.setFrameSize(o):s=new mW(a,o,this._sharedAudioContext,this._workletReady),s.on("data",i),this._audioFetchMap.set(e,s)}else{var c=this._audioFetchMap.get(e);null==c||c.removeAllListeners("data"),null==c||c.destroy(),this._audioFetchMap.delete(e)}}},{key:"enableAudioMixingBuffer",value:function(e){QL(e,"type",AK(Lh));var t=this._context.getLocalAudioTrack();if(t){var r=t.preprocessingTrack;if(r&&this.mixMediaStream(new MediaStream([r])),e===Lh.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:Uh.AUDIO_MIXING_STATE_PCM_ENABLED,error:hw.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:Uh.AUDIO_MIXING_STATE_PCM_DISABLED,error:hw.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=Ug(Dg().mark((function e(){var t,r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=by(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:ch.STREAM_INDEX_MAIN,mediaType:uh.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&&e.close(),this.cachedBuffer=[],this.mixingMap.clear(),this.resourcesCache.clear(),this.volumeConfig.clear(),this._startingIds=new hT,this._revokeURLs.forEach((function(e){Gj.revokeObjectURL(e)}))}}]),e}();XY([zM("id","filePath","options")],YY.prototype,"startAudioMixing",1),XY([zM("id")],YY.prototype,"stopAudioMixing",1),XY([zM("id")],YY.prototype,"pauseAudioMixing",1),XY([zM("id")],YY.prototype,"resumeAudioMixing",1),XY([zM("id")],YY.prototype,"preloadAudioMixing",1),XY([zM("id")],YY.prototype,"unloadAudioMixing",1),XY([zM("id")],YY.prototype,"getAudioMixingVolume",1),XY([zM("id","volume")],YY.prototype,"setAudioMixingVolume",1),XY([zM("id")],YY.prototype,"getAudioMixingDuration",1),XY([zM("id")],YY.prototype,"getAudioMixingCurrentPosition",1),XY([zM("id","position")],YY.prototype,"setAudioMixingPosition",1),XY([zM("id","callback","frameSize")],YY.prototype,"setAudioFrameCallback",1),XY([zM("type")],YY.prototype,"enableAudioMixingBuffer",1),XY([zM()],YY.prototype,"disableAudioMixingBuffer",1),XY([zM("buffer")],YY.prototype,"pushAudioMixingBuffer",1);var qY=function(e){BA(c,e);var t,r,n,i,o,a,s=nC(c);function c(e){var t;return Hh(this,c),Jd(uA(t=s.call(this)),"_loginSessionId",null),Jd(uA(t),"_userId",null),Jd(uA(t),"_token",null),Jd(uA(t),"_loginResolveCallback",void 0),Jd(uA(t),"_loginRejectCallback",void 0),Jd(uA(t),"_waitLoginToken",!1),Jd(uA(t),"_serverParamsCache",void 0),Jd(uA(t),"id",void 0),Jd(uA(t),"logger",void 0),Jd(uA(t),"_clearListeners",void 0),t._ctx=e,t.id=e.id,t.logger=new hD("RTSClient",1,e.id),t}return jh(c,[{key:"login",value:function(e,t){var r=this;return new Gg((function(n,i){var o;if(r.logger.info("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new _w(dw.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new _w(dw.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=HM(r.id))||void 0===o||o.set({rtm_user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._ctx.signalingManager.connect().then((function(){r._addSignalEventHandler(),r._login()}))}))}},{key:"logout",value:(a=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new _w(dw.NOT_LOGIN,"login first");case 2:return e.next=4,this._ctx.signalingManager.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId},{functionType:BX.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=Ug(Dg().mark((function e(t){var r=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new Gg((function(e,t){r._waitLoginToken?(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=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new _w(dw.NOT_LOGIN,"login first");case 2:return e.next=4,this._ctx.signalingManager.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,peerUserId:t},{functionType:BX.C2RTM});case 4:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(n=Ug(Dg().mark((function e(t,r){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new _w(dw.NOT_LOGIN,"login first");case 2:return e.abrupt("return",this._ctx.signalingManager.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:t,room:"",msg:r}));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"setServerParams",value:(r=Ug(Dg().mark((function e(t,r){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,JL(t,"signature"),JL(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new _w(dw.NOT_LOGIN,"login first");case 5:return e.next=7,this._ctx.signalingManager.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,signature:t,url:r},{functionType:BX.C2RTM}).catch((function(e){throw new _w(dw.UNEXPECTED_ERROR,e.msg)}));case 7:LM.setServerUrl(this.id,r),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=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new _w(dw.NOT_LOGIN,"login first");case 2:return e.abrupt("return",this._ctx.signalingManager.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:"",room:"",type:DX.BUSINESS_SERVER,msg:t}));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){this.logger.info("destroy","invoke."),VA(UA(c.prototype),"removeAllListeners",this).call(this),this._loginResolveCallback&&this._loginRejectCallback&&(this._loginRejectCallback(new _w(dw.LOGIN_FAILED,"logout")),delete this._loginResolveCallback,delete this._loginRejectCallback),this._clearState(),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=RL();this._ctx.signalingManager.sendSignaling("login",{Token:wL.token2auth(this._ctx.appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:cL.VERSION,deviceId:tL.getDeviceId(),appId:this._ctx.appId,userId:this._userId}},{functionType:BX.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,LM.setRtsSessionId(e.id,t),e._waitLoginToken=!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._waitLoginToken=!1,o>=700&&o<800?708===o?(r=dw.INVALID_PARAMS,n="Invalid userId"):(r=dw.INVALID_TOKEN,n="Invalid token",e._waitLoginToken=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=dw.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new _w(r,a||n))})).finally((function(){delete e._loginResolveCallback,delete e._loginRejectCallback}))}}},{key:"_addSignalEventHandler",value:function(){var e=this,t=function(t){t.state===dh.CONNECTION_STATE_RECONNECTED&&e._login()},r=function(){return e._clearState()},n=function(t){e.emit("onUserMessageReceivedOutsideRoom",{userId:t.from,message:t.msg})},i=function(t){e.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:t.from,message:t.msg})},o=function(t){t.clientId!==e._userId||t.roomId||(e.emit("onUserDisconnection"),e._clearState())};this._ctx.signalingManager.on(IU.ON_CONNECTION_STATE_CHANGE,t),this._ctx.signalingManager.on(IU.ON_RECONNECT_FAILED,r),this._ctx.signalingManager.on(kU.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,n),this._ctx.signalingManager.on(kU.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,i),this._ctx.signalingManager.on(kU.USER_DISCONNECTION,o),this._clearListeners=function(){e._ctx.signalingManager.off(IU.ON_CONNECTION_STATE_CHANGE,t),e._ctx.signalingManager.off(IU.ON_RECONNECT_FAILED,r),e._ctx.signalingManager.off(kU.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,n),e._ctx.signalingManager.off(kU.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,i),e._ctx.signalingManager.off(kU.USER_DISCONNECTION,o)}}},{key:"_clearState",value:function(){var e;null===(e=this._clearListeners)||void 0===e||e.call(this),this._userId=null,this._token=null,this._loginSessionId=null,LM.setRtsSessionId(this.id,"")}}]),c}(_U.EventEmitter),JY=fT,QY=WI,ZY=function(e,t,r,n){for(var i,o=n>1?void 0:n?QY(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&&JY(t,r,o),o},$Y=function(e){BA(a,e);var t,r,n,i,o=nC(a);function a(e){var t;return Hh(this,a),Jd(uA(t=o.call(this)),"_remoteStreams",new hT),Jd(uA(t),"_logger",void 0),Jd(uA(t),"_monitor",void 0),Jd(uA(t),"_ontrackCallbackMap",new hT),t._ctx=e,t._monitor=HM(e.id),t._logger=new hD("PublicStreamManager",1,e.id),t}return jh(a,[{key:"getRemoteStream",value:function(e){return this._remoteStreams.get(e)}},{key:"getRemoteStreams",value:function(){return this._remoteStreams}},{key:"startPlayPublicStream",value:(i=Ug(Dg().mark((function e(t){var r,n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.getRemoteStream(t)){e.next=2;break}throw new _w(dw.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new aK(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=jL(e),i=0;i<t.seiCount;i++)n.safeEmit("onSEIMessageReceived",{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._ctx.signalingManager.connect();case 6:return e.next=8,this._subscribePublicStream(r);case 8:return this._remoteStreams.set(t,r),e.abrupt("return",r);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(n=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getRemoteStream(t)){e.next=3;break}return e.abrupt("return");case 3:return this._remoteStreams.delete(t),e.next=6,this._ctx.signalingManager.connect();case 6:return e.abrupt("return",this._unsubscribePublicStream(r));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"destroy",value:function(){this._remoteStreams.forEach((function(e){e.clean()})),this._remoteStreams=new hT,this.removeAllListeners(),this._ontrackCallbackMap.clear()}},{key:"_subscribePublicStream",value:(r=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,h,f,v,p,_,m=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._ctx.handler)||void 0===r?void 0:r.subscribe(t,{multiChatMode:!1});case 2:if(a=e.sent){e.next=5;break}throw new _w(dw.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return s=AL(),c=a.audioMid,u=a.videoMid,e.t0=this._ctx.appId,e.t1=t.streamId,e.t2=c,e.t3=u,e.t4={sdp:a.partialSdp,semantics:a.semantics,type:a.type},e.next=15,VU();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=cL.VERSION,e.t8=tL.getDeviceId(),e.t9=this._ctx.appId,e.t10=this._ctx.businessId,e.t11=this._ctx.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,this._ctx.signalingManager.sendSignaling("startPullStream",l);case 27:return d=e.sent,(h=[]).push(new Gg((function(e,r){var n=setTimeout((function(){return r(new _w(dw.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),wK);t.on("ontrack",(function r(i){"video"===i.mediaType&&(m._logger.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),h.push(new Gg((function(e,r){var n=setTimeout((function(){return r(new _w(dw.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),wK);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(m._logger.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),f=function(e){t.ontrack(e)},null===(n=this._ctx.handler)||void 0===n||n.on("ontrack",f),this._ontrackCallbackMap.set(t,f),v=d.relayMessage,p=v.sequenceId,_=v.sdp,t.videoMid=u,t.audioMid=c,t.sequenceId=p,t.streamState=iK.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=43,null===(i=this._ctx.handler)||void 0===i?void 0:i.handleAck({action:$X.subscribe,streamId:t.streamId,audioMid:c,videoMid:u,audioTransceiverInit:a.audioTransceiverInit,videoTransceiverInit:a.videoTransceiverInit,signalingAck:{sdp:_,sequenceId:p},stream:t});case 43:return e.next=45,Gg.all(h);case 45:null===(o=this._monitor)||void 0===o||o.report("rtc_subscribe_stat",{result:"success",start:s,message:"unknown",stream_user_id:t.userId}),t.startReport((function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,m.safeEmit("onRemoteStreamStats",BL(e))}),this._ctx.handler);case 47:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_unsubscribePublicStream",value:(t=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return xK("_unsubscribePublicStream()",t,this._logger),n={appId:this._ctx.appId,streamId:t.streamId},e.prev=2,e.next=5,this._ctx.signalingManager.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=iK.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._ctx.handler)||void 0===r?void 0:r.handleAck({action:$X.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),t.subMediaType=iV.NONE,this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return t.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t=this._ontrackCallbackMap.get(e);if(t){var r=e.vendorHandler||this._ctx.handler;null==r||r.off("ontrack",t),this._ontrackCallbackMap.delete(e)}}},{key:"handleReconnected",value:function(){var e,t=this,r=by(this._remoteStreams);try{for(r.s();!(e=r.n()).done;){var n=Ey(e.value,2),i=n[0],o=n[1];o.clean(),o.statsReport.unsubscribe(),this._remoteStreams.delete(i),this.startPlayPublicStream(i).then((function(e){t.safeEmit("onResubscribe",{stream:e})}))}}catch(XJ){r.e(XJ)}finally{r.f()}}}]),a}(yU);ZY([pY],$Y.prototype,"_subscribePublicStream",1),ZY([pY],$Y.prototype,"_unsubscribePublicStream",1);var eq=new hD("AudioDeviceManager",1),tq=function(e){BA(c,e);var t,r,n,i,o,a,s=nC(c);function c(e,t){var r;return Hh(this,c),Jd(uA(r=s.call(this)),"_audioLevelFetcher",void 0),Jd(uA(r),"_playbackDeviceTestTimer",void 0),Jd(uA(r),"_audioElement",void 0),Jd(uA(r),"_audioTrack",void 0),Jd(uA(r),"_mediaRecorder",void 0),Jd(uA(r),"_recoderTimer",void 0),Jd(uA(r),"_isAudioPlaybackDeviceTesting",!1),Jd(uA(r),"_isAudioDeviceRecordTesting",!1),Jd(uA(r),"_audioCaptureAndRecoderResolve",void 0),Jd(uA(r),"_onAutoplayFailed",void 0),Jd(uA(r),"_audioPlaybackDeviceId",void 0),r._ctx=e,r._extensionManager=t,r}return jh(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=Ug(Dg().mark((function e(t,r){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new _w(dw.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,eq.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),eq.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&&(eq.info("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=Ug(Dg().mark((function e(t,r,n){var i,o=this,a=arguments;return Dg().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 _w(dw.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 3:if(!this._isAudioDeviceRecordTesting&&!this._isAudioPlaybackDeviceTesting){e.next=5;break}throw new _w(dw.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 5:return this._isAudioDeviceRecordTesting=!0,eq.info("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){eq.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(){eq.info("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(eq.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=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(eq.info("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new _w(dw.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,PW.getAudioPlaybackDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new _w(dw.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(){eq.info("destroy()","Invoke"),VA(UA(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=Ug(Dg().mark((function e(t,r){var n,i=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return eq.info("_playAudioFile()",Hg(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new Gg((function(e,n){var o=VY("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new _W(o),o.onplaying=function(){o.onplaying=null,eq.info("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=Ug(Dg().mark((function e(t){var r,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:eq.error("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new _w(dw.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;eq.warn("_playAudioFile()","autoplay error",e);var r=Hg(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return Gg.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new _w(dw.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&&(eq.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&&(eq.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&&(eq.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=Ug(Dg().mark((function e(t,r){var n,i=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,jW(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r+.01),n=new MediaStream([this._audioTrack.preprocessingTrack]),eq.info("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new Gg((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=lI(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),eq.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=Ug(Dg().mark((function n(o){var a,c;return Dg().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return eq.info("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(Gj.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 _w(dw.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.destroy(),delete this._audioTrack}},{key:"_setAudioCtxSinkId",value:(t=Ug(Dg().mark((function e(){var t,r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=gW.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),eq.info("setSinkId","ctx.sinkId=".concat(t))}catch(o){eq.error("setSinkId",Hg(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}(_U.EventEmitter),rq=function(){return{url:"",video:{codec:Ch.H264,width:640,height:360,fps:15,gop:2,kBitRate:nq(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:Ah.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function nq(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 iq(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new _w(dw.INVALID_PARAMS,"Invalid rtmp address")}function oq(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new _w(dw.INVALID_PARAMS,"regions should not be empty.");var t,r=by(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new _w(dw.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if(iU(n.userId),"boolean"!=typeof n.isScreenStream)throw new _w(dw.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(XJ){r.e(XJ)}finally{r.f()}}function aq(e,t){var r,n,i,o=function(e,r){var n=uS(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=uS(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})),l=(null===(r=t.video)||void 0===r?void 0:r.kBitRate)||0,d=o(["audio","sampleRate"],(function(e){var t;return!!lI(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:d<100?1e3*d:d,channels:o(["audio","channels"],(function(e){var t;return Qy(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return Qy(t=[Ah.LC,Ah.HEv1,Ah.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return Qy(t=["H264","H265"]).call(t,e)})),fps:u,gop:o(["video","gop"],(function(e){return e>=1&&e<=5}))*u,bitRate:1e3*(l>=16&&l<=1e4?l:nq(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:$g(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&&Qy(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&Qy(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 sq,cq={getDefaultValue:rq,checkStartParams:function(e){var t;iq(e.url),oq(null===(t=e.layout)||void 0===t?void 0:t.regions)},checkUpdateParams:function(e){var t;e.url&&iq(e.url),oq(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return aq("started",e)},getUpdateParams:function(e){return aq("layoutChanged",e)}},uq=qf,lq=ei;Cr({target:"Object",stat:!0},{fromEntries:function(e){var t={};return uq(e,(function(e,r){lq(t,e,r)}),{AS_ENTRIES:!0}),t}});var dq,hq=r(te.Object.fromEntries),fq=["ele","fakeEle"],vq=["orgTrack","mediaTrack","preprocessingTrack"],pq=["orgTrack","mediaTrack","preprocessingTrack"],_q=["currentTime","duration","ended","error","muted","networkState","paused","readyState","seekable","sinkId","src","volume"],mq=["currentTime","sampleRate","state","baseLatency","outputLatency","sinkId"],gq=["contentHint","enabled","id","kind","label","muted","readyState"],yq=["currentDirection","direction","mid","stopped"];function Sq(e){return bq.apply(this,arguments)}function bq(){return(bq=Ug(Dg().mark((function e(t){var r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Date.now(),n=[],!t._ctx.handler||!t._ctx.handler._peerConnection){e.next=6;break}return e.next=5,t._ctx.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 Eq(e){var t={};if(e instanceof MediaStream){t.id=e.id,t.active=e.active;var r=e.getTracks();t.tracks=$g(r).call(r,(function(e){return hq($g(gq).call(gq,(function(t){return[t,e[t]]})))}))}return t}function kq(e){return Tq.apply(this,arguments)}function Tq(){return(Tq=Ug(Dg().mark((function e(t){var r,n,i,o,a;return Dg().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&&t._remoteVideoPlayer.forEach((function(e,t){n.push({userId:t,mediaType:"video",isScreen:!1,isPublic:!1,ele:e?e._videoDom:void 0})})),t._remoteScreenPlayer&&(null===(i=t._remoteScreenPlayer)||void 0===i||i.forEach((function(e,t){n.push({userId:t,mediaType:"video",isScreen:!0,isPublic:!1,ele:e?e._videoDom:void 0})}))),t._remoteAudioPlayer&&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})})),t._localVideoTrack&&t._localVideoTrack.videoPlayers&&t._localVideoTrack.videoPlayers.forEach((function(e,t){n.push({playerId:t.toString(),userId:"__local__",mediaType:"video",isScreen:!1,isPublic:!1,ele:e._videoDom})})),t._localScreenTrack&&t._localScreenTrack.videoPlayers&&t._localScreenTrack.videoPlayers.forEach((function(e,t){n.push({playerId:t.toString(),userId:"__local__",mediaType:"video",isScreen:!0,isPublic:!1,ele:e._videoDom})})),t._room&&t._room._remoteStreams&&t._room._remoteStreams.forEach((function(e,t){e.forEach((function(e){if(e.audioTrack){var r=e.audioTrack._audioPlayer;n.push({userId:t,mediaType:"audio",isScreen:e.isScreen,isPublic:!1,ele:r?r._audioDom:void 0,fakeEle:r?r._fakeAudioDom:void 0})}e.videoTrack&&e.videoTrack.videoPlayers&&e.videoTrack.videoPlayers.forEach((function(r,i){n.push({playerId:i.toString(),userId:t,mediaType:"video",isScreen:e.isScreen,isPublic:!1,ele:r?r._videoDom:void 0})}))}))})),(o=t._publicStreamManager)||(o=t._outsideRoom),o&&o.remoteStreams&&o.remoteStreams.forEach((function(e,t){if(e.audioTrack){var r=e.audioTrack._audioPlayer;n.push({userId:t,mediaType:"audio",isScreen:!1,isPublic:!0,ele:r?r._audioDom:void 0,fakeEle:r?r._fakeAudioDom:void 0})}e.videoTrack&&e.videoTrack.videoPlayers&&e.videoTrack.videoPlayers.forEach((function(e,r){n.push({playerId:r.toString(),userId:t,mediaType:"video",isScreen:!1,isPublic:!0,ele:e?e._videoDom:void 0})}))})),t&&t._room&&t._room._virtualStreams&&t._room._virtualStreams.forEach((function(e,t){if(e.audioTrack){var r=e.audioTrack._audioPlayer;n.push({userId:"virtualStream-".concat(t),mediaType:"audio",isScreen:!1,isPublic:!1,isVirtual:!0,ele:r?r._audioDom:void 0,fakeEle:r?r._fakeAudioDom:void 0})}})),a=$g(n).call(n,(function(e){var t=e.ele,r=e.fakeEle,n=bM(e,fq),i=Zd({ele:Zd({srcObject:t?Eq(t.srcObject):void 0},hq($g(_q).call(_q,(function(e){return[e,t[e]]}))))},n);return r&&(i.fakeEle=Zd({srcObject:Eq(r.srcObject)},hq($g(_q).call(_q,(function(e){return[e,r[e]]}))))),i})),e.abrupt("return",{timestamp:r,elementStats:a});case 19:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Iq(e){var t,r=[],n=[];e&&e._room&&e._room._remoteStreams&&(n=$w(t=e._room._remoteStreams).call(t));var i,o=by(n);try{for(o.s();!(i=o.n()).done;){i.value.forEach((function(e){e.audioTrack&&r.push(e.audioTrack)}))}}catch(XJ){o.e(XJ)}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,l=s[a];if(l._audioLevelFetcher&&l._audioLevelFetcher._ctx)return l._audioLevelFetcher._ctx;if(l._ac)return l._ac;if(l._audioFetchMap)if(Fw($w(c=l._audioFetchMap).call(c)).length)return Fw($w(u=l._audioFetchMap).call(u))[0]._ctx;if(l._ap&&l._ap._ac)return l._ap._ac}return null}function Rq(e){return Aq.apply(this,arguments)}function Aq(){return(Aq=Ug(Dg().mark((function e(t){var r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Date.now(),n=Iq(t),i={},n){e.next=5;break}return e.abrupt("return",{timestamp:r,acState:void 0});case 5:return mq.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 Cq(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&&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 wq(e,t){return xq.apply(this,arguments)}function xq(){return(xq=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,h,f,v;return Dg().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),l=r.createAnalyser(),u.connect(l),"suspended"===r.state&&(console.warn(r.state),r.resume()),d=new Uint8Array(n),l.getByteTimeDomainData(d),e.next=17,new Gg((function(e){setTimeout(e,i)}));case 17:return l.getByteTimeDomainData(d),e.next=20,new Gg((function(e){setTimeout(e,i)}));case 20:return h=0,d.forEach((function(e){return h=Math.max(h,Math.abs(e-o))})),v=(f=h/o*a)>s?f:0,u.disconnect(),l.disconnect(),e.abrupt("return",v);case 27:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Oq(e){return Nq.apply(this,arguments)}function Nq(){return Nq=Ug(Dg().mark((function e(t){var r,n,i,o;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1e3,n=Date.now(),dq||(dq=new AudioContext),"suspended"!==dq.state){e.next=6;break}return e.next=6,new Gg((function(e){var r=setTimeout((function(){console.warn("[RTC_AMBULANCE] AudioContext resume failed, try to find one in RTCEngine"),(dq=Iq(t))&&console.warn("[RTC_AMBULANCE] find AudioContext in RTCEngine success"),e()}),1e3);dq.resume().then((function(){clearTimeout(r),e()}),(function(){clearTimeout(r),dq=null,e()}))}));case 6:if(dq){e.next=9;break}return console.error("[RTC_AMBULANCE] get volume is not supported"),e.abrupt("return");case 9:return i=Cq(t),o=[],e.next=13,Gg.all($g(r=Cy(i).call(i,(function(e){return"audio"===e.mediaType}))).call(r,function(){var e=Ug(Dg().mark((function e(t){var r,n,i,a,s;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.orgTrack,n=t.mediaTrack,i=t.preprocessingTrack,a=bM(t,vq),s=Zd({},a),e.next=4,Gg.all([wq(r,dq).then((function(e){s.orgTrackVolume=e})),wq(n,dq).then((function(e){s.mediaTrackVolume=e})),wq(i,dq).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)}))),Nq.apply(this,arguments)}function Pq(e){return Mq.apply(this,arguments)}function Mq(){return(Mq=Ug(Dg().mark((function e(t){var r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Date.now(),n=Cq(t),i=$g(n).call(n,(function(e){var t=e.orgTrack,r=e.mediaTrack,n=e.preprocessingTrack,i=bM(e,pq);return Zd({orgTrack:t?hq($g(gq).call(gq,(function(e){return[e,t[e]]}))):void 0,mediaTrack:r?hq($g(gq).call(gq,(function(e){return[e,r[e]]}))):void 0,preprocessingTrack:n?hq($g(gq).call(gq,(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 Dq(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 Lq(e){return Uq.apply(this,arguments)}function Uq(){return(Uq=Ug(Dg().mark((function e(t){var r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Date.now(),n=[],t._ctx._handler&&t._ctx._handler._peerConnection&&(n=t._ctx._handler._peerConnection.getTransceivers()),i=[],n.forEach((function(e){var t=Zd({sender:Dq(e.sender),receiver:Dq(e.receiver)},hq($g(yq).call(yq,(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 Vq(e){return Fq.apply(this,arguments)}function Fq(){return(Fq=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={stats:[],mediaElementStates:[],audioContextStates:[],volumes:[],trackStates:[],tranceiverStates:[]},n=[],e.next=4,new Gg((function(e){var i,o=0;i=setTimeout((function a(){n.push(Sq(t).then((function(e){r.stats.push(e)})),kq(t).then((function(e){r.mediaElementStates.push(e)})),Rq(t).then((function(e){r.audioContextStates.push(e)})),Oq(t).then((function(e){r.volumes.push(e)})),Pq(t).then((function(e){r.trackStates.push(e)})),Lq(t).then((function(e){r.tranceiverStates.push(e)}))),++o>=10?Gg.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 Bq=_,jq=uE,Hq=zb.getWeakData,Gq=Rv,zq=rr,Wq=W,Kq=ee,Xq=qf,Yq=Ze,qq=ro.set,Jq=ro.getterFor,Qq=Vo.find,Zq=Vo.findIndex,$q=Bq([].splice),eJ=0,tJ=function(e){return e.frozen||(e.frozen=new rJ)},rJ=function(){this.entries=[]},nJ=function(e,t){return Qq(e.entries,(function(e){return e[0]===t}))};rJ.prototype={get:function(e){var t=nJ(this,e);if(t)return t[1]},has:function(e){return!!nJ(this,e)},set:function(e,t){var r=nJ(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=Zq(this.entries,(function(t){return t[0]===e}));return~t&&$q(this.entries,t,1),!!~t}},sE("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),{getConstructor:function(e,t,r,n){var i=e((function(e,i){Gq(e,o),qq(e,{type:t,id:eJ++,frozen:void 0}),Wq(i)||Xq(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=Jq(t),s=function(e,t,r){var n=a(e),i=Hq(zq(t),!0);return!0===i?tJ(n).set(t,r):i[n.id]=r,e};return jq(o,{delete:function(e){var t=a(this);if(!Kq(e))return!1;var r=Hq(e);return!0===r?tJ(t).delete(e):r&&Yq(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!Kq(e))return!1;var r=Hq(e);return!0===r?tJ(t).has(e):r&&Yq(r,t.id)}}),jq(o,r?{get:function(e){var t=a(this);if(Kq(e)){var r=Hq(e);return!0===r?tJ(t).get(e):r?r[t.id]:void 0}},set:function(e,t){return s(this,e,t)}}:{add:function(e){return s(this,e,!0)}}),i}});var iJ=te.WeakSet,oJ=Ae,aJ=function(e){if("object"==typeof e&&"has"in e&&"add"in e&&"delete"in e)return e;throw TypeError(oJ(e)+" is not a weakset")},sJ=RE,cJ={WeakSet:ae("WeakSet"),add:sJ("add",1),has:sJ("has",1),remove:sJ("delete",1)},uJ=aJ,lJ=cJ.add;Cr({target:"WeakSet",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=uJ(this),t=0,r=arguments.length;t<r;t++)lJ(e,arguments[t]);return e}});var dJ=aJ,hJ=cJ.remove;Cr({target:"WeakSet",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=dJ(this),r=!0,n=0,i=arguments.length;n<i;n++)e=hJ(t,arguments[n]),r=r&&e;return!!r}}),Cr({target:"WeakSet",stat:!0,forced:!0},{from:XE}),Cr({target:"WeakSet",stat:!0,forced:!0},{of:qE});var fJ=r(iJ),vJ=function(){function e(){Hh(this,e),Jd(this,"containers",new fJ)}return jh(e,[{key:"getContainerById",value:function(e){return document.getElementById(e)}},{key:"registerContainer",value:function(e){var t;"string"==typeof e&&(e=null!==(t=this.getContainerById(e))&&void 0!==t?t:void 0);return!(!e||this.containers.has(e))&&(this.containers.add(e),!0)}},{key:"unregisterContainer",value:function(e){var t;"string"==typeof e&&(e=null!==(t=this.getContainerById(e))&&void 0!==t?t:void 0);return!!e&&(this.containers.delete(e),!0)}}]),e}(),pJ=fT,_J=WI,mJ=function(e,t,r,n){for(var i,o=n>1?void 0:n?_J(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&&pJ(t,r,o),o},gJ=function(e){BA(Ue,e);var t,r,n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R,A,C,w,x,O,N,P,M,D,L,U,V,F,B,j,H,G,z,W,K,X,Y,q,J,Q,Z,$,ee,te,re,ne,ie,oe,ae,se,ce,ue,le,de,he,fe,ve,pe,_e,me,ge,ye,Se,be,Ee,ke,Te,Ie,Re,Ae,Ce,we,xe,Oe,Ne,Pe,Me,De,Le=nC(Ue);function Ue(e,t,r){var n,i,o;return Hh(this,Ue),Jd(uA(o=Le.call(this)),"monitor",void 0),Jd(uA(o),"logger",void 0),Jd(uA(o),"_room",void 0),Jd(uA(o),"_publicStreamManager",void 0),Jd(uA(o),"_appId",void 0),Jd(uA(o),"_localVideoTrack",void 0),Jd(uA(o),"_localAudioTrack",void 0),Jd(uA(o),"_localImgVideoTrack",void 0),Jd(uA(o),"_localImgScreenTrack",void 0),Jd(uA(o),"_localScreenVideoTrack",void 0),Jd(uA(o),"_localScreenAudioTrack",void 0),Jd(uA(o),"_tempMixingAudioTrack",void 0),Jd(uA(o),"_localAudioVolume",100),Jd(uA(o),"_localScreenAudioVolume",100),Jd(uA(o),"_remoteAudioVolume",new hT),Jd(uA(o),"_remoteScreenAudioVolume",new hT),Jd(uA(o),"_publicAudioVolume",new hT),Jd(uA(o),"_localVideoPlayerConfig",(Jd(n={},ch.STREAM_INDEX_MAIN,new hT),Jd(n,ch.STREAM_INDEX_SCREEN,new hT),n)),Jd(uA(o),"_remoteVideoPlayerConfig",(Jd(i={},ch.STREAM_INDEX_MAIN,new hT),Jd(i,ch.STREAM_INDEX_SCREEN,new hT),i)),Jd(uA(o),"_publicVideoPlayerConfig",new hT),Jd(uA(o),"_publicStreamIds",new hT),Jd(uA(o),"_videoStreamConstraints",Zd({},pL)),Jd(uA(o),"_audioStreamConstraints",{}),Jd(uA(o),"_enableSimulcast",!1),Jd(uA(o),"_videoStreamEncodeConfig",[Zd({},pL)]),Jd(uA(o),"_screenStreamEncodeConfig",[Zd({},_L)]),Jd(uA(o),"_dummyMainImage",void 0),Jd(uA(o),"_dummyScreenImage",void 0),Jd(uA(o),"_trackSourceType",void 0),Jd(uA(o),"_liveTranscodeConfig",void 0),Jd(uA(o),"_startCloudProxyTimestamp",void 0),Jd(uA(o),"_localVideoDeviceId",void 0),Jd(uA(o),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeAudioStreamIds:{},resumeVideoStreamIds:{}}),Jd(uA(o),"_audioVolumeIndicationTimer",void 0),Jd(uA(o),"_dummyMainTimer",void 0),Jd(uA(o),"_dummyScreenTimer",void 0),Jd(uA(o),"_audioPropertiesReportTimer",null),Jd(uA(o),"_mirrorType",fh.MIRROR_TYPE_RENDER),Jd(uA(o),"_audioMixingManager",void 0),Jd(uA(o),"_pubLock",void 0),Jd(uA(o),"_subLocks",void 0),Jd(uA(o),"_audioCaptureLock",void 0),Jd(uA(o),"_videoCaptureLock",void 0),Jd(uA(o),"_screenCaptureLock",void 0),Jd(uA(o),"_subScreenLocks",void 0),Jd(uA(o),"_rtmClient",void 0),Jd(uA(o),"_messageStatisticsObserver",void 0),Jd(uA(o),"_waitForNewToken",!1),Jd(uA(o),"_originIceConfigRequestUrls",void 0),Jd(uA(o),"_originConfigServerUrls",void 0),Jd(uA(o),"_originLogServerUrl",void 0),Jd(uA(o),"_extensionManager",void 0),Jd(uA(o),"_audioDeviceManager",void 0),Jd(uA(o),"_remoteVideoConfig",new hT),Jd(uA(o),"_config",void 0),Jd(uA(o),"_needClosePreTrack",!1),Jd(uA(o),"_containerCollisionDetector",new vJ),Jd(uA(o),"_ctx",void 0),Jd(uA(o),"_updateMixAudioTrack",function(){var e=Ug(Dg().mark((function e(t){var r,n,i=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=i.length>1&&void 0!==i[1]?i[1]:Lh.PLAYOUT_AND_PUBLISH,o.logger.info("_updateMixAudioTrack()"),o._localAudioTrack){e.next=5;break}return t&&(o._tempMixingAudioTrack={track:t,type:n}),e.abrupt("return");case 5:if(t?(o._localAudioTrack.mixType=n,o._localAudioTrack.mixedAudioTrack=t):(delete o._localAudioTrack.mixType,delete o._localAudioTrack.mixedAudioTrack),null===(r=o._room)||void 0===r||!r.hasPublished){e.next=9;break}return e.next=9,o._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),Jd(uA(o),"_onAudioMixingMessage",(function(e){o.safeEmit(Fh.onAudioMixingStateChanged,e)})),Jd(uA(o),"_onAudioMixingAutoplayFailed",(function(e){o.safeEmit(Fh.onAutoplayFailed,e)})),o.id=t,o._appId=e,o.monitor=HM(t),o._ctx=new vY(t,e,r),o._pubLock=new dY("pubLock"),o._subLocks=new hT,o._subScreenLocks=new hT,o._audioCaptureLock=new dY("audioCap"),o._videoCaptureLock=new dY("videoCap"),o._screenCaptureLock=new dY("screenCap"),o._addDeviceEventHandler(),o._extensionManager=new $z(t),o._audioDeviceManager=new tq(o._ctx,o._extensionManager),o._audioMixingManager=new YY({getLocalAudioTrack:function(){return o._localAudioTrack},updateLocalAudioTrack:o._updateMixAudioTrack,emitMessage:o._onAudioMixingMessage,onAutoPlayFailed:o._onAudioMixingAutoplayFailed},t),o._addSignalingEventHandler(),o._publicStreamManager=new $Y(o._ctx),o._addPublicStreamEventHandler(),window.__rtc_engine__=uA(o),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=uA(o),o._trackSourceType={video:$d.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:$d.VIDEO_SOURCE_TYPE_INTERNAL,audio:eh.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:eh.AUDIO_SOURCE_TYPE_INTERNAL},o._config=r,o._rtmClient=new qY(o._ctx),o._handleRTMClient(o._rtmClient),o._handleAudioDeviceManager(),o._messageStatisticsObserver=new UM(t),o.logger=new hD("Engine",0,t),LM.createRTSMsgReportor(o.id),o._getServerConfig(),o.monitor.reportLongString("NativeDetector",Xg(BS)),o}return jh(Ue,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(De=Ug(Dg().mark((function e(t){var r,n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateToken()","token: %s",t),JL(t,"token"),!this._room||!this._waitForNewToken){e.next=8;break}return this._waitForNewToken=!1,this._room.config.token=t,e.next=7,this._join(this._room);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new _w(dw.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,this._room.updateToken(t);case 12:return r=[],this._room.config.tokenPublishPrivilegeExpired&&this._room.config.isAutoPublish&&this._ctx.visibility&&r.push(this._updatePublish({mediaType:uh.AUDIO_AND_VIDEO})),this._room.config.tokenSubscribePrivilegeExpired&&(n=this._room.config,i=n.isAutoSubscribeAudio,o=n.isAutoSubscribeVideo,(a=(i?uh.AUDIO:0)|(o?uh.VIDEO:0))&&r.push(this._triedResumeAllRemoteStreams(a,!0))),e.next=17,Gg.allSettled(r);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return De.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(Me=Ug(Dg().mark((function e(t){var r,n,i,o,a,s=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setVideoCaptureDevice()","deviceId: %s",t),JL(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:if(!OD||!MD){e.next=9;break}if(this._localVideoTrack.originTrack.getSettings().deviceId!==t){e.next=9;break}return e.abrupt("return");case 9:return n=IK({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete n.deviceId,n.facingMode=t):!AD||PD?n.deviceId={exact:t}:delete n.deviceId,MD&&bD&&KD>=85&&KD<=91&&(null===(i=this.localVideoTrack)||void 0===i||i.removePlayerTrack()),this._needClosePreTrack=this._needClosePreTrack||eV,this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.destroy(),delete this._localVideoTrack),this.logger.info("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=17,FW(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.destroy(),delete s._localVideoTrack,FW(n,s._extensionManager).then((function(e){return s._needClosePreTrack=!0,e})).catch(Ug(Dg().mark((function t(){var r;return Dg().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.logger.error("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,FW(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.destroy()),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 Me.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(Pe=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setAudioCaptureDevice()","deviceId: %s",t),JL(t,"deviceId"),this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return this._localAudioTrack.destroy(),this._removeLocalTrackEvents(this._localAudioTrack),e.next=9,jW(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 Pe.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){PW.on(Fh.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),PW.on(Fh.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addSignalingEventHandler",value:function(){var e=this,t=this._ctx.signalingManager;t.on(IU.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),t.on(IU.ON_RECONNECT_FAILED,(function(){e.safeEmit(Fh.onError,{errorCode:dw.RECONNECT_FAILED})})),t.on(IU.CONNECT_WITH_TCP,(function(){e.safeEmit(Fh.onIceConnectWithTcp)}))}},{key:"_addPublicStreamEventHandler",value:function(){var e=this;this._publicStreamManager.on("onResubscribe",(function(t){var r=t.stream;r&&(r.audioTrack&&e._updateAudioPlayerState(r),r.videoTrack&&e._updateVideoPlayerState(r))})),this._publicStreamManager.on("onRemoteStreamStats",(function(t){e.safeEmit(Fh.onPublicStreamStats,t)})),this._publicStreamManager.on("onSEIMessageReceived",(function(t){e.safeEmit(Fh.onPublicStreamSEIMessageReceived,t)}))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R,A,C,w,x,O,N,P,M,D,L,U,V,F,B,j=this;null===(e=this._room)||void 0===e||e.on(kU.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(kU.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(kU.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(sK.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(sK.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(sK.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(kU.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(kU.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(kU.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(kU.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(l=this._room)||void 0===l||l.on(kU.ON_TOKEN_PUBLISH_PRIVILEGE_WILL_EXPIRE,this._onUserTokenPublishPrivilegeWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(kU.ON_TOKEN_PUBLISH_PRIVILEGE_DID_EXPIRED,this._onUserTokenPublishPrivilegeDidExpired.bind(this)),null===(h=this._room)||void 0===h||h.on(kU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_WILL_EXPIRE,this._onUserTokenSubscribePrivilegeWillExpire.bind(this)),null===(f=this._room)||void 0===f||f.on(kU.ON_TOKEN_SUBSCRIBE_PRIVILEGE_DID_EXPIRED,this._onUserTokenSubscribePrivilegeDidExpired.bind(this)),null===(v=this._room)||void 0===v||v.on(kU.POST_PROCESSING_MESSAGE,(function(e){var t;"2.0"===(null==(t=e)?void 0:t.protocol)?j._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?j._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&j._onLiveTranscodingResult(e)})),null===(p=this._room)||void 0===p||p.on(IU.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return j.safeEmit(Fh.onVendorConnectionStateChanged,e)})),null===(_=this._room)||void 0===_||_.on(sK.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(m=this._room)||void 0===m||m.on(sK.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(g=this._room)||void 0===g||g.on(sK.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(y=this._room)||void 0===y||y.on(sK.ON_PUBLISH_RESULT,(function(e){var t,r,n;e.state===oh.PUBLISH_SUCC&&(null===(r=j._room)||void 0===r||r.config.setTokenPublishPrivilegeExpired(!1));e.state===oh.PUBLISH_FAIL&&e.errorCode===dw.TOKEN_NO_PUBLISH_PERMISSION&&(null===(n=j._room)||void 0===n||n.config.setTokenPublishPrivilegeExpired(!0));var i=!(e.retry||null===(t=j._room)||void 0===t||!t.config.isAutoPublish);i&&j.safeEmit(Fh.onAutoPublishResult,e),j.safeEmit(Fh.onPublishResult,{isScreen:e.isScreen,isAutoPublish:i,errorCode:e.errorCode})})),null===(S=this._room)||void 0===S||S.on(sK.ON_SUBSCRIBE_RESULT,(function(e){var t;e.state===ih.SUBSCRIBE_SUCC&&(null===(t=j._room)||void 0===t||t.config.setTokenSubscribePrivilegeExpired(!1));e.state===ih.SUBSCRIBE_FAIL&&e.errorCode===dw.TOKEN_NO_SUBSCRIBE_PERMISSION&&j._handleLoseSubscribePrivilege(),j.safeEmit(Fh.onSubscribeResult,{userId:e.userId,isScreen:e.isScreen,isAutoSubscribe:!1,errorCode:e.errorCode})})),null===(b=this._room)||void 0===b||b.on(sK.ON_REMOTE_STREAM_STATS,(function(e){j.safeEmit(Fh.onRemoteStreamStats,e)})),null===(E=this._room)||void 0===E||E.on(sK.ON_LOCAL_STREAM_STATS,(function(e){j.safeEmit(Fh.onLocalStreamStats,e)})),null===(k=this._room)||void 0===k||k.on(sK.ON_SUBTITLE_STATE_CHANGED,(function(e){j.safeEmit(Fh.onSubtitleStateChanged,e)})),null===(T=this._room)||void 0===T||T.on(sK.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){j.safeEmit(Fh.onSubtitleMessageReceived,e)})),null===(I=this._room)||void 0===I||I.on(sK.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(R=this._room)||void 0===R||R.on(sK.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;j._updateAudioPlayerState(t),j.safeEmit(Fh.onUserStartAudioCapture,{userId:r})})),null===(A=this._room)||void 0===A||A.on(sK.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;j.safeEmit(Fh.onUserStopAudioCapture,{userId:t})})),null===(C=this._room)||void 0===C||C.on(sK.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;j.safeEmit(Fh.onUserStartVideoCapture,{userId:t})})),null===(w=this._room)||void 0===w||w.on(sK.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;j.safeEmit(Fh.onUserStopVideoCapture,{userId:t})})),null===(x=this._room)||void 0===x||x.on(sK.ON_SEI_MESSAGED_RECEIVED,(function(e){j.safeEmit(Fh.onSEIMessageReceived,e)})),null===(O=this._room)||void 0===O||O.on(sK.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){j.safeEmit(Fh.onRemoteVideoSizeChanged,e,t)})),null===(N=this._room)||void 0===N||N.on(sK.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return j.safeEmit(Fh.onSimulcastSubscribeFallback,e)})),null===(P=this._room)||void 0===P||P.on(sK.ON_VIDEO_STREAM_BANNED,(function(e){j.safeEmit(Fh.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(M=this._room)||void 0===M||M.on(sK.ON_AUDIO_STREAM_BANNED,(function(e){j.safeEmit(Fh.onAudioStreamBanned,{uid:e.uid,banned:e.banned})})),null===(D=this._room)||void 0===D||D.on(sK.ON_FORWARD_STREAM_ERROR,(function(e){j.safeEmit(Fh.onForwardStreamError,e)})),null===(L=this._room)||void 0===L||L.on(sK.ON_REJOIN_WITH_TCP,(function(){j.safeEmit(Fh.onRejoinWithTcp)})),null===(U=this._room)||void 0===U||U.on(sK.PUB_RETRY,(function(e){j.safeEmit(Fh.onPublishRetry,e)})),null===(V=this._room)||void 0===V||V.on(sK.SUB_RETRY,(function(e){j.safeEmit(Fh.onSubscribeRetry,e)})),null===(F=this._room)||void 0===F||F.on(sK.VIDEO_TYPE_CHANGE,(function(e){j.safeEmit(Fh.onSEIStreamUpdate,e)})),null===(B=this._room)||void 0===B||B.on(sK.JOIN_SUCCESS,(function(e){j._ctx.isPreConnection||j.safeEmit(Fh.onConnectionStateChanged,{state:e?dh.CONNECTION_STATE_RECONNECTED:dh.CONNECTION_STATE_CONNECTED})}))}},{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(t=VA(UA(Ue.prototype),"safeEmit",this)).call.apply(t,Hg(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(Ne=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ctx.signalingManager.connect();case 2:case"end":return e.stop()}}),e,this)}))),function(){return Ne.apply(this,arguments)})},{key:"joinRoom",value:(Oe=Ug(Dg().mark((function e(t,r,n,i){var o,a,s,c,u;return Dg().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),rU(t)||JL(t,"token"),!this._room){e.next=4;break}throw new _w(dw.REPEAT_JOIN,"Already joined");case 4:return nU(r),aU(n),sU((u=new CK({token:t,roomId:r,userInfo:n},this._ctx)).updateRoomConfig(i)),u.setLiveControlMessage(this._liveTranscodeConfig&&cq.getStartParams(this._liveTranscodeConfig)),this._room=new UY(u,this._ctx),this._addHandlerEventHandler(),this._ctx.useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),null===(o=this._localVideoTrack)||void 0===o||o.setUserId(n.userId),null===(a=this._localScreenVideoTrack)||void 0===a||a.setUserId(n.userId),null===(s=this._localAudioTrack)||void 0===s||s.setUserId(n.userId),null===(c=this._localScreenAudioTrack)||void 0===c||c.setUserId(n.userId),SK(n),e.next=19,this._join(this._room);case 19:return e.abrupt("return",e.sent);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return Oe.apply(this,arguments)})},{key:"_join",value:(xe=Ug(Dg().mark((function e(t){var r,n,i=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.join();case 3:return n=e.sent,this.monitor.set({rtc_session_id:t.config.sessionId}),this._waitForNewToken=!1,this._ctx.audioProfileManager.setRoomId(t.config.roomId),null!==(r=this._room)&&void 0!==r&&r.config.isAutoPublish&&(this._ctx.visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:uh.AUDIO_AND_VIDEO}).catch((function(e){i.logger.error("_join","_updatePublish failed",e)})):(this.safeEmit(Fh.onAutoPublishResult,{isScreen:!1,state:oh.PUBLISH_FAIL}),this.safeEmit(Fh.onPublishResult,{isScreen:!1,isAutoPublish:!0,errorCode:dw.NO_PUBLISH_PERMISSION}))),this.monitor.set({rtc_vid:t.config.rtcVid}),LM.setRoomId(this.id,t.config.roomId),LM.setUserId(this.id,t.config.userId),e.abrupt("return",n);case 14:throw e.prev=14,e.t0=e.catch(0),e.t0.code===dw.INVALID_TOKEN?this._waitForNewToken=!0:(t.destroy(),this._room===t&&delete this._room),e.t0;case 18:case"end":return e.stop()}}),e,this,[[0,14]])}))),function(e){return xe.apply(this,arguments)})},{key:"leaveRoom",value:(we=Ug(Dg().mark((function e(){var t,r,n=this,i=arguments;return Dg().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()"),r=this._room,delete this._room,this._ctx.resetPubSubLock(fY.LEAVE),!t){e.next=10;break}return e.next=8,null==r?void 0:r.leave(t);case 8:e.next=11;break;case 10:null==r||r.leave(t).catch();case 11:this._removeHandlerEventHandler(),this._subLocks=new hT,this._subScreenLocks=new hT,this._ctx.audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),null==r||r.destroy(),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){e.forEach((function(e){var t=e.player,r=e.renderDom;null==t||t.destroy(),n._containerCollisionDetector.unregisterContainer(r)}))})),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_MAIN].clear(),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].forEach((function(e){e.forEach((function(e){var t=e.player,r=e.renderDom;null==t||t.destroy(),n._containerCollisionDetector.unregisterContainer(r)}))})),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].clear(),this._publicStreamIds=new hT,LM.setRoomId(this.id,""),LM.setUserId(this.id,""),this.monitor.set({rtc_session_id:"",rtc_vid:""});case 25:case"end":return e.stop()}}),e,this)}))),function(){return we.apply(this,arguments)})},{key:"_destroyLocalTrack",value:function(){this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.destroy(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.destroy(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.destroy(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.destroy(),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;this.logger.info("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,this._subLocks=new hT,this._subScreenLocks=new hT,this._audioCaptureLock=new dY("audioCap"),this._videoCaptureLock=new dY("videoCap"),this._screenCaptureLock=new dY("screenCap"),this._videoStreamConstraints={},this._videoStreamEncodeConfig=[pL],this._screenStreamEncodeConfig=[_L],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeVideoStreamIds:{},resumeAudioStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),LM.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._destroyLocalTrack(),hW.on("".concat(this.id,"capture-end"),this._destroyLocalTrack.bind(this)),this._audioMixingManager.destroy(),this._rtmClient.destroy(),this._publicStreamManager.destroy(),this._publicStreamIds=new hT,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new hT,this._extensionManager.destroy(),this._ctx.destroy(),this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear(),this._localVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){e.player.destroy()})),this._localVideoPlayerConfig[ch.STREAM_INDEX_MAIN].clear(),this._localVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].forEach((function(e){e.player.destroy()})),this._localVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].clear(),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){e.forEach((function(e){e.player.destroy()}))})),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_MAIN].clear(),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].forEach((function(e){e.forEach((function(e){e.player.destroy()}))})),this._remoteVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].clear(),this._publicVideoPlayerConfig.forEach((function(e){e.player.destroy()})),this._publicVideoPlayerConfig.clear()}},{key:"publishStream",value:(Ce=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!FL(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,DW(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t},!0);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return Ce.apply(this,arguments)})},{key:"unpublishStream",value:(Ae=Ug(Dg().mark((function e(t,r){var n;return Dg().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:uK.UNPUB},!0);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return Ae.apply(this,arguments)})},{key:"publishScreen",value:(Re=Ug(Dg().mark((function e(t){return Dg().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,!FL(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,UW(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:uK.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof _w)){e.next=18;break}throw e.t0;case 18:throw new _w(dw.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return Re.apply(this,arguments)})},{key:"unpublishScreen",value:(Ie=Ug(Dg().mark((function e(t){return Dg().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:uK.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return Ie.apply(this,arguments)})},{key:"subscribeStream",value:(Te=Ug(Dg().mark((function e(t,r){return Dg().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 Te.apply(this,arguments)})},{key:"_subscribe",value:(ke=Ug(Dg().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n,n!==uh.AUDIO||null===(i=this._room)||void 0===i||!i.config.isMultiChatMode()){e.next=4;break}return this.logger.warn("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 4:if(s=this._room.remoteStreams.get(r),c=null==s?void 0:lI(s).call(s,(function(e){return e.isScreen===t}))){e.next=8;break}throw new _w(dw.STREAM_NOT_EXIST,"stream not exist");case 8:return u=this._pauseAllSubscribeState.audio,l=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&uh.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&uh.VIDEO),this.logger.warn("subscribeStream()","due to pauseAll mediaType: %o",n),d=c.hasSubscribed,h=this._remoteVideoConfig.get(r)||(null===(o=this._room)||void 0===o?void 0:o.config.remoteVideoConfig),c.originalMediaType=n,e.prev=16,e.next=19,this._room.subscribe(c,n,h);case 19:VL(n)&&this._updateAudioPlayerState(c),FL(n)&&this._updateVideoPlayerState(c),v=0,p=0,u!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?v|=uh.AUDIO:p|=uh.AUDIO),l!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?v|=uh.VIDEO:p|=uh.VIDEO),v&&this.pauseAllSubscribedStream(v),p&&this.resumeAllSubscribedStream(p),VL(a)&&(this._pauseAllSubscribeState.resumeAudioStreamIds[c.streamId]=c.streamId),FL(a)&&(this._pauseAllSubscribeState.resumeVideoStreamIds[c.streamId]=c.streamId),(c.audioTrack||c.videoTrack)&&(g=!(t||!(null!==(_=this._room)&&void 0!==_&&_.config.isAutoSubscribeAudio||null!==(m=this._room)&&void 0!==m&&m.config.isAutoSubscribeVideo)),y={userId:r,isScreen:!1,state:ih.SUBSCRIBE_SUCC},g&&this.safeEmit(Fh.onAutoSubscribeResult,y),this.safeEmit(Fh.onSubscribeResult,{userId:r,isScreen:t,isAutoSubscribe:g})),null!==(f=this._room)&&void 0!==f&&f.config.isMultiChatMode()||d||!VL(n)||!c.hasAudio||null===(S=c.observer)||void 0===S||S.setSubscribeAudio(!0),!d&&FL(n)&&c.hasVideo&&(null===(b=c.observer)||void 0===b||b.setSubscribeVideo(!0)),e.next=38;break;case 34:throw e.prev=34,e.t0=e.catch(16),e.t0 instanceof _w&&e.t0.code===dw.TOKEN_NO_SUBSCRIBE_PERMISSION&&this._handleLoseSubscribePrivilege(),e.t0;case 38:case"end":return e.stop()}}),e,this,[[16,34]])}))),function(e,t,r){return ke.apply(this,arguments)})},{key:"_handleLoseSubscribePrivilege",value:(Ee=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(t=this._room)||void 0===t||t.config.setTokenSubscribePrivilegeExpired(!0),e.prev=1,e.next=4,this._unSubscribeAllRemoteStreams();case 4:e.next=8;break;case 6:e.prev=6,e.t0=e.catch(1);case 8:case"end":return e.stop()}}),e,this,[[1,6]])}))),function(){return Ee.apply(this,arguments)})},{key:"unsubscribeStream",value:(be=Ug(Dg().mark((function e(t,r){return Dg().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 be.apply(this,arguments)})},{key:"subscribeScreen",value:(Se=Ug(Dg().mark((function e(t,r){return Dg().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 Se.apply(this,arguments)})},{key:"unsubscribeScreen",value:(ye=Ug(Dg().mark((function e(t,r){return Dg().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 ye.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(r!==uh.AUDIO||null===(i=this._room)||void 0===i||!i.config.isMultiChatMode()){var a,s=this._room.remoteStreams.get(t),c=null==s?void 0:lI(s).call(s,(function(t){return t.isScreen===e}));if(!c)throw new _w(dw.STREAM_NOT_EXIST,"stream not exist");if(MD&&KD&&KD>=85&&KD<=91&&r!==uh.AUDIO)null===(a=c.videoTrack)||void 0===a||a.stopAll();return this._room.unsubscribe(c,r).then((function(){n||(VL(r)&&delete o._pauseAllSubscribeState.resumeAudioStreamIds[c.streamId],FL(r)&&delete o._pauseAllSubscribeState.resumeVideoStreamIds[c.streamId])}))}this.logger.warn("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(ge=Ug(Dg().mark((function e(t,r){var n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),iU(t),lU(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 ge.apply(this,arguments)})},{key:"startVideoCapture",value:(me=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,h,f=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startVideoCapture()","deviceId: %s",t),rU(t)||JL(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new _w(dw.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!this._localVideoTrack||this._localVideoTrack.dummy){e.next=8;break}throw new _w(dw.REPEAT_CAPTURE,"Has already capture");case 8:return a=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?(a.facingMode=t,delete a.deviceId):!AD||PD?a.deviceId={exact:t}:delete a.deviceId,this._videoStreamConstraints=a),s={},e.next=13,FW(a,this._extensionManager);case 13:if(c=e.sent,null!==(r=this._videoStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&c.setContentHint(null===(u=this._videoStreamEncodeConfig[0])||void 0===u?void 0:u.contentHint),this._initLocalTrackEvents(c),this._localVideoTrack=c,this._localVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){var t,r;null===(t=f._localVideoTrack)||void 0===t||t.setPlayer(f.id,e,f._mirrorType,null===(r=f._config)||void 0===r?void 0:r.autoPlayPolicy,f._initPlayerEvents.bind(f))})),l=c.originTrack,s=l.getSettings(),d={width:s.width,height:s.height},this._localVideoTrack.resolution=d,this.autoResetVideoEncoderConfig(s),setTimeout((function(){return f.safeEmit(Fh.onLocalVideoSizeChanged,{streamIndex:ch.STREAM_INDEX_MAIN,info:d})})),hW.emit("".concat(this.id,"capture-end")),this._room){e.next=28;break}return e.abrupt("return",s);case 28:return h=this._room.config.isAutoPublish,(null!==(n=this._room.localStream)&&void 0!==n&&n.pubVideo||h)&&this._ctx.visibility&&this._updatePublish(),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableVideo(!0),e.abrupt("return",s);case 32:case"end":return e.stop()}}),e,this)}))),function(e){return me.apply(this,arguments)})},{key:"getLocalStreamStats",value:(_e=Ug(Dg().mark((function e(){var t;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._room)||void 0===t?void 0:t.getLocalStreamStats();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return _e.apply(this,arguments)})},{key:"stopVideoCapture",value:(pe=Ug(Dg().mark((function e(){var t,r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopVideoCapture()"),this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=3;break}throw new _w(dw.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 3:if(this._localVideoTrack&&(this._localVideoTrack.dummy||((i=this._extensionManager.getPluginByName(Qz.PRE_PROCESSING,"RTCBeautyExtension"))&&i.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.destroy(),this._localImgVideoTrack?this._localVideoTrack.setTrack(this._localImgVideoTrack,this._extensionManager,{isDummy:!0}):this._localVideoTrack=void 0)),this._room){e.next=6;break}return e.abrupt("return");case 6:if(null===(t=this._room.localStream)||void 0===t||!t.pubVideo){e.next=9;break}return e.next=9,this._updatePublish();case 9:null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableVideo(!1);case 10:case"end":return e.stop()}}),e,this)}))),function(){return pe.apply(this,arguments)})},{key:"startAudioCapture",value:(ve=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,l;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startAudioCapture()","deviceId: $o",t),rU(t)||JL(t,"deviceId"),t&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._trackSourceType.audio!==eh.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new _w(dw.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 5:if(!this._localAudioTrack){e.next=7;break}throw new _w(dw.REPEAT_CAPTURE,"Has already capture");case 7:return o={},e.next=10,jW(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 10:if(a=e.sent,o=a.originTrack.getSettings(),this._initLocalTrackEvents(a),this._localAudioTrack=a,this._localAudioTrack.setVolume(this._localAudioVolume),s=this._ctx._localAudioTrackDumpConfig[ch.STREAM_INDEX_MAIN],c=s.frameSize,u=s.callback,c&&u&&this._localAudioTrack.setDataFetcher(c,u),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),hW.emit("".concat(this.id,"capture-end")),this._room){e.next=21;break}return e.abrupt("return",o);case 21:return l=this._room.config.isAutoPublish,(null!==(r=this._room.localStream)&&void 0!==r&&r.pubAudio||l)&&this._ctx.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 ve.apply(this,arguments)})},{key:"stopAudioCapture",value:(fe=Ug(Dg().mark((function e(){var t,r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopAudioCapture()"),this._trackSourceType.audio!==eh.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=3;break}throw new _w(dw.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 3:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.destroy()),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 fe.apply(this,arguments)})},{key:"checkAudioAndVideoDeviceId",value:function(e,t){var r;return rU(t)||JL(t,"videoDeviceId"),rU(e)||("string"==typeof e?(JL(e,"audioDeviceId"),r=e):(r=null==e?void 0:e.audioDeviceId,t=null==e?void 0:e.videoDeviceId,JL(r,"audioDeviceId"),JL(t,"videoDeviceId"))),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,{audioDeviceId:r,videoDeviceId:t}}},{key:"startAudioAndVideoCapture",value:(he=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(l=this.checkAudioAndVideoDeviceId(t,r),d=l.audioDeviceId,h=l.videoDeviceId,r=h,d&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:d}}),this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL&&this._trackSourceType.audio!==eh.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new _w(dw.STREAM_TYPE_NOT_MATCH,this._trackSourceType.video===$d.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 _w(dw.REPEAT_CAPTURE,"video has already capture");case 7:if(!this._localAudioTrack){e.next=9;break}throw new _w(dw.REPEAT_CAPTURE,"audio has already capture");case 9:return f=this._videoStreamConstraints,r&&("user"===r||"environment"===r||"left"===r||"right"===r?(f.facingMode=r,delete f.deviceId):!AD||PD?f.deviceId={exact:r}:delete f.deviceId,this._videoStreamConstraints=f),v={},p={},e.next=15,GW(this._ctx.audioProfileManager.getConstraints(),f,this._extensionManager);case 15:if(_=e.sent,m=_.audioTrack,g=_.videoTrack,null!==(n=this._videoStreamEncodeConfig[0])&&void 0!==n&&n.contentHint&&g.setContentHint(null===(y=this._videoStreamEncodeConfig[0])||void 0===y?void 0:y.contentHint),this._initLocalTrackEvents(g),this._localVideoTrack=g,this._localVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){var t,r;null===(t=R._localVideoTrack)||void 0===t||t.setPlayer(R.id,e,R._mirrorType,null===(r=R._config)||void 0===r?void 0:r.autoPlayPolicy,R._initPlayerEvents.bind(R))})),this._initLocalTrackEvents(m),this._localAudioTrack=m,this._localAudioTrack.setVolume(this._localAudioVolume),S=this._ctx._localAudioTrackDumpConfig[ch.STREAM_INDEX_MAIN],b=S.frameSize,E=S.callback,b&&E&&this._localAudioTrack.setDataFetcher(b,E),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),k=g.originTrack,v=k.getSettings(),T={width:v.width||0,height:v.height||0},this._localVideoTrack.resolution=T,this.autoResetVideoEncoderConfig(v),setTimeout((function(){return R.safeEmit(Fh.onLocalVideoSizeChanged,{streamIndex:ch.STREAM_INDEX_MAIN,info:T})})),k=m.originTrack,p=k.getSettings(),hW.emit("".concat(this.id,"capture-end")),this._room){e.next=40;break}return e.abrupt("return",{audioTrackSettings:p,videoTrackSettings:v});case 40:return I=this._room.config.isAutoPublish,(null!==(i=this._room.localStream)&&void 0!==i&&i.pubVideo||null!==(o=this._room.localStream)&&void 0!==o&&o.pubAudio||I)&&this._ctx.visibility&&this._updatePublish(),null===(a=this._room.localStream)||void 0===a||null===(s=a.observer)||void 0===s||s.setEnableVideo(!0),null===(c=this._room.localStream)||void 0===c||null===(u=c.observer)||void 0===u||u.setEnableAudio(!0),e.abrupt("return",{audioTrackSettings:p,videoTrackSettings:v});case 45:case"end":return e.stop()}}),e,this)}))),function(e,t){return he.apply(this,arguments)})},{key:"startVideoAndAudioCapture",value:(de=Ug(Dg().mark((function e(t,r){return Dg().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 de.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return this.logger.info("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(le=Ug(Dg().mark((function e(){var t,r,n,i,o,a,s,c,u,l,d,h,f,v=this,p=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=p.length>0&&void 0!==p[0]?p[0]:{},this.logger.info("startScreenCapture()","config: %o",s),this._trackSourceType.screenVideo!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=4;break}throw new _w(dw.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 4:if(this._trackSourceType.screenAudio!==eh.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new _w(dw.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:return e.next=8,WW(s,this._extensionManager,this._screenStreamEncodeConfig[0]);case 8:if(c=e.sent,u=Ey(c,2),l=u[0],null==(d=u[1])||d.setVolume(this._localScreenAudioVolume),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.destroy()),null===(t=this._localScreenAudioTrack)||void 0===t||t.destroy(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=l,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&l.setContentHint(null===(h=this._screenStreamEncodeConfig[0])||void 0===h?void 0:h.contentHint),f=l.originTrack,setTimeout((function(){var e=f.getSettings(),t={width:e.width,height:e.height};l.resolution=t,v.safeEmit(Fh.onLocalVideoSizeChanged,{streamIndex:ch.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),d&&(this._localScreenAudioTrack=d,this._initLocalTrackEvents(d)),this._localVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].forEach((function(e){var t,r;null===(t=v._localScreenVideoTrack)||void 0===t||t.setPlayer(v.id,e,fh.MIRROR_TYPE_NONE,null===(r=v._config)||void 0===r?void 0:r.autoPlayPolicy,v._initPlayerEvents.bind(v))})),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),!(null!==(n=this._room)&&void 0!==n&&null!==(i=n.localScreenStream)&&void 0!==i&&i.pubAudio||null!==(o=this._room)&&void 0!==o&&null!==(a=o.localScreenStream)&&void 0!==a&&a.pubVideo)){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return le.apply(this,arguments)})},{key:"stopScreenCapture",value:(ue=Ug(Dg().mark((function e(){var t,r,n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopScreenCapture()"),null===(t=this._localScreenVideoTrack)||void 0===t||t.stopAll(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.destroy(),this._localImgScreenTrack&&this._localScreenVideoTrack.setTrack(this._localImgScreenTrack,this._extensionManager,{isDummy:!0}))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.destroy()),this._localScreenAudioTrack=void 0,null!==(r=this._localScreenVideoTrack)&&void 0!==r&&r.dummy||(this._localScreenVideoTrack=void 0),!(null!==(n=this._room)&&void 0!==n&&null!==(i=n.localScreenStream)&&void 0!==i&&i.pubAudio||null!==(o=this._room)&&void 0!==o&&null!==(a=o.localScreenStream)&&void 0!==a&&a.pubVideo)){e.next=9;break}return e.next=9,this._updateScreenPublish();case 9:case"end":return e.stop()}}),e,this)}))),function(){return ue.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){var r;this.logger.info("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),QL(e,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]);var n=e===ch.STREAM_INDEX_MAIN?this._localVideoTrack:this._localScreenVideoTrack,i=null!==(r=null==t?void 0:t.playerId)&&void 0!==r?r:CW;if(null==t||!t.renderDom){var o,a,s;null===(o=this._localVideoPlayerConfig[e].get(i))||void 0===o||null===(a=o.player)||void 0===a||a.destroy();var c=null===(s=this._localVideoPlayerConfig[e].get(i))||void 0===s?void 0:s.renderDom;return this._containerCollisionDetector.unregisterContainer(c),void this._localVideoPlayerConfig[e].delete(i)}cU(t);var u=this._localVideoPlayerConfig[e].get(i);if(!u){var l,d,h,f=t.renderDom;if(!this._containerCollisionDetector.registerContainer(f))return void zL("renderDom is not empty");var v=new HY(this._ctx.id,i,Zd(Zd({},t),{},{isLocal:!0,isScreen:e===ch.STREAM_INDEX_SCREEN,userId:null!==(l=t.userId)&&void 0!==l?l:"_local_"})),p=Zd(Zd({},t),{},{player:v});return this._localVideoPlayerConfig[e].set(i,p),null==n||n.setPlayer(this.id,p,e===ch.STREAM_INDEX_MAIN?this._mirrorType:fh.MIRROR_TYPE_NONE,null===(d=this._config)||void 0===d?void 0:d.autoPlayPolicy,this._initPlayerEvents.bind(this)),null===(h=p.player)||void 0===h?void 0:h.domElement}void 0!==t.renderMode&&(null==n||n.setRenderMode(i,t.renderMode),u.renderMode=t.renderMode)}},{key:"startLiveTranscoding",value:(ce=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startLiveTranscoding()","transcode: %o",t),cq.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.config)&&n.roomId.length+n.userId.length>126)){e.next=6;break}throw new _w(dw.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(Fh.onStreamMixingEvent,{event:cK.START,error:0,message:""}),!this._room||!this._ctx.signalingManager.isConnected()){e.next=11;break}return e.next=11,this._room.liveControlMessage(cq.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof _w)){e.next=19;break}throw e.t0;case 19:throw new _w(dw.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return ce.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(se=Ug(Dg().mark((function e(t){var r,n,i,o;return Dg().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=IK({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,cq.checkUpdateParams(i),this._liveTranscodeConfig=IK(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(Fh.onStreamMixingEvent,{event:cK.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(cq.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof _w)){e.next=21;break}throw e.t0;case 21:throw new _w(dw.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return se.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(ae=Ug(Dg().mark((function e(){var t;return Dg().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(Fh.onStreamMixingEvent,{event:cK.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 _w)){e.next=16;break}throw e.t0;case 16:throw new _w(dw.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return ae.apply(this,arguments)})},{key:"startSubtitle",value:(oe=Ug(Dg().mark((function e(t){var r;return Dg().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 oe.apply(this,arguments)})},{key:"updateSubtitleConfig",value:(ie=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateSubtitleConfig()","config: %o",t),this._assertNotInRoom(),e.next=4,null===(r=this._room)||void 0===r?void 0:r.updateSubtitleConfig(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return ie.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._ctx.businessId=e,!0)}},{key:"setUserVisibility",value:(ne=Ug(Dg().mark((function e(t){var r,n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setUserVisibility()","enable: %o",t),t=!!t,this._ctx.visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._ctx.visibility=t,e.abrupt("return");case 7:if(this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),t){e.next=14;break}return e.next=12,this._pubLock.lock();case 12:i=e.sent;try{this._room.unpublish(),this._room.unpublishScreen()}finally{i()}case 14:return this._ctx.visibility=t,e.prev=15,e.next=18,this._room.updateUserAttributes();case 18:e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(15),this._ctx.visibility=!t,e.t0;case 24:t&&null!==(r=this._room)&&void 0!==r&&r.config.isAutoPublish&&this._updatePublish({mediaType:uh.AUDIO_AND_VIDEO});case 25:case"end":return e.stop()}}),e,this,[[15,20]])}))),function(e){return ne.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]:ch.STREAM_INDEX_MAIN)===ch.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:lI(a).call(a,(function(e){return e.isScreen===n})),u=function(){r?t.safeEmit(Fh.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(Fh.onAudioFirstFrameDecoded,{userId:s,isScreen:n}),t.safeEmit(Fh.onRemoteAudioFirstFrame,{userId:s,isScreen:n}))};null==c||!c.observer||c.observer.audioFirstFrameReceived?u():c.observer.once("recvAudioFirstFrame",u)}else{var l,d,h={userId:e.userId,height:(null===(l=e.domElement)||void 0===l?void 0:l.videoHeight)||0,width:(null===(d=e.domElement)||void 0===d?void 0:d.videoWidth)||0,isScreen:n,playerId:e.playerId};r?(h.publicStreamId=h.userId,delete h.userId,delete h.isScreen,t.safeEmit(Fh.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(Fh.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(Fh.onVideoFirstFrameRendered,h),t.safeEmit(Fh.onVideoFirstFrameDecoded,h),t.safeEmit(Fh.onRemoteVideoFirstFrame,h))}break;case"autoplay-error":r&&(i.publicStreamId=i.userId),t.id,i.userId;var f={userId:i.userId,kind:e instanceof HY?"video":"audio",mediaType:e instanceof HY?uh.VIDEO:uh.AUDIO,streamIndex:e.isScreen?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN};return e instanceof HY&&(f.playerId=e.playerId===CW?void 0:e.playerId),void t.safeEmit(Fh.onAutoplayFailed,f)}e instanceof HY&&(i.playerId=e.playerId===CW?void 0:e.playerId),t.safeEmit(Fh.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=Ug(Dg().mark((function e(n){var i,o;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(i=!0),o=n.originTrack.kind,t.safeEmit({"track-ended":Fh.onTrackEnded,"track-mute":Fh.onTrackMute,"track-unmute":Fh.onTrackUnmute}[r],{kind:o,isScreen:i}),!PD&&!wD){e.next=12;break}if("track-mute"!==r){e.next=11;break}if(hW.emit(lW.ON_IOS_LOCAL_TRACK_MUTE,o),"audio"!==o){e.next=11;break}return e.next=10,t.stopAudioCapture();case 10:t.startAudioCapture();case 11:"track-unmute"===r&&hW.emit(lW.ON_IOS_LOCAL_TRACK_UNMUTE,o);case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),e.on("resolution-change",(function(e){t._extensionManager.getPluginsByType(Qz.PRE_PROCESSING).forEach((function(t){var n;null==t||null===(n=t.applyConstraints)||void 0===n||n.call(t,r?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN,e)})),t.safeEmit(Fh.onLocalVideoSizeChanged,{streamIndex:r?ch.STREAM_INDEX_SCREEN:ch.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){var r,n,i,o,a,s,c,u;this.logger.info("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),QL(e,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),cU(t);var l=t.userId,d=e===ch.STREAM_INDEX_SCREEN,h=null===(r=this._room)||void 0===r||null===(n=r.remoteStreams.get(l))||void 0===n?void 0:lI(n).call(n,(function(e){return e.isScreen===d})),f=null==h?void 0:h.videoTrack,v=null!==(i=t.playerId)&&void 0!==i?i:CW;null===(o=this._getRemoteVideoPlayerConfig(e,l,v))||void 0===o||null===(a=o.player)||void 0===a||a.destroy();var p=null===(s=this._getRemoteVideoPlayerConfig(e,l,v))||void 0===s?void 0:s.renderDom;if(this._containerCollisionDetector.unregisterContainer(p),t.renderDom){var _=t.renderDom;if(this._containerCollisionDetector.registerContainer(_)){var m=new HY(this.id,v,Zd(Zd({},t),{},{isLocal:!1,isScreen:d,userId:l})),g=Zd(Zd({},t),{},{player:m});return this._setRemoteVideoPlayerConfig(e,l,v,g),null==f||f.setPlayer(this.id,g,null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy,this._initPlayerEvents.bind(this)),h&&this._updateVideoPlayerState(h),null===(u=g.player)||void 0===u?void 0:u.domElement}zL("renderDom is not empty")}else{var y;null===(y=this._remoteVideoPlayerConfig[e].get(l))||void 0===y||y.delete(v)}}},{key:"setLocalVideoMirrorType",value:function(e){var t;this.logger.info("setLocalVideoMirrorType()","mirrorType: %o",e),QL(e,"mirrorType",[fh.MIRROR_TYPE_NONE,fh.MIRROR_TYPE_RENDER]),this._mirrorType=e,null===(t=this.localVideoTrack)||void 0===t||t.mirror(!!e)}},{key:"setRemoteVideoMirrorType",value:function(e,t,r){var n,i,o,a;this.logger.info("setRemoteVideoMirrorType()","userId: %s, streamIndex: %o, mirrorType: %o",e,t,r),iU(e),QL(t,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),QL(r,"mirrorType",[fh.MIRROR_TYPE_NONE,fh.MIRROR_TYPE_RENDER]),this._ctx.setUserStreamConf(e,t,{mirrorType:r}),null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(e))||void 0===i||null===(o=lI(i).call(i,(function(e){return e.isScreen===(t===ch.STREAM_INDEX_SCREEN)})))||void 0===o||null===(a=o.videoTrack)||void 0===a||a.mirror(!!r)}},{key:"setAudioPlaybackDevice",value:(re=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setAudioPlaybackDevice()","deviceId: %s",t),JL(t,"deviceId"),e.next=4,this._audioDeviceManager.setSinkId(t);case 4:n=e.sent,null===(r=this._room)||void 0===r||r.remoteStreams.forEach((function(e){e.forEach((function(e){var r;null===(r=e.audioTrack)||void 0===r||r.setPlaybackDevice(t)}))})),this.safeEmit(Fh.onAudioPlaybackDeviceChanged,n);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return re.apply(this,arguments)})},{key:"play",value:(te=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,h,f,v,p,_,m=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=m.length>1&&void 0!==m[1]?m[1]:uh.AUDIO_AND_VIDEO,i=m.length>2?m[2]:void 0,o=m.length>3?m[3]:void 0,this.logger.info("play()","userId: %s, mediaType: %s, streamIndex: %s",t,n,i),a=null!=o?o:CW,s=!t||t===this._getUserId()||"local_user"===t,c=void 0===i||i===ch.STREAM_INDEX_MAIN,u=void 0===i||i===ch.STREAM_INDEX_SCREEN,l=n!==uh.VIDEO,d=n!==uh.AUDIO,h=[],s&&d&&(c&&this._localVideoTrack&&(this._localVideoTrack.mirror(!!this._mirrorType),(f=this._localVideoTrack.play(a))&&h.push(f)),u&&this._localScreenVideoTrack&&(null===(v=this._localScreenVideoTrack)||void 0===v?void 0:v.manuallyPlay(a))&&h.push()),t===this._audioMixingManager.id&&h.push(this._audioMixingManager.resumeLocalPlay()),p=[],null===(r=this._room)||void 0===r||r.remoteStreams.forEach((function(e,r){t&&t!==r||e.forEach((function(e){e.audioTrack&&p.push(e.audioTrack),e.videoTrack&&p.push(e.videoTrack)}))})),this._publicStreamManager.getRemoteStreams().forEach((function(e,r){t&&t!==r||(e.audioTrack&&p.push(e.audioTrack),e.videoTrack&&p.push(e.videoTrack))})),c||(p=Cy(p).call(p,(function(e){return!!e.isScreen}))),u||(p=Cy(p).call(p,(function(e){return!e.isScreen}))),l||(p=Cy(p).call(p,(function(e){return"audio"!==e.mediaType}))),d||(p=Cy(p).call(p,(function(e){return"video"!==e.mediaType}))),l&&(null===(_=this._room)||void 0===_||_.virtualStreams.forEach((function(e){e.audioTrack&&p.push(e.audioTrack)}))),p.forEach((function(e){var t=e.play(a);t&&h.push(t)})),e.abrupt("return",Gg.all(h).then((function(){})));case 23:case"end":return e.stop()}}),e,this)}))),function(e){return te.apply(this,arguments)})},{key:"stop",value:(ee=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,h,f,v,p=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=p.length>1&&void 0!==p[1]?p[1]:uh.AUDIO_AND_VIDEO,n=p.length>2?p[2]:void 0,i=p.length>3?p[3]:void 0,this.logger.info("stop()","userId: %s, mediaType: %s, streamIndex: %s, playerId: %s",t,r,n,i),o=null!=i?i:CW,a=!t||t===this._getUserId()||"local_user"===t,s=void 0===n||n===ch.STREAM_INDEX_MAIN,c=void 0===n||n===ch.STREAM_INDEX_SCREEN,u=r!==uh.VIDEO,l=r!==uh.AUDIO,a&&l&&(s&&this._localVideoTrack&&this._localVideoTrack.pause(o),c&&this._localScreenVideoTrack&&this._localScreenVideoTrack.pause(o)),t&&(f=[],null===(d=this._room)||void 0===d||null===(h=d.remoteStreams.get(t))||void 0===h||h.forEach((function(e){e.audioTrack&&f.push(e.audioTrack),e.videoTrack&&f.push(e.videoTrack)})),(null==(v=this._publicStreamManager.getRemoteStream(t))?void 0:v.audioTrack)&&f.push(v.audioTrack),(null==v?void 0:v.videoTrack)&&f.push(v.videoTrack),s||(f=Cy(f).call(f,(function(e){return!!e.isScreen}))),c||(f=Cy(f).call(f,(function(e){return!e.isScreen}))),u||(f=Cy(f).call(f,(function(e){return"audio"!==e.mediaType}))),l||(f=Cy(f).call(f,(function(e){return"video"!==e.mediaType}))),f.forEach((function(e){e.pause(o)})));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return ee.apply(this,arguments)})},{key:"getAudioVolume",value:function(e,t){QL(e,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]);var r=0;if(t){var n,i,o,a=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=lI(i).call(i,(function(t){return t.isScreen===(e===ch.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.audioTrack;a&&(r=a.getAudioLevel())}else{var s=e===ch.STREAM_INDEX_MAIN?this._localAudioTrack:this._localScreenAudioTrack;s&&(r=s.getAudioLevel())}return{linearVolume:r,nonlinearVolume:UL(r)}}},{key:"setAudioFrameCallback",value:function(e,t,r){var n,i,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:4096;if(this.logger.info("setAudioFrameCallback()","streamIndex: %s, userId: %s, callback: %s, frameSize: %s",e,t,r?"true":"false",a),QL(a,"frameSize",[256,512,1024,2048,4096,8192,16384]),void 0===gW.isWorkletReady&&gW.getAudioContextInstance(),null===gW.isWorkletReady)throw this.logger.error("setAudioFrameCallback()","Not support AudioWorklet"),new _w(dw.NOT_SUPPORTED,"Not support AudioWorklet");t?r?this._ctx._remoteAudioTrackDumpConfig[e].set(t,{callback:r,frameSize:a}):this._ctx._remoteAudioTrackDumpConfig[e].delete(t):this._ctx._localAudioTrackDumpConfig[e]={callback:r,frameSize:r?a:void 0};var s=t?null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=lI(i).call(i,(function(t){return t.isScreen===(e===ch.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.audioTrack:e===ch.STREAM_INDEX_MAIN?this._localAudioTrack:this._localScreenAudioTrack;s?r?s.setDataFetcher(a,r):s.stopDataFetcher():this.logger.warn("setAudioFrameCallback()","track not found")}},{key:"pauseAllSubscribedStream",value:($=Ug(Dg().mark((function e(t){var r=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),VL(t)&&(r._pauseAllSubscribeState.audio=!0),FL(t)&&(r._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",Gg.resolve());case 6:return e.abrupt("return",this._pauseAllRemoteStreams(t));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return $.apply(this,arguments)})},{key:"_pauseAllRemoteStreams",value:(Z=Ug(Dg().mark((function e(t){var r,n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._room){e.next=2;break}return e.abrupt("return",Gg.resolve());case 2:return r=[],this._room.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){if(e.hasSubscribed){e.attributes.audiostream&&VL(t)&&(n._pauseAllSubscribeState.resumeAudioStreamIds[e.streamId]=e.streamId),e.attributes.videostream&&FL(t)&&(n._pauseAllSubscribeState.resumeVideoStreamIds[e.streamId]=e.streamId);var i=n._unsubscribe(e.isScreen,e.userId,t,!0);i&&r.push(i)}}))})),e.abrupt("return",Gg.all(r).then((function(){})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return Z.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(Q=Ug(Dg().mark((function e(t){var r=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),VL(t)&&(r._pauseAllSubscribeState.audio=!1),FL(t)&&(r._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",Gg.resolve());case 6:return e.next=8,this._triedResumeAllRemoteStreams(t,!1);case 8:return e.abrupt("return");case 9:case"end":return e.stop()}}),e,this)}))),function(e){return Q.apply(this,arguments)})},{key:"_triedResumeAllRemoteStreams",value:(J=Ug(Dg().mark((function e(t,r){var n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._room){e.next=2;break}return e.abrupt("return",Gg.resolve());case 2:if(!this._pauseAllSubscribeState.audio||t!==uh.AUDIO){e.next=4;break}return e.abrupt("return",Gg.resolve());case 4:if(!this._pauseAllSubscribeState.video||t!==uh.VIDEO){e.next=6;break}return e.abrupt("return",Gg.resolve());case 6:if(!this._pauseAllSubscribeState.video||!this._pauseAllSubscribeState.audio||t!==uh.AUDIO_AND_VIDEO){e.next=8;break}return e.abrupt("return",Gg.resolve());case 8:return n=[],i=iR(FS(this._pauseAllSubscribeState.resumeAudioStreamIds)),o=iR(FS(this._pauseAllSubscribeState.resumeVideoStreamIds)),this._room.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){if(!r||!e.isScreen){var i=a._pauseAllSubscribeState.resumeAudioStreamIds[e.streamId],o=a._pauseAllSubscribeState.resumeVideoStreamIds[e.streamId];if(i&&VL(t)||o&&FL(t)){var s=a._subscribe(e.isScreen,e.userId,t).then((function(){i&&VL(t)&&delete a._pauseAllSubscribeState.resumeAudioStreamIds[e.streamId],o&&FL(t)&&delete a._pauseAllSubscribeState.resumeVideoStreamIds[e.streamId]}));s&&n.push(s)}}}))})),e.abrupt("return",Gg.all(n).then((function(){var e;return null===(e=a._room)||void 0===e||e.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){a._updateAudioPlayerState(e),a._updateVideoPlayerState(e)}))})),Gg.resolve()})).finally((function(){var e;return null!==(e=a._room)&&void 0!==e&&e.config.tokenSubscribePrivilegeExpired&&(i.forEach((function(e){a._pauseAllSubscribeState.resumeAudioStreamIds[e]=e})),o.forEach((function(e){a._pauseAllSubscribeState.resumeVideoStreamIds[e]=e}))),Gg.resolve()})));case 13:case"end":return e.stop()}}),e,this)}))),function(e,t){return J.apply(this,arguments)})},{key:"sendUserMessage",value:(q=Ug(Dg().mark((function e(t,r){var n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return iU(t),uU(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 q.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(Y=Ug(Dg().mark((function e(t,r){var n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return iU(t),eU(r,"message"),uU(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 Y.apply(this,arguments)})},{key:"sendRoomMessage",value:(X=Ug(Dg().mark((function e(t){var r,n,i,o,a,s=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return uU(t),this._assertNotInRoom(),o=null===(r=this._room)||void 0===r?void 0:r.config.roomId,a=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendRoomMessage(t))||void 0===i?void 0:i.then((function(e){return s._messageStatisticsObserver.countRoomMessage(!0,o,!1,a),e})).catch((function(e){throw s._messageStatisticsObserver.countRoomMessage(!1,o,!1,a),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return X.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(K=Ug(Dg().mark((function e(t){var r,n,i,o,a,s=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return uU(t),this._assertNotInRoom(),o=null===(r=this._room)||void 0===r?void 0:r.config.roomId,a=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendRoomMessage(t,!0))||void 0===i?void 0:i.then((function(e){return s._messageStatisticsObserver.countRoomMessage(!0,o,!0,a),e})).catch((function(e){throw s._messageStatisticsObserver.countRoomMessage(!1,o,!0,a),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return K.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(W=Ug(Dg().mark((function e(){var t,r=arguments;return Dg().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,tU(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._ctx.audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return W.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(z=Ug(Dg().mark((function e(){var t,r=arguments;return Dg().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 z.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(G=Ug(Dg().mark((function e(){var t,r,n,i=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,tU(r),n=Zd(Zd({},r),{},{deviceId:this._videoStreamConstraints.deviceId}),!this._localVideoTrack){e.next=7;break}return e.next=7,this._localVideoTrack.updateVideoCaptureConfig(n);case 7:return this._videoStreamConstraints=n,e.abrupt("return",(null===(t=this._localVideoTrack)||void 0===t?void 0:t.originTrack.getSettings())||{});case 9:case"end":return e.stop()}}),e,this)}))),function(){return G.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return this.logger.info("enableSimulcastMode()","enabled: %o",e),!yD&&!CD&&14!==(null==GD?void 0:GD[0])&&(this._enableSimulcast=e,null!==(t=this._room)&&void 0!==t&&t.hasPublished&&zL("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(H=Ug(Dg().mark((function e(t){var r,n,i,o,a;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(this.logger.info("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),hU(t=Cy(t).call(t,(function(e){return!!e}))),t.length>3&&(zL("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=dI(t).call(t,0,3)),n=1;n<t.length;n++)i=WL(t[0].width)/WL(t[n].width)||1,Math.floor(i)!==i&&zL("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");return BC(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(Zd({},t[0]));case 10:this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(ch.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 H.apply(this,arguments)})},{key:"setVideoEncoderAutoConfigList",value:function(e){if(Array.isArray(e))return BC(e).call(e,(function(e,t){return e.maxKbps-t.maxKbps})),fL(e)}},{key:"autoResetVideoEncoderConfig",value:function(e){var t,r=hL;if(r.length){this._videoStreamEncodeConfig.length||(this._videoStreamEncodeConfig=[pL]);var n=this._videoStreamEncodeConfig[0],i=e.width||WL(n.width),o=e.height||WL(n.height),a=i*o;if(!(WL(n.width)*WL(n.height)<=a)){var s,c,u=r[0];r.forEach((function(e){var t=WL(e.width)*WL(e.height);s||(a<t?s=e:u=e)})),c=s&&WL(s.width)*WL(s.height)-a<a-WL(u.width)*WL(u.height)?CT({},s):CT({},u),this._videoStreamEncodeConfig=Cy(t=this._videoStreamEncodeConfig).call(t,(function(e){return!(c&&WL(e.width)*WL(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.id,Xg(this._videoStreamEncodeConfig)}}}},{key:"setScreenEncoderConfig",value:(j=Ug(Dg().mark((function e(t){var r;return Dg().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"===HD){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(ch.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 j.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(this.logger.info("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!qU())return zL("Your browser does not support sending SEI"),!1;QL(e,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),qL(r,"repeatCount",0,30);var n,i="string"==typeof t?new Uint8Array(wL.str2ab(t)):t;if(!t.length)return this.logger.warn("sei message must not be empty"),!1;if(e===ch.STREAM_INDEX_MAIN){var o,a,s,c;if(!(null!==(o=this._room)&&void 0!==o&&null!==(a=o.localStream)&&void 0!==a&&a.pubAudio||null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubVideo))return;n=this._room.localStream}else{var u,l,d,h;if(!(null!==(u=this._room)&&void 0!==u&&null!==(l=u.localScreenStream)&&void 0!==l&&l.pubAudio||null!==(d=this._room)&&void 0!==d&&null!==(h=d.localScreenStream)&&void 0!==h&&h.pubVideo))return;n=this._room.localScreenStream}if(i.byteLength>4096)this.logger.warn("sei size must not bigger than 4KB");else{var f;if(!MD)null===(f=this._room)||void 0===f||f.maybeFillBackFrame2Stream(n);var v=RL();n.seiList.push({content:i,uuid:v,repeatCount:r+1}),setTimeout((function(){var e;if(n){var r,i=qC(e=n.seiList).call(e,(function(e){return e.uuid===v}));if(i>=0)zI(r=n.seiList).call(r,i,1),console.error("[RTC WebSDK] sei timeout for message: %o",t)}}),lL("SEI_TIME_OUT"))}}},{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=lI(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(Fh.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n,i=e[0],o=uS(t).call(t,(function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=i?o?i.audioPropertiesInfo.nonlinearVolume>o.audioPropertiesInfo.nonlinearVolume?i:o:i:o)&&r.audioPropertiesInfo.nonlinearVolume>-35)(n=r.streamKey?this._room.remoteUsers.get(r.streamKey.userId):this._room.config.userInfo)&&this.safeEmit(Fh.onActiveSpeaker,{userId:n.userId,extraInfo:n.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?vh.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(),l=r.getAudioLevel(s),d=UL(l),h={streamIndex:ch.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:l,nonlinearVolume:d}};if(c||u)t.push(h);else switch(o){case vh.DISCONNECT:break;case vh.RESET:h.audioPropertiesInfo.linearVolume=0,h.audioPropertiesInfo.nonlinearVolume=-127,t.push(h);break;case vh.NORMAL:t.push(h);break;default:throw new _w(dw.INVALID_PARAMS,"invalid localMainReportMode: ".concat(o," in config"))}}if(e._localScreenAudioTrack){var f=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:ch.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:f,nonlinearVolume:UL(f)}})}if(e.safeEmit(Fh.onLocalAudioPropertiesReport,t),e._room){var v=[];if(e._room.config.isMultiChatMode())e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i=255*t.audioLevel;v.push({streamKey:{userId:t.userId,streamIndex:ch.STREAM_INDEX_MAIN,roomId:null!==(r=null===(n=e._room)||void 0===n?void 0:n.config.roomId)&&void 0!==r?r:""},audioPropertiesInfo:{linearVolume:i,nonlinearVolume:UL(i)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();v.push({streamKey:{userId:r,streamIndex:t.isScreen?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN,roomId:null!==(n=null===(i=e._room)||void 0===i?void 0:i.config.roomId)&&void 0!==n?n:""},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:UL(o)}})}}))}));e.safeEmit(Fh.onRemoteAudioPropertiesReport,v),e._sendActiveSpeaker(t,Cy(v).call(v,(function(e){return e.streamKey.streamIndex!==ch.STREAM_INDEX_SCREEN})))}}}),u))}},{key:"setVideoSourceType",value:(B=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k,T,I,R;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(QL(t,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),QL(r,"VideoSourceType",[$d.VIDEO_SOURCE_TYPE_EXTERNAL,$d.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===ch.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,!this._localVideoTrack||t!==ch.STREAM_INDEX_MAIN){e.next=15;break}if(c=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(c=!0,(u=this._extensionManager.getPluginByName(Qz.PRE_PROCESSING,"RTCBeautyExtension"))&&u.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.destroy()),null===(i=this._localVideoTrack)||void 0===i||i.destroy(),this._localVideoTrack=void 0,l=null===(o=this._room)||void 0===o?void 0:o.config.isAutoPublish,c?null===(d=this._room)||void 0===d||null===(h=d.localStream)||void 0===h||null===(f=h.observer)||void 0===f||f.setEnableVideo(!1):null===(v=this._room)||void 0===v||null===(p=v.localStream)||void 0===p||null===(_=p.observer)||void 0===_||_.setPushVideo(!1),!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubVideo||l)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(!this._localScreenVideoTrack||t!==ch.STREAM_INDEX_SCREEN){e.next=24;break}if(S=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(S=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.destroy()),null===(m=this._localScreenVideoTrack)||void 0===m||m.destroy(),this._localScreenVideoTrack=void 0,S?null===(b=this._room)||void 0===b||null===(E=b.localScreenStream)||void 0===E||null===(k=E.observer)||void 0===k||k.setEnableVideo(!1):null===(T=this._room)||void 0===T||null===(I=T.localScreenStream)||void 0===I||null===(R=I.observer)||void 0===R||R.setPushVideo(!1),null===(g=this._room)||void 0===g||null===(y=g.localScreenStream)||void 0===y||!y.pubVideo){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return B.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(F=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,h,f,v=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(QL(t,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),ZL(r),t!==ch.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.video===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new _w(dw.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 5:return e.next=7,YW(r,this._extensionManager);case 7:if(this._localVideoTrack=e.sent,!r.contentHint&&null!==(n=this._videoStreamEncodeConfig[0])&&void 0!==n&&n.contentHint&&this._localVideoTrack.setContentHint(null===(s=this._videoStreamEncodeConfig[0])||void 0===s?void 0:s.contentHint),this._initLocalTrackEvents(this._localVideoTrack),this._localVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){var t,r;null===(t=v._localVideoTrack)||void 0===t||t.setPlayer(v.id,e,v._mirrorType,null===(r=v._config)||void 0===r?void 0:r.autoPlayPolicy,v._initPlayerEvents.bind(v))})),c=null===(i=this._room)||void 0===i?void 0:i.config.isAutoPublish,!(null!==(o=this._room)&&void 0!==o&&null!==(a=o.localStream)&&void 0!==a&&a.pubVideo||c)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(t!==ch.STREAM_INDEX_SCREEN){e.next=27;break}if(this._trackSourceType.screenVideo===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new _w(dw.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 18:return e.next=20,ZW(r,this._extensionManager);case 20:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),this._localVideoPlayerConfig[ch.STREAM_INDEX_SCREEN].forEach((function(e){var t,r;null===(t=v._localScreenVideoTrack)||void 0===t||t.setPlayer(v.id,e,v._mirrorType,null===(r=v._config)||void 0===r?void 0:r.autoPlayPolicy,v._initPlayerEvents.bind(v))})),null===(u=this._room)||void 0===u||null===(l=u.localScreenStream)||void 0===l||null===(d=l.observer)||void 0===d||d.setPushVideo(!0),null===(h=this._room)||void 0===h||null===(f=h.localScreenStream)||void 0===f||!f.pubVideo){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return F.apply(this,arguments)})},{key:"setAudioSourceType",value:(V=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,h,f,v,p,_,m,g,y,S,b,E,k;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(QL(t,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),QL(r,"audioSourceType",[eh.AUDIO_SOURCE_TYPE_EXTERNAL,eh.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===ch.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=22;break}if(this._trackSourceType[n]=r,!this._localAudioTrack||t!==ch.STREAM_INDEX_MAIN){e.next=14;break}if(s=!1,this._trackSourceType.audio===eh.AUDIO_SOURCE_TYPE_EXTERNAL&&(s=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.destroy()),this._localAudioTrack=void 0,c=null===(i=this._room)||void 0===i?void 0:i.config.isAutoPublish,s?null===(u=this._room)||void 0===u||null===(l=u.localStream)||void 0===l||null===(d=l.observer)||void 0===d||d.setEnableAudio(!1):null===(h=this._room)||void 0===h||null===(f=h.localStream)||void 0===f||null===(v=f.observer)||void 0===v||v.setPushAudio(!1),!(null!==(o=this._room)&&void 0!==o&&null!==(a=o.localStream)&&void 0!==a&&a.pubAudio||c)){e.next=14;break}return e.next=14,this._updatePublish();case 14:if(!this._localScreenAudioTrack||t!==ch.STREAM_INDEX_SCREEN){e.next=22;break}if(m=!1,this._trackSourceType.audio===eh.AUDIO_SOURCE_TYPE_EXTERNAL&&(m=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.destroy()),this._localScreenAudioTrack=void 0,m?null===(g=this._room)||void 0===g||null===(y=g.localScreenStream)||void 0===y||null===(S=y.observer)||void 0===S||S.setEnableAudio(!1):null===(b=this._room)||void 0===b||null===(E=b.localScreenStream)||void 0===E||null===(k=E.observer)||void 0===k||k.setPushAudio(!1),null===(p=this._room)||void 0===p||null===(_=p.localScreenStream)||void 0===_||!_.pubAudio){e.next=22;break}return e.next=22,this._updateScreenPublish();case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return V.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(U=Ug(Dg().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,h,f,v,p,_;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(QL(t,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),ZL(r),t!==ch.STREAM_INDEX_MAIN){e.next=17;break}if(this._trackSourceType.audio===eh.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new _w(dw.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 5:return e.next=7,JW(r,this._extensionManager);case 7:if(this._localAudioTrack=e.sent,this._localAudioTrack.setVolume(this._localAudioVolume),this._initLocalTrackEvents(this._localAudioTrack),(u=this._ctx._localAudioTrackDumpConfig[ch.STREAM_INDEX_MAIN]).frameSize&&u.callback&&this._localAudioTrack.setDataFetcher(u.frameSize,u.callback),l=null===(n=this._room)||void 0===n?void 0:n.config.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||l)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(t!==ch.STREAM_INDEX_SCREEN){e.next=31;break}if(this._trackSourceType.screenAudio===eh.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=20;break}throw new _w(dw.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 20:return e.next=22,eK(r,this._extensionManager);case 22:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),(_=this._ctx._localAudioTrackDumpConfig[ch.STREAM_INDEX_SCREEN]).frameSize&&_.callback&&this._localScreenAudioTrack.setDataFetcher(_.frameSize,_.callback),null===(d=this._room)||void 0===d||null===(h=d.localScreenStream)||void 0===h||null===(f=h.observer)||void 0===f||f.setPushAudio(!0),null===(v=this._room)||void 0===v||null===(p=v.localScreenStream)||void 0===p||!p.pubAudio){e.next=31;break}return e.next=31,this._updateScreenPublish();case 31:case"end":return e.stop()}}),e,this)}))),function(e,t){return U.apply(this,arguments)})},{key:"login",value:(L=Ug(Dg().mark((function e(t,r){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("login()","token: %o, userInfo: %o",t,r),rU(t)||JL(t,"token"),iU(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return L.apply(this,arguments)})},{key:"logout",value:(D=Ug(Dg().mark((function e(){return Dg().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 D.apply(this,arguments)})},{key:"updateLoginToken",value:(M=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateLoginToken()","token: %o",t),rU(t)||JL(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return M.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(P=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("getPeerOnlineStatus()","userId: %o",t),iU(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return P.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(N=Ug(Dg().mark((function e(t,r){var n,i=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return iU(t),uU(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 N.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(O=Ug(Dg().mark((function e(t,r){var n,i=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return iU(t),eU(r,"message"),uU(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 O.apply(this,arguments)})},{key:"setServerParams",value:(x=Ug(Dg().mark((function e(t,r){return Dg().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 x.apply(this,arguments)})},{key:"sendServerMessage",value:(w=Ug(Dg().mark((function e(t){var r,n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return JL(t,"message"),uU(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 w.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(C=Ug(Dg().mark((function e(t){var r,n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return eU(t,"message"),uU(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 C.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new _w(dw.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");this.logger.info("startCloudProxy()",e),JL(e.logProxy,"logProxy"),JL(e.accessProxy,"accessProxy"),JL(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=lL("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=lL("LOG_SERVER_URL"),this._originConfigServerUrls=lL("CONFIG_REQUEST_DOMAINS"),uL("ICE_CONFIG_REQUEST_URLS",e.accessProxy),uL("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)),uL("CONFIG_REQUEST_DOMAINS",[e.configProxy]),tL.clearAccessNode(this._appId),tL.clearAccessUrls(),this._ctx.useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){var e,t,r;if(this._room)throw new _w(dw.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:$g(e).call(e,(function(e){return e.replace("https://","").replace("/dispatch/v1/AccessInfo?Action=GetAccessInfo","")}));uL("ICE_CONFIG_REQUEST_URLS",null!=n?n:[]),uL("LOG_SERVER_URL",null!==(t=this._originLogServerUrl)&&void 0!==t?t:""),uL("CONFIG_REQUEST_DOMAINS",null!==(r=this._originConfigServerUrls)&&void 0!==r?r:[]),tL.clearAccessNode(this._appId),tL.clearAccessUrls(),this._ctx.useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(A=Ug(Dg().mark((function e(t,r){var n,i,o,a=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(oU(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=4;break}throw new _w(dw.REPEAT_PUSH,"repeat push public media stream");case 4:return o=dL(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 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return A.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(R=Ug(Dg().mark((function e(t,r){var n,i;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oU(t),this._assertNotInRoom(),i=dL(t,"layoutChanged",r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.publicStreamControlMessage(i));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"stopPushPublicStream",value:(I=Ug(Dg().mark((function e(t){var r,n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oU(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 3:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"startPlayPublicStream",value:(T=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c,u;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oU(t),e.next=3,this._publicStreamManager.startPlayPublicStream(t);case 3:n=e.sent,(i=this._publicVideoPlayerConfig.get(t))&&(null===(o=n.videoTrack)||void 0===o||o.setPlayer(this.id,i,null===(a=this._config)||void 0===a?void 0:a.autoPlayPolicy,this._initPlayerEvents.bind(this))),null===(r=n.videoTrack)||void 0===r||r.play(CW),n.audioTrack&&(u=new GY(this.id,t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===Rh.VIDEO_ONLY||(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)===Rh.PLAY_MANUALLY,isScreen:!1}),n.audioTrack.setPlayer(u),this._initPlayerEvents(u,!0),u.playAudio(n.audioTrack));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(k=Ug(Dg().mark((function e(t){var r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._publicStreamManager.stopPlayPublicStream(t),null==(n=this._publicStreamManager.getRemoteStream(t))||null===(r=n.audioTrack)||void 0===r||r.stop();case 3:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"setAudioProfile",value:(E=Ug(Dg().mark((function e(t){return Dg().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 E.apply(this,arguments)})},{key:"setAudioEncodeMaxBitrate",value:(b=Ug(Dg().mark((function e(t){var r,n,i,o,a,s;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(qL(t,"maxBitrate",6,256),this._ctx.audioProfileManager.setCustomMaxBitrate(t),!this._ctx.audioProfileManager.customMaxBitrate){e.next=9;break}if(!yD||!(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=5;break}throw new _w(dw.NOT_SUPPORTED,"Your browser does not support set audio encode maxBitrate dynamically.");case 5:return e.next=7,null===(a=this._room)||void 0===a?void 0:a.setAudioEncodeMaxBitrate(ch.STREAM_INDEX_MAIN,t);case 7:return e.next=9,null===(s=this._room)||void 0===s?void 0:s.setAudioEncodeMaxBitrate(ch.STREAM_INDEX_SCREEN,t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i,o,a=this._publicStreamManager.getRemoteStream(e);if(null===(r=this._publicVideoPlayerConfig.get(e))||void 0===r||null===(n=r.player)||void 0===n||n.destroy(),t.renderDom){var s=new HY(this._ctx.id,CW,Zd(Zd({},t),{},{isLocal:!1,userId:e})),c=Zd(Zd({},t),{},{player:s});this._publicVideoPlayerConfig.set(e,c),null==a||null===(i=a.videoTrack)||void 0===i||i.setPlayer(this.id,Zd({},c),null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy,this._initPlayerEvents.bind(this))}else this._publicVideoPlayerConfig.delete(e)}},{key:"setDummyCaptureImagePath",value:(S=Ug(Dg().mark((function e(t,r){var n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Gg((function(e,i){JL(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===ch.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new _w(dw.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new _w(dw.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return S.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===ch.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=WL(r.width),c=WL(r.height);if(!a)throw new _w(dw.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===ch.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=u):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=u);var l,d,h=o.captureStream(5).getVideoTracks()[0];if(e===ch.STREAM_INDEX_MAIN)this._localImgVideoTrack=h,null!==(l=this._localVideoTrack)&&void 0!==l&&l.dummy&&this._localVideoTrack.setTrack(this._localImgVideoTrack,this._extensionManager);else this._localImgScreenTrack=h,null!==(d=this._localScreenVideoTrack)&&void 0!==d&&d.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=Ug(Dg().mark((function e(r,n){var i,o;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=18;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.prev=2,e.next=5,t._localVideoTrack.generatePreProcessingTrack();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),t._localVideoTrack.stopAll(),t._localVideoTrack.playAll(),t.safeEmit(Fh.onLocalStreamTrackChangedByExtension,{streamIndex:ch.STREAM_INDEX_MAIN,type:"video"}),r(),null===(i=t._room)||void 0===i||null===(o=i.localStream)||void 0===o||!o.pubVideo){e.next=18;break}return e.next=18,t._updatePublish();case 18:r();case 19:case"end":return e.stop()}}),e,null,[[2,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"registerExtension",value:(y=Ug(Dg().mark((function e(t){var r,n;return Dg().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(),null===(n=this._localVideoTrack)||void 0===n||n.generatePreProcessingTrack();case 18:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return y.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(Xg(cq.getDefaultValue()))}},{key:"_updatePublish",value:(g=Ug(Dg().mark((function e(){var t,r,n,i,o=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:{},r=o.length>1&&void 0!==o[1]&&o[1],this.logger.info("_updatePublish()","config: %o",t),n={mediaType:void 0,invokeByJoinRoom:!1,pubState:uK.PUB},t=Zd(Zd({},n),t),this._ctx.visibility){e.next=7;break}throw new _w(dw.NO_PUBLISH_PERMISSION,"no publish permission");case 7:return e.next=9,this._pubLock.lock();case 9:if(i=e.sent,this._room&&this._ctx.signalingManager.isConnected()){e.next=17;break}if(i(),!r){e.next=16;break}throw new _w(dw.NOT_CONNECTED_YET,"not connected");case 16:return e.abrupt("return");case 17:return e.prev=17,e.next=20,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 20:e.next=30;break;case 22:if(e.prev=22,e.t0=e.catch(17),!(e.t0 instanceof _w)){e.next=29;break}throw e.t0.code===dw.TOKEN_NO_PUBLISH_PERMISSION&&this._room.config.setTokenPublishPrivilegeExpired(!0),e.t0;case 29:throw new _w(dw.UNEXPECTED_ERROR,"unexpected error",e.t0);case 30:return e.prev=30,i(),e.finish(30);case 33:case"end":return e.stop()}}),e,this,[[17,22,30,33]])}))),function(){return g.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(m=Ug(Dg().mark((function e(t,r){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return JL(t,"filePath"),qL(r,"indicationInterval"),e.next=4,this._audioDeviceManager.startAudioPlaybackDeviceTest(t,r);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this.logger.info("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(_=Ug(Dg().mark((function e(t,r){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qL(t,"indicationInterval"),e.next=3,this._audioDeviceManager.startAudioDeviceRecordTest(t,r,this._localAudioVolume);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return _.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;try{iU(e),QL(t,"priority",[bh.HIGH,bh.MEDIUM,bh.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:(p=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(QL(t,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),r=t===ch.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=4;break}throw new _w(dw.INVOKED_BEFORE_CAPTURE,"capture first");case 4:return e.abrupt("return",r.snapshot());case 5:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(v=Ug(Dg().mark((function e(t,r){var n,i,o,a,s;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(JL(t,"id"),QL(r,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),s=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=lI(i).call(i,(function(e){return e.isScreen===(r===ch.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._publicStreamManager.getRemoteStream(t))||void 0===a?void 0:a.videoTrack)){e.next=5;break}throw new _w(dw.STREAM_NOT_EXIST,"stream not exist");case 5:return e.abrupt("return",s.snapshot());case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){this.logger.info("setSubscribeFallbackOption()","option: %o",e);try{QL(e,"option",[Sh.DISABLE,Sh.VIDEO_STREAM_LOW,Sh.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===ch.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 bW&&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(null!=o&&o.length){var a,s,c,u,l;if(t===ch.STREAM_INDEX_MAIN)a=lI(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=lI(o).call(o,(function(e){return e.isScreen})),i="video"===r?null===(u=a)||void 0===u?void 0:u.videoTrack:null===(l=a)||void 0===l?void 0:l.audioTrack;if(i){var d=i.preprocessingTrack;if(d&&a){var h=a.streamId;return this._reportMsTrackEvent(d,h),d}}}}},{key:"getPublicStreamTrack",value:function(e,t){var r=this._publicStreamManager.getRemoteStream(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:"setAudioSelectionConfig",value:(f=Ug(Dg().mark((function e(t){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(QL(t,"audioSelectionPriority",[Ph.DEFAULT,Ph.HIGH]),this._ctx.mediaParams||(this._ctx.mediaParams={}),this._ctx.mediaParams.audioSelectionConfig={isHighPriority:t===Ph.HIGH},!this._room){e.next=6;break}return e.next=6,this._room.updateMediaParams(this._ctx.mediaParams);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"setCaptureVolume",value:function(e,t){var r,n,i,o,a,s=this;(QL(e,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),t=fU(t,"volume",0,400),e===ch.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(iU(e),QL(t,"streamIndex",[ch.STREAM_INDEX_MAIN,ch.STREAM_INDEX_SCREEN]),r=fU(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.config.isMultiChatMode())zL("setPlaybackVolume is not supported in Conference mode");else{var s=t===ch.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:lI(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;JL(e,"publicStreamId"),t=fU(t,"volume",0,400),this._publicAudioVolume.set(e,t),null===(r=this._publicStreamManager.getRemoteStream(e))||void 0===r||null===(n=r.audioTrack)||void 0===n||n.setVolume(t)}},{key:"startForwardStreamToRooms",value:(h=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){nU(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 h.apply(this,arguments)})},{key:"updateForwardStreamToRooms",value:(d=Ug(Dg().mark((function e(t){var r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){nU(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 d.apply(this,arguments)})},{key:"stopForwardStreamToRooms",value:(l=Ug(Dg().mark((function e(){var t;return Dg().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 l.apply(this,arguments)})},{key:"pauseForwardStreamToAllRooms",value:(u=Ug(Dg().mark((function e(){var t;return Dg().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 u.apply(this,arguments)})},{key:"resumeForwardStreamToAllRooms",value:(c=Ug(Dg().mark((function e(){var t;return Dg().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 c.apply(this,arguments)})},{key:"ambulance",value:(s=Ug(Dg().mark((function e(){var t,r;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Vq(this);case 2:return t=e.sent,r=Xg(t),this.monitor.reportLongString("ambulance",r),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e,this)}))),function(){return s.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(){r.id,n.call(e)}}}},{key:"_updateScreenPublish",value:(a=Ug(Dg().mark((function e(){var t,r,n,i=arguments;return Dg().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:uK.PUB},t=Zd(Zd({},r),t),this._ctx.visibility){e.next=6;break}throw new _w(dw.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._ctx.signalingManager.isConnected()){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 _w)){e.next=23;break}throw e.t0;case 23:throw new _w(dw.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 a.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){var t;this.logger.info("_updateAudioPlayerState()");var r,n=e.userId,i=e.isScreen,o=e.isPublic,a=null===(t=e.audioTrack)||void 0===t?void 0:t.dangerousGetPlayer();if(e.audioTrack&&e.attributes.audiostream&&e.subAudio){var s,c,u;if(!a){var l,d;a=new GY(this.id,n,{muted:(null===(l=this._config)||void 0===l?void 0:l.autoPlayPolicy)===Rh.VIDEO_ONLY||(null===(d=this._config)||void 0===d?void 0:d.autoPlayPolicy)===Rh.PLAY_MANUALLY,isScreen:!o&&i}),this._initPlayerEvents(a,!1,i?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN),e.audioTrack.setPlayer(a);var h=this._audioDeviceManager.getSinkId();h&&a.setPlaybackDevice(h)}a.playAudio(e.audioTrack),e.audioTrack.setPlayer(a);var f=o?null!==(s=this._publicAudioVolume.get(n))&&void 0!==s?s:100:i?null!==(c=this._remoteScreenAudioVolume.get(n))&&void 0!==c?c:100:null!==(u=this._remoteAudioVolume.get(n))&&void 0!==u?u:100;if(e.audioTrack.setVolume(f),SD&&wD){var v,p,_=null!==(v=null===(p=this._room)||void 0===p?void 0:p.remoteStreams)&&void 0!==v?v:new hT;r=_,sq&&clearTimeout(sq),sq=setTimeout((function(){var e,t=by(r);try{for(t.s();!(e=t.n()).done;){var n=Ey(e.value,2),i=n[0],o=n[1];null!=i&&lw(i).call(i,"mux")&&o.forEach((function(e){var t;null===(t=e.audioTrack)||void 0===t||t.pause()}))}}catch(XJ){t.e(XJ)}finally{t.f()}var a,s=by(r);try{for(s.s();!(a=s.n()).done;){var c=Ey(a.value,2),u=c[0],l=c[1];null!=u&&lw(u).call(u,"mux")&&l.forEach((function(e){var t;null===(t=e.audioTrack)||void 0===t||t.play()}))}}catch(XJ){s.e(XJ)}finally{s.f()}}),2e3)}}else{var m;null===(m=a)||void 0===m||m.stop()}}},{key:"_updateVideoPlayerState",value:function(e){if(this.logger.info("_updateVideoPlayerState()"),e.videoTrack){var t=e.isPublic?this._publicVideoPlayerConfig:this._remoteVideoPlayerConfig[e.isScreen?ch.STREAM_INDEX_SCREEN:ch.STREAM_INDEX_MAIN].get(e.userId);if(t){var r,n=by(t);try{for(n.s();!(r=n.n()).done;){var i,o=Ey(r.value,2)[1];e.videoTrack.setPlayer(this.id,o,null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy,this._initPlayerEvents.bind(this))}}catch(XJ){n.e(XJ)}finally{n.f()}}}}},{key:"_onAddStream",value:(o=Ug(Dg().mark((function e(t){var r,n,i,o,a,s,c;return Dg().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=iV.NONE,o&&(c|=uh.AUDIO),s&&(c|=uh.VIDEO),!c){e.next=11;break}return e.next=8,new Gg((function(e){return setTimeout(e)}));case 8:r.isScreen?this.safeEmit(Fh.onUserPublishScreen,{userId:r.userId,mediaType:c}):(this.safeEmit(Fh.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(Fh.onUserStartAudioCapture,{userId:r.userId}),a&&this.safeEmit(Fh.onUserStartVideoCapture,{userId:r.userId}));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=iV.NONE;if(null!==(r=this._room)&&void 0!==r&&r.config.isAutoSubscribeAudio&&(i|=uh.AUDIO),null!==(n=this._room)&&void 0!==n&&n.config.isAutoSubscribeVideo&&(i|=uh.VIDEO),i){var o,a,s;if(t&&VL(i))null===(a=e.observer)||void 0===a||a.setAutoSubscribeAudio(!0);if(t&&FL(i))null===(s=e.observer)||void 0===s||s.setAutoSubscribeVideo(!0);null!==(o=this._room)&&void 0!==o&&o.config.tokenSubscribePrivilegeExpired?(VL(i)&&(this._pauseAllSubscribeState.resumeAudioStreamIds[e.streamId]=e.streamId),FL(i)&&(this._pauseAllSubscribeState.resumeVideoStreamIds[e.streamId]=e.streamId)):this._subscribe(!1,e.userId,i)}}},{key:"_onRemoveStream",value:function(e){var t,r=e.stream,n=null!==(t=yJ[e.reason])&&void 0!==t?t:lh.STREAM_REMOVE_REASON_OTHER,i=r.isScreen?Fh.onUserUnpublishScreen:Fh.onUserUnpublishStream,o=iV.NONE;r.attributes.audiostream&&(o|=uh.AUDIO),r.attributes.videostream&&(o|=uh.VIDEO),o!==iV.NONE&&(this.safeEmit(i,{userId:r.userId,mediaType:o,reason:n}),this.safeEmit("onRemoveStream",{userId:r.userId,isScreen:r.isScreen})),delete this._pauseAllSubscribeState.resumeAudioStreamIds[r.streamId],delete this._pauseAllSubscribeState.resumeVideoStreamIds[r.streamId],"function"==typeof e.callback&&e.callback()}},{key:"_onUserConnection",value:function(e){var t=this;setTimeout((function(){return t.safeEmit(Fh.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){this.safeEmit(Fh.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(Fh.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,Hg(e=[Fh.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(Fh.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),(this._ctx.isPreConnection||e.state!==dh.CONNECTION_STATE_CONNECTED&&e.state!==dh.CONNECTION_STATE_RECONNECTED)&&this.safeEmit(Fh.onConnectionStateChanged,e),e.state===dh.CONNECTION_STATE_RECONNECTING){var t,r,n,i=by(null!==(t=null===(r=this._room)||void 0===r?void 0:r.remoteStreams)&&void 0!==t?t:new hT);try{for(i.s();!(n=i.n()).done;){var o=Ey(n.value,2),a=o[0],s=o[1];lw(a).call(a,"mux")&&s.forEach((function(e){var t;return null===(t=e.audioTrack)||void 0===t?void 0:t.stop()}))}}catch(XJ){i.e(XJ)}finally{i.f()}}else e.state===dh.CONNECTION_STATE_RECONNECTED&&this._publicStreamManager.handleReconnected()}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){var t,r;e.stream&&(null===(t=e.stream.videoTrack)||void 0===t||t.stopAll(),null===(r=e.stream.audioTrack)||void 0===r||r.stop(),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(Fh.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(Fh.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&uh.AUDIO&&setTimeout((function(){t._updateAudioPlayerState(a)})),n?o===uK.PUB?this.safeEmit(Fh.onUserPublishScreen,s):this.safeEmit(Fh.onUserUnpublishScreen,Zd(Zd({},s),{},{reason:lh.STREAM_REMOVE_REASON_UNPUBLISH})):o===uK.PUB?(s.videoStreamDescriptions=a.attributes.videoDescriptions,this.safeEmit(Fh.onUserPublishStream,s),this._handleAutoSubscribe(a,!0)):this.safeEmit(Fh.onUserUnpublishStream,Zd(Zd({},s),{},{reason:lh.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(Fh.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(Fh.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Fh.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Fh.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(Fh.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(Fh.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Fh.onTokenWillExpire)}},{key:"_onUserTokenPublishPrivilegeWillExpire",value:function(){this.safeEmit(Fh.onTokenPublishPrivilegeWillExpire)}},{key:"_onUserTokenPublishPrivilegeDidExpired",value:(i=Ug(Dg().mark((function e(){var t,r,n;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._room)||void 0===t?void 0:t.unpublish();case 2:return e.next=4,null===(r=this._room)||void 0===r?void 0:r.unpublishScreen();case 4:null===(n=this._room)||void 0===n||n.config.setTokenPublishPrivilegeExpired(!0),this.safeEmit(Fh.onTokenPublishPrivilegeDidExpired,{errorCode:dw.TOKEN_NO_PUBLISH_PERMISSION,message:"Token no longer has publish privilege"});case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_onUserTokenSubscribePrivilegeWillExpire",value:function(){this.safeEmit(Fh.onTokenSubscribePrivilegeWillExpire)}},{key:"_onUserTokenSubscribePrivilegeDidExpired",value:(n=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._handleLoseSubscribePrivilege(),this.safeEmit(Fh.onTokenSubscribePrivilegeDidExpired,{errorCode:dw.TOKEN_NO_SUBSCRIBE_PERMISSION,message:"Token no longer has subscribe privilege"});case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_unSubscribeAllRemoteStreams",value:(r=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._room){e.next=2;break}return e.abrupt("return",Gg.resolve());case 2:return e.abrupt("return",this._pauseAllRemoteStreams(uh.AUDIO_AND_VIDEO));case 3:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(Fh.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Fh.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Fh.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(Fh.onError,{errorCode:dw.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(Fh.onError,{errorCode:dw.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(Fh.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"getSubLock",value:function(e,t){var r,n=e?this._subScreenLocks:this._subLocks,i=n.get(t);i||(i=new dY(Hg(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;return null===(e=this._ctx.peerConnection)||void 0===e?void 0:e.getIceConnectionState()}},{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.config.isMultiChatMode())}},{key:"checkMediaType",get:function(){return this._checkMediaType}},{key:"assertNotInRoom",get:function(){return this._assertNotInRoom}},{key:"peerConnection",get:function(){var e;return null===(e=this._ctx.peerConnection)||void 0===e?void 0:e.getOriginRTCPeerConnection()}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(Fh.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||!this._ctx.signalingManager.isConnected())throw new _w(dw.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){QL(e,"mediaType",[uh.AUDIO,uh.VIDEO,uh.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e;return(null===(e=this._room)||void 0===e?void 0:e.config.userInfo.userId)||"local_user"}},{key:"_switchTrack",value:(t=Ug(Dg().mark((function e(t){var r,n,i=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,this._localVideoPlayerConfig[ch.STREAM_INDEX_MAIN].forEach((function(e){var r;t.setPlayer(i.id,e,i._mirrorType,null===(r=i._config)||void 0===r?void 0:r.autoPlayPolicy,i._initPlayerEvents.bind(i))})),null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.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===wU.INTERNAL;if(i){var o="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: ".concat(o)),this.id}return!i}},{key:"_getServerConfig",value:function(){var e=this,t=tL.getServerConfig(this.appId);t.rts_report&&LM.setConfig(t.rts_report),this._ctx.joinRoomConfig.setServerConfig(t.web_join_room),this._preConnect(t),this._getServerConfigExecutor(t),vD({engineId:this.id,appId:this.appId,sdkVersion:lL("VERSION"),requestDomains:lL("CONFIG_REQUEST_DOMAINS"),keys:["rts_report","web_join_room","web_rtc_config"],deviceId:lL("DEVICE_ID")}).then((function(t){tL.setServerConfig(e.appId,t)}))}},{key:"_getServerConfigExecutor",value:function(e){var t,r,n,i;Lx.setParameter("UPLOAD_CONSOLE_ON",!(null==e||null===(t=e.web_rtc_config)||void 0===t||!t.upload_console_on)),Lx.setParameter("UPLOAD_CONSOLE_LENGTH_CUT",null==e||null===(r=e.web_rtc_config)||void 0===r?void 0:r.upload_console_length_cut),Lx.setParameter("UPLOAD_REPORT_LIMIT",null==e||null===(n=e.web_rtc_config)||void 0===n?void 0:n.upload_report_limit),Lx.setParameter("ENABLE_REPORT_IDB_BUFFER",!(null==e||null===(i=e.web_rtc_config)||void 0===i||!i.enable_report_idb_buffer))}},{key:"_preConnect",value:function(e){var t,r=lL("PRE_ICE");"boolean"==typeof(null==e||null===(t=e.web_rtc_config)||void 0===t?void 0:t.pre_ice)&&(r=e.web_rtc_config.pre_ice),r&&(this._ctx.signalingManager.connect(),this.monitor.set({pre_connection:!0}),this._ctx.isPreConnection=!0)}},{key:"_getRemoteVideoPlayerConfig",value:function(e,t,r){var n;return null===(n=this._remoteVideoPlayerConfig[e].get(t))||void 0===n?void 0:n.get(r)}},{key:"_setRemoteVideoPlayerConfig",value:function(e,t,r,n){var i=this._remoteVideoPlayerConfig[e].get(t)||new hT;i.set(r,n),this._remoteVideoPlayerConfig[e].set(t,i)}},{key:"getRemoteVideoStats",value:function(){var e,t=null===(e=this._room)||void 0===e?void 0:e.remoteStreams;if(!t||0===t.size)return{};var r={};return t.forEach((function(e,t){var n,i,o,a,s;null!==(n=e[0])&&void 0!==n&&n.isScreen?(s=e[0],a=e[1]):(s=e[1],a=e[0]);var c={mainVideoStats:BL((null===(i=a)||void 0===i?void 0:i.getRemoteStreamStats().videoStats)||{}),screenVideoStats:BL((null===(o=s)||void 0===o?void 0:o.getRemoteStreamStats().videoStats)||{})};r[t]=c})),r}},{key:"getRemoteAudioStats",value:function(){var e,t=null===(e=this._room)||void 0===e?void 0:e.remoteStreams;if(!t||0===t.size)return{};var r={};return t.forEach((function(e,t){var n,i,o,a,s;null!==(n=e[0])&&void 0!==n&&n.isScreen?(s=e[0],a=e[1]):(s=e[1],a=e[0]);var c={mainAudioStats:BL((null===(i=a)||void 0===i?void 0:i.getRemoteStreamStats().audioStats)||{}),screenAudioStats:BL((null===(o=s)||void 0===o?void 0:o.getRemoteStreamStats().audioStats)||{})};r[t]=c})),r}},{key:"getLocalVideoStats",value:function(){var e,t,r,n;return{mainVideoStats:BL((null===(e=this._room)||void 0===e||null===(t=e.localStream)||void 0===t?void 0:t.getLocalStreamStats().videoStats)||{}),screenVideoStats:BL((null===(r=this._room)||void 0===r||null===(n=r.localScreenStream)||void 0===n?void 0:n.getLocalStreamStats().videoStats)||{})}}},{key:"getLocalAudioStats",value:function(){var e,t,r,n;return{mainAudioStats:BL((null===(e=this._room)||void 0===e||null===(t=e.localStream)||void 0===t?void 0:t.getLocalStreamStats().audioStats)||{}),screenAudioStats:BL((null===(r=this._room)||void 0===r||null===(n=r.localScreenStream)||void 0===n?void 0:n.getLocalStreamStats().audioStats)||{})}}},{key:"getPublicVideoStats",value:function(){var e=this._publicStreamManager.getRemoteStreams();if(!e||0===e.size)return{};var t={};return e.forEach((function(e,r){var n=BL(e.getRemoteStreamStats().videoStats||{});delete n.isScreen,t[r]=n})),t}},{key:"getPublicAudioStats",value:function(){var e=this._publicStreamManager.getRemoteStreams();if(!e||0===e.size)return{};var t={};return e.forEach((function(e,r){var n=BL(e.getRemoteStreamStats().audioStats||{});delete n.isScreen,t[r]=n})),t}}]),Ue}(yU);mJ([zM()],gJ.prototype,"updateToken",1),mJ([zM(),EJ("video")],gJ.prototype,"setVideoCaptureDevice",1),mJ([zM(),EJ("audio")],gJ.prototype,"setAudioCaptureDevice",1),mJ([zM()],gJ.prototype,"connect",1),mJ([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=HM(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)}}},zM()],gJ.prototype,"joinRoom",1),mJ([zM()],gJ.prototype,"leaveRoom",1),mJ([zM()],gJ.prototype,"destroy",1),mJ([zM()],gJ.prototype,"publishStream",1),mJ([zM()],gJ.prototype,"unpublishStream",1),mJ([zM()],gJ.prototype,"publishScreen",1),mJ([zM()],gJ.prototype,"unpublishScreen",1),mJ([zM()],gJ.prototype,"subscribeStream",1),mJ([SJ],gJ.prototype,"_subscribe",1),mJ([zM()],gJ.prototype,"unsubscribeStream",1),mJ([zM()],gJ.prototype,"subscribeScreen",1),mJ([zM()],gJ.prototype,"unsubscribeScreen",1),mJ([SJ],gJ.prototype,"_unsubscribe",1),mJ([zM(),bJ],gJ.prototype,"setRemoteVideoConfig",1),mJ([zM(),EJ("video")],gJ.prototype,"startVideoCapture",1),mJ([zM(),EJ("video")],gJ.prototype,"stopVideoCapture",1),mJ([zM(),EJ("audio")],gJ.prototype,"startAudioCapture",1),mJ([zM(),EJ("audio")],gJ.prototype,"stopAudioCapture",1),mJ([zM(),EJ("all")],gJ.prototype,"startAudioAndVideoCapture",1),mJ([zM()],gJ.prototype,"startVideoAndAudioCapture",1),mJ([zM()],gJ.prototype,"getAudioMixingManager",1),mJ([zM(),kJ],gJ.prototype,"startScreenCapture",1),mJ([zM(),kJ],gJ.prototype,"stopScreenCapture",1),mJ([zM()],gJ.prototype,"setLocalVideoPlayer",1),mJ([zM()],gJ.prototype,"startLiveTranscoding",1),mJ([zM()],gJ.prototype,"updateLiveTranscoding",1),mJ([zM()],gJ.prototype,"stopLiveTranscoding",1),mJ([zM()],gJ.prototype,"startSubtitle",1),mJ([zM()],gJ.prototype,"updateSubtitleConfig",1),mJ([zM()],gJ.prototype,"stopSubtitle",1),mJ([zM()],gJ.prototype,"setBusinessId",1),mJ([zM()],gJ.prototype,"setUserVisibility",1),mJ([zM()],gJ.prototype,"setRemoteVideoPlayer",1),mJ([zM()],gJ.prototype,"setLocalVideoMirrorType",1),mJ([zM()],gJ.prototype,"setRemoteVideoMirrorType",1),mJ([zM()],gJ.prototype,"setAudioPlaybackDevice",1),mJ([zM()],gJ.prototype,"play",1),mJ([zM()],gJ.prototype,"stop",1),mJ([zM()],gJ.prototype,"getAudioVolume",1),mJ([zM()],gJ.prototype,"setAudioFrameCallback",1),mJ([zM()],gJ.prototype,"pauseAllSubscribedStream",1),mJ([zM()],gJ.prototype,"resumeAllSubscribedStream",1),mJ([zM()],gJ.prototype,"sendUserMessage",1),mJ([zM()],gJ.prototype,"sendUserBinaryMessage",1),mJ([zM()],gJ.prototype,"sendRoomMessage",1),mJ([zM()],gJ.prototype,"sendRoomBinaryMessage",1),mJ([zM()],gJ.prototype,"setAudioCaptureConfig",1),mJ([GL("4.51"),zM()],gJ.prototype,"setVideoCaptureConfig",1),mJ([zM()],gJ.prototype,"enableSimulcastMode",1),mJ([zM()],gJ.prototype,"setVideoEncoderConfig",1),mJ([zM()],gJ.prototype,"setScreenEncoderConfig",1),mJ([zM()],gJ.prototype,"sendSEIMessage",1),mJ([GL("4.42"),zM()],gJ.prototype,"setAudioVolumeIndicationInterval",1),mJ([zM()],gJ.prototype,"enableAudioPropertiesReport",1),mJ([zM()],gJ.prototype,"setVideoSourceType",1),mJ([zM()],gJ.prototype,"setExternalVideoTrack",1),mJ([zM()],gJ.prototype,"setAudioSourceType",1),mJ([zM()],gJ.prototype,"setExternalAudioTrack",1),mJ([zM()],gJ.prototype,"login",1),mJ([zM()],gJ.prototype,"logout",1),mJ([zM()],gJ.prototype,"updateLoginToken",1),mJ([zM()],gJ.prototype,"getPeerOnlineStatus",1),mJ([zM()],gJ.prototype,"sendUserMessageOutsideRoom",1),mJ([zM()],gJ.prototype,"sendUserBinaryMessageOutsideRoom",1),mJ([zM()],gJ.prototype,"setServerParams",1),mJ([zM()],gJ.prototype,"sendServerMessage",1),mJ([zM()],gJ.prototype,"sendServerBinaryMessage",1),mJ([zM()],gJ.prototype,"startCloudProxy",1),mJ([zM()],gJ.prototype,"stopCloudProxy",1),mJ([zM()],gJ.prototype,"startPushPublicStream",1),mJ([zM()],gJ.prototype,"updatePublicStreamParam",1),mJ([zM()],gJ.prototype,"stopPushPublicStream",1),mJ([zM("streamId")],gJ.prototype,"startPlayPublicStream",1),mJ([zM("streamId")],gJ.prototype,"stopPlayPublicStream",1),mJ([zM()],gJ.prototype,"setAudioProfile",1),mJ([zM()],gJ.prototype,"setAudioEncodeMaxBitrate",1),mJ([zM()],gJ.prototype,"setPublicStreamVideoPlayer",1),mJ([zM()],gJ.prototype,"setDummyCaptureImagePath",1),mJ([zM()],gJ.prototype,"registerExtension",1),mJ([zM()],gJ.prototype,"startAudioPlaybackDeviceTest",1),mJ([zM()],gJ.prototype,"stopAudioPlaybackDeviceTest",1),mJ([zM()],gJ.prototype,"startAudioDeviceRecordTest",1),mJ([zM()],gJ.prototype,"stopAudioDeviceRecordAndPlayTest",1),mJ([zM()],gJ.prototype,"stopAudioDevicePlayTest",1),mJ([zM(),bJ],gJ.prototype,"setRemoteUserPriority",1),mJ([zM()],gJ.prototype,"takeLocalSnapshot",1),mJ([zM()],gJ.prototype,"takeRemoteSnapshot",1),mJ([zM()],gJ.prototype,"setSubscribeFallbackOption",1),mJ([zM()],gJ.prototype,"getLocalStreamTrack",1),mJ([zM()],gJ.prototype,"getRemoteStreamTrack",1),mJ([zM()],gJ.prototype,"getPublicStreamTrack",1),mJ([zM()],gJ.prototype,"setRemoteStreamRenderSync",1),mJ([zM()],gJ.prototype,"setJoinRoomParams",1),mJ([zM()],gJ.prototype,"setAudioSelectionConfig",1),mJ([zM()],gJ.prototype,"startForwardStreamToRooms",1),mJ([zM()],gJ.prototype,"updateForwardStreamToRooms",1),mJ([zM()],gJ.prototype,"stopForwardStreamToRooms",1),mJ([zM()],gJ.prototype,"pauseForwardStreamToAllRooms",1),mJ([zM()],gJ.prototype,"resumeForwardStreamToAllRooms",1);var yJ={"client unpublished":lh.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":lh.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":lh.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":lh.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":lh.STREAM_REMOVE_REASON_REPUBLISH,"token publish privilege expired":lh.STREAM_REMOVE_REASON_TOKEN_PRIVILEGE_EXPIRED};function SJ(e,t,r){var n=r.value;return r.value=Ug(Dg().mark((function e(){var t,r,i,o,a,s,c,u=arguments;return Dg().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 bJ(e,t,r){var n=r.value;return r.value=Ug(Dg().mark((function e(){var t,r,i,o,a,s=arguments;return Dg().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 EJ(e){return function(t,r,n){var i=n.value;return n.value=Ug(Dg().mark((function t(){var r,n,o,a,s,c=arguments;return Dg().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,Gg.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 kJ(e,t,r){var n=r.value;return r.value=Ug(Dg().mark((function e(){var t,r,i,o,a=arguments;return Dg().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 TJ,IJ=fT,RJ=WI,AJ=function(e,t,r,n){for(var i,o=n>1?void 0:n?RJ(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&&IJ(t,r,o),o},CJ=function(e){BA(i,e);var t,r,n=nC(i);function i(e,t,r){var o;return Hh(this,i),Jd(uA(o=n.call(this,e,t,r)),"singleStreamRenderMode",!1),o.id=t,o.logger=new hD("BLWEngine",0,t),fL([{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 jh(i,[{key:"subscribeStream",value:(r=Ug(Dg().mark((function e(t,r){var n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.singleStreamRenderMode&&FL(r)&&VA(UA(i.prototype),"subscribeScreen",this).call(this,t,uh.VIDEO).catch((function(e){n.logger.error("singleStreamRenderMode subscribeScreen()",e)})),e.abrupt("return",VA(UA(i.prototype),"subscribeStream",this).call(this,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"unsubscribeStream",value:(t=Ug(Dg().mark((function e(t,r){var n=this;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.singleStreamRenderMode&&FL(r)&&VA(UA(i.prototype),"unsubscribeScreen",this).call(this,t,uh.VIDEO).catch((function(e){n.logger.error("singleStreamRenderMode unsubscribeScreen()",e)})),e.abrupt("return",VA(UA(i.prototype),"unsubscribeStream",this).call(this,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"setRemoteScreenVideoStreamIndex",value:function(e){return!this._room&&(this.singleStreamRenderMode=e===ch.STREAM_INDEX_MAIN,!0)}},{key:"setRemoteVideoPlayer",value:function(e,t){if(null==t||delete t.playerId,!this.singleStreamRenderMode||e!==ch.STREAM_INDEX_SCREEN)return VA(UA(i.prototype),"setRemoteVideoPlayer",this).call(this,e,t)}},{key:"destroy",value:function(){this.singleStreamRenderMode=!1,VA(UA(i.prototype),"destroy",this).call(this)}},{key:"_updateVideoPlayerState",value:function(e){var t,r,n,o,a;if(!this.singleStreamRenderMode)return VA(UA(i.prototype),"_updateVideoPlayerState",this).call(this,e);var s,c,u=e.userId,l=null===(t=this._room)||void 0===t?void 0:t.remoteStreams.get(u);Array.isArray(l)&&l.forEach((function(e){e.isScreen?s=e:c=e}));var d,h,f,v=null===(r=c)||void 0===r||null===(n=r.videoTrack)||void 0===n?void 0:n.dangerousGetPlayer(CW);if(!v){var p,_,m,g,y,S,b=null===(p=this._remoteVideoPlayerConfig[ch.STREAM_INDEX_MAIN].get(u))||void 0===p?void 0:p.get(CW);if(!b)return;null===(_=c)||void 0===_||null===(m=_.videoTrack)||void 0===m||m.setPlayer(this.id,b,null===(g=this._config)||void 0===g?void 0:g.autoPlayPolicy,this._initPlayerEvents.bind(this)),v=null===(y=c)||void 0===y||null===(S=y.videoTrack)||void 0===S?void 0:S.dangerousGetPlayer(CW)}!e.isScreen&&null!==(o=s)&&void 0!==o&&o.videoTrack&&s.videoHasPublish?null===(d=v)||void 0===d||d.playVideo(s.videoTrack):e.videoTrack?(null===(h=this._config)||void 0===h?void 0:h.autoPlayPolicy)!==Rh.PLAY_MANUALLY&&(null===(f=v)||void 0===f||f.playVideo(e.videoTrack)):null!==(a=v)&&void 0!==a&&a.played&&v.stop()}},{key:"_handleEngineEvents",value:function(){var e=this;this.on(Fh.onUserPublishScreen,(function(t){if(e.singleStreamRenderMode&&FL(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:lI(i).call(i,(function(e){return!e.isScreen})),a=null==i?void 0:lI(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._room)&&void 0!==n&&n.config.isAutoSubscribeVideo||null!=o&&o.hasSubscribed&&FL(o.subMediaType))&&(e.logger.info("onUserPublishScreen","singleStreamRenderMode subscribeScreen"),e.subscribeScreen(t.userId,uh.VIDEO))}})),this.on(Fh.onUserUnpublishScreen,(function(t){if(e.singleStreamRenderMode&&FL(t.mediaType)){var r,n=null===(r=e._room)||void 0===r?void 0:r.remoteStreams.get(t.userId),i=null==n?void 0:lI(n).call(n,(function(e){return!e.isScreen}));i&&setTimeout((function(){e._updateVideoPlayerState(i)}))}}))}}]),i}(gJ);AJ([zM()],CJ.prototype,"subscribeStream",1),AJ([zM()],CJ.prototype,"unsubscribeStream",1),AJ([zM()],CJ.prototype,"setRemoteScreenVideoStreamIndex",1),AJ([zM()],CJ.prototype,"setRemoteVideoPlayer",1),AJ([zM()],CJ.prototype,"destroy",1);var wJ=new hD("VERTC",0);Rx.storeKey=Hg(TJ="".concat(Date.now(),"-")).call(TJ,tL.getDeviceId()),VM({rtc_sdk_version:cL.VERSION,device_id:tL.getDeviceId(),log_cache_key:Rx.storeKey}),FM(cL.LOG_SERVER_URL);var xJ=1,OJ=function(e,t){wJ.info("createEngine","Invoke VERTC.createEngine"),JL(e,"appId");var r=(xJ++).toString();return GM(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new gJ(e,r,t)},NJ=function(e,t){wJ.print("createBLWEngine","Invoke VERTC.createBLWEngine"),JL(e,"appId");var r=(xJ++).toString();return GM(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new CJ(e,r,t)},PJ=function(e){if(wJ.info("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof gJ))throw new _w(dw.INVALID_ENGINE,"Invalid engine object");try{e.destroy()}catch(r){console.log("catch an error",r)}var t;t=e.monitor,jM.delete(t.id)},MJ=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",PW.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),DJ=function(){var e=Ug(Dg().mark((function e(){var t,r,n,i,o,a=arguments;return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=(t=a.length>0&&void 0!==a[0]?a[0]:{video:!0,audio:!0}).video,n=t.audio,i={video:!1,audio:!1},o=[],r&&o.push(PW.getPermissions({video:!0,force:!0}).then((function(e){i.video=e.video,e.video||(i.videoExceptionError=e.reason)}))),n&&o.push(PW.getPermissions({audio:!0,force:!0}).then((function(e){i.audio=e.audio,e.audio||(i.audioExceptionError=e.reason)}))),e.next=8,Gg.allSettled(o);case 8:return e.abrupt("return",i);case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),LJ=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",PW.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),UJ=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",PW.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),VJ=function(){var e=Ug(Dg().mark((function e(){return Dg().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",PW.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),FJ=function(){return cL.VERSION},BJ=function(){return UU()},jJ=function(){return FU()},HJ=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(Rx.logLevel=t),r&&(Rx.LogfileSize=r)},GJ=function(e){Rx.download(e)};function zJ(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Xg($g(t).call(t,(function(e){return e instanceof gJ?"[ENGINE]":e})))}function WJ(e,t){return function(){zJ.apply(void 0,arguments);var t=e.apply(void 0,arguments);return"function"==typeof(null==t?void 0:t.then)?t.then((function(e){return zJ(e),e})).catch((function(e){throw e.code,e.message,e})):(zJ(t),t)}}return Zd(Zd(Zd(Zd({},new(jh((function e(){Hh(this,e),Jd(this,"getSdkVersion",WJ(FJ)),Jd(this,"createEngine",WJ(OJ)),Jd(this,"createBLWEngine",WJ(NJ)),Jd(this,"destroyEngine",WJ(PJ)),Jd(this,"enumerateDevices",WJ(MJ)),Jd(this,"enableDevices",WJ(DJ)),Jd(this,"enumerateAudioCaptureDevices",WJ(LJ)),Jd(this,"enumerateVideoCaptureDevices",WJ(UJ)),Jd(this,"enumerateAudioPlaybackDevices",WJ(VJ)),Jd(this,"getParameter",lL),Jd(this,"setParameter",uL),Jd(this,"isSupported",WJ(BJ)),Jd(this,"getSupportedCodecs",WJ(jJ)),Jd(this,"events",Fh),Jd(this,"ErrorCode",dw),Jd(this,"platform","BytePlus"),Jd(this,"commitInfo","HEAD<5be7c37*>"),Jd(this,"downloadLog",WJ(GJ)),Jd(this,"setLogConfig",WJ(HJ))})))),Mh),Vh),{},{events:Fh})}));