@byteplus/rtc 4.56.16 → 4.56.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.min.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright (c) 2020 The BytePlusRTC project authors. All Rights Reserved.
3
3
  * @brief BytePlusRTC Advance API
4
- * version: 4.56.16
4
+ * version: 4.56.18
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}function n(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];return r.push.apply(r,arguments),new(Function.bind.apply(t,r))}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var i=function(e){return e&&e.Math==Math&&e},o=i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof t&&t)||function(){return this}()||Function("return this")(),a=function(e){try{return!!e()}catch(t){return!0}},s=!a((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),c=s,u=Function.prototype,d=u.apply,l=u.call,h="object"==typeof Reflect&&Reflect.apply||(c?l.bind(d):function(){return l.apply(d,arguments)}),v=s,p=Function.prototype,f=p.call,_=v&&p.bind.bind(f,f),m=v?_:function(e){return function(){return f.apply(e,arguments)}},g=m,y=g({}.toString),S=g("".slice),b=function(e){return S(y(e),8,-1)},E=b,k=m,T=function(e){if("Function"===E(e))return k(e)},I="object"==typeof document&&document.all,R={all:I,IS_HTMLDDA:void 0===I&&void 0!==I},A=R.all,w=R.IS_HTMLDDA?function(e){return"function"==typeof e||e===A}:function(e){return"function"==typeof e},C={},x=!a((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),O=s,P=Function.prototype.call,N=O?P.bind(P):function(){return P.apply(P,arguments)},D={},M={}.propertyIsEnumerable,L=Object.getOwnPropertyDescriptor,U=L&&!M.call({1:2},1);D.f=U?function(e){var t=L(this,e);return!!t&&t.enumerable}:M;var V,F,B=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},j=a,H=b,G=Object,z=T("".split),K=j((function(){return!G("z").propertyIsEnumerable(0)}))?function(e){return"String"==H(e)?z(e,""):G(e)}:G,X=function(e){return null==e},W=X,Y=TypeError,q=function(e){if(W(e))throw Y("Can't call method on "+e);return e},J=K,Q=q,Z=function(e){return J(Q(e))},$=w,ee=R.all,te=R.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:$(e)||e===ee}:function(e){return"object"==typeof e?null!==e:$(e)},re={},ne=re,ie=o,oe=w,ae=function(e){return oe(e)?e:void 0},se=function(e,t){return arguments.length<2?ae(ne[e])||ae(ie[e]):ne[e]&&ne[e][t]||ie[e]&&ie[e][t]},ce=T({}.isPrototypeOf),ue=se("navigator","userAgent")||"",de=o,le=ue,he=de.process,ve=de.Deno,pe=he&&he.versions||ve&&ve.version,fe=pe&&pe.v8;fe&&(F=(V=fe.split("."))[0]>0&&V[0]<4?1:+(V[0]+V[1])),!F&&le&&(!(V=le.match(/Edge\/(\d+)/))||V[1]>=74)&&(V=le.match(/Chrome\/(\d+)/))&&(F=+V[1]);var _e=F,me=_e,ge=a,ye=!!Object.getOwnPropertySymbols&&!ge((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&me&&me<41})),Se=ye&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,be=se,Ee=w,ke=ce,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=w,Ce=Ae,xe=TypeError,Oe=function(e){if(we(e))return e;throw xe(Ce(e)+" is not a function")},Pe=Oe,Ne=X,De=function(e,t){var r=e[t];return Ne(r)?void 0:Pe(r)},Me=N,Le=w,Ue=te,Ve=TypeError,Fe={exports:{}},Be=o,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=o[Ge]||He(Ge,{}),Ke=ze;(Fe.exports=function(e,t){return Ke[e]||(Ke[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.0",mode:"pure",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Xe=Fe.exports,We=q,Ye=Object,qe=function(e){return Ye(We(e))},Je=qe,Qe=T({}.hasOwnProperty),Ze=Object.hasOwn||function(e,t){return Qe(Je(e),t)},$e=T,et=0,tt=Math.random(),rt=$e(1..toString),nt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+rt(++et+tt,36)},it=o,ot=Ze,at=nt,st=ye,ct=Se,ut=Xe("wks"),dt=it.Symbol,lt=dt&&dt.for,ht=ct?dt:dt&&dt.withoutSetter||at,vt=function(e){if(!ot(ut,e)||!st&&"string"!=typeof ut[e]){var t="Symbol."+e;st&&ot(dt,e)?ut[e]=dt[e]:ut[e]=ct&&lt?lt(t):ht(t)}return ut[e]},pt=N,ft=te,_t=Ie,mt=De,gt=function(e,t){var r,n;if("string"===t&&Le(r=e.toString)&&!Ue(n=Me(r,e)))return n;if(Le(r=e.valueOf)&&!Ue(n=Me(r,e)))return n;if("string"!==t&&Le(r=e.toString)&&!Ue(n=Me(r,e)))return n;throw Ve("Can't convert object to primitive value")},yt=TypeError,St=vt("toPrimitive"),bt=function(e,t){if(!ft(e)||_t(e))return e;var r,n=mt(e,St);if(n){if(void 0===t&&(t="default"),r=pt(n,e,t),!ft(r)||_t(r))return r;throw yt("Can't convert object to primitive value")}return void 0===t&&(t="number"),gt(e,t)},Et=Ie,kt=function(e){var t=bt(e,"string");return Et(t)?t:t+""},Tt=te,It=o.document,Rt=Tt(It)&&Tt(It.createElement),At=function(e){return Rt?It.createElement(e):{}},wt=At,Ct=!x&&!a((function(){return 7!=Object.defineProperty(wt("div"),"a",{get:function(){return 7}}).a})),xt=x,Ot=N,Pt=D,Nt=B,Dt=Z,Mt=kt,Lt=Ze,Ut=Ct,Vt=Object.getOwnPropertyDescriptor;C.f=xt?Vt:function(e,t){if(e=Dt(e),t=Mt(t),Ut)try{return Vt(e,t)}catch(r){}if(Lt(e,t))return Nt(!Ot(Pt.f,e,t),e[t])};var Ft=a,Bt=w,jt=/#|\.prototype\./,Ht=function(e,t){var r=zt[Gt(e)];return r==Xt||r!=Kt&&(Bt(t)?Ft(t):!!t)},Gt=Ht.normalize=function(e){return String(e).replace(jt,".").toLowerCase()},zt=Ht.data={},Kt=Ht.NATIVE="N",Xt=Ht.POLYFILL="P",Wt=Ht,Yt=Oe,qt=s,Jt=T(T.bind),Qt=function(e,t){return Yt(e),void 0===t?e:qt?Jt(e,t):function(){return e.apply(t,arguments)}},Zt={},$t=x&&a((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),er=te,tr=String,rr=TypeError,nr=function(e){if(er(e))return e;throw rr(tr(e)+" is not an object")},ir=x,or=Ct,ar=$t,sr=nr,cr=kt,ur=TypeError,dr=Object.defineProperty,lr=Object.getOwnPropertyDescriptor,hr="enumerable",vr="configurable",pr="writable";Zt.f=ir?ar?function(e,t,r){if(sr(e),t=cr(t),sr(r),"function"==typeof e&&"prototype"===t&&"value"in r&&pr in r&&!r[pr]){var n=lr(e,t);n&&n[pr]&&(e[t]=r.value,r={configurable:vr in r?r[vr]:n[vr],enumerable:hr in r?r[hr]:n[hr],writable:!1})}return dr(e,t,r)}:dr:function(e,t,r){if(sr(e),t=cr(t),sr(r),or)try{return dr(e,t,r)}catch(n){}if("get"in r||"set"in r)throw ur("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var fr=Zt,_r=B,mr=x?function(e,t,r){return fr.f(e,t,_r(1,r))}:function(e,t,r){return e[t]=r,e},gr=o,yr=h,Sr=T,br=w,Er=C.f,kr=Wt,Tr=re,Ir=Qt,Rr=mr,Ar=Ze,wr=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 yr(e,this,arguments)};return t.prototype=e.prototype,t},Cr=function(e,t){var r,n,i,o,a,s,c,u,d=e.target,l=e.global,h=e.stat,v=e.proto,p=l?gr:h?gr[d]:(gr[d]||{}).prototype,f=l?Tr:Tr[d]||Rr(Tr,d,{})[d],_=f.prototype;for(i in t)r=!kr(l?i:d+(h?".":"#")+i,e.forced)&&p&&Ar(p,i),a=f[i],r&&(s=e.dontCallGetSet?(u=Er(p,i))&&u.value:p[i]),o=r&&s?s:t[i],r&&typeof a==typeof o||(c=e.bind&&r?Ir(o,gr):e.wrap&&r?wr(o):v&&br(o)?Sr(o):o,(e.sham||o&&o.sham||a&&a.sham)&&Rr(c,"sham",!0),Rr(f,i,c),v&&(Ar(Tr,n=d+"Prototype")||Rr(Tr,n,{}),Rr(Tr[n],i,o),e.real&&_&&!_[i]&&Rr(_,i,o)))},xr=Math.ceil,Or=Math.floor,Pr=Math.trunc||function(e){var t=+e;return(t>0?Or:xr)(t)},Nr=function(e){var t=+e;return t!=t||0===t?0:Pr(t)},Dr=Nr,Mr=Math.max,Lr=Math.min,Ur=function(e,t){var r=Dr(e);return r<0?Mr(r+t,0):Lr(r,t)},Vr=Nr,Fr=Math.min,Br=function(e){return e>0?Fr(Vr(e),9007199254740991):0},jr=Br,Hr=function(e){return jr(e.length)},Gr=Z,zr=Ur,Kr=Hr,Xr=function(e){return function(t,r,n){var i,o=Gr(t),a=Kr(o),s=zr(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:Xr(!0),indexOf:Xr(!1)},Yr={},qr=Ze,Jr=Z,Qr=Wr.indexOf,Zr=Yr,$r=T([].push),en=function(e,t){var r,n=Jr(e),i=0,o=[];for(r in n)!qr(Zr,r)&&qr(n,r)&&$r(o,r);for(;t.length>i;)qr(n,r=t[i++])&&(~Qr(o,r)||$r(o,r));return o},tn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],rn=en,nn=tn,on=Object.keys||function(e){return rn(e,nn)},an=qe,sn=on;Cr({target:"Object",stat:!0,forced:a((function(){sn(1)}))},{keys:function(e){return sn(an(e))}});var cn=r(re.Object.keys),un={};un[vt("toStringTag")]="z";var dn="[object z]"===String(un),ln=dn,hn=w,vn=b,pn=vt("toStringTag"),fn=Object,_n="Arguments"==vn(function(){return arguments}()),mn=ln?vn: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=fn(e),pn))?r:_n?vn(t):"Object"==(n=vn(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=x,kn=$t,Tn=Zt,In=nr,Rn=Z,An=on;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=se("document","documentElement"),xn=nt,On=Xe("keys"),Pn=function(e){return On[e]||(On[e]=xn(e))},Nn=nr,Dn=bn,Mn=tn,Ln=Yr,Un=Cn,Vn=At,Fn="prototype",Bn="script",jn=Pn("IE_PROTO"),Hn=function(){},Gn=function(e){return"<"+Bn+">"+e+"</"+Bn+">"},zn=function(e){e.write(Gn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Kn=function(){try{wn=new ActiveXObject("htmlfile")}catch(i){}var e,t,r;Kn="undefined"!=typeof document?document.domain&&wn?zn(wn):(t=Vn("iframe"),r="java"+Bn+":",t.style.display="none",Un.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(Gn("document.F=Object")),e.close(),e.F):zn(wn);for(var n=Mn.length;n--;)delete Kn[Fn][Mn[n]];return Kn()};Ln[jn]=!0;var Xn=Object.create||function(e,t){var r;return null!==e?(Hn[Fn]=Nn(e),r=new Hn,Hn[Fn]=null,r[jn]=e):r=Kn(),void 0===t?r:Dn.f(r,t)},Wn={},Yn=en,qn=tn.concat("length","prototype");Wn.f=Object.getOwnPropertyNames||function(e){return Yn(e,qn)};var Jn={},Qn=kt,Zn=Zt,$n=B,ei=function(e,t,r){var n=Qn(t);n in e?Zn.f(e,n,$n(0,r)):e[n]=r},ti=Ur,ri=Hr,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=b,ci=Z,ui=Wn.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 vi=mr,pi=function(e,t,r,n){return n&&n.enumerable?e[t]=r:vi(e,t,r),e},fi={},_i=vt;fi.f=_i;var mi,gi,yi,Si=re,bi=Ze,Ei=fi,ki=Zt.f,Ti=function(e){var t=Si.Symbol||(Si.Symbol={});bi(t,e)||ki(t,e,{value:Ei.f(e)})},Ii=N,Ri=se,Ai=vt,wi=pi,Ci=function(){var e=Ri("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=Ai("toPrimitive");t&&!t[n]&&wi(t,n,(function(e){return Ii(r,this)}),{arity:1})},xi=mn,Oi=dn?{}.toString:function(){return"[object "+xi(this)+"]"},Pi=dn,Ni=Zt.f,Di=mr,Mi=Ze,Li=Oi,Ui=vt("toStringTag"),Vi=function(e,t,r,n){if(e){var i=r?e:e.prototype;Mi(i,Ui)||Ni(i,Ui,{configurable:!0,value:t}),n&&!Pi&&Di(i,"toString",Li)}},Fi=w,Bi=o.WeakMap,ji=Fi(Bi)&&/native code/.test(String(Bi)),Hi=o,Gi=te,zi=mr,Ki=Ze,Xi=ze,Wi=Pn,Yi=Yr,qi="Object already initialized",Ji=Hi.TypeError,Qi=Hi.WeakMap;if(ji||Xi.state){var Zi=Xi.state||(Xi.state=new Qi);Zi.get=Zi.get,Zi.has=Zi.has,Zi.set=Zi.set,mi=function(e,t){if(Zi.has(e))throw Ji(qi);return t.facade=e,Zi.set(e,t),t},gi=function(e){return Zi.get(e)||{}},yi=function(e){return Zi.has(e)}}else{var $i=Wi("state");Yi[$i]=!0,mi=function(e,t){if(Ki(e,$i))throw Ji(qi);return t.facade=e,zi(e,$i,t),t},gi=function(e){return Ki(e,$i)?e[$i]:{}},yi=function(e){return Ki(e,$i)}}var eo={set:mi,get:gi,has:yi,enforce:function(e){return yi(e)?gi(e):mi(e,{})},getterFor:function(e){return function(t){var r;if(!Gi(t)||(r=gi(t)).type!==e)throw Ji("Incompatible receiver, "+e+" required");return r}}},to=b,ro=Array.isArray||function(e){return"Array"==to(e)},no=w,io=ze,oo=T(Function.toString);no(io.inspectSource)||(io.inspectSource=function(e){return oo(e)});var ao=io.inspectSource,so=T,co=a,uo=w,lo=mn,ho=ao,vo=function(){},po=[],fo=se("Reflect","construct"),_o=/^\s*(?:class|function)\b/,mo=so(_o.exec),go=!_o.exec(vo),yo=function(e){if(!uo(e))return!1;try{return fo(vo,po,e),!0}catch(t){return!1}},So=function(e){if(!uo(e))return!1;switch(lo(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return go||!!mo(_o,ho(e))}catch(t){return!0}};So.sham=!0;var bo=!fo||co((function(){var e;return yo(yo.call)||!yo(Object)||!yo((function(){e=!0}))||e}))?So:yo,Eo=ro,ko=bo,To=te,Io=vt("species"),Ro=Array,Ao=function(e){var t;return Eo(e)&&(t=e.constructor,(ko(t)&&(t===Ro||Eo(t.prototype))||To(t)&&null===(t=t[Io]))&&(t=void 0)),void 0===t?Ro:t},wo=function(e,t){return new(Ao(e))(0===t?0:t)},Co=Qt,xo=K,Oo=qe,Po=Hr,No=wo,Do=T([].push),Mo=function(e){var t=1==e,r=2==e,n=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,d,l){for(var h,v,p=Oo(c),f=xo(p),_=Co(u,d),m=Po(f),g=0,y=l||No,S=t?y(c,m):r||a?y(c,0):void 0;m>g;g++)if((s||g in f)&&(v=_(h=f[g],g,p),e))if(t)S[g]=v;else if(v)switch(e){case 3:return!0;case 5:return h;case 6:return g;case 2:Do(S,h)}else switch(e){case 4:return!1;case 7:Do(S,h)}return o?-1:n||i?i:S}},Lo={forEach:Mo(0),map:Mo(1),filter:Mo(2),some:Mo(3),every:Mo(4),find:Mo(5),findIndex:Mo(6),filterReject:Mo(7)},Uo=Cr,Vo=o,Fo=N,Bo=T,jo=x,Ho=ye,Go=a,zo=Ze,Ko=ce,Xo=nr,Wo=Z,Yo=kt,qo=Sn,Jo=B,Qo=Xn,Zo=on,$o=Wn,ea=Jn,ta=hi,ra=C,na=Zt,ia=bn,oa=D,aa=pi,sa=Xe,ca=Yr,ua=nt,da=vt,la=fi,ha=Ti,va=Ci,pa=Vi,fa=eo,_a=Lo.forEach,ma=Pn("hidden"),ga="Symbol",ya="prototype",Sa=fa.set,ba=fa.getterFor(ga),Ea=Object[ya],ka=Vo.Symbol,Ta=ka&&ka[ya],Ia=Vo.TypeError,Ra=Vo.QObject,Aa=ra.f,wa=na.f,Ca=ea.f,xa=oa.f,Oa=Bo([].push),Pa=sa("symbols"),Na=sa("op-symbols"),Da=sa("wks"),Ma=!Ra||!Ra[ya]||!Ra[ya].findChild,La=jo&&Go((function(){return 7!=Qo(wa({},"a",{get:function(){return wa(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=Aa(Ea,t);n&&delete Ea[t],wa(e,t,r),n&&e!==Ea&&wa(Ea,t,n)}:wa,Ua=function(e,t){var r=Pa[e]=Qo(Ta);return Sa(r,{type:ga,tag:e,description:t}),jo||(r.description=t),r},Va=function(e,t,r){e===Ea&&Va(Na,t,r),Xo(e);var n=Yo(t);return Xo(r),zo(Pa,n)?(r.enumerable?(zo(e,ma)&&e[ma][n]&&(e[ma][n]=!1),r=Qo(r,{enumerable:Jo(0,!1)})):(zo(e,ma)||wa(e,ma,Jo(1,{})),e[ma][n]=!0),La(e,n,r)):wa(e,n,r)},Fa=function(e,t){Xo(e);var r=Wo(t),n=Zo(r).concat(Ga(r));return _a(n,(function(t){jo&&!Fo(Ba,r,t)||Va(e,t,r[t])})),e},Ba=function(e){var t=Yo(e),r=Fo(xa,this,t);return!(this===Ea&&zo(Pa,t)&&!zo(Na,t))&&(!(r||!zo(this,t)||!zo(Pa,t)||zo(this,ma)&&this[ma][t])||r)},ja=function(e,t){var r=Wo(e),n=Yo(t);if(r!==Ea||!zo(Pa,n)||zo(Na,n)){var i=Aa(r,n);return!i||!zo(Pa,n)||zo(r,ma)&&r[ma][n]||(i.enumerable=!0),i}},Ha=function(e){var t=Ca(Wo(e)),r=[];return _a(t,(function(e){zo(Pa,e)||zo(ca,e)||Oa(r,e)})),r},Ga=function(e){var t=e===Ea,r=Ca(t?Na:Wo(e)),n=[];return _a(r,(function(e){!zo(Pa,e)||t&&!zo(Ea,e)||Oa(n,Pa[e])})),n};Ho||(ka=function(){if(Ko(Ta,this))throw Ia("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?qo(arguments[0]):void 0,t=ua(e),r=function(e){this===Ea&&Fo(r,Na,e),zo(this,ma)&&zo(this[ma],t)&&(this[ma][t]=!1),La(this,t,Jo(1,e))};return jo&&Ma&&La(Ea,t,{configurable:!0,set:r}),Ua(t,e)},aa(Ta=ka[ya],"toString",(function(){return ba(this).tag})),aa(ka,"withoutSetter",(function(e){return Ua(ua(e),e)})),oa.f=Ba,na.f=Va,ia.f=Fa,ra.f=ja,$o.f=ea.f=Ha,ta.f=Ga,la.f=function(e){return Ua(da(e),e)},jo&&wa(Ta,"description",{configurable:!0,get:function(){return ba(this).description}})),Uo({global:!0,constructor:!0,wrap:!0,forced:!Ho,sham:!Ho},{Symbol:ka}),_a(Zo(Da),(function(e){ha(e)})),Uo({target:ga,stat:!0,forced:!Ho},{useSetter:function(){Ma=!0},useSimple:function(){Ma=!1}}),Uo({target:"Object",stat:!0,forced:!Ho,sham:!jo},{create:function(e,t){return void 0===t?Qo(e):Fa(Qo(e),t)},defineProperty:Va,defineProperties:Fa,getOwnPropertyDescriptor:ja}),Uo({target:"Object",stat:!0,forced:!Ho},{getOwnPropertyNames:Ha}),va(),pa(ka,ga),ca[ma]=!0;var za=ye&&!!Symbol.for&&!!Symbol.keyFor,Ka=Cr,Xa=se,Wa=Ze,Ya=Sn,qa=Xe,Ja=za,Qa=qa("string-to-symbol-registry"),Za=qa("symbol-to-string-registry");Ka({target:"Symbol",stat:!0,forced:!Ja},{for:function(e){var t=Ya(e);if(Wa(Qa,t))return Qa[t];var r=Xa("Symbol")(t);return Qa[t]=r,Za[r]=t,r}});var $a=Cr,es=Ze,ts=Ie,rs=Ae,ns=za,is=Xe("symbol-to-string-registry");$a({target:"Symbol",stat:!0,forced:!ns},{keyFor:function(e){if(!ts(e))throw TypeError(rs(e)+" is not a symbol");if(es(is,e))return is[e]}});var os=T([].slice),as=Cr,ss=se,cs=h,us=N,ds=T,ls=a,hs=ro,vs=w,ps=te,fs=Ie,_s=os,ms=ye,gs=ss("JSON","stringify"),ys=ds(/./.exec),Ss=ds("".charAt),bs=ds("".charCodeAt),Es=ds("".replace),ks=ds(1..toString),Ts=/[\uD800-\uDFFF]/g,Is=/^[\uD800-\uDBFF]$/,Rs=/^[\uDC00-\uDFFF]$/,As=!ms||ls((function(){var e=ss("Symbol")();return"[null]"!=gs([e])||"{}"!=gs({a:e})||"{}"!=gs(Object(e))})),ws=ls((function(){return'"\\udf06\\ud834"'!==gs("\udf06\ud834")||'"\\udead"'!==gs("\udead")})),Cs=function(e,t){var r=_s(arguments),n=t;if((ps(t)||void 0!==e)&&!fs(e))return hs(t)||(t=function(e,t){if(vs(n)&&(t=us(n,this,e,t)),!fs(t))return t}),r[1]=t,cs(gs,null,r)},xs=function(e,t,r){var n=Ss(r,t-1),i=Ss(r,t+1);return ys(Is,e)&&!ys(Rs,i)||ys(Rs,e)&&!ys(Is,n)?"\\u"+ks(bs(e,0),16):e};gs&&as({target:"JSON",stat:!0,arity:3,forced:As||ws},{stringify:function(e,t,r){var n=_s(arguments),i=cs(As?Cs:gs,null,n);return ws&&"string"==typeof i?Es(i,Ts,xs):i}});var Os=hi,Ps=qe;Cr({target:"Object",stat:!0,forced:!ye||a((function(){Os.f(1)}))},{getOwnPropertySymbols:function(e){var t=Os.f;return t?t(Ps(e)):[]}});var Ns=r(re.Object.getOwnPropertySymbols),Ds=a,Ms=_e,Ls=vt("species"),Us=function(e){return Ms>=51||!Ds((function(){var t=[];return(t.constructor={})[Ls]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Vs=Lo.filter;Cr({target:"Array",proto:!0,forced:!Us("filter")},{filter:function(e){return Vs(this,e,arguments.length>1?arguments[1]:void 0)}});var Fs=re,Bs=function(e){return Fs[e+"Prototype"]},js=Bs("Array").filter,Hs=ce,Gs=js,zs=Array.prototype,Ks=r((function(e){var t=e.filter;return e===zs||Hs(zs,e)&&t===zs.filter?Gs:t})),Xs={exports:{}},Ws=Cr,Ys=a,qs=Z,Js=C.f,Qs=x,Zs=Ys((function(){Js(1)}));Ws({target:"Object",stat:!0,forced:!Qs||Zs,sham:!Qs},{getOwnPropertyDescriptor:function(e,t){return Js(qs(e),t)}});var $s=re.Object,ec=Xs.exports=function(e,t){return $s.getOwnPropertyDescriptor(e,t)};$s.getOwnPropertyDescriptor.sham&&(ec.sham=!0);var tc,rc,nc,ic=r(Xs.exports),oc={},ac=x,sc=Ze,cc=Function.prototype,uc=ac&&Object.getOwnPropertyDescriptor,dc=sc(cc,"name"),lc={EXISTS:dc,PROPER:dc&&"something"===function(){}.name,CONFIGURABLE:dc&&(!ac||ac&&uc(cc,"name").configurable)},hc=!a((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),vc=Ze,pc=w,fc=qe,_c=hc,mc=Pn("IE_PROTO"),gc=Object,yc=gc.prototype,Sc=_c?gc.getPrototypeOf:function(e){var t=fc(e);if(vc(t,mc))return t[mc];var r=t.constructor;return pc(r)&&t instanceof r?r.prototype:t instanceof gc?yc:null},bc=a,Ec=w,kc=te,Tc=Xn,Ic=Sc,Rc=pi,Ac=vt("iterator"),wc=!1;[].keys&&("next"in(nc=[].keys())?(rc=Ic(Ic(nc)))!==Object.prototype&&(tc=rc):wc=!0);var Cc=!kc(tc)||bc((function(){var e={};return tc[Ac].call(e)!==e}));Ec((tc=Cc?{}:Tc(tc))[Ac])||Rc(tc,Ac,(function(){return this}));var xc={IteratorPrototype:tc,BUGGY_SAFARI_ITERATORS:wc},Oc=xc.IteratorPrototype,Pc=Xn,Nc=B,Dc=Vi,Mc=oc,Lc=function(){return this},Uc=function(e,t,r,n){var i=t+" Iterator";return e.prototype=Pc(Oc,{next:Nc(+!n,r)}),Dc(e,i,!1,!0),Mc[i]=Lc,e},Vc=w,Fc=String,Bc=TypeError,jc=T,Hc=nr,Gc=function(e){if("object"==typeof e||Vc(e))return e;throw Bc("Can't set "+Fc(e)+" as a prototype")},zc=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=jc(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return Hc(r),Gc(n),t?e(r,n):r.__proto__=n,r}}():void 0),Kc=Cr,Xc=N,Wc=lc,Yc=Uc,qc=Sc,Jc=Vi,Qc=pi,Zc=oc,$c=xc,eu=Wc.PROPER,tu=$c.BUGGY_SAFARI_ITERATORS,ru=vt("iterator"),nu="keys",iu="values",ou="entries",au=function(){return this},su=function(e,t,r,n,i,o,a){Yc(r,t,n);var s,c,u,d=function(e){if(e===i&&f)return f;if(!tu&&e in v)return v[e];switch(e){case nu:case iu:case ou:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,v=e.prototype,p=v[ru]||v["@@iterator"]||i&&v[i],f=!tu&&p||d(i),_="Array"==t&&v.entries||p;if(_&&(s=qc(_.call(new e)))!==Object.prototype&&s.next&&(Jc(s,l,!0,!0),Zc[l]=au),eu&&i==iu&&p&&p.name!==iu&&(h=!0,f=function(){return Xc(p,this)}),i)if(c={values:d(iu),keys:o?f:d(nu),entries:d(ou)},a)for(u in c)(tu||h||!(u in v))&&Qc(v,u,c[u]);else Kc({target:t,proto:!0,forced:tu||h},c);return a&&v[ru]!==f&&Qc(v,ru,f,{name:i}),Zc[t]=f,c},cu=function(e,t){return{value:e,done:t}},uu=Z,du=oc,lu=eo;Zt.f;var hu=su,vu=cu,pu="Array Iterator",fu=lu.set,_u=lu.getterFor(pu);hu(Array,"Array",(function(e,t){fu(this,{type:pu,target:uu(e),index:0,kind:t})}),(function(){var e=_u(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,vu(void 0,!0)):vu("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values"),du.Arguments=du.Array;var mu={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},gu=o,yu=mn,Su=mr,bu=oc,Eu=vt("toStringTag");for(var ku in mu){var Tu=gu[ku],Iu=Tu&&Tu.prototype;Iu&&yu(Iu)!==Eu&&Su(Iu,Eu,ku),bu[ku]=bu.Array}var Ru=a,Au=function(e,t){var r=[][e];return!!r&&Ru((function(){r.call(null,t||function(){return 1},1)}))},wu=Lo.forEach,Cu=Au("forEach")?[].forEach:function(e){return wu(this,e,arguments.length>1?arguments[1]:void 0)};Cr({target:"Array",proto:!0,forced:[].forEach!=Cu},{forEach:Cu});var xu=Bs("Array").forEach,Ou=mn,Pu=Ze,Nu=ce,Du=xu,Mu=Array.prototype,Lu={DOMTokenList:!0,NodeList:!0},Uu=r((function(e){var t=e.forEach;return e===Mu||Nu(Mu,e)&&t===Mu.forEach||Pu(Lu,Ou(e))?Du:t})),Vu=se,Fu=Wn,Bu=hi,ju=nr,Hu=T([].concat),Gu=Vu("Reflect","ownKeys")||function(e){var t=Fu.f(ju(e)),r=Bu.f;return r?Hu(t,r(e)):t},zu=Gu,Ku=Z,Xu=C,Wu=ei;Cr({target:"Object",stat:!0,sham:!x},{getOwnPropertyDescriptors:function(e){for(var t,r,n=Ku(e),i=Xu.f,o=zu(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&Wu(a,t,r);return a}});var Yu=r(re.Object.getOwnPropertyDescriptors),qu={exports:{}},Ju=Cr,Qu=x,Zu=bn.f;Ju({target:"Object",stat:!0,forced:Object.defineProperties!==Zu,sham:!Qu},{defineProperties:Zu});var $u=re.Object,ed=qu.exports=function(e,t){return $u.defineProperties(e,t)};$u.defineProperties.sham&&(ed.sham=!0);var td=r(qu.exports),rd={exports:{}},nd=Cr,id=x,od=Zt.f;nd({target:"Object",stat:!0,forced:Object.defineProperty!==od,sham:!id},{defineProperty:od});var ad=re.Object,sd=rd.exports=function(e,t,r){return ad.defineProperty(e,t,r)};ad.defineProperty.sham&&(sd.sham=!0);var cd=r(rd.exports),ud=TypeError,dd=function(e){if(e>9007199254740991)throw ud("Maximum allowed index exceeded");return e},ld=Cr,hd=a,vd=ro,pd=te,fd=qe,_d=Hr,md=dd,gd=ei,yd=wo,Sd=Us,bd=_e,Ed=vt("isConcatSpreadable"),kd=bd>=51||!hd((function(){var e=[];return e[Ed]=!1,e.concat()[0]!==e})),Td=Sd("concat"),Id=function(e){if(!pd(e))return!1;var t=e[Ed];return void 0!==t?!!t:vd(e)};ld({target:"Array",proto:!0,arity:1,forced:!kd||!Td},{concat:function(e){var t,r,n,i,o,a=fd(this),s=yd(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(Id(o=-1===t?a:arguments[t]))for(i=_d(o),md(c+i),r=0;r<i;r++,c++)r in o&&gd(s,c,o[r]);else md(c+1),gd(s,c++,o);return s.length=c,s}}),Ti("asyncIterator"),Ti("hasInstance"),Ti("isConcatSpreadable"),Ti("iterator"),Ti("match"),Ti("matchAll"),Ti("replace"),Ti("search"),Ti("species"),Ti("split");var Rd=Ci;Ti("toPrimitive"),Rd();var Ad=se,wd=Vi;Ti("toStringTag"),wd(Ad("Symbol"),"Symbol"),Ti("unscopables"),Vi(o.JSON,"JSON",!0);var Cd=re.Symbol;Ti("asyncDispose"),Ti("dispose"),Ti("matcher"),Ti("metadataKey"),Ti("observable"),Ti("metadata"),Ti("patternMatch"),Ti("replaceAll");var xd=r(Cd),Od=T,Pd=Nr,Nd=Sn,Dd=q,Md=Od("".charAt),Ld=Od("".charCodeAt),Ud=Od("".slice),Vd=function(e){return function(t,r){var n,i,o=Nd(Dd(t)),a=Pd(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Ld(o,a))<55296||n>56319||a+1===s||(i=Ld(o,a+1))<56320||i>57343?e?Md(o,a):n:e?Ud(o,a,a+2):i-56320+(n-55296<<10)+65536}},Fd={codeAt:Vd(!1),charAt:Vd(!0)},Bd=Fd.charAt,jd=Sn,Hd=eo,Gd=su,zd=cu,Kd="String Iterator",Xd=Hd.set,Wd=Hd.getterFor(Kd);Gd(String,"String",(function(e){Xd(this,{type:Kd,string:jd(e),index:0})}),(function(){var e,t=Wd(this),r=t.string,n=t.index;return n>=r.length?zd(void 0,!0):(e=Bd(r,n),t.index+=e.length,zd(e,!1))}));var Yd=r(fi.f("iterator"));function qd(e){return(qd="function"==typeof xd&&"symbol"==typeof Yd?function(e){return typeof e}:function(e){return e&&"function"==typeof xd&&e.constructor===xd&&e!==xd.prototype?"symbol":typeof e})(e)}var Jd=r(fi.f("toPrimitive"));function Qd(e){var t=function(e,t){if("object"!==qd(e)||null===e)return e;var r=e[Jd];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==qd(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===qd(t)?t:String(t)}function Zd(e,t,r){return(t=Qd(t))in e?cd(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function $d(e,t){var r=cn(e);if(Ns){var n=Ns(e);t&&(n=Ks(n).call(n,(function(t){return ic(e,t).enumerable}))),r.push.apply(r,n)}return r}function el(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?Uu(r=$d(Object(i),!0)).call(r,(function(t){Zd(e,t,i[t])})):Yu?td(e,Yu(i)):Uu(n=$d(Object(i))).call(n,(function(t){cd(e,t,ic(i,t))}))}return e}var tl=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}(tl||{}),rl=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}(rl||{}),nl=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}(nl||{}),il=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(il||{}),ol=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(ol||{}),al=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(al||{}),sl=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(sl||{}),cl=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(cl||{}),ul=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}(ul||{}),dl=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(dl||{}),ll=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(ll||{}),hl=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}(hl||{}),vl=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}(vl||{}),pl=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(pl||{}),fl=function(e){return e[e.NORMAL=0]="NORMAL",e[e.DISCONNECT=1]="DISCONNECT",e[e.RESET=2]="RESET",e}(fl||{}),_l=function(e){return e[e.MICROPHONE=0]="MICROPHONE",e[e.AUDIOMIXING=1]="AUDIOMIXING",e}(_l||{}),ml=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(ml||{}),gl=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(gl||{}),yl=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}(yl||{}),Sl=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(Sl||{}),bl=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}(bl||{}),El=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(El||{}),kl=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}(kl||{}),Tl=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(Tl||{}),Il=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}(Il||{}),Rl=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}(Rl||{}),Al=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}(Al||{}),wl=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(wl||{}),Cl=function(e){return e.H264="H264",e.H265="H265",e}(Cl||{}),xl=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(xl||{}),Ol=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(Ol||{}),Pl=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}(Pl||{}),Nl=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}(Nl||{}),Dl=Object.freeze({__proto__:null,AAC_PROFILE:wl,AudioProfileType:Rl,AudioReportMode:_l,AudioSourceType:rl,ChannelProfile:il,ConnectionState:vl,FallbackOrRecoverReason:Tl,ForwardStreamError:Nl,ForwardStreamState:Pl,LocalMainReportMode:fl,LogChannel:ml,MediaType:ll,MirrorMode:cl,MirrorType:pl,NetworkQuality:kl,PublicInterpolationMode:Sl,PublicStreamType:yl,PublishState:sl,RTCAutoPlayPolicy:Al,RemoteUserPriority:El,RoomProfileType:Il,SUBTITLE_MODE:xl,StreamIndex:dl,StreamRemoveReason:hl,SubscribeFallbackOption:bl,SubscribeMode:ol,SubscribeState:al,SubtitleEventType:Ol,TRANSCODING_VIDEO_CODEC:Cl,USER_ONLINE_STATUS:gl,UserOfflineReason:nl,VideoRenderMode:ul,VideoSourceType:tl}),Ml=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}(Ml||{}),Ll=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(Ll||{}),Ul=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}(Ul||{}),Vl=Object.freeze({__proto__:null,AudioMixingDualMonoMode:Ml,AudioMixingState:Ul,AudioMixingType:Ll}),Fl=function(e){return e.onTrackEnded="onTrackEnded",e.onTrackMute="onTrackMute",e.onTrackUnmute="onTrackUnmute",e.onPlayerEvent="onPlayerEvent",e.onAutoplayFailed="onAutoplayFailed",e.onUserJoined="onUserJoined",e.onUserLeave="onUserLeave",e.onConnectionStateChanged="onConnectionStateChanged",e.onUserPublishStream="onUserPublishStream",e.onUserUnpublishStream="onUserUnpublishStream",e.onUserPublishScreen="onUserPublishScreen",e.onUserUnpublishScreen="onUserUnpublishScreen",e.onRoomMessageReceived="onRoomMessageReceived",e.onRoomBinaryMessageReceived="onRoomBinaryMessageReceived",e.onUserMessageReceived="onUserMessageReceived",e.onUserBinaryMessageReceived="onUserBinaryMessageReceived",e.onVideoFirstFrameRendered="onVideoFirstFrameRendered",e.onVideoFirstFrameDecoded="onVideoFirstFrameDecoded",e.onRemoteVideoFirstFrame="onRemoteVideoFirstFrame",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onRemoteAudioFirstFrame="onRemoteAudioFirstFrame",e.onFirstPublicStreamVideoFrameRendered="onFirstPublicStreamVideoFrameRendered",e.onFirstPublicStreamVideoFrameDecoded="onFirstPublicStreamVideoFrameDecoded",e.onFirstPublicStreamAudioFrameDecoded="onFirstPublicStreamAudioFrameDecoded",e.onVideoDeviceStateChanged="onVideoDeviceStateChanged",e.onAudioDeviceStateChanged="onAudioDeviceStateChanged",e.onRemoteStreamStats="onRemoteStreamStats",e.onPublicStreamStats="onPublicStreamStats",e.onLocalStreamStats="onLocalStreamStats",e.onAudioVolumeIndication="onAudioVolumeIndication",e.onLocalAudioPropertiesReport="onLocalAudioPropertiesReport",e.onRemoteAudioPropertiesReport="onRemoteAudioPropertiesReport",e.onActiveSpeaker="onActiveSpeaker",e.onAudioPlaybackDeviceChanged="onAudioPlaybackDeviceChanged",e.onUserStartVideoCapture="onUserStartVideoCapture",e.onUserStopVideoCapture="onUserStopVideoCapture",e.onUserStartAudioCapture="onUserStartAudioCapture",e.onUserStopAudioCapture="onUserStopAudioCapture",e.onAutoPublishResult="onAutoPublishResult",e.onAutoSubscribeResult="onAutoSubscribeResult",e.onLiveTranscodingResult="onLiveTranscodingResult",e.onStreamMixingEvent="onStreamMixingEvent",e.onAudioPlaybackDeviceTestVolume="onAudioPlaybackDeviceTestVolume",e.onSEIMessageReceived="onSEIMessageReceived",e.onError="onError",e.onAudioMixingStateChanged="onAudioMixingStateChanged",e.onUserMessageReceivedOutsideRoom="onUserMessageReceivedOutsideRoom",e.onUserBinaryMessageReceivedOutsideRoom="onUserBinaryMessageReceivedOutsideRoom",e.onTokenWillExpire="onTokenWillExpire",e.onCloudProxyConnected="onCloudProxyConnected",e.onPushPublicStreamResult="onPushPublicStreamResult",e.onPublicStreamSEIMessageReceived="onPublicStreamSEIMessageReceived",e.onNetworkQuality="onNetworkQuality",e.onSimulcastSubscribeFallback="onSimulcastSubscribeFallback",e.onRemoteVideoSizeChanged="onRemoteVideoSizeChanged",e.onVideoStreamBanned="onVideoStreamBanned",e.onAudioStreamBanned="onAudioStreamBanned",e.onLocalVideoSizeChanged="onLocalVideoSizeChanged",e.onSubtitleStateChanged="onSubtitleStateChanged",e.onSubtitleMessageReceived="onSubtitleMessageReceived",e.onServerParamsSetResult="onServerParamsSetResult",e.onLocalStreamTrackChangedByExtension="onLocalStreamTrackChangedByExtension",e.onVendorConnectionStateChanged="onVendorConnectionStateChanged",e.onForwardStreamError="onForwardStreamError",e.onRejoinWithTcp="onRejoinWithTcp",e.onIceConnectWithTcp="onIceConnectWithTcp",e.onPublishRetry="onPublishRetry",e.onSubscribeRetry="onSubscribeRetry",e}(Fl||{});function Bl(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),cd(e,Qd(n.key),n)}}function jl(e,t,r){return t&&Bl(e.prototype,t),r&&Bl(e,r),cd(e,"prototype",{writable:!1}),e}function Hl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Cr({target:"Object",stat:!0,sham:!x},{create:Xn});var Gl=re.Object,zl=r((function(e,t){return Gl.create(e,t)})),Kl=qe,Xl=Sc,Wl=hc;Cr({target:"Object",stat:!0,forced:a((function(){Xl(1)})),sham:!Wl},{getPrototypeOf:function(e){return Xl(Kl(e))}});var Yl=r(re.Object.getPrototypeOf);Cr({target:"Object",stat:!0},{setPrototypeOf:zc});var ql=r(re.Object.setPrototypeOf),Jl=Ze,Ql=Gu,Zl=C,$l=Zt,eh=Error,th=T("".replace),rh=String(eh("zxcasd").stack),nh=/\n\s*at [^:]*:[^\n]*/,ih=nh.test(rh),oh=te,ah=mr,sh=oc,ch=vt("iterator"),uh=Array.prototype,dh=function(e){return void 0!==e&&(sh.Array===e||uh[ch]===e)},lh=mn,hh=De,vh=X,ph=oc,fh=vt("iterator"),_h=function(e){if(!vh(e))return hh(e,fh)||hh(e,"@@iterator")||ph[lh(e)]},mh=N,gh=Oe,yh=nr,Sh=Ae,bh=_h,Eh=TypeError,kh=function(e,t){var r=arguments.length<2?bh(e):t;if(gh(r))return yh(mh(r,e));throw Eh(Sh(e)+" is not iterable")},Th=N,Ih=nr,Rh=De,Ah=function(e,t,r){var n,i;Ih(e);try{if(!(n=Rh(e,"return"))){if("throw"===t)throw r;return r}n=Th(n,e)}catch(o){i=!0,n=o}if("throw"===t)throw r;if(i)throw n;return Ih(n),r},wh=Qt,Ch=N,xh=nr,Oh=Ae,Ph=dh,Nh=Hr,Dh=ce,Mh=kh,Lh=_h,Uh=Ah,Vh=TypeError,Fh=function(e,t){this.stopped=e,this.result=t},Bh=Fh.prototype,jh=function(e,t,r){var n,i,o,a,s,c,u,d=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),v=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),f=wh(t,d),_=function(e){return n&&Uh(n,"normal",e),new Fh(!0,e)},m=function(e){return l?(xh(e),p?f(e[0],e[1],_):f(e[0],e[1])):p?f(e,_):f(e)};if(h)n=e.iterator;else if(v)n=e;else{if(!(i=Lh(e)))throw Vh(Oh(e)+" is not iterable");if(Ph(i)){for(o=0,a=Nh(e);a>o;o++)if((s=m(e[o]))&&Dh(Bh,s))return s;return new Fh(!1)}n=Mh(e,i)}for(c=h?e.next:n.next;!(u=Ch(c,n)).done;){try{s=m(u.value)}catch(g){Uh(n,"throw",g)}if("object"==typeof s&&s&&Dh(Bh,s))return s}return new Fh(!1)},Hh=Sn,Gh=B,zh=!a((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Gh(1,7)),7!==e.stack)})),Kh=Cr,Xh=ce,Wh=Sc,Yh=zc,qh=function(e,t,r){for(var n=Ql(t),i=$l.f,o=Zl.f,a=0;a<n.length;a++){var s=n[a];Jl(e,s)||r&&Jl(r,s)||i(e,s,o(t,s))}},Jh=Xn,Qh=mr,Zh=B,$h=function(e,t){if(ih&&"string"==typeof e&&!eh.prepareStackTrace)for(;t--;)e=th(e,nh,"");return e},ev=function(e,t){oh(t)&&"cause"in t&&ah(e,"cause",t.cause)},tv=jh,rv=function(e,t){return void 0===e?arguments.length<2?"":t:Hh(e)},nv=zh,iv=vt("toStringTag"),ov=Error,av=[].push,sv=function(e,t){var r,n=arguments.length>2?arguments[2]:void 0,i=Xh(cv,this);Yh?r=Yh(ov(),i?Wh(this):cv):(r=i?this:Jh(cv),Qh(r,iv,"Error")),void 0!==t&&Qh(r,"message",rv(t)),nv&&Qh(r,"stack",$h(r.stack,1)),ev(r,n);var o=[];return tv(e,av,{that:o}),Qh(r,"errors",o),r};Yh?Yh(sv,ov):qh(sv,ov,{name:!0});var cv=sv.prototype=Jh(ov.prototype,{constructor:Zh(1,sv),message:Zh(1,""),name:Zh(1,"AggregateError")});Kh({global:!0,constructor:!0,arity:2},{AggregateError:sv});var uv,dv,lv,hv,vv="process"==b(o.process),pv=se,fv=Zt,_v=x,mv=vt("species"),gv=function(e){var t=pv(e),r=fv.f;_v&&t&&!t[mv]&&r(t,mv,{configurable:!0,get:function(){return this}})},yv=ce,Sv=TypeError,bv=function(e,t){if(yv(t,e))return e;throw Sv("Incorrect invocation")},Ev=bo,kv=Ae,Tv=TypeError,Iv=function(e){if(Ev(e))return e;throw Tv(kv(e)+" is not a constructor")},Rv=nr,Av=Iv,wv=X,Cv=vt("species"),xv=function(e,t){var r,n=Rv(e).constructor;return void 0===n||wv(r=Rv(n)[Cv])?t:Av(r)},Ov=TypeError,Pv=function(e,t){if(e<t)throw Ov("Not enough arguments");return e},Nv=/(?:ipad|iphone|ipod).*applewebkit/i.test(ue),Dv=o,Mv=h,Lv=Qt,Uv=w,Vv=Ze,Fv=a,Bv=Cn,jv=os,Hv=At,Gv=Pv,zv=Nv,Kv=vv,Xv=Dv.setImmediate,Wv=Dv.clearImmediate,Yv=Dv.process,qv=Dv.Dispatch,Jv=Dv.Function,Qv=Dv.MessageChannel,Zv=Dv.String,$v=0,ep={},tp="onreadystatechange";try{uv=Dv.location}catch(Iq){}var rp=function(e){if(Vv(ep,e)){var t=ep[e];delete ep[e],t()}},np=function(e){return function(){rp(e)}},ip=function(e){rp(e.data)},op=function(e){Dv.postMessage(Zv(e),uv.protocol+"//"+uv.host)};Xv&&Wv||(Xv=function(e){Gv(arguments.length,1);var t=Uv(e)?e:Jv(e),r=jv(arguments,1);return ep[++$v]=function(){Mv(t,void 0,r)},dv($v),$v},Wv=function(e){delete ep[e]},Kv?dv=function(e){Yv.nextTick(np(e))}:qv&&qv.now?dv=function(e){qv.now(np(e))}:Qv&&!zv?(hv=(lv=new Qv).port2,lv.port1.onmessage=ip,dv=Lv(hv.postMessage,hv)):Dv.addEventListener&&Uv(Dv.postMessage)&&!Dv.importScripts&&uv&&"file:"!==uv.protocol&&!Fv(op)?(dv=op,Dv.addEventListener("message",ip,!1)):dv=tp in Hv("script")?function(e){Bv.appendChild(Hv("script"))[tp]=function(){Bv.removeChild(this),rp(e)}}:function(e){setTimeout(np(e),0)});var ap,sp,cp,up,dp,lp,hp,vp,pp={set:Xv,clear:Wv},fp=o,_p=/ipad|iphone|ipod/i.test(ue)&&void 0!==fp.Pebble,mp=/web0s(?!.*chrome)/i.test(ue),gp=o,yp=Qt,Sp=C.f,bp=pp.set,Ep=Nv,kp=_p,Tp=mp,Ip=vv,Rp=gp.MutationObserver||gp.WebKitMutationObserver,Ap=gp.document,wp=gp.process,Cp=gp.Promise,xp=Sp(gp,"queueMicrotask"),Op=xp&&xp.value;Op||(ap=function(){var e,t;for(Ip&&(e=wp.domain)&&e.exit();sp;){t=sp.fn,sp=sp.next;try{t()}catch(Iq){throw sp?up():cp=void 0,Iq}}cp=void 0,e&&e.enter()},Ep||Ip||Tp||!Rp||!Ap?!kp&&Cp&&Cp.resolve?((hp=Cp.resolve(void 0)).constructor=Cp,vp=yp(hp.then,hp),up=function(){vp(ap)}):Ip?up=function(){wp.nextTick(ap)}:(bp=yp(bp,gp),up=function(){bp(ap)}):(dp=!0,lp=Ap.createTextNode(""),new Rp(ap).observe(lp,{characterData:!0}),up=function(){lp.data=dp=!dp}));var Pp=Op||function(e){var t={fn:e,next:void 0};cp&&(cp.next=t),sp||(sp=t,up()),cp=t},Np=o,Dp=function(e){try{return{error:!1,value:e()}}catch(Iq){return{error:!0,value:Iq}}},Mp=function(){this.head=null,this.tail=null};Mp.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var Lp=Mp,Up=o.Promise,Vp="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Fp=!Vp&&!vv&&"object"==typeof window&&"object"==typeof document,Bp=o,jp=Up,Hp=w,Gp=Wt,zp=ao,Kp=vt,Xp=Fp,Wp=Vp,Yp=_e,qp=jp&&jp.prototype,Jp=Kp("species"),Qp=!1,Zp=Hp(Bp.PromiseRejectionEvent),$p={CONSTRUCTOR:Gp("Promise",(function(){var e=zp(jp),t=e!==String(jp);if(!t&&66===Yp)return!0;if(!qp.catch||!qp.finally)return!0;if(!Yp||Yp<51||!/native code/.test(e)){var r=new jp((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[Jp]=n,!(Qp=r.then((function(){}))instanceof n))return!0}return!t&&(Xp||Wp)&&!Zp})),REJECTION_EVENT:Zp,SUBCLASSING:Qp},ef={},tf=Oe,rf=TypeError,nf=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw rf("Bad Promise constructor");t=e,r=n})),this.resolve=tf(t),this.reject=tf(r)};ef.f=function(e){return new nf(e)};var of,af,sf=Cr,cf=vv,uf=o,df=N,lf=pi,hf=Vi,vf=gv,pf=Oe,ff=w,_f=te,mf=bv,gf=xv,yf=pp.set,Sf=Pp,bf=function(e,t){var r=Np.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},Ef=Dp,kf=Lp,Tf=eo,If=Up,Rf=$p,Af=ef,wf="Promise",Cf=Rf.CONSTRUCTOR,xf=Rf.REJECTION_EVENT,Of=Tf.getterFor(wf),Pf=Tf.set,Nf=If&&If.prototype,Df=If,Mf=Nf,Lf=uf.TypeError,Uf=uf.document,Vf=uf.process,Ff=Af.f,Bf=Ff,jf=!!(Uf&&Uf.createEvent&&uf.dispatchEvent),Hf="unhandledrejection",Gf=function(e){var t;return!(!_f(e)||!ff(t=e.then))&&t},zf=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&&qf(t),t.rejection=1),!0===s?r=o:(d&&d.enter(),r=s(o),d&&(d.exit(),i=!0)),r===e.promise?u(Lf("Promise-chain cycle")):(n=Gf(r))?df(n,r,c,u):c(r)):u(o)}catch(Iq){d&&!i&&d.exit(),u(Iq)}},Kf=function(e,t){e.notified||(e.notified=!0,Sf((function(){for(var r,n=e.reactions;r=n.get();)zf(r,e);e.notified=!1,t&&!e.rejection&&Wf(e)})))},Xf=function(e,t,r){var n,i;jf?((n=Uf.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),uf.dispatchEvent(n)):n={promise:t,reason:r},!xf&&(i=uf["on"+e])?i(n):e===Hf&&bf("Unhandled promise rejection",r)},Wf=function(e){df(yf,uf,(function(){var t,r=e.facade,n=e.value;if(Yf(e)&&(t=Ef((function(){cf?Vf.emit("unhandledRejection",n,r):Xf(Hf,r,n)})),e.rejection=cf||Yf(e)?2:1,t.error))throw t.value}))},Yf=function(e){return 1!==e.rejection&&!e.parent},qf=function(e){df(yf,uf,(function(){var t=e.facade;cf?Vf.emit("rejectionHandled",t):Xf("rejectionhandled",t,e.value)}))},Jf=function(e,t,r){return function(n){e(t,n,r)}},Qf=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,Kf(e,!0))},Zf=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw Lf("Promise can't be resolved itself");var n=Gf(t);n?Sf((function(){var r={done:!1};try{df(n,t,Jf(Zf,r,e),Jf(Qf,r,e))}catch(Iq){Qf(r,Iq,e)}})):(e.value=t,e.state=1,Kf(e,!1))}catch(Iq){Qf({done:!1},Iq,e)}}};Cf&&(Mf=(Df=function(e){mf(this,Mf),pf(e),df(of,this);var t=Of(this);try{e(Jf(Zf,t),Jf(Qf,t))}catch(Iq){Qf(t,Iq)}}).prototype,(of=function(e){Pf(this,{type:wf,done:!1,notified:!1,parent:!1,reactions:new kf,rejection:!1,state:0,value:void 0})}).prototype=lf(Mf,"then",(function(e,t){var r=Of(this),n=Ff(gf(this,Df));return r.parent=!0,n.ok=!ff(e)||e,n.fail=ff(t)&&t,n.domain=cf?Vf.domain:void 0,0==r.state?r.reactions.add(n):Sf((function(){zf(n,r)})),n.promise})),af=function(){var e=new of,t=Of(e);this.promise=e,this.resolve=Jf(Zf,t),this.reject=Jf(Qf,t)},Af.f=Ff=function(e){return e===Df||undefined===e?new af(e):Bf(e)}),sf({global:!0,constructor:!0,wrap:!0,forced:Cf},{Promise:Df}),hf(Df,wf,!1,!0),vf(wf);var $f=vt("iterator"),e_=!1;try{var t_=0,r_={next:function(){return{done:!!t_++}},return:function(){e_=!0}};r_[$f]=function(){return this},Array.from(r_,(function(){throw 2}))}catch(Iq){}var n_=function(e,t){if(!t&&!e_)return!1;var r=!1;try{var n={};n[$f]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(Iq){}return r},i_=Up,o_=$p.CONSTRUCTOR||!n_((function(e){i_.all(e).then(void 0,(function(){}))})),a_=N,s_=Oe,c_=ef,u_=Dp,d_=jh;Cr({target:"Promise",stat:!0,forced:o_},{all:function(e){var t=this,r=c_.f(t),n=r.resolve,i=r.reject,o=u_((function(){var r=s_(t.resolve),o=[],a=0,s=1;d_(e,(function(e){var c=a++,u=!1;s++,a_(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 l_=Cr,h_=$p.CONSTRUCTOR;Up&&Up.prototype,l_({target:"Promise",proto:!0,forced:h_,real:!0},{catch:function(e){return this.then(void 0,e)}});var v_=N,p_=Oe,f_=ef,__=Dp,m_=jh;Cr({target:"Promise",stat:!0,forced:o_},{race:function(e){var t=this,r=f_.f(t),n=r.reject,i=__((function(){var i=p_(t.resolve);m_(e,(function(e){v_(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var g_=N,y_=ef;Cr({target:"Promise",stat:!0,forced:$p.CONSTRUCTOR},{reject:function(e){var t=y_.f(this);return g_(t.reject,void 0,e),t.promise}});var S_=nr,b_=te,E_=ef,k_=function(e,t){if(S_(e),b_(t)&&t.constructor===e)return t;var r=E_.f(e);return(0,r.resolve)(t),r.promise},T_=Cr,I_=Up,R_=$p.CONSTRUCTOR,A_=k_,w_=se("Promise"),C_=!R_;T_({target:"Promise",stat:!0,forced:true},{resolve:function(e){return A_(C_&&this===w_?I_:this,e)}});var x_=N,O_=Oe,P_=ef,N_=Dp,D_=jh;Cr({target:"Promise",stat:!0},{allSettled:function(e){var t=this,r=P_.f(t),n=r.resolve,i=r.reject,o=N_((function(){var r=O_(t.resolve),i=[],o=0,a=1;D_(e,(function(e){var s=o++,c=!1;a++,x_(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 M_=N,L_=Oe,U_=se,V_=ef,F_=Dp,B_=jh,j_="No one promise resolved";Cr({target:"Promise",stat:!0},{any:function(e){var t=this,r=U_("AggregateError"),n=V_.f(t),i=n.resolve,o=n.reject,a=F_((function(){var n=L_(t.resolve),a=[],s=0,c=1,u=!1;B_(e,(function(e){var d=s++,l=!1;c++,M_(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,j_)))}))})),--c||o(new r(a,j_))}));return a.error&&o(a.value),n.promise}});var H_=Cr,G_=Up,z_=a,K_=se,X_=w,W_=xv,Y_=k_,q_=G_&&G_.prototype;H_({target:"Promise",proto:!0,real:!0,forced:!!G_&&z_((function(){q_.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=W_(this,K_("Promise")),r=X_(e);return this.then(r?function(r){return Y_(t,e()).then((function(){return r}))}:e,r?function(r){return Y_(t,e()).then((function(){throw r}))}:e)}});var J_=re.Promise,Q_=ef,Z_=Dp;Cr({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=Q_.f(this),r=Z_(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var $_=r(J_),em=Cr,tm=ro,rm=T([].reverse),nm=[1,2];em({target:"Array",proto:!0,forced:String(nm)===String(nm.reverse())},{reverse:function(){return tm(this)&&(this.length=this.length),rm(this)}});var im=Bs("Array").reverse,om=ce,am=im,sm=Array.prototype,cm=r((function(e){var t=e.reverse;return e===sm||om(sm,e)&&t===sm.reverse?am:t})),um=Cr,dm=ro,lm=bo,hm=te,vm=Ur,pm=Hr,fm=Z,_m=ei,mm=vt,gm=os,ym=Us("slice"),Sm=mm("species"),bm=Array,Em=Math.max;um({target:"Array",proto:!0,forced:!ym},{slice:function(e,t){var r,n,i,o=fm(this),a=pm(o),s=vm(e,a),c=vm(void 0===t?a:t,a);if(dm(o)&&(r=o.constructor,(lm(r)&&(r===bm||dm(r.prototype))||hm(r)&&null===(r=r[Sm]))&&(r=void 0),r===bm||void 0===r))return gm(o,s,c);for(n=new(void 0===r?bm:r)(Em(c-s,0)),i=0;s<c;s++,i++)s in o&&_m(n,i,o[s]);return n.length=i,n}});var km=Bs("Array").slice,Tm=ce,Im=km,Rm=Array.prototype,Am=r((function(e){var t=e.slice;return e===Rm||Tm(Rm,e)&&t===Rm.slice?Im:t}));function wm(){wm=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=cd||function(e,t,r){e[t]=r.value},i="function"==typeof xd?xd:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,r){return cd(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(A){c=function(e,t,r){return e[t]=r}}function u(e,t,r,i){var o=t&&t.prototype instanceof h?t:h,a=zl(o.prototype),s=new T(i||[]);return n(a,"_invoke",{value:S(e,r,s)}),a}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(A){return{type:"throw",arg:A}}}e.wrap=u;var l={};function h(){}function v(){}function p(){}var f={};c(f,o,(function(){return this}));var _=Yl&&Yl(Yl(I([])));_&&_!==t&&r.call(_,o)&&(f=_);var m=p.prototype=h.prototype=zl(f);function g(e){var t;Uu(t=["next","throw","return"]).call(t,(function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){function i(n,o,a,s){var c=d(e[n],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==qd(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return i("throw",e,a,s)}))}s(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function S(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=b(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=d(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function b(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),l;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,l;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],Uu(e).call(e,E,this),this.reset(!0)}function I(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:R}}function R(){return{value:void 0,done:!0}}return v.prototype=p,n(m,"constructor",{value:p,configurable:!0}),n(p,"constructor",{value:v,configurable:!0}),v.displayName=c(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return ql?ql(e,p):(e.__proto__=p,c(e,s,"GeneratorFunction")),e.prototype=zl(m),e},e.awrap=function(e){return{__await:e}},g(y.prototype),c(y.prototype,a,(function(){return this})),e.AsyncIterator=y,e.async=function(t,r,n,i,o){void 0===o&&(o=$_);var a=new y(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),c(m,s,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return cm(r).call(r),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,T.prototype={constructor:T,reset:function(e){var t;if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,Uu(t=this.tryEntries).call(t,k),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+Am(n).call(n,1))&&(this[n]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;k(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function Cm(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(Iq){return void r(Iq)}s.done?t(c):$_.resolve(c).then(n,i)}function xm(e){return function(){var t=this,r=arguments;return new $_((function(n,i){var o=e.apply(t,r);function a(e){Cm(o,n,i,a,s,"next",e)}function s(e){Cm(o,n,i,a,s,"throw",e)}a(void 0)}))}}var Om=Bs("Array").concat,Pm=ce,Nm=Om,Dm=Array.prototype,Mm=r((function(e){var t=e.concat;return e===Dm||Pm(Dm,e)&&t===Dm.concat?Nm:t})),Lm=re,Um=h;Lm.JSON||(Lm.JSON={stringify:JSON.stringify});var Vm=function(e,t,r){return Um(Lm.JSON.stringify,null,arguments)},Fm=r(Vm),Bm=Lo.map;Cr({target:"Array",proto:!0,forced:!Us("map")},{map:function(e){return Bm(this,e,arguments.length>1?arguments[1]:void 0)}});var jm=Bs("Array").map,Hm=ce,Gm=jm,zm=Array.prototype,Km=r((function(e){var t=e.map;return e===zm||Hm(zm,e)&&t===zm.map?Gm:t})),Xm="\t\n\v\f\r                 \u2028\u2029\ufeff",Wm=q,Ym=Sn,qm=Xm,Jm=T("".replace),Qm="["+qm+"]",Zm=RegExp("^"+Qm+Qm+"*"),$m=RegExp(Qm+Qm+"*$"),eg=function(e){return function(t){var r=Ym(Wm(t));return 1&e&&(r=Jm(r,Zm,"")),2&e&&(r=Jm(r,$m,"")),r}},tg={start:eg(1),end:eg(2),trim:eg(3)},rg=o,ng=a,ig=T,og=Sn,ag=tg.trim,sg=Xm,cg=rg.parseInt,ug=rg.Symbol,dg=ug&&ug.iterator,lg=/^[+-]?0x/i,hg=ig(lg.exec),vg=8!==cg(sg+"08")||22!==cg(sg+"0x16")||dg&&!ng((function(){cg(Object(dg))}))?function(e,t){var r=ag(og(e));return cg(r,t>>>0||(hg(lg,r)?16:10))}:cg;Cr({global:!0,forced:parseInt!=vg},{parseInt:vg});var pg=r(re.parseInt),fg={exports:{}},_g=a((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),mg=a,gg=te,yg=b,Sg=_g,bg=Object.isExtensible,Eg=mg((function(){bg(1)}))||Sg?function(e){return!!gg(e)&&((!Sg||"ArrayBuffer"!=yg(e))&&(!bg||bg(e)))}:bg,kg=!a((function(){return Object.isExtensible(Object.preventExtensions({}))})),Tg=Cr,Ig=T,Rg=Yr,Ag=te,wg=Ze,Cg=Zt.f,xg=Wn,Og=Jn,Pg=Eg,Ng=kg,Dg=!1,Mg=nt("meta"),Lg=0,Ug=function(e){Cg(e,Mg,{value:{objectID:"O"+Lg++,weakData:{}}})},Vg=fg.exports={enable:function(){Vg.enable=function(){},Dg=!0;var e=xg.f,t=Ig([].splice),r={};r[Mg]=1,e(r).length&&(xg.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===Mg){t(n,i,1);break}return n},Tg({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Og.f}))},fastKey:function(e,t){if(!Ag(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!wg(e,Mg)){if(!Pg(e))return"F";if(!t)return"E";Ug(e)}return e[Mg].objectID},getWeakData:function(e,t){if(!wg(e,Mg)){if(!Pg(e))return!0;if(!t)return!1;Ug(e)}return e[Mg].weakData},onFreeze:function(e){return Ng&&Dg&&Pg(e)&&!wg(e,Mg)&&Ug(e),e}};Rg[Mg]=!0;var Fg=fg.exports,Bg=Cr,jg=o,Hg=Fg,Gg=a,zg=mr,Kg=jh,Xg=bv,Wg=w,Yg=te,qg=Vi,Jg=Zt.f,Qg=Lo.forEach,Zg=x,$g=eo.set,ey=eo.getterFor,ty=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=jg[e],c=s&&s.prototype,u={};if(Zg&&Wg(s)&&(o||c.forEach&&!Gg((function(){(new s).entries().next()})))){var d=(n=t((function(t,r){$g(Xg(t,d),{type:e,collection:new s}),null!=r&&Kg(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,l=ey(e);Qg(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in c)||o&&"clear"==e||zg(d,e,(function(r,n){var i=l(this).collection;if(!t&&o&&!Yg(r))return"get"==e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||Jg(d,"size",{configurable:!0,get:function(){return l(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Hg.enable();return qg(n,e,!1,!0),u[e]=n,Bg({global:!0,forced:!0},u),o||r.setStrong(n,e,i),n},ry=pi,ny=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:ry(e,n,t[n],r);return e},iy=Zt.f,oy=Xn,ay=ny,sy=Qt,cy=bv,uy=X,dy=jh,ly=su,hy=cu,vy=gv,py=x,fy=Fg.fastKey,_y=eo.set,my=eo.getterFor,gy={getConstructor:function(e,t,r,n){var i=e((function(e,i){cy(e,o),_y(e,{type:t,index:oy(null),first:void 0,last:void 0,size:0}),py||(e.size=0),uy(i)||dy(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=my(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=fy(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),py?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=fy(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return ay(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,py?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),py?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=sy(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)}}),ay(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)}}),py&&iy(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=my(t),o=my(n);ly(e,t,(function(e,t){_y(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)?hy("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,hy(void 0,!0))}),r?"entries":"values",!r,!0),vy(t)}};ty("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),gy);var yy=re.Map,Sy=Qt,by=N,Ey=Oe,ky=Iv,Ty=X,Iy=jh,Ry=[].push,Ay=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return ky(this),(t=void 0!==a)&&Ey(a),Ty(e)?new this:(r=[],t?(n=0,i=Sy(a,o>2?arguments[2]:void 0),Iy(e,(function(e){by(Ry,r,i(e,n++))}))):Iy(e,Ry,{that:r}),new this(r))};Cr({target:"Map",stat:!0,forced:!0},{from:Ay});var wy=os,Cy=function(){return new this(wy(arguments))};Cr({target:"Map",stat:!0,forced:!0},{of:Cy});var xy=N,Oy=Oe,Py=nr,Ny=function(){for(var e,t=Py(this),r=Oy(t.delete),n=!0,i=0,o=arguments.length;i<o;i++)e=xy(r,t,arguments[i]),n=n&&e;return!!n};Cr({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:Ny});var Dy=N,My=Oe,Ly=nr;Cr({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,t){var r,n,i=Ly(this),o=My(i.get),a=My(i.has),s=My(i.set);return Dy(a,i,e)?(r=Dy(o,i,e),"update"in t&&(r=t.update(r,e,i),Dy(s,i,e,r)),r):(n=t.insert(e,i),Dy(s,i,e,n),n)}});var Uy=kh,Vy=nr,Fy=Qt,By=Uy,jy=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=Vy(this),r=By(t),n=Fy(e,arguments.length>1?arguments[1]:void 0);return!jy(r,(function(e,r,i){if(!n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var Hy=se,Gy=Qt,zy=N,Ky=Oe,Xy=nr,Wy=xv,Yy=Uy,qy=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=Xy(this),r=Yy(t),n=Gy(e,arguments.length>1?arguments[1]:void 0),i=new(Wy(t,Hy("Map"))),o=Ky(i.set);return qy(r,(function(e,r){n(r,e,t)&&zy(o,i,e,r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var Jy=nr,Qy=Qt,Zy=Uy,$y=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=Jy(this),r=Zy(t),n=Qy(e,arguments.length>1?arguments[1]:void 0);return $y(r,(function(e,r,i){if(n(r,e,t))return i(r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var eS=nr,tS=Qt,rS=Uy,nS=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=eS(this),r=rS(t),n=tS(e,arguments.length>1?arguments[1]:void 0);return nS(r,(function(e,r,i){if(n(r,e,t))return i(e)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var iS=Cr,oS=N,aS=Oe,sS=kh,cS=jh,uS=T([].push);iS({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){aS(t);var r=sS(e),n=new this,i=aS(n.has),o=aS(n.get),a=aS(n.set);return cS(r,(function(e){var r=t(e);oS(i,n,r)?uS(oS(o,n,r),e):oS(a,n,r,[e])}),{IS_ITERATOR:!0}),n}});var dS=nr,lS=Uy,hS=function(e,t){return e===t||e!=e&&t!=t},vS=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return vS(lS(dS(this)),(function(t,r,n){if(hS(r,e))return n()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var pS=N,fS=jh,_S=Oe;Cr({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new this;_S(t);var n=_S(r.set);return fS(e,(function(e){pS(n,r,t(e),e)})),r}});var mS=nr,gS=Uy,yS=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){return yS(gS(mS(this)),(function(t,r,n){if(r===e)return n(t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var SS=se,bS=Qt,ES=N,kS=Oe,TS=nr,IS=xv,RS=Uy,AS=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=TS(this),r=RS(t),n=bS(e,arguments.length>1?arguments[1]:void 0),i=new(IS(t,SS("Map"))),o=kS(i.set);return AS(r,(function(e,r){ES(o,i,n(r,e,t),r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var wS=se,CS=Qt,xS=N,OS=Oe,PS=nr,NS=xv,DS=Uy,MS=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=PS(this),r=DS(t),n=CS(e,arguments.length>1?arguments[1]:void 0),i=new(NS(t,wS("Map"))),o=OS(i.set);return MS(r,(function(e,r){xS(o,i,e,n(r,e,t))}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var LS=Oe,US=nr,VS=jh;Cr({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=US(this),r=LS(t.set),n=arguments.length,i=0;i<n;)VS(arguments[i++],r,{that:t,AS_ENTRIES:!0});return t}});var FS=nr,BS=Oe,jS=Uy,HS=jh,GS=TypeError;Cr({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=FS(this),r=jS(t),n=arguments.length<2,i=n?void 0:arguments[1];if(BS(e),HS(r,(function(r,o){n?(n=!1,i=o):i=e(i,o,r,t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),n)throw GS("Reduce of empty map with no initial value");return i}});var zS=nr,KS=Qt,XS=Uy,WS=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=zS(this),r=XS(t),n=KS(e,arguments.length>1?arguments[1]:void 0);return WS(r,(function(e,r,i){if(n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var YS=N,qS=nr,JS=Oe,QS=TypeError;Cr({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=qS(this),n=JS(r.get),i=JS(r.has),o=JS(r.set),a=arguments.length;JS(t);var s=YS(i,r,e);if(!s&&a<3)throw QS("Updating absent value");var c=s?YS(n,r,e):JS(a>2?arguments[2]:void 0)(e,r);return YS(o,r,e,t(c,e,r)),r}});var ZS=N,$S=Oe,eb=w,tb=nr,rb=TypeError,nb=function(e,t){var r,n=tb(this),i=$S(n.get),o=$S(n.has),a=$S(n.set),s=arguments.length>2?arguments[2]:void 0;if(!eb(t)&&!eb(s))throw rb("At least one callback required");return ZS(o,n,e)?(r=ZS(i,n,e),eb(t)&&(r=t(r),ZS(a,n,e,r))):eb(s)&&(r=s(),ZS(a,n,e,r)),r};Cr({target:"Map",proto:!0,real:!0,forced:!0},{upsert:nb}),Cr({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:nb});var ib=r(yy),ob=Oe,ab=qe,sb=K,cb=Hr,ub=TypeError,db=function(e){return function(t,r,n,i){ob(r);var o=ab(t),a=sb(o),s=cb(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 ub("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}},lb={left:db(!1),right:db(!0)}.left,hb=_e,vb=vv;Cr({target:"Array",proto:!0,forced:!Au("reduce")||!vb&&hb>79&&hb<83},{reduce:function(e){var t=arguments.length;return lb(this,e,t,t>1?arguments[1]:void 0)}});var pb=Bs("Array").reduce,fb=ce,_b=pb,mb=Array.prototype,gb=r((function(e){var t=e.reduce;return e===mb||fb(mb,e)&&t===mb.reduce?_b:t})),yb=x,Sb=T,bb=N,Eb=a,kb=on,Tb=hi,Ib=D,Rb=qe,Ab=K,wb=Object.assign,Cb=Object.defineProperty,xb=Sb([].concat),Ob=!wb||Eb((function(){if(yb&&1!==wb({b:1},wb(Cb({},"a",{enumerable:!0,get:function(){Cb(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=wb({},e)[r]||kb(wb({},t)).join("")!=n}))?function(e,t){for(var r=Rb(e),n=arguments.length,i=1,o=Tb.f,a=Ib.f;n>i;)for(var s,c=Ab(arguments[i++]),u=o?xb(kb(c),o(c)):kb(c),d=u.length,l=0;d>l;)s=u[l++],yb&&!bb(a,c,s)||(r[s]=c[s]);return r}:wb,Pb=Ob;Cr({target:"Object",stat:!0,arity:2,forced:Object.assign!==Pb},{assign:Pb});var Nb=r(re.Object.assign),Db=te,Mb=b,Lb=vt("match"),Ub=function(e){var t;return Db(e)&&(void 0!==(t=e[Lb])?!!t:"RegExp"==Mb(e))},Vb=TypeError,Fb=function(e){if(Ub(e))throw Vb("The method doesn't accept regular expressions");return e},Bb=vt("match"),jb=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Bb]=!1,"/./"[e](t)}catch(n){}}return!1},Hb=Cr,Gb=T;C.f;var zb=Br,Kb=Sn,Xb=Fb,Wb=q,Yb=jb,qb=Gb("".endsWith),Jb=Gb("".slice),Qb=Math.min;Hb({target:"String",proto:!0,forced:!Yb("endsWith")},{endsWith:function(e){var t=Kb(Wb(this));Xb(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:Qb(zb(r),n),o=Kb(e);return qb?qb(t,o,i):Jb(t,i-o.length,i)===o}});var Zb=Bs("String").endsWith,$b=ce,eE=Zb,tE=String.prototype,rE=r((function(e){var t=e.endsWith;return"string"==typeof e||e===tE||$b(tE,e)&&t===tE.endsWith?eE:t})),nE=!0,iE=!0;function oE(e,t,r){var n=e.match(t);return n&&n.length>=r&&pg(n[r],10)}function aE(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 ib),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===cn(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},cd(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 sE(e){return"boolean"!=typeof e?new Error("Argument type: "+qd(e)+". Please use a boolean."):(nE=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function cE(e){return"boolean"!=typeof e?new Error("Argument type: "+qd(e)+". Please use a boolean."):(iE=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function uE(){if("object"===("undefined"==typeof window?"undefined":qd(window))){if(nE)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function dE(e,t){iE&&console.warn(e+" is deprecated, please use "+t+" instead.")}function lE(e){return"[object Object]"===Object.prototype.toString.call(e)}function hE(e){var t;return lE(e)?gb(t=cn(e)).call(t,(function(t,r){var n=lE(e[r]),i=n?hE(e[r]):e[r],o=n&&!cn(i).length;return void 0===i||o?t:Nb(t,Zd({},r,i))}),{}):e}function vE(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),cn(t).forEach((function(n){rE(n).call(n,"Id")?vE(e,e.get(t[n]),r):rE(n).call(n,"Ids")&&t[n].forEach((function(t){vE(e,e.get(t),r)}))})))}function pE(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new ib;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&&vE(e,r,i)}))})),i}var fE=Cr,_E=Lo.find,mE="find",gE=!0;mE in[]&&Array(1)[mE]((function(){gE=!1})),fE({target:"Array",proto:!0,forced:gE},{find:function(e){return _E(this,e,arguments.length>1?arguments[1]:void 0)}});var yE=Bs("Array").find,SE=ce,bE=yE,EE=Array.prototype,kE=r((function(e){var t=e.find;return e===EE||SE(EE,e)&&t===EE.find?bE:t})),TE=Cr,IE=Wr.indexOf,RE=Au,AE=T([].indexOf),wE=!!AE&&1/AE([1],1,-0)<0,CE=RE("indexOf");TE({target:"Array",proto:!0,forced:wE||!CE},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return wE?AE(this,e,t)||0:IE(this,e,t)}});var xE=Bs("Array").indexOf,OE=ce,PE=xE,NE=Array.prototype,DE=r((function(e){var t=e.indexOf;return e===NE||OE(NE,e)&&t===NE.indexOf?PE:t})),ME=x,LE=ro,UE=TypeError,VE=Object.getOwnPropertyDescriptor,FE=ME&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(Iq){return Iq instanceof TypeError}}(),BE=Ae,jE=TypeError,HE=function(e,t){if(!delete e[t])throw jE("Cannot delete property "+BE(t)+" of "+BE(e))},GE=Cr,zE=qe,KE=Ur,XE=Nr,WE=Hr,YE=FE?function(e,t){if(LE(e)&&!VE(e,"length").writable)throw UE("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},qE=dd,JE=wo,QE=ei,ZE=HE,$E=Us("splice"),ek=Math.max,tk=Math.min;GE({target:"Array",proto:!0,forced:!$E},{splice:function(e,t){var r,n,i,o,a,s,c=zE(this),u=WE(c),d=KE(e,u),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=u-d):(r=l-2,n=tk(ek(XE(t),0),u-d)),qE(u+r-n),i=JE(c,n),o=0;o<n;o++)(a=d+o)in c&&QE(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]:ZE(c,s);for(o=u;o>u-n+r;o--)ZE(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]:ZE(c,s);for(o=0;o<r;o++)c[o+d]=arguments[o+2];return YE(c,u-n+r),i}});var rk=Bs("Array").splice,nk=ce,ik=rk,ok=Array.prototype,ak=r((function(e){var t=e.splice;return e===ok||nk(ok,e)&&t===ok.splice?ik:t})),sk=Wr.includes;Cr({target:"Array",proto:!0,forced:a((function(){return!Array(1).includes()}))},{includes:function(e){return sk(this,e,arguments.length>1?arguments[1]:void 0)}});var ck=Bs("Array").includes,uk=Cr,dk=Fb,lk=q,hk=Sn,vk=jb,pk=T("".indexOf);uk({target:"String",proto:!0,forced:!vk("includes")},{includes:function(e){return!!~pk(hk(lk(this)),hk(dk(e)),arguments.length>1?arguments[1]:void 0)}});var fk=Bs("String").includes,_k=ce,mk=ck,gk=fk,yk=Array.prototype,Sk=String.prototype,bk=r((function(e){var t=e.includes;return e===yk||_k(yk,e)&&t===yk.includes?mk:"string"==typeof e||e===Sk||_k(Sk,e)&&t===Sk.includes?gk:t})),Ek=uE;function kk(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==qd(e)||e.mandatory||e.optional)return e;var t,r={};(cn(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===qd(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()+Am(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=Mm(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(Fm(e)))&&"object"===qd(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(Fm(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===qd(e.video)){var a=e.video.facingMode;a=a&&("object"===qd(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=Ks(t).call(t,(function(e){return"videoinput"===e.kind}));var r=kE(t).call(t,(function(e){return s.some((function(t){var r;return bk(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&bk(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),Ek("chrome: "+Fm(e)),i(e)}));e.video=n(e.video)}return Ek("chrome: "+Fm(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 $_.reject(o(e))}))}))}}}}function Tk(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function Ik(e){if("object"===qd(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){cd(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=kE(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=kE(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 aE(e,"track",(function(e){return e.transceiver||cd(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function Rk(e){if("object"===qd(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||[],Am(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=DE(t=this._senders).call(t,e);-1!==i&&ak(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=kE(r=t._senders).call(r,(function(t){return t.track===e}));o&&ak(n=t._senders).call(n,DE(i=t._senders).call(i,o),1)}))}}else if("object"===qd(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},cd(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 Ak(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=Am(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 ib(Km(t=cn(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 $_((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function wk(e){if("object"===qd(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 pE(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}),aE(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 pE(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?$_.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():$_.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function Ck(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Km(e=cn(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===DE(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(kE(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=Ks(t=this.getSenders()).call(t,(function(e){return-1===DE(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Mm(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&&cn(this._shimmedLocalStreams).forEach((function(r){var n,i,o=DE(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&ak(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function xk(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Ck(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},Km(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(kE(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=Am([]).call(arguments,1);if(1!==s.length||!kE(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(kE(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),$_.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 kE(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Zd({},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,cn(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=ic(e.RTCPeerConnection.prototype,"localDescription");cd(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||{},cn(this._streams).forEach((function(n){var i;kE(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 cn(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 Ok(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=Zd({},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 Pk(e,t){aE(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 Nk=Object.freeze({__proto__:null,fixNegotiationNeeded:Pk,shimAddTrackRemoveTrack:xk,shimAddTrackRemoveTrackWithNative:Ck,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:Rk,shimGetStats:Ak,shimGetUserMedia:kk,shimMediaStream:Tk,shimOnTrack:Ik,shimPeerConnection:Ok,shimSenderReceiverGetStats:wk});Cr({target:"Array",stat:!0},{isArray:ro});var Dk=r(re.Array.isArray);function Mk(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Lk=r(_h),Uk=nr,Vk=Ah,Fk=Qt,Bk=N,jk=qe,Hk=function(e,t,r,n){try{return n?t(Uk(r)[0],r[1]):t(r)}catch(Iq){Vk(e,"throw",Iq)}},Gk=dh,zk=bo,Kk=Hr,Xk=ei,Wk=kh,Yk=_h,qk=Array,Jk=function(e){var t=jk(e),r=zk(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=Fk(i,n>2?arguments[2]:void 0));var a,s,c,u,d,l,h=Yk(t),v=0;if(!h||this===qk&&Gk(h))for(a=Kk(t),s=r?new this(a):qk(a);a>v;v++)l=o?i(t[v],v):t[v],Xk(s,v,l);else for(d=(u=Wk(t,h)).next,s=r?new this:[];!(c=Bk(d,u)).done;v++)l=o?Hk(u,i,[c.value,v],!0):c.value,Xk(s,v,l);return s.length=v,s},Qk=Jk;Cr({target:"Array",stat:!0,forced:!n_((function(e){Array.from(e)}))},{from:Qk});var Zk=r(re.Array.from);function $k(e,t){var r;if(e){if("string"==typeof e)return Mk(e,t);var n=Am(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Zk(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Mk(e,t):void 0}}function eT(e){return function(e){if(Dk(e))return Mk(e)}(e)||function(e){if(void 0!==xd&&null!=Lk(e)||null!=e["@@iterator"])return Zk(e)}(e)||$k(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 tT=o,rT=a,nT=Sn,iT=tg.trim,oT=Xm,aT=T("".charAt),sT=tT.parseFloat,cT=tT.Symbol,uT=cT&&cT.iterator,dT=1/sT(oT+"-0")!=-1/0||uT&&!rT((function(){sT(Object(uT))}))?function(e){var t=iT(nT(e)),r=sT(t);return 0===r&&"-"==aT(t,0)?-0:r}:sT;Cr({global:!0,forced:parseFloat!=dT},{parseFloat:dT});var lT=r(re.parseFloat);function hT(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){dE("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"===qd(e)&&"object"===qd(e.audio)&&(e=JSON.parse(Fm(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"===qd(e)&&(e=JSON.parse(Fm(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function vT(e){"object"===qd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&cd(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function pT(e,t){if("object"===qd(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=Zd({},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=Am(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,Nb({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function fT(e){if("object"===qd(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):$_.resolve(new ib)}}}function _T(e){if("object"===qd(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}),aE(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function mT(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;dE("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&bk(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function gT(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function yT(e){if("object"===qd(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=eT(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&&!(lT(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(lT(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===cn(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 ST(e){if("object"===qd(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=Mm(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function bT(e){if("object"===qd(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?$_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function ET(e){if("object"===qd(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?$_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var kT=Object.freeze({__proto__:null,shimAddTransceiver:yT,shimCreateAnswer:ET,shimCreateOffer:bT,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,$_.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})},shimGetParameters:ST,shimGetUserMedia:hT,shimOnTrack:vT,shimPeerConnection:pT,shimRTCDataChannel:gT,shimReceiverGetStats:_T,shimRemoveStream:mT,shimSenderGetStats:fT});function TT(e){if("object"===qd(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=[]),bk(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?bk(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=DE(t=this._localStreams).call(t,e);if(-1!==i){ak(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){bk(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function IT(e){if("object"===qd(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){cd(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=[]),!bk(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=[]),!(DE(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 RT(e){if("object"===qd(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),$_.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),$_.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),$_.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),$_.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),$_.resolve()):n},t.addIceCandidate=s}}function AT(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(wT(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function wT(e){return e&&void 0!==e.video?Nb({},e,{video:hE(e.video)}):e}function CT(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")?(dE("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(Fm(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&&cd(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function xT(e){"object"===qd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&cd(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function OT(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=kE(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=kE(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 PT(e){"object"!==qd(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var NT=Object.freeze({__proto__:null,shimAudioContext:PT,shimCallbacksAPI:RT,shimConstraints:wT,shimCreateOfferLegacy:OT,shimGetUserMedia:AT,shimLocalStreamsAPI:TT,shimRTCIceServerUrls:CT,shimRemoteStreamsAPI:IT,shimTrackEventTransceiver:xT}),DT=lc.PROPER,MT=a,LT=Xm,UT=tg.trim;Cr({target:"String",proto:!0,forced:function(e){return MT((function(){return!!LT[e]()||"​…᠎"!=="​…᠎"[e]()||DT&&LT[e].name!==e}))}("trim")},{trim:function(){return UT(this)}});var VT,FT,BT=Bs("String").trim,jT=ce,HT=BT,GT=String.prototype,zT=r((function(e){var t=e.trim;return"string"==typeof e||e===GT||jT(GT,e)&&t===GT.trim?HT:t})),KT={exports:{}};VT=KT,(FT={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=FT.generateIdentifier(),FT.splitLines=function(e){var t;return Km(t=zT(e).call(e).split("\n")).call(t,(function(e){return zT(e).call(e)}))},FT.splitSections=function(e){var t=e.split("\nm=");return Km(t).call(t,(function(e,t){var r;return zT(r=t>0?"m="+e:e).call(r)+"\r\n"}))},FT.getDescription=function(e){var t=FT.splitSections(e);return t&&t[0]},FT.getMediaSections=function(e){var t=FT.splitSections(e);return t.shift(),t},FT.matchPrefix=function(e,t){var r;return Ks(r=FT.splitLines(e)).call(r,(function(e){return 0===DE(e).call(e,t)}))},FT.parseCandidate=function(e){for(var t,r={foundation:(t=0===DE(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:pg(t[3],10),ip:t[4],address:t[4],port:pg(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=pg(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},FT.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(" ")},FT.parseIceOptions=function(e){return e.substr(14).split(" ")},FT.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:pg(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=pg(t[1],10),r.channels=3===t.length?pg(t[2],10):1,r.numChannels=r.channels,r},FT.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"},FT.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:pg(r[0],10),direction:DE(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},FT.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},FT.parseFmtp=function(e){for(var t,r={},n=e.substr(DE(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=zT(o=n[i]).call(o).split("="),r[zT(a=t[0]).call(a)]=t[1]}return r},FT.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&cn(e.parameters).length){var n=[];cn(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},FT.parseRtcpFb=function(e){var t=e.substr(DE(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},FT.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},FT.parseSsrcMedia=function(e){var t=DE(e).call(e," "),r={ssrc:pg(e.substr(7,t-7),10)},n=DE(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},FT.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:Km(t).call(t,(function(e){return pg(e,10)}))}},FT.getMid=function(e){var t=FT.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},FT.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},FT.getDtlsParameters=function(e,t){var r=FT.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:Km(r).call(r,FT.parseFingerprint)}},FT.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},FT.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:pg(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:Am(t).call(t,3)}},FT.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===qd(e.keyParams)?FT.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},FT.parseCryptoKeyParams=function(e){if(0!==DE(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}},FT.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},FT.getCryptoParameters=function(e,t){var r=FT.matchPrefix(e+t,"a=crypto:");return Km(r).call(r,FT.parseCryptoLine)},FT.getIceParameters=function(e,t){var r=FT.matchPrefix(e+t,"a=ice-ufrag:")[0],n=FT.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},FT.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},FT.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=FT.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=FT.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=FT.parseRtpMap(o),c=FT.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=c.length?FT.parseFmtp(c[0]):{},s.rtcpFeedback=Km(a=FT.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,FT.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return FT.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(FT.parseExtmap(e))})),t},FT.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=Km(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+=FT.writeRtpMap(e),n+=FT.writeFmtp(e),n+=FT.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+=FT.writeExtmap(e)})),n},FT.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],c=FT.parseRtpParameters(e),u=-1!==DE(t=c.fecMechanisms).call(t,"RED"),d=-1!==DE(r=c.fecMechanisms).call(r,"ULPFEC"),l=Ks(n=Km(i=FT.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return FT.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=l.length>0&&l[0].ssrc,v=Km(o=FT.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return Km(t).call(t,(function(e){return pg(e,10)}))}));v.length>0&&v[0].length>1&&v[0][0]===h&&(a=v[0][1]),c.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:h,codecPayloadType:pg(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),u&&((t=JSON.parse(Fm(t))).fec={ssrc:h,mechanism:d?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var p,f,_=FT.matchPrefix(e,"b=");return _.length&&(_=0===DE(p=_[0]).call(p,"b=TIAS:")?pg(_[0].substr(7),10):0===DE(f=_[0]).call(f,"b=AS:")?1e3*pg(_[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=_}))),s},FT.parseRtcpParameters=function(e){var t,r,n={},i=Ks(t=Km(r=FT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return FT.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=FT.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=FT.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},FT.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},FT.parseMsid=function(e){var t,r,n,i=FT.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=Ks(t=Km(r=FT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return FT.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},FT.parseSctpDescription=function(e){var t,r=FT.parseMLine(e),n=FT.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=pg(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=FT.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:pg(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=FT.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:pg(a[0],10),protocol:a[1],maxMessageSize:t}}},FT.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("")},FT.generateSessionId=function(){return Math.random().toString().substr(2,21)},FT.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||FT.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},FT.getDirection=function(e,t){for(var r=FT.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?FT.getDirection(t):"sendrecv"},FT.getKind=function(e){return FT.splitLines(e)[0].split(" ")[0].substr(2)},FT.isRejected=function(e){return"0"===e.split(" ",2)[1]},FT.parseMLine=function(e){var t=FT.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:pg(t[1],10),protocol:t[2],fmt:Am(t).call(t,3).join(" ")}},FT.parseOLine=function(e){var t=FT.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:pg(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},FT.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=FT.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},VT.exports=FT;var XT=KT.exports,WT=r(XT),YT=e({__proto__:null,default:WT},[XT]);function qT(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===qd(e)&&e.candidate&&0===DE(r=e.candidate).call(r,"a=")&&((e=JSON.parse(Fm(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=WT.parseCandidate(e.candidate),o=Nb(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,aE(e,"icecandidate",(function(t){return t.candidate&&cd(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function JT(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||aE(e,"icecandidate",(function(e){if(e.candidate){var t=WT.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function QT(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||cd(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&&cd(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=WT.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=WT.parseMLine(e);return r&&"application"===r.kind&&-1!==DE(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=pg(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=WT.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=pg(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={};cd(c,"maxMessageSize",{get:function(){return i}}),this._sctp=c}return r.apply(this,arguments)}}}function ZT(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},aE(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 $T(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;cd(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),cd(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 eI(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!==DE(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=Ks(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==zT(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 tI(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?$_.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),$_.resolve())})}}function rI(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"!==qd(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 nI=Object.freeze({__proto__:null,removeExtmapAllowMixed:eI,shimAddIceCandidateNullOrEmpty:tI,shimConnectionState:$T,shimMaxMessageSize:QT,shimParameterlessSetLocalDescription:rI,shimRTCIceCandidate:qT,shimRTCIceCandidateRelayProtocol:JT,shimSendThrowTypeError:ZT});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=uE,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=oE(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=oE(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=oE(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),i={browserDetails:n,commonShim:nI,extractVersion:oE,disableLog:sE,disableWarnings:cE,sdp:YT};switch(n.browser){case"chrome":if(!Nk||!Ok||!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=Nk,tI(e,n),rI(e),kk(e,n),Tk(e),Ok(e,n),Ik(e),xk(e,n),Rk(e),Ak(e),wk(e),Pk(e,n),qT(e),JT(e),$T(e),QT(e,n),ZT(e),eI(e,n);break;case"firefox":if(!kT||!pT||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),i;r("adapter.js shimming firefox."),i.browserShim=kT,tI(e,n),rI(e),hT(e,n),pT(e,n),vT(e),mT(e),fT(e),_T(e),gT(e),yT(e),ST(e),bT(e),ET(e),qT(e),$T(e),QT(e,n),ZT(e);break;case"safari":if(!NT||!t.shimSafari)return r("Safari shim is not included in this adapter release."),i;r("adapter.js shimming safari."),i.browserShim=NT,tI(e,n),rI(e),CT(e),OT(e),RT(e),TT(e),IT(e),xT(e),AT(e),PT(e),qT(e),JT(e),QT(e,n),ZT(e),eI(e,n);break;default:r("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var iI=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=iI.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 oI(e,t){var r=void 0!==xd&&Lk(e)||e["@@iterator"];if(!r){if(Dk(e)||(r=$k(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 aI(e,t){return function(e){if(Dk(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==xd&&Lk(e)||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(d){u=!0,i=d}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||$k(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function sI(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var cI=Ze,uI=function(e){return void 0!==e&&(cI(e,"value")||cI(e,"writable"))},dI=N,lI=te,hI=nr,vI=uI,pI=C,fI=Sc;Cr({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return hI(t)===o?t[r]:(n=pI.f(t,r))?vI(n)?n.value:void 0===n.get?void 0:dI(n.get,o):lI(i=fI(t))?e(i,r,o):void 0}});var _I=r(re.Reflect.get),mI=T,gI=Oe,yI=te,SI=Ze,bI=os,EI=s,kI=Function,TI=mI([].concat),II=mI([].join),RI={},AI=EI?kI.bind:function(e){var t=gI(this),r=t.prototype,n=bI(arguments,1),i=function(){var r=TI(n,bI(arguments));return this instanceof i?function(e,t,r){if(!SI(RI,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";RI[t]=kI("C,a","return new C("+II(n,",")+")")}return RI[t](e,r)}(t,r.length,r):t.apply(e,r)};return yI(r)&&(i.prototype=r),i},wI=AI;Cr({target:"Function",proto:!0,forced:Function.bind!==wI},{bind:wI});var CI=Bs("Function").bind,xI=ce,OI=CI,PI=Function.prototype,NI=r((function(e){var t=e.bind;return e===PI||xI(PI,e)&&t===PI.bind?OI:t}));function DI(e){var t;return(DI=ql?NI(t=Yl).call(t):function(e){return e.__proto__||Yl(e)})(e)}function MI(){var e;"undefined"!=typeof Reflect&&_I?MI=NI(e=_I).call(e):MI=function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=DI(e)););return e}(e,t);if(n){var i=ic(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return MI.apply(this,arguments)}function LI(e,t){var r;return(LI=ql?NI(r=ql).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function UI(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=zl(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),cd(e,"prototype",{writable:!1}),t&&LI(e,t)}var VI=Cr,FI=h,BI=AI,jI=Iv,HI=nr,GI=te,zI=Xn,KI=a,XI=se("Reflect","construct"),WI=Object.prototype,YI=[].push,qI=KI((function(){function e(){}return!(XI((function(){}),[],e)instanceof e)})),JI=!KI((function(){XI((function(){}))})),QI=qI||JI;VI({target:"Reflect",stat:!0,forced:QI,sham:QI},{construct:function(e,t){jI(e),HI(t);var r=arguments.length<3?e:jI(arguments[2]);if(JI&&!qI)return XI(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 FI(YI,n,t),new(FI(BI,e,n))}var i=r.prototype,o=zI(GI(i)?i:WI),a=FI(e,o,t);return GI(a)?a:o}});var ZI=r(re.Reflect.construct);function $I(){if("undefined"==typeof Reflect||!ZI)return!1;if(ZI.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(ZI(Boolean,[],(function(){}))),!0}catch(e){return!1}}function eR(e){var t=$I();return function(){var r,n=DI(e);if(t){var i=DI(this).constructor;r=ZI(n,arguments,i)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===qd(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return sI(e)}(this,r)}}var tR=Bs("Array").values,rR=mn,nR=Ze,iR=ce,oR=tR,aR=Array.prototype,sR={DOMTokenList:!0,NodeList:!0},cR=r((function(e){var t=e.values;return e===aR||iR(aR,e)&&t===aR.values||nR(sR,rR(e))?oR:t})),uR=ai,dR=Math.floor,lR=function(e,t){var r=e.length,n=dR(r/2);return r<8?hR(e,t):vR(e,lR(uR(e,0,n),t),lR(uR(e,n),t),t)},hR=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},vR=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},pR=lR,fR=ue.match(/firefox\/(\d+)/i),_R=!!fR&&+fR[1],mR=/MSIE|Trident/.test(ue),gR=ue.match(/AppleWebKit\/(\d+)\./),yR=!!gR&&+gR[1],SR=Cr,bR=T,ER=Oe,kR=qe,TR=Hr,IR=HE,RR=Sn,AR=a,wR=pR,CR=Au,xR=_R,OR=mR,PR=_e,NR=yR,DR=[],MR=bR(DR.sort),LR=bR(DR.push),UR=AR((function(){DR.sort(void 0)})),VR=AR((function(){DR.sort(null)})),FR=CR("sort"),BR=!AR((function(){if(PR)return PR<70;if(!(xR&&xR>3)){if(OR)return!0;if(NR)return NR<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++)DR.push({k:t+n,v:r})}for(DR.sort((function(e,t){return t.v-e.v})),n=0;n<DR.length;n++)t=DR[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));SR({target:"Array",proto:!0,forced:UR||!VR||!FR||!BR},{sort:function(e){void 0!==e&&ER(e);var t=kR(this);if(BR)return void 0===e?MR(t):MR(t,e);var r,n,i=[],o=TR(t);for(n=0;n<o;n++)n in t&&LR(i,t[n]);for(wR(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:RR(t)>RR(r)?1:-1}}(e)),r=TR(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)IR(t,n++);return t}});var jR=Bs("Array").sort,HR=ce,GR=jR,zR=Array.prototype,KR=r((function(e){var t=e.sort;return e===zR||HR(zR,e)&&t===zR.sort?GR:t})),XR=Cr,WR=Lo.findIndex,YR="findIndex",qR=!0;YR in[]&&Array(1)[YR]((function(){qR=!1})),XR({target:"Array",proto:!0,forced:qR},{findIndex:function(e){return WR(this,e,arguments.length>1?arguments[1]:void 0)}});var JR=Bs("Array").findIndex,QR=ce,ZR=JR,$R=Array.prototype,eA=r((function(e){var t=e.findIndex;return e===$R||QR($R,e)&&t===$R.findIndex?ZR:t})),tA=Cr,rA=T;C.f;var nA=Br,iA=Sn,oA=Fb,aA=q,sA=jb,cA=rA("".startsWith),uA=rA("".slice),dA=Math.min;tA({target:"String",proto:!0,forced:!sA("startsWith")},{startsWith:function(e){var t=iA(aA(this));oA(e);var r=nA(dA(arguments.length>1?arguments[1]:void 0,t.length)),n=iA(e);return cA?cA(t,n,r):uA(t,r,r+n.length)===n}});var lA=Bs("String").startsWith,hA=ce,vA=lA,pA=String.prototype,fA=r((function(e){var t=e.startsWith;return"string"==typeof e||e===pA||hA(pA,e)&&t===pA.startsWith?vA:t})),_A=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_EXCEED_QPS="USER_MESSAGE_EXCEED_QPS",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e.SUBTITLE_ALREADY_ON="SUBTITLE_ALREADY_ON",e.SUBTITLE_NOT_TURNED_ON="SUBTITLE_NOT_TURNED_ON",e.SUBTITLE_ERR_POSTPROCESS="SUBTITLE_ERR_POSTPROCESS",e.SUBTITLE_ERR_CONNECTION_ERROR="SUBTITLE_ERR_CONNECTION_ERROR",e.SUBTITLE_ERR_PROCESS_ERROR="SUBTITLE_ERR_PROCESS_ERROR",e.SUBTITLE_ERR_UNKNOWN="SUBTITLE_ERR_UNKNOWN",e.UNEXPECTED_INVOKE_FORWARD_STREAM="UNEXPECTED_INVOKE_FORWARD_STREAM",e.ROOM_FORBIDDEN="ROOM_FORBIDDEN",e.USER_FORBIDDEN="USER_FORBIDDEN",e}(_A||{}),mA=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}(mA||{});function gA(e,t,r){var n;$I()?gA=NI(n=ZI).call(n):gA=function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(NI(Function).apply(e,n));return r&&LI(i,r.prototype),i};return gA.apply(null,arguments)}function yA(e){var t="function"==typeof ib?new ib:void 0;return yA=function(e){if(null===e||(r=e,-1===DE(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 gA(e,arguments,DI(this).constructor)}return i.prototype=zl(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),LI(i,e)},yA(e)}var SA=function(e){UI(r,e);var t=eR(r);function r(e,n,i){var o;return Hl(this,r),Zd(sI(o=t.call(this,n)),"code",void 0),Zd(sI(o),"message",void 0),Zd(sI(o),"error",void 0),o.code=e,o.message=n,o.error=i,ql(sI(o),r.prototype),o}return jl(r,[{key:"toString",value:function(){var e;return Mm(e="SDKError: ".concat(this.code," ")).call(e,this.message)}}]),r}(yA(Error)),bA=x,EA=T,kA=on,TA=Z,IA=EA(D.f),RA=EA([].push),AA=function(e){return function(t){for(var r,n=TA(t),i=kA(n),o=i.length,a=0,s=[];o>a;)r=i[a++],bA&&!IA(n,r)||RA(s,e?[r,n[r]]:n[r]);return s}},wA={entries:AA(!0),values:AA(!1)}.entries;Cr({target:"Object",stat:!0},{entries:function(e){return wA(e)}});var CA=r(re.Object.entries),xA=Nr,OA=Sn,PA=q,NA=RangeError,DA=T,MA=Br,LA=Sn,UA=function(e){var t=OA(PA(this)),r="",n=xA(e);if(n<0||n==1/0)throw NA("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},VA=q,FA=DA(UA),BA=DA("".slice),jA=Math.ceil,HA=function(e){return function(t,r,n){var i,o,a=LA(VA(t)),s=MA(r),c=a.length,u=void 0===n?" ":LA(n);return s<=c||""==u?a:((o=FA(u,jA((i=s-c)/u.length))).length>i&&(o=BA(o,0,i)),e?a+o:o+a)}},GA={start:HA(!1),end:HA(!0)},zA=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(ue),KA=GA.end;Cr({target:"String",proto:!0,forced:zA},{padEnd:function(e){return KA(this,e,arguments.length>1?arguments[1]:void 0)}});var XA=Bs("String").padEnd,WA=ce,YA=XA,qA=String.prototype,JA=r((function(e){var t=e.padEnd;return"string"==typeof e||e===qA||WA(qA,e)&&t===qA.padEnd?YA:t})),QA=vg;Cr({target:"Number",stat:!0,forced:Number.parseInt!=QA},{parseInt:QA});var ZA=r(re.Number.parseInt),$A=Math.log,ew=Math.LOG10E;Cr({target:"Math",stat:!0},{log10:Math.log10||function(e){return $A(e)*ew}});var tw,rw=r(re.Math.log10),nw=Bs("Array").keys,iw=mn,ow=Ze,aw=ce,sw=nw,cw=Array.prototype,uw={DOMTokenList:!0,NodeList:!0},dw=r((function(e){var t=e.keys;return e===cw||aw(cw,e)&&t===cw.keys||ow(uw,iw(e))?sw:t})),lw=new Uint8Array(16);function hw(){if(!tw&&!(tw="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 tw(lw)}var vw=/^(?:[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 pw=[],fw=0;fw<256;++fw)pw.push((fw+256).toString(16).substr(1));function _w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(pw[e[t+0]]+pw[e[t+1]]+pw[e[t+2]]+pw[e[t+3]]+"-"+pw[e[t+4]]+pw[e[t+5]]+"-"+pw[e[t+6]]+pw[e[t+7]]+"-"+pw[e[t+8]]+pw[e[t+9]]+"-"+pw[e[t+10]]+pw[e[t+11]]+pw[e[t+12]]+pw[e[t+13]]+pw[e[t+14]]+pw[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&vw.test(e)}(r))throw TypeError("Stringified UUID is invalid");return r}function mw(e,t,r){var n=(e=e||{}).random||(e.rng||hw)();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 _w(n)}var gw=function(){return"undefined"==typeof window},yw=function(){return mw()},Sw=function(e){return"number"==typeof e},bw=function(e){var t;return bk(t=Function.prototype.toString.call(e)).call(t,"[native code]")};function Ew(e){return null==e?"undefined | null":"string"==typeof e?e:Fm({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function kw(e){return null==e?"undefined | null":"string"==typeof e?e:Fm({id:e.id,active:e.active})}function Tw(e){return null==e?"undefined | null":"string"==typeof e?e:Fm({track:Ew(e.track)})}function Iw(e){return null==e?"undefined | null":"string"==typeof e?e:Fm({track:Ew(e.track)})}function Rw(e){return null==e?"undefined | null":"string"==typeof e?e:Fm({currentDirection:e.currentDirection,direction:e.direction,mid:e.mid,stopped:e.stopped,receiver:Iw(e.receiver),sender:Tw(e.sender)})}var Aw="@byted/ve-rtc",ww="@byted/ve-rtc-cache-size",Cw=function(){function e(){Hl(this,e),Zd(this,"storeKey",void 0),Zd(this,"logLevel",void 0),Zd(this,"LogfileSize",void 0),Zd(this,"db",void 0),Zd(this,"logId",void 0),Zd(this,"cacheLog",void 0),Zd(this,"cachedSize",void 0),Zd(this,"preCacheTime",void 0),Zd(this,"timer",void 0),Zd(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 jl(e,[{key:"_createStore",value:function(){var e=this;if(!gw()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(Aw);try{localStorage.removeItem(ww)}catch(Iq){}},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(ww);if(t)this.cachedSize=Number(t);else cR(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(Iq){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(ww,"".concat(this.cachedSize))}catch(Iq){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(Aw,e).objectStore(Aw)}},{key:"set",value:function(e){var t=this;return new $_((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Mm(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=Mm(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Mm(s=Mm(c="".concat(l?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(Mm(u="".concat(l)).call(u,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Mm(d="".concat(t.cacheLog)).call(d,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(p){var v;if(!e)return n(p);t.cacheLog+=Mm(v="\n\n".concat(t.logId,": ")).call(v,e),t.logId++,n(p)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Mm(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new $_((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 $_((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 dw(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 $_((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 $_((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}(),xw=new Cw,Ow=GA.start;Cr({target:"String",proto:!0,forced:zA},{padStart:function(e){return Ow(this,e,arguments.length>1?arguments[1]:void 0)}});var Pw=Bs("String").padStart,Nw=ce,Dw=Pw,Mw=String.prototype,Lw=r((function(e){var t=e.padStart;return"string"==typeof e||e===Mw||Nw(Mw,e)&&t===Mw.padStart?Dw:t})),Uw=function(){function e(){Hl(this,e),Zd(this,"_all",{})}return jl(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||ak(r).call(r,DE(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||Am(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,Mm(t=[e]).call(t,n))}catch(Iq){console.error(Iq)}}},{key:"destroy",value:function(){this._all={}}}]),e}(),Vw=["UPLOAD_CONSOLE_LENGTH_CUT","UPLOAD_REPORT_LIMIT"];var Fw=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Mm(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 jl(r,[{key:"setParameter",value:function(e,t){if(function(e){return bk(Vw).call(Vw,e)}(e))try{var r=Number(t);if(Number.isNaN(r))return;this.config[e]=r}catch(i){var n;return void console.warn(Mm(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 cn(this.config)}}]),r}(Uw),Bw=new Fw,jw=ro,Hw=Hr,Gw=dd,zw=Qt,Kw=function(e,t,r,n,i,o,a,s){for(var c,u,d=i,l=0,h=!!a&&zw(a,s);l<n;)l in r&&(c=h?h(r[l],l,t):r[l],o>0&&jw(c)?(u=Hw(c),d=Kw(e,t,c,u,d,o-1)-1):(Gw(d+1),e[d]=c),d++),l++;return d},Xw=Kw,Ww=qe,Yw=Hr,qw=Nr,Jw=wo;Cr({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Ww(this),r=Yw(t),n=Jw(t,0);return n.length=Xw(n,t,t,r,0,void 0===e?1:qw(e)),n}});var Qw=Bs("Array").flat,Zw=ce,$w=Qw,eC=Array.prototype,tC=r((function(e){var t=e.flat;return e===eC||Zw(eC,e)&&t===eC.flat?$w:t})),rC={};!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=Am(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==qd(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 Mm([]).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)}(rC);var nC={},iC={},oC={},aC=rC,sC=0,cC=1;function uC(e){for(var t=e.length;--t>=0;)e[t]=0}var dC=0,lC=29,hC=256,vC=hC+1+lC,pC=30,fC=19,_C=2*vC+1,mC=15,gC=16,yC=7,SC=256,bC=16,EC=17,kC=18,TC=[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],IC=[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],RC=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],AC=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],wC=new Array(2*(vC+2));uC(wC);var CC=new Array(2*pC);uC(CC);var xC=new Array(512);uC(xC);var OC=new Array(256);uC(OC);var PC=new Array(lC);uC(PC);var NC,DC,MC,LC=new Array(pC);function UC(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 VC(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function FC(e){return e<256?xC[e]:xC[256+(e>>>7)]}function BC(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function jC(e,t,r){e.bi_valid>gC-r?(e.bi_buf|=t<<e.bi_valid&65535,BC(e,e.bi_buf),e.bi_buf=t>>gC-e.bi_valid,e.bi_valid+=r-gC):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function HC(e,t,r){jC(e,r[2*t],r[2*t+1])}function GC(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function zC(e,t,r){var n,i,o=new Array(mC+1),a=0;for(n=1;n<=mC;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]=GC(o[s]++,s))}}function KC(e){var t;for(t=0;t<vC;t++)e.dyn_ltree[2*t]=0;for(t=0;t<pC;t++)e.dyn_dtree[2*t]=0;for(t=0;t<fC;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*SC]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function XC(e){e.bi_valid>8?BC(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 WC(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 YC(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&WC(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!WC(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function qC(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?HC(e,i,t):(HC(e,(o=OC[i])+hC+1,t),0!==(a=TC[o])&&jC(e,i-=PC[o],a),HC(e,o=FC(--n),r),0!==(a=IC[o])&&jC(e,n-=LC[o],a))}while(s<e.last_lit);HC(e,SC,t)}function JC(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=_C,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--)YC(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],YC(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++,YC(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,a,s,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,v=t.stat_desc.extra_base,p=t.stat_desc.max_length,f=0;for(o=0;o<=mC;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<_C;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>p&&(o=p,f++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=v&&(a=h[n-v]),s=c[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(d[2*n+1]+a)));if(0!==f){do{for(o=p-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[p]--,f-=2}while(f>0);for(o=p;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>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),zC(o,u,e.bl_count)}function QC(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*bC]++):s<=10?e.bl_tree[2*EC]++:e.bl_tree[2*kC]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function ZC(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{HC(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(HC(e,i,e.bl_tree),s--),HC(e,bC,e.bl_tree),jC(e,s-3,2)):s<=10?(HC(e,EC,e.bl_tree),jC(e,s-3,3)):(HC(e,kC,e.bl_tree),jC(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}uC(LC);var $C=!1;function ex(e,t,r,n){jC(e,(dC<<1)+(n?1:0),3),function(e,t,r,n){XC(e),n&&(BC(e,r),BC(e,~r)),aC.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}oC._tr_init=function(e){$C||(!function(){var e,t,r,n,i,o=new Array(mC+1);for(r=0,n=0;n<lC-1;n++)for(PC[n]=r,e=0;e<1<<TC[n];e++)OC[r++]=n;for(OC[r-1]=n,i=0,n=0;n<16;n++)for(LC[n]=i,e=0;e<1<<IC[n];e++)xC[i++]=n;for(i>>=7;n<pC;n++)for(LC[n]=i<<7,e=0;e<1<<IC[n]-7;e++)xC[256+i++]=n;for(t=0;t<=mC;t++)o[t]=0;for(e=0;e<=143;)wC[2*e+1]=8,e++,o[8]++;for(;e<=255;)wC[2*e+1]=9,e++,o[9]++;for(;e<=279;)wC[2*e+1]=7,e++,o[7]++;for(;e<=287;)wC[2*e+1]=8,e++,o[8]++;for(zC(wC,vC+1,o),e=0;e<pC;e++)CC[2*e+1]=5,CC[2*e]=GC(e,5);NC=new UC(wC,TC,hC+1,vC,mC),DC=new UC(CC,IC,0,pC,mC),MC=new UC(new Array(0),RC,0,fC,yC)}(),$C=!0),e.l_desc=new VC(e.dyn_ltree,NC),e.d_desc=new VC(e.dyn_dtree,DC),e.bl_desc=new VC(e.bl_tree,MC),e.bi_buf=0,e.bi_valid=0,KC(e)},oC._tr_stored_block=ex,oC._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 sC;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return cC;for(t=32;t<hC;t++)if(0!==e.dyn_ltree[2*t])return cC;return sC}(e)),JC(e,e.l_desc),JC(e,e.d_desc),a=function(e){var t;for(QC(e,e.dyn_ltree,e.l_desc.max_code),QC(e,e.dyn_dtree,e.d_desc.max_code),JC(e,e.bl_desc),t=fC-1;t>=3&&0===e.bl_tree[2*AC[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?ex(e,t,r,n):4===e.strategy||o===i?(jC(e,2+(n?1:0),3),qC(e,wC,CC)):(jC(e,4+(n?1:0),3),function(e,t,r,n){var i;for(jC(e,t-257,5),jC(e,r-1,5),jC(e,n-4,4),i=0;i<n;i++)jC(e,e.bl_tree[2*AC[i]+1],3);ZC(e,e.dyn_ltree,t-1),ZC(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),qC(e,e.dyn_ltree,e.dyn_dtree)),KC(e),n&&XC(e)},oC._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*(OC[r]+hC+1)]++,e.dyn_dtree[2*FC(t)]++),e.last_lit===e.lit_bufsize-1},oC._tr_align=function(e){jC(e,2,3),HC(e,SC,wC),function(e){16===e.bi_valid?(BC(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 tx=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 rx=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 nx,ix=function(e,t,r,n){var i=rx,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},ox={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"},ax=rC,sx=oC,cx=tx,ux=ix,dx=ox,lx=0,hx=4,vx=0,px=-2,fx=-1,_x=4,mx=2,gx=8,yx=9,Sx=286,bx=30,Ex=19,kx=2*Sx+1,Tx=15,Ix=3,Rx=258,Ax=Rx+Ix+1,wx=42,Cx=103,xx=113,Ox=666,Px=1,Nx=2,Dx=3,Mx=4;function Lx(e,t){return e.msg=dx[t],t}function Ux(e){return(e<<1)-(e>4?9:0)}function Vx(e){for(var t=e.length;--t>=0;)e[t]=0}function Fx(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(ax.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 Bx(e,t){sx._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Fx(e.strm)}function jx(e,t){e.pending_buf[e.pending++]=t}function Hx(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function Gx(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-Ax?e.strstart-(e.w_size-Ax):0,u=e.window,d=e.w_mask,l=e.prev,h=e.strstart+Rx,v=u[o+a-1],p=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===p&&u[r+a-1]===v&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<h);if(n=Rx-(h-o),o=h-Rx,n>a){if(e.match_start=t,a=n,n>=s)break;v=u[o+a-1],p=u[o+a]}}}while((t=l[t&d])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function zx(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-Ax)){ax.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,ax.arraySet(s,a.input,a.next_in,d,c),1===a.state.wrap?a.adler=cx(a.adler,s,d,c):2===a.state.wrap&&(a.adler=ux(a.adler,s,d,c)),a.next_in+=d,a.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=Ix)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+Ix-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<Ix)););}while(e.lookahead<Ax&&0!==e.strm.avail_in)}function Kx(e,t){for(var r,n;;){if(e.lookahead<Ax){if(zx(e),e.lookahead<Ax&&t===lx)return Px;if(0===e.lookahead)break}if(r=0,e.lookahead>=Ix&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ix-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-Ax&&(e.match_length=Gx(e,r)),e.match_length>=Ix)if(n=sx._tr_tally(e,e.strstart-e.match_start,e.match_length-Ix),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Ix){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ix-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=sx._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(Bx(e,!1),0===e.strm.avail_out))return Px}return e.insert=e.strstart<Ix-1?e.strstart:Ix-1,t===hx?(Bx(e,!0),0===e.strm.avail_out?Dx:Mx):e.last_lit&&(Bx(e,!1),0===e.strm.avail_out)?Px:Nx}function Xx(e,t){for(var r,n,i;;){if(e.lookahead<Ax){if(zx(e),e.lookahead<Ax&&t===lx)return Px;if(0===e.lookahead)break}if(r=0,e.lookahead>=Ix&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ix-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=Ix-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-Ax&&(e.match_length=Gx(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===Ix&&e.strstart-e.match_start>4096)&&(e.match_length=Ix-1)),e.prev_length>=Ix&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-Ix,n=sx._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Ix),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+Ix-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=Ix-1,e.strstart++,n&&(Bx(e,!1),0===e.strm.avail_out))return Px}else if(e.match_available){if((n=sx._tr_tally(e,0,e.window[e.strstart-1]))&&Bx(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return Px}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=sx._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Ix-1?e.strstart:Ix-1,t===hx?(Bx(e,!0),0===e.strm.avail_out?Dx:Mx):e.last_lit&&(Bx(e,!1),0===e.strm.avail_out)?Px:Nx}function Wx(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 Yx(){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=gx,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 ax.Buf16(2*kx),this.dyn_dtree=new ax.Buf16(2*(2*bx+1)),this.bl_tree=new ax.Buf16(2*(2*Ex+1)),Vx(this.dyn_ltree),Vx(this.dyn_dtree),Vx(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new ax.Buf16(Tx+1),this.heap=new ax.Buf16(2*Sx+1),Vx(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new ax.Buf16(2*Sx+1),Vx(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 qx(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=mx,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?wx:xx,e.adler=2===t.wrap?0:1,t.last_flush=lx,sx._tr_init(t),vx):Lx(e,px)}function Jx(e){var t,r=qx(e);return r===vx&&((t=e.state).window_size=2*t.w_size,Vx(t.head),t.max_lazy_match=nx[t.level].max_lazy,t.good_match=nx[t.level].good_length,t.nice_match=nx[t.level].nice_length,t.max_chain_length=nx[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=Ix-1,t.match_available=0,t.ins_h=0),r}function Qx(e,t,r,n,i,o){if(!e)return px;var a=1;if(t===fx&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>yx||r!==gx||n<8||n>15||t<0||t>9||o<0||o>_x)return Lx(e,px);8===n&&(n=9);var s=new Yx;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+Ix-1)/Ix),s.window=new ax.Buf8(2*s.w_size),s.head=new ax.Buf16(s.hash_size),s.prev=new ax.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new ax.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,Jx(e)}nx=[new Wx(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(zx(e),0===e.lookahead&&t===lx)return Px;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,Bx(e,!1),0===e.strm.avail_out))return Px;if(e.strstart-e.block_start>=e.w_size-Ax&&(Bx(e,!1),0===e.strm.avail_out))return Px}return e.insert=0,t===hx?(Bx(e,!0),0===e.strm.avail_out?Dx:Mx):(e.strstart>e.block_start&&(Bx(e,!1),e.strm.avail_out),Px)})),new Wx(4,4,8,4,Kx),new Wx(4,5,16,8,Kx),new Wx(4,6,32,32,Kx),new Wx(4,4,16,16,Xx),new Wx(8,16,32,32,Xx),new Wx(8,16,128,128,Xx),new Wx(8,32,128,256,Xx),new Wx(32,128,258,1024,Xx),new Wx(32,258,258,4096,Xx)],iC.deflateInit=function(e,t){return Qx(e,t,gx,15,8,0)},iC.deflateInit2=Qx,iC.deflateReset=Jx,iC.deflateResetKeep=qx,iC.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?px:(e.state.gzhead=t,vx):px},iC.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?Lx(e,px):px;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===Ox&&t!==hx)return Lx(e,0===e.avail_out?-5:px);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===wx)if(2===n.wrap)e.adler=0,jx(n,31),jx(n,139),jx(n,8),n.gzhead?(jx(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)),jx(n,255&n.gzhead.time),jx(n,n.gzhead.time>>8&255),jx(n,n.gzhead.time>>16&255),jx(n,n.gzhead.time>>24&255),jx(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),jx(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(jx(n,255&n.gzhead.extra.length),jx(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=ux(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(jx(n,0),jx(n,0),jx(n,0),jx(n,0),jx(n,0),jx(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),jx(n,3),n.status=xx);else{var a=gx+(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=xx,Hx(n,a),0!==n.strstart&&(Hx(n,e.adler>>>16),Hx(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=ux(e.adler,n.pending_buf,n.pending-i,i)),Fx(e),i=n.pending,n.pending!==n.pending_buf_size));)jx(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=ux(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=ux(e.adler,n.pending_buf,n.pending-i,i)),Fx(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,jx(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=ux(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=ux(e.adler,n.pending_buf,n.pending-i,i)),Fx(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,jx(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=ux(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=Cx)}else n.status=Cx;if(n.status===Cx&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&Fx(e),n.pending+2<=n.pending_buf_size&&(jx(n,255&e.adler),jx(n,e.adler>>8&255),e.adler=0,n.status=xx)):n.status=xx),0!==n.pending){if(Fx(e),0===e.avail_out)return n.last_flush=-1,vx}else if(0===e.avail_in&&Ux(t)<=Ux(r)&&t!==hx)return Lx(e,-5);if(n.status===Ox&&0!==e.avail_in)return Lx(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==lx&&n.status!==Ox){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(zx(e),0===e.lookahead)){if(t===lx)return Px;break}if(e.match_length=0,r=sx._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Bx(e,!1),0===e.strm.avail_out))return Px}return e.insert=0,t===hx?(Bx(e,!0),0===e.strm.avail_out?Dx:Mx):e.last_lit&&(Bx(e,!1),0===e.strm.avail_out)?Px:Nx}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=Rx){if(zx(e),e.lookahead<=Rx&&t===lx)return Px;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=Ix&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+Rx;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=Rx-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Ix?(r=sx._tr_tally(e,1,e.match_length-Ix),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=sx._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Bx(e,!1),0===e.strm.avail_out))return Px}return e.insert=0,t===hx?(Bx(e,!0),0===e.strm.avail_out?Dx:Mx):e.last_lit&&(Bx(e,!1),0===e.strm.avail_out)?Px:Nx}(n,t):nx[n.level].func(n,t);if(s!==Dx&&s!==Mx||(n.status=Ox),s===Px||s===Dx)return 0===e.avail_out&&(n.last_flush=-1),vx;if(s===Nx&&(1===t?sx._tr_align(n):5!==t&&(sx._tr_stored_block(n,0,0,!1),3===t&&(Vx(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Fx(e),0===e.avail_out))return n.last_flush=-1,vx}return t!==hx?vx:n.wrap<=0?1:(2===n.wrap?(jx(n,255&e.adler),jx(n,e.adler>>8&255),jx(n,e.adler>>16&255),jx(n,e.adler>>24&255),jx(n,255&e.total_in),jx(n,e.total_in>>8&255),jx(n,e.total_in>>16&255),jx(n,e.total_in>>24&255)):(Hx(n,e.adler>>>16),Hx(n,65535&e.adler)),Fx(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?vx:1)},iC.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==wx&&69!==t&&73!==t&&91!==t&&t!==Cx&&t!==xx&&t!==Ox?Lx(e,px):(e.state=null,t===xx?Lx(e,-3):vx):px},iC.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,d=t.length;if(!e||!e.state)return px;if(2===(o=(r=e.state).wrap)||1===o&&r.status!==wx||r.lookahead)return px;for(1===o&&(e.adler=cx(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(Vx(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new ax.Buf8(r.w_size),ax.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,zx(r);r.lookahead>=Ix;){n=r.strstart,i=r.lookahead-(Ix-1);do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+Ix-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=Ix-1,zx(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=Ix-1,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,vx},iC.deflateInfo="pako deflate (from Nodeca project)";var Zx={},$x=rC,eO=!0,tO=!0;try{String.fromCharCode.apply(null,[0])}catch(Rq){eO=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(Rq){tO=!1}for(var rO=new $x.Buf8(256),nO=0;nO<256;nO++)rO[nO]=nO>=252?6:nO>=248?5:nO>=240?4:nO>=224?3:nO>=192?2:1;function iO(e,t){if(t<65534&&(e.subarray&&tO||!e.subarray&&eO))return String.fromCharCode.apply(null,$x.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}rO[254]=rO[254]=1,Zx.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 $x.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},Zx.buf2binstring=function(e){return iO(e,e.length)},Zx.binstring2buf=function(e){for(var t=new $x.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},Zx.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=rO[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 iO(s,n)},Zx.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+rO[e[r]]>t?r:t};var oO=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},aO=iC,sO=rC,cO=Zx,uO=ox,dO=oO,lO=Object.prototype.toString,hO=0,vO=-1,pO=0,fO=8;function _O(e){if(!(this instanceof _O))return new _O(e);this.options=sO.assign({level:vO,method:fO,chunkSize:16384,windowBits:15,memLevel:8,strategy:pO,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 dO,this.strm.avail_out=0;var r=aO.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==hO)throw new Error(uO[r]);if(t.header&&aO.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?cO.string2buf(t.dictionary):"[object ArrayBuffer]"===lO.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=aO.deflateSetDictionary(this.strm,n))!==hO)throw new Error(uO[r]);this._dict_set=!0}}function mO(e,t){var r=new _O(t);if(r.push(e,!0),r.err)throw r.msg||uO[r.err];return r.result}_O.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=cO.string2buf(e):"[object ArrayBuffer]"===lO.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 sO.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=aO.deflate(i,n))&&r!==hO)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(cO.buf2binstring(sO.shrinkBuf(i.output,i.next_out))):this.onData(sO.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=aO.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===hO):2!==n||(this.onEnd(hO),i.avail_out=0,!0)},_O.prototype.onData=function(e){this.chunks.push(e)},_O.prototype.onEnd=function(e){e===hO&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=sO.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},nC.Deflate=_O,nC.deflate=mO,nC.deflateRaw=function(e,t){return(t=t||{}).raw=!0,mO(e,t)},nC.gzip=function(e,t){return(t=t||{}).gzip=!0,mO(e,t)};var gO={},yO=nr,SO=N,bO=Ze,EO=ce,kO=function(){var e=yO(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},TO=RegExp.prototype,IO=ce,RO=function(e){var t=e.flags;return void 0!==t||"flags"in TO||bO(e,"flags")||!EO(TO,e)?t:SO(kO,e)},AO=RegExp.prototype,wO=r((function(e){return e===AO||IO(AO,e)?RO(e):e.flags})),CO={},xO=rC,OO=15,PO=[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],NO=[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],DO=[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],MO=[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],LO=rC,UO=tx,VO=ix,FO=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,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,v=r.hold,p=r.bits,f=r.lencode,_=r.distcode,m=(1<<r.lenbits)-1,g=(1<<r.distbits)-1;e:do{p<15&&(v+=I[n++]<<p,p+=8,v+=I[n++]<<p,p+=8),y=f[v&m];t:for(;;){if(v>>>=S=y>>>24,p-=S,0===(S=y>>>16&255))R[o++]=65535&y;else{if(!(16&S)){if(0==(64&S)){y=f[(65535&y)+(v&(1<<S)-1)];continue t}if(32&S){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=65535&y,(S&=15)&&(p<S&&(v+=I[n++]<<p,p+=8),b+=v&(1<<S)-1,v>>>=S,p-=S),p<15&&(v+=I[n++]<<p,p+=8,v+=I[n++]<<p,p+=8),y=_[v&g];r:for(;;){if(v>>>=S=y>>>24,p-=S,!(16&(S=y>>>16&255))){if(0==(64&S)){y=_[(65535&y)+(v&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(E=65535&y,p<(S&=15)&&(v+=I[n++]<<p,(p+=8)<S&&(v+=I[n++]<<p,p+=8)),(E+=v&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(v>>>=S,p-=S,E>(S=o-a)){if((S=E-S)>d&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(k=0,T=h,0===l){if(k+=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=p>>3,v&=(1<<(p-=b<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<s?s-o+257:257-(o-s),r.hold=v,r.bits=p},BO=function(e,t,r,n,i,o,a,s){var c,u,d,l,h,v,p,f,_,m=s.bits,g=0,y=0,S=0,b=0,E=0,k=0,T=0,I=0,R=0,A=0,w=null,C=0,x=new xO.Buf16(16),O=new xO.Buf16(16),P=null,N=0;for(g=0;g<=OO;g++)x[g]=0;for(y=0;y<n;y++)x[t[r+y]]++;for(E=m,b=OO;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<=OO;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<OO;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,v=19):1===e?(w=PO,C-=257,P=NO,N-=257,v=256):(w=DO,P=MO,v=-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(;;){p=g-T,a[y]<v?(f=0,_=a[y]):a[y]>v?(f=P[N+a[y]],_=w[C+a[y]]):(f=96,_=0),c=1<<g-T,S=u=1<<k;do{i[h+(A>>T)+(u-=c)]=p<<24|f<<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&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},jO=1,HO=2,GO=0,zO=-2,KO=1,XO=12,WO=30,YO=852,qO=592;function JO(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function QO(){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 LO.Buf16(320),this.work=new LO.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function ZO(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=KO,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new LO.Buf32(YO),t.distcode=t.distdyn=new LO.Buf32(qO),t.sane=1,t.back=-1,GO):zO}function $O(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,ZO(e)):zO}function eP(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)?zO:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,$O(e))):zO}function tP(e,t){var r,n;return e?(n=new QO,e.state=n,n.window=null,(r=eP(e,t))!==GO&&(e.state=null),r):zO}var rP,nP,iP=!0;function oP(e){if(iP){var t;for(rP=new LO.Buf32(512),nP=new LO.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(BO(jO,e.lens,0,288,rP,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;BO(HO,e.lens,0,32,nP,0,e.work,{bits:5}),iP=!1}e.lencode=rP,e.lenbits=9,e.distcode=nP,e.distbits=5}function aP(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 LO.Buf8(o.wsize)),n>=o.wsize?(LO.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),LO.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(LO.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}CO.inflateReset=$O,CO.inflateReset2=eP,CO.inflateResetKeep=ZO,CO.inflateInit=function(e){return tP(e,15)},CO.inflateInit2=tP,CO.inflate=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,R=0,A=new LO.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 zO;(r=e.state).mode===XO&&(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=GO;e:for(;;)switch(r.mode){case KO: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=VO(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=WO;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=WO;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=WO;break}r.dmax=1<<E,e.adler=r.check=1,r.mode=512&u?10:XO,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&wO(r))){e.msg="unknown compression method",r.mode=WO;break}if(57344&wO(r)){e.msg="unknown header flags set",r.mode=WO;break}r.head&&(r.head.text=u>>8&1),512&wO(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=VO(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&wO(r)&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=VO(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&wO(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=VO(r.check,A,2,0)),u=0,d=0,r.mode=5;case 5:if(1024&wO(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&wO(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=VO(r.check,A,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&wO(r)&&((v=r.length)>s&&(v=s),v&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),LO.arraySet(r.head.extra,n,o,v,E)),512&wO(r)&&(r.check=VO(r.check,n,v,o)),s-=v,o+=v,r.length-=v),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&wO(r)){if(0===s)break e;v=0;do{E=n[o+v++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&v<s);if(512&wO(r)&&(r.check=VO(r.check,n,v,o)),s-=v,o+=v,E)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&wO(r)){if(0===s)break e;v=0;do{E=n[o+v++],r.head&&E&&r.length<65536&&(r.head.comment+=String.fromCharCode(E))}while(E&&v<s);if(512&wO(r)&&(r.check=VO(r.check,n,v,o)),s-=v,o+=v,E)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&wO(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=WO;break}u=0,d=0}r.head&&(r.head.hcrc=wO(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=XO;break;case 10:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}e.adler=r.check=JO(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=XO;case XO: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(oP(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=WO}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=WO;break}if(r.length=65535&u,u=0,d=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(v=r.length){if(v>s&&(v=s),v>c&&(v=c),0===v)break e;LO.arraySet(i,n,o,v,a),s-=v,o+=v,c-=v,a+=v,r.length-=v;break}r.mode=XO;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=WO;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=BO(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid code lengths set",r.mode=WO;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)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(g<16)u>>>=_,d-=_,r.lens[r.have++]=g;else{if(16===g){for(I=_+2;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u>>>=_,d-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=WO;break}E=r.lens[r.have-1],v=3+(3&u),u>>>=2,d-=2}else if(17===g){for(I=_+3;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,E=0,v=3+(7&(u>>>=_)),u>>>=3,d-=3}else{for(I=_+7;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,E=0,v=11+(127&(u>>>=_)),u>>>=7,d-=7}if(r.have+v>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=WO;break}for(;v--;)r.lens[r.have++]=E}}if(r.mode===WO)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=WO;break}if(r.lenbits=9,T={bits:r.lenbits},k=BO(jO,r.lens,0,r.nlen,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid literal/lengths set",r.mode=WO;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},k=BO(HO,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,T),r.distbits=T.bits,k){e.msg="invalid distances set",r.mode=WO;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,FO(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===XO&&(r.back=-1);break}for(r.back=0;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=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)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=y,d-=y,r.back+=y}if(u>>>=_,d-=_,r.back+=_,r.length=g,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=XO;break}if(64&m){e.msg="invalid literal/length code",r.mode=WO;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,!((_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=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)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=y,d-=y,r.back+=y}if(u>>>=_,d-=_,r.back+=_,64&m){e.msg="invalid distance code",r.mode=WO;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=WO;break}r.mode=25;case 25:if(0===c)break e;if(v=h-c,r.offset>v){if((v=r.offset-v)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=WO;break}v>r.wnext?(v-=r.wnext,p=r.wsize-v):p=r.wnext-v,v>r.length&&(v=r.length),f=r.window}else f=i,p=a-r.offset,v=r.length;v>c&&(v=c),c-=v,r.length-=v;do{i[a++]=f[p++]}while(--v);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===s)break e;s--,u|=n[o++]<<d,d+=8}if(h-=c,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=wO(r)?VO(r.check,i,h,a-h):UO(r.check,i,h,a-h)),h=c,(wO(r)?u:JO(u))!==r.check){e.msg="incorrect data check",r.mode=WO;break}u=0,d=0}r.mode=28;case 28:if(r.wrap&&wO(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=WO;break}u=0,d=0}r.mode=29;case 29:k=1;break e;case WO:k=-3;break e;case 31:return-4;default:return zO}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<WO&&(r.mode<27||4!==t))&&aP(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=wO(r)?VO(r.check,i,h,e.next_out-h):UO(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===XO?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&k===GO&&(k=-5),k},CO.inflateEnd=function(e){if(!e||!e.state)return zO;var t=e.state;return t.window&&(t.window=null),e.state=null,GO},CO.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?zO:(r.head=t,t.done=!1,GO):zO},CO.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?zO:11===r.mode&&UO(1,t,n,0)!==r.check?-3:aP(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,GO):zO},CO.inflateInfo="pako inflate (from Nodeca project)";var sP={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 cP=CO,uP=rC,dP=Zx,lP=sP,hP=ox,vP=oO,pP=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},fP=Object.prototype.toString;function _P(e){if(!(this instanceof _P))return new _P(e);this.options=uP.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 vP,this.strm.avail_out=0;var r=cP.inflateInit2(this.strm,t.windowBits);if(r!==lP.Z_OK)throw new Error(hP[r]);if(this.header=new pP,cP.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=dP.string2buf(t.dictionary):"[object ArrayBuffer]"===fP.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=cP.inflateSetDictionary(this.strm,t.dictionary))!==lP.Z_OK))throw new Error(hP[r])}function mP(e,t){var r=new _P(t);if(r.push(e,!0),r.err)throw r.msg||hP[r.err];return r.result}_P.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?lP.Z_FINISH:lP.Z_NO_FLUSH,"string"==typeof e?s.input=dP.binstring2buf(e):"[object ArrayBuffer]"===fP.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 uP.Buf8(c),s.next_out=0,s.avail_out=c),(r=cP.inflate(s,lP.Z_NO_FLUSH))===lP.Z_NEED_DICT&&u&&(r=cP.inflateSetDictionary(this.strm,u)),r===lP.Z_BUF_ERROR&&!0===d&&(r=lP.Z_OK,d=!1),r!==lP.Z_STREAM_END&&r!==lP.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==lP.Z_STREAM_END&&(0!==s.avail_in||n!==lP.Z_FINISH&&n!==lP.Z_SYNC_FLUSH)||("string"===this.options.to?(i=dP.utf8border(s.output,s.next_out),o=s.next_out-i,a=dP.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&uP.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(uP.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!==lP.Z_STREAM_END);return r===lP.Z_STREAM_END&&(n=lP.Z_FINISH),n===lP.Z_FINISH?(r=cP.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===lP.Z_OK):n!==lP.Z_SYNC_FLUSH||(this.onEnd(lP.Z_OK),s.avail_out=0,!0)},_P.prototype.onData=function(e){this.chunks.push(e)},_P.prototype.onEnd=function(e){e===lP.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=uP.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},gO.Inflate=_P,gO.inflate=mP,gO.inflateRaw=function(e,t){return(t=t||{}).raw=!0,mP(e,t)},gO.ungzip=mP;var gP={};(0,rC.assign)(gP,nC,gO,sP);var yP,SP,bP,EP=r(gP),kP=1,TP=function(){function e(t){Hl(this,e),Zd(this,"lockingPromise",$_.resolve()),Zd(this,"locks",0),Zd(this,"name",""),Zd(this,"lockId",void 0),this.lockId=kP++,t&&(this.name=t)}return jl(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t=this;this.locks+=1;var r=new $_((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}(),IP="BytePlusRTC",RP=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},AP=function(){function e(t){Hl(this,e),Zd(this,"storeName",void 0),Zd(this,"pendingList",[]),this.storeName=t,!gw()&&RP()&&this._checkAndCreateStore(t)}var t,r,n,i,o,a,s;return jl(e,[{key:"_checkAndCreateStore",value:(s=xm(wm().mark((function t(r,n){var i,o,a=this;return wm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e._promiseLock.lock();case 2:if(i=t.sent,!RP.databases){t.next=6;break}return t.next=6,new $_((function(e){var t=function(){return RP.databases().finally(e)};o=setInterval(t,100),t()})).finally((function(){return clearInterval(o)}));case 6:return t.abrupt("return",new $_((function(t){e.db&&(e.db.close(),delete e.db);var o=n?RP().open(IP,n):RP().open(IP);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=xm(wm().mark((function e(t){var r,n,i,o;return wm().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=xm(wm().mark((function t(r){var n,i=this;return wm().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 $_((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=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{n=Fm(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=xm(wm().mark((function e(t){var r,n;return wm().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=xm(wm().mark((function e(t,r){var n;return wm().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 $_((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=xm(wm().mark((function e(t){var r;return wm().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 $_((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=xm(wm().mark((function e(t){var r;return wm().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 $_((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}();Zd(AP,"db",void 0),Zd(AP,"state","init"),Zd(AP,"_promiseLock",new TP("iDB"));var wP={product_line:"rtc",report_version:"5",os:"web",user_agent:gw()?"":null===(yP=navigator)||void 0===yP?void 0:yP.userAgent,platform:"web",product:"webrtc",app_state:"active"},CP="LogReportor",xP="undefined"!=typeof window&&(bk(SP=window.location.search).call(SP,"_rtc_debug_")||(null===(bP=window.localStorage)||void 0===bP?void 0:bP.getItem("_rtc_debug_"))),OP=function(){function e(t){Hl(this,e),Zd(this,"_buffer",void 0),this._buffer=new AP(t)}var t,r;return jl(e,[{key:"set",value:(r=xm(wm().mark((function e(t,r){return wm().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=xm(wm().mark((function e(t){var r,n;return wm().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}(),PP=function(){function e(){var t=this;Hl(this,e),Zd(this,"reportCommon",wP),Zd(this,"reportIds",new ib),Zd(this,"dataBuffer",[]),Zd(this,"reportorList",[]),Zd(this,"dbBuffer",void 0),Zd(this,"posting",!1),Zd(this,"sucSendTimer",void 0),Zd(this,"preSucTime",0),Zd(this,"errSendTimer",void 0),Zd(this,"errSendDelay",100),Zd(this,"_logServerUrl",void 0),Zd(this,"_retryCount",0),Zd(this,"_reportLimit",5e5),Zd(this,"_disableTimeout",!1),gw()||(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"})})),xP&&(window.__rtc_debug_reportor__=this)),Bw.on("UPLOAD_REPORT_LIMIT",(function(e){t.setReportLimit(e)})),Bw.on("ENABLE_REPORT_IDB_BUFFER",(function(e){e&&t.enableIndexedDBBuffer()})),setTimeout((function(){t.reportorList.push(cN)}))}var t;return jl(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.reportCommon=Nb(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&&(KP("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){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.send(e):(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 OP("ReportorDBBuffer"),this.dbBuffer.get(CP).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){e.forEach((function(e){t.push(e)}))}))})))}},{key:"backup",value:function(){var e=this;try{var t;null===(t=this.dbBuffer)||void 0===t||t.set(eT(this.dataBuffer),CP),this.reportorList.forEach((function(t){var r;null===(r=e.dbBuffer)||void 0===r||r.set(eT(t.get()),t.name)}))}catch(r){KP("Error when save log into IDB",-1,r)}}},{key:"unshift",value:function(e){var t;this.dataBuffer=Mm(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+=Fm(e[n]).length)>t)return n;return e.length}(this.dataBuffer,this._reportLimit);0===r&&this.dataBuffer.length>0&&(this._reportLimit=Fm(this.dataBuffer[0]).length+10,r=1,KP("update report limit to ".concat(this._reportLimit),0,null));var n=ak(e=this.dataBuffer).call(e,0,r),i=Fm(n).length,o=[n],a=this._reportLimit-i;return this.reportorList.forEach((function(e){var r=ak(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),!gw()&&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=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.backup(),i=gb(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=xP,s={data:t||tC(o).call(o),header:el(el({},this.reportCommon),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},c={method:"POST",body:a?Fm(s):EP.gzip(Fm(s))},!this._disableTimeout)try{u=new AbortController,c.signal=u.signal,setTimeout((function(){u.abort()}),1e4)}catch(v){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;KP(Mm(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 NP,DP=new PP,MP=function(){function e(t){Hl(this,e),Zd(this,"modifyIds",{}),this.id=t}return jl(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=el(el(el({event_key:e,rtc_timestamp:Date.now()},this.modifyIds),t),{},{common_extra_info:Fm(i),report_id:DP.getReportId(this.modifyIds.engine_session_id)});!gw()&&window.__onRTCReport&&(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.modifyIds.engine_session_id,o,DP.getCommonStats()));DP.push(o)}},{key:"reportLog",value:function(e){var t=el(el({event_key:"rtc_invoke_status",sdk_api_name:"console_log",rtc_timestamp:Date.now()},this.modifyIds),{},{message:e});cN.push(t)}},{key:"set",value:function(e){this.modifyIds=Nb(this.modifyIds,e)}},{key:"destroy",value:function(){}}]),e}();setTimeout((function(){NP=new fN("MessageReportor",1)}),0);var LP=function(){function e(t){Hl(this,e),Zd(this,"_preTime",Date.now()),Zd(this,"_one2oneNum",0),Zd(this,"_one2manyNum",0),Zd(this,"_one2oneMsgCache",new ib),Zd(this,"_one2manyMsgCache",new ib),Zd(this,"roomId",""),Zd(this,"userId",""),Zd(this,"rtsSessionId",""),this.id=t}return jl(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,el({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,el(el({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,el({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,el(el({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(NP.info("reportP2PMsg",r.type,Fm(r)),null===(t=YP(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(NP.info("reportOne2ManyMsg",r.type,Fm(r)),null===(t=YP(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)||"",NP.info("reportMsgRecv",t.type,Fm(t)),null===(n=YP(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}();Zd(LP,"config",void 0);var UP=new ib,VP={_cache:UP,setConfig:function(e){NP.info("setConfig","get config: ".concat(Fm(e))),LP.config=e},setRtsSessionId:function(e,t){var r=UP.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=UP.get(e)||new LP(e);return UP.set(e,t),t},destroyRTSMsgReportor:function(e){var t=UP.get(e);t&&(t.destroy(),UP.delete(e))},setRoomId:function(e,t){var r=UP.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=UP.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=UP.get(e);if(null!=r&&r.needReport("one2one")){var n,i=Mm(n="".concat(t.from)).call(n,t.id),o=t.to?"one2one":"one2server";t.enable_report=!0,t.report_msg_id=t.id,r.cacheP2PMsg({rts_session_id:r.rtsSessionId,msg_id:i,node_role:"src_sdk",from:t.from,to:t.to||"server",type:o,rts_room_id:t.room,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""})}return t},updateP2PMsgReq:function(e,t,r){var n,i;t.enable_report&&Sw(t.report_msg_id)&&(null===(n=UP.get(e))||void 0===n||n.updateP2PMsg(Mm(i="".concat(t.from)).call(i,t.report_msg_id),{send_ts:Date.now(),msg_size:r}))},updateP2PMsgAck:function(e,t,r){if(t.enable_report&&Sw(t.report_msg_id)){var n,i,o=UP.get(e);null==o||o.updateP2PMsg(Mm(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(Mm(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n,i=UP.get(e);null!=i&&i.needReport("one2many")&&(r.enable_report=!0,r.report_msg_id=t,i.cacheCustomMsg({rts_session_id:i.rtsSessionId,msg_id:Mm(n="".concat(r.clientId)).call(n,t),node_role:"src_sdk",from:r.clientId,to:i.roomId,type:"one2many",rts_room_id:i.roomId,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""}));return r},reportP2PMsgRecv:function(e,t,r){if(t.enable_report&&Sw(t.report_msg_id)){var n,i=UP.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Mm(n="".concat(t.from)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:o,rts_room_id:t.room,from:t.from,to:t.to||t.room,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:t.to?"":i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},updateOne2ManyMsgAck:function(e,t,r){if(t.enable_report&&Sw(t.report_msg_id)){var n,i,o=UP.get(e);if(o)null==o||o.updateOne2ManyMsg(Mm(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(Mm(i="".concat(t.clientId)).call(i,t.report_msg_id))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&Sw(t.report_msg_id)){var n,i=UP.get(e);if(i)i.updateOne2ManyMsg(Mm(n="".concat(t.clientId)).call(n,t.report_msg_id),{send_ts:Date.now(),msg_size:r})}},reportOne2ManyMsgRecv:function(e,t,r){if(t.enable_report&&Sw(t.report_msg_id)){var n,i=UP.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Mm(n="".concat(t.clientId)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:"one2many",rts_room_id:t.roomId,from:t.clientId,to:t.roomId,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}}},FP=function(){function e(t){Hl(this,e),Zd(this,"_timer",void 0),Zd(this,"userMessage",{}),Zd(this,"roomMessage",{}),this.id=t,this._setTimer()}return jl(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(cn(this.userMessage).length||cn(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e,t,r,n=this;null===(e=YP(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:Km(t=cn(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:Km(r=cn(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[Mm(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Mm(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[Mm(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Mm(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Mm(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Mm(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)&&(bk(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[Mm(o="".concat(t,"-")).call(o,e)];a&&(a.dc_send_ack++,a.dc_cost_time+=r,a.dc_cost_s2s+=n||0,a.dc_cost_peer_s2e+=i,a.dc_cost_e2s+=r-(n||0)-i,r<=100?(a.dc_send_ack_100++,a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=200?(a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=400?(a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=1e3&&a.dc_send_ack_1s++,r<a.dc_least_time&&(a.dc_least_time=r),r>a.dc_most_time&&(a.dc_most_time=r))}},{key:"sendRoomMessage",value:function(e,t){this.roomMessage[e]||(this.roomMessage[e]={dc_room_id:e,dc_send_total:0,dc_send_ack:0,dc_cost_time:0,dc_least_time:Number(1/0),dc_most_time:0,dc_send_fail:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_send_binary:0}),this.roomMessage[e].dc_send_total++,t&&this.roomMessage[e].dc_send_binary++}},{key:"sendRoomFail",value:function(e){var t=this.roomMessage[e];t&&t.dc_send_fail++}},{key:"sendRoomAck",value:function(e,t){var r=this.roomMessage[e];r&&(r.dc_send_ack++,r.dc_cost_time+=t,t<r.dc_least_time&&(r.dc_least_time=t),t>r.dc_most_time&&(r.dc_most_time=t),t<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=1e3&&r.dc_send_ack_1s++)}},{key:"sendP2PMessage",value:function(e,t){this._sendUserMessage(e,"p2p",t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,"p2p")}},{key:"sendP2PFail",value:function(e,t){this._sendUserFail(e,"p2p",t)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p",t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,"p2p_outside_room",t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,"p2p_outside_room")}},{key:"sendP2POutRoomFail",value:function(e,t){this._sendUserFail(e,"p2p_outside_room",t)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p_outside_room",t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("","p2server",e)}},{key:"sendP2serverFail",value:function(e){this._sendUserFail("","p2server",e)}},{key:"sendP2serveAck",value:function(e,t,r){this._sendUserAck("","p2server",e,t,r)}},{key:"countP2PMessage",value:function(e,t,r,n,i){this.sendP2PMessage(t,r),e?this.sendP2PAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2PFail(t,i)}},{key:"countRoomMessage",value:function(e,t,r,n){this.sendRoomMessage(t,r),e?this.sendRoomAck(t,Date.now()-n):this.sendRoomFail(t)}},{key:"countUserMessageOutsideRoom",value:function(e,t,r,n,i){this.sendP2POutRoomMessage(t,r),e?this.sendP2POutRoomAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2POutRoomFail(t,i)}},{key:"countServerMessage",value:function(e,t,r,n){this.sendP2serverMessage(t),e?(n=n||{},this.sendP2serveAck(Date.now()-r,n.s2s_time||0,n.s2e_time||0)):this.sendP2serverFail(n)}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),BP=function(e){DP.setCommonStats(e)},jP=function(e){DP.setUrl(e)},HP=new MP("global"),GP=function(e,t,r){HP.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},zP=function(e,t,r){HP.report("rtc_sdk_callback",{sdk_callback_name:e,error_code:t,message:r})},KP=function(e,t,r){HP.report("rtc_error",{message:e,error_code:t},r)},XP=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;HP.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)};var WP=new ib,YP=function(e){return WP.get(e)},qP=function(e,t){var r=new MP(e);return r.set(el(el({},t),{},{engine_session_id:yw()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),WP.set(e,r),r};function JP(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r,n){if("function"==typeof n.value){var i=n.value;n.value=function(){for(var e,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];var s,c,u=this.engineId||this.id,d={};(t.forEach((function(e,t){d[e]=o[t]})),"joinRoom"===r)&&(null===(s=YP(u))||void 0===s||s.set({room_id:o[1],user_id:null===(c=o[2])||void 0===c?void 0:c.userId}));null===(e=YP(u))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:Fm(tN(o)),error_code:0},d);var l=i.apply(this,o);return"function"==typeof(null==l?void 0:l.then)?l.then((function(e){return ZP(u,r,[e||{}]),e})).catch((function(e){throw ZP(u,r,e.message,e.code),e})):(ZP(u,r,[l||{}]),l)}}}}var QP,ZP=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:Fm(Array.isArray(r)?tN(r):r)};i&&(o.room_id=i),null===(n=YP(e))||void 0===n||n.report("rtc_sdk_callback",o)},$P=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=YP(e))||void 0===n||n.report("rtc_invoke_status",{sdk_api_name:t,message:r,error_code:i,stream_id:o,elapse:0},a)},eN=10;function tN(e){return Km(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>eN){var c,u,d,l,h=new DataView(o),v=Km(c=Zk({length:eN/2})).call(c,(function(e,t){return h.getUint8(t)})),p=Km(u=Km(d=Zk({length:eN/2})).call(d,(function(e,t){return a-1-t})).reverse()).call(u,(function(e){return h.getUint8(e)}));s=Mm(l=[]).call(l,eT(v),["..."],eT(p))}else s=Zk(new Uint8Array(o));return Mm(n=Mm(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return Km(t).call(t,e);if(bk(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var f={};for(var _ in t)f[_]=e(t[_]);return f}return t}))}var rN="undefined"!=typeof window&&bk(QP=window.location.search).call(QP,"_rtc_upload_console_"),nN=function(){function e(){var t=this;Hl(this,e),Zd(this,"name","ConsoleReportor"),Zd(this,"_uuid","".concat(Math.floor(899*Math.random())+100)),Zd(this,"_consoleReportId",0),Zd(this,"_engineReportIdMap",new ib),Zd(this,"_enabled","NULL"),Zd(this,"_consoleCutLength",Bw.getParameter("UPLOAD_CONSOLE_LENGTH_CUT")),Zd(this,"buffer",[]),rN&&setTimeout((function(){t.switchOn()}),0),Bw.on("UPLOAD_CONSOLE_ON",(function(e){e?t.switchOn():t.turnOff()})),Bw.on("UPLOAD_CONSOLE_LENGTH_CUT",(function(e){t._consoleCutLength=e}))}return jl(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,v,p,f,_,m,g,y,S=this;if("OFF"!==this._enabled){var b,E=YP(t),k=this._consoleReportId++,T=this.getEngineConsoleId(t),I=iN(c,this._consoleCutLength),R=eT(c),A="".concat(s).replace(/%o|%s/gi,(function(){return iN([R.shift()],S._consoleCutLength)})),w=Mm(u=Mm(d=Mm(l=Mm(h=Mm(v=Mm(p=Mm(f=Mm(_=Mm(m=Mm(g=Mm(y="[".concat(this._uuid,"-")).call(y,k,"][")).call(g,t,"-")).call(m,T,"]-")).call(_,r,"-")).call(f,e,"[")).call(p,n,"]")).call(v,i,"[")).call(h,o,".")).call(l,a,"] ")).call(d,A," ")).call(u,I);E?E.reportLog(w):(b=w,HP.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=Fm(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:ak(t=this.buffer).call(t,0,n),payloadSize:i}}},{key:"unshift",value:function(e){this.buffer=Mm(e).call(e,this.buffer)}},{key:"get",value:function(){return this.buffer}},{key:"isEmpty",value:function(){return"OFF"===this._enabled||0===this.buffer.length}}]),e}();function iN(e,t){return Km(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 Ew(e);if(e instanceof MediaStream)return kw(e);if(e instanceof RTCRtpSender)return Tw(e);if(e instanceof RTCRtpReceiver)return Iw(e);if(e instanceof RTCRtpTransceiver)return Rw(e);r=Fm(e)}catch(n){r=e.toString()}return r&&r.length>=t&&(r=Am(r).call(r,0,t)),r})).join(", ")}var oN,aN,sN,cN=new nN,uN="[VERTC]",dN="#0050b3",lN=(Zd(oN={},"DEBUG","rgba(0, 0, 0, 0)"),Zd(oN," INFO","rgba(93, 173, 226, 0)"),Zd(oN," WARN","rgba(255, 119, 0, 0.3)"),Zd(oN,"ERROR","rgba(255, 0, 0, 0.3)"),Zd(oN," SUCC","rgba(0, 119, 0, 0.3)"),oN),hN="undefined"!=typeof window&&(bk(aN=window.location.search).call(aN,"_rtc_debug_")||(null===(sN=window.localStorage)||void 0===sN?void 0:sN.getItem("_rtc_debug_"))),vN=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"global";Hl(this,e),Zd(this,"indent",void 0),Zd(this,"module",void 0),Zd(this,"_engineId",void 0),this.module=t,this.indent=r,this._engineId=n}return jl(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 v=l.shift();try{var p,f,_,m,g=Mm(p=[]).call(p,l),y="".concat(v).replace(/%o/gi,(function(){var e=g.shift();return Fm(e)}));xw.set(Mm(f=Mm(_=Mm(m="".concat(uN,"[").concat(this.module,".")).call(m,t,"] ")).call(_,y," ")).call(f,Km(g).call(g,(function(e){return Fm(e)})).join(", ")))}catch(Iq){}for(var S="",b=0;b<this.indent;b++)S+=" ";var E=pN();cN.report(uN,this._engineId,E,e,S,this.module,t,v,l),hN&&(r=console).log.apply(r,Mm(n=[Mm(i=Mm(o=Mm(a=Mm(s=Mm(c=Mm(u="%c".concat(E,"-")).call(u,uN,"%c[")).call(c,e,"]%c")).call(s,S,"[")).call(a,this.module,".")).call(o,t,"] ")).call(i,v),"color:".concat(dN,";"),"background-color:".concat(lN[e],";"),"color:".concat(dN,";")]).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,Mm(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,Mm(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,Mm(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,Mm(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,Mm(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,Mm(t=[" SUCC",e]).call(t,n))}}]),e}(),pN=function(){var e,t,r=new Date;return Mm(e="".concat(r.toTimeString().split(" ")[0],":")).call(e,Lw(t=r.getMilliseconds().toString()).call(t,3,"0"))},fN=vN,_N=function(e){var t,r=YP(e.engineId),n={keys:dw(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId,deviceId:e.deviceId,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0},i=Km(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:Fm(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=Km(i).call(i,function(){var e=xm(wm().mark((function e(t,r){var i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:Fm(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 $_((function(e){(function(e){return new $_((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:Fm(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})}))}))},mN={exports:{}},gN=o;Cr({global:!0,forced:gN.globalThis!==gN},{globalThis:gN});var yN=r(o);var SN,bN={exports:{}},EN=new Proxy({},{get(e,t){throw new Error(`Module "" has been externalized for browser compatibility. Cannot access ".${t}" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.`)}}),kN=n(Object.freeze({__proto__:null,default:EN}));function TN(){return SN||(SN=1,function(e,r){var n;e.exports=(n=n||function(e,r){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),void 0!==yN&&yN.crypto&&(n=yN.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==t&&t.crypto&&(n=t.crypto),!n)try{n=kN}catch(_){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(_){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(_){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),a={},s=a.lib={},c=s.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=s.WordArray=c.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=t!=r?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var s=0;s<i;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e,t=c.clone.call(this);return t.words=Am(e=this.words).call(e,0),t},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new u.init(t,e)}}),d=a.enc={},l=d.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=pg(e.substr(n,2),16)<<24-n%8*4;return new u.init(r,t/2)}},h=d.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new u.init(r,t)}},v=d.Utf8={stringify:function(e){try{return decodeURIComponent(escape(h.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return h.parse(unescape(encodeURIComponent(e)))}},p=s.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){var t;"string"==typeof e&&(e=v.parse(e)),Mm(t=this._data).call(t,e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,s=o/(4*a),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,d=e.min(4*c,o);if(c){for(var l=0;l<c;l+=a)this._doProcessBlock(i,l);r=ak(i).call(i,0,c),n.sigBytes-=d}return new u.init(r,d)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=p.extend({cfg:c.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new f.HMAC.init(e,r).finalize(t)}}});var f=a.algo={};return a}(Math),n)}(bN)),bN.exports}!function(e,t){var r;e.exports=(r=TN(),function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init,n=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};n.prototype=e}}(),r.lib.WordArray)}(mN);var IN,RN=r(mN.exports),AN={exports:{}},wN={exports:{}};function CN(){return IN||(IN=1,function(e,t){var r;e.exports=(r=TN(),function(){var e=r,t=e.lib.WordArray;function n(e,r,n){for(var i=[],o=0,a=0;a<r;a++)if(a%4){var s=n[e.charCodeAt(a-1)]<<a%4*2|n[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=s<<24-o%4*8,o++}return t.create(i,o)}e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)i.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<r.length;o++)i[r.charCodeAt(o)]=o}var a=r.charAt(64);if(a){var s=DE(e).call(e,a);-1!==s&&(t=s)}return n(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),r.enc.Base64)}(wN)),wN.exports}var xN,ON={exports:{}};function PN(){return xN||(xN=1,function(e,t){var r;e.exports=(r=TN(),function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,a=t.algo,s=[];!function(){for(var t=0;t<64;t++)s[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,a=e[t+0],c=e[t+1],v=e[t+2],p=e[t+3],f=e[t+4],_=e[t+5],m=e[t+6],g=e[t+7],y=e[t+8],S=e[t+9],b=e[t+10],E=e[t+11],k=e[t+12],T=e[t+13],I=e[t+14],R=e[t+15],A=o[0],w=o[1],C=o[2],x=o[3];A=u(A,w,C,x,a,7,s[0]),x=u(x,A,w,C,c,12,s[1]),C=u(C,x,A,w,v,17,s[2]),w=u(w,C,x,A,p,22,s[3]),A=u(A,w,C,x,f,7,s[4]),x=u(x,A,w,C,_,12,s[5]),C=u(C,x,A,w,m,17,s[6]),w=u(w,C,x,A,g,22,s[7]),A=u(A,w,C,x,y,7,s[8]),x=u(x,A,w,C,S,12,s[9]),C=u(C,x,A,w,b,17,s[10]),w=u(w,C,x,A,E,22,s[11]),A=u(A,w,C,x,k,7,s[12]),x=u(x,A,w,C,T,12,s[13]),C=u(C,x,A,w,I,17,s[14]),A=d(A,w=u(w,C,x,A,R,22,s[15]),C,x,c,5,s[16]),x=d(x,A,w,C,m,9,s[17]),C=d(C,x,A,w,E,14,s[18]),w=d(w,C,x,A,a,20,s[19]),A=d(A,w,C,x,_,5,s[20]),x=d(x,A,w,C,b,9,s[21]),C=d(C,x,A,w,R,14,s[22]),w=d(w,C,x,A,f,20,s[23]),A=d(A,w,C,x,S,5,s[24]),x=d(x,A,w,C,I,9,s[25]),C=d(C,x,A,w,p,14,s[26]),w=d(w,C,x,A,y,20,s[27]),A=d(A,w,C,x,T,5,s[28]),x=d(x,A,w,C,v,9,s[29]),C=d(C,x,A,w,g,14,s[30]),A=l(A,w=d(w,C,x,A,k,20,s[31]),C,x,_,4,s[32]),x=l(x,A,w,C,y,11,s[33]),C=l(C,x,A,w,E,16,s[34]),w=l(w,C,x,A,I,23,s[35]),A=l(A,w,C,x,c,4,s[36]),x=l(x,A,w,C,f,11,s[37]),C=l(C,x,A,w,g,16,s[38]),w=l(w,C,x,A,b,23,s[39]),A=l(A,w,C,x,T,4,s[40]),x=l(x,A,w,C,a,11,s[41]),C=l(C,x,A,w,p,16,s[42]),w=l(w,C,x,A,m,23,s[43]),A=l(A,w,C,x,S,4,s[44]),x=l(x,A,w,C,k,11,s[45]),C=l(C,x,A,w,R,16,s[46]),A=h(A,w=l(w,C,x,A,v,23,s[47]),C,x,a,6,s[48]),x=h(x,A,w,C,g,10,s[49]),C=h(C,x,A,w,I,15,s[50]),w=h(w,C,x,A,_,21,s[51]),A=h(A,w,C,x,k,6,s[52]),x=h(x,A,w,C,p,10,s[53]),C=h(C,x,A,w,b,15,s[54]),w=h(w,C,x,A,c,21,s[55]),A=h(A,w,C,x,y,6,s[56]),x=h(x,A,w,C,R,10,s[57]),C=h(C,x,A,w,m,15,s[58]),w=h(w,C,x,A,T,21,s[59]),A=h(A,w,C,x,f,6,s[60]),x=h(x,A,w,C,E,10,s[61]),C=h(C,x,A,w,v,15,s[62]),w=h(w,C,x,A,S,21,s[63]),o[0]=o[0]+A|0,o[1]=o[1]+w|0,o[2]=o[2]+C|0,o[3]=o[3]+x|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,c=s.words,u=0;u<4;u++){var d=c[u];c[u]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+i+a;return(s<<o|s>>>32-o)+t}function d(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+i+a;return(s<<o|s>>>32-o)+t}function l(e,t,r,n,i,o,a){var s=e+(t^r^n)+i+a;return(s<<o|s>>>32-o)+t}function h(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+i+a;return(s<<o|s>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),r.MD5)}(ON)),ON.exports}var NN,DN={exports:{}},MN={exports:{}};function LN(){return NN||(NN=1,function(e,t){var r,n,i,o,a,s,c,u;e.exports=(u=TN(),n=(r=u).lib,i=n.WordArray,o=n.Hasher,a=r.algo,s=[],c=a.SHA1=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)s[u]=0|e[t+u];else{var d=s[u-3]^s[u-8]^s[u-14]^s[u-16];s[u]=d<<1|d>>>31}var l=(n<<5|n>>>27)+c+s[u];l+=u<20?1518500249+(i&o|~i&a):u<40?1859775393+(i^o^a):u<60?(i&o|i&a|o&a)-1894007588:(i^o^a)-899497514,c=a,a=o,o=i<<30|i>>>2,i=n,n=l}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=o._createHelper(c),r.HmacSHA1=o._createHmacHelper(c),u.SHA1)}(MN)),MN.exports}var UN,VN,FN={exports:{}};function BN(){return UN||(UN=1,function(e,t){var r,n,i,o;e.exports=(r=TN(),i=(n=r).lib.Base,o=n.enc.Utf8,void(n.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=o.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),a=this._iKey=t.clone(),s=i.words,c=a.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;i.sigBytes=a.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t,r=this._hasher,n=r.finalize(e);return r.reset(),r.finalize(Mm(t=this._oKey.clone()).call(t,n))}})))}(FN)),FN.exports}function jN(){return VN||(VN=1,function(e,t){var r,n,i,o,a,s,c,u;e.exports=(u=TN(),LN(),BN(),n=(r=u).lib,i=n.Base,o=n.WordArray,a=r.algo,s=a.MD5,c=a.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=o.create(),s=a.words,c=n.keySize,u=n.iterations;s.length<c;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var d=1;d<u;d++)r=i.finalize(r),i.reset();Mm(a).call(a,r)}return a.sigBytes=4*c,a}}),r.EvpKDF=function(e,t,r){return c.create(r).compute(e,t)},u.EvpKDF)}(DN)),DN.exports}var HN,GN={exports:{}};function zN(){return HN||(HN=1,function(e,t){var r;e.exports=(r=TN(),jN(),void(r.lib.Cipher||function(e){var t=r,n=t.lib,i=n.Base,o=n.WordArray,a=n.BufferedBlockAlgorithm,s=t.enc;s.Utf8;var c=s.Base64,u=t.algo.EvpKDF,d=n.Cipher=a.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?y:m}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()});n.StreamCipher=d.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var l=t.mode={},h=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),v=l.CBC=function(){var t=h.extend();function r(t,r,n){var i,o=this._iv;o?(i=o,this._iv=e):i=this._prevBlock;for(var a=0;a<n;a++)t[r+a]^=i[a]}return t.Encryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize;r.call(this,e,t,i),n.encryptBlock(e,t),this._prevBlock=Am(e).call(e,t,t+i)}}),t.Decryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,o=Am(e).call(e,t,t+i);n.decryptBlock(e,t),r.call(this,e,t,i),this._prevBlock=o}}),t}(),p=(t.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var c=o.create(a,n);Mm(e).call(e,c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};n.BlockCipher=d.extend({cfg:d.cfg.extend({mode:v,padding:p}),reset:function(){var e;d.reset.call(this);var t=this.cfg,r=t.iv,n=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=n.createEncryptor:(e=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(n,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var f=n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),_=(t.format={}).OpenSSL={stringify:function(e){var t,r,n=e.ciphertext,i=e.salt;return(i?Mm(t=Mm(r=o.create([1398893684,1701076831])).call(r,i)).call(t,n):n).toString(c)},parse:function(e){var t,r=c.parse(e),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(t=o.create(Am(n).call(n,2,4)),ak(n).call(n,0,4),r.sigBytes-=16),f.create({ciphertext:r,salt:t})}},m=n.SerializableCipher=i.extend({cfg:i.extend({format:_}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),a=i.cfg;return f.create({ciphertext:o,key:r,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),g=(t.kdf={}).OpenSSL={execute:function(e,t,r,n,i){var a;if(n||(n=o.random(8)),i)s=u.create({keySize:t+r,hasher:i}).compute(e,n);else var s=u.create({keySize:t+r}).compute(e,n);var c=o.create(Am(a=s.words).call(a,t),4*r);return s.sigBytes=4*t,f.create({key:s,iv:c,salt:n})}},y=n.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:g}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize,n.salt,n.hasher);n.iv=i.iv;var o=m.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt,n.hasher);return n.iv=i.iv,m.decrypt.call(this,e,t,i.key,n)}})}()))}(GN)),GN.exports}!function(e,t){var r;e.exports=(r=TN(),CN(),PN(),jN(),zN(),function(){var e=r,t=e.lib.BlockCipher,n=e.algo,i=[],o=[],a=[],s=[],c=[],u=[],d=[],l=[],h=[],v=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var p=n^n<<1^n<<2^n<<3^n<<4;p=p>>>8^255&p^99,i[r]=p,o[p]=r;var f=e[r],_=e[f],m=e[_],g=257*e[p]^16843008*p;a[r]=g<<24|g>>>8,s[r]=g<<16|g>>>16,c[r]=g<<8|g>>>24,u[r]=g,g=16843009*m^65537*_^257*f^16843008*r,d[p]=g<<24|g>>>8,l[p]=g<<16|g>>>16,h[p]=g<<8|g>>>24,v[p]=g,r?(r=f^e[e[e[m^f]]],n^=e[e[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],f=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a<n;a++)a<r?o[a]=t[a]:(u=o[a-1],a%r?r>6&&a%r==4&&(u=i[u>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u]):(u=i[(u=u<<8|u>>>24)>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u],u^=p[a/r|0]<<24),o[a]=o[a-r]^u);for(var s=this._invKeySchedule=[],c=0;c<n;c++){if(a=n-c,c%4)var u=o[a];else u=o[a-4];s[c]=c<4||a<=4?u:d[i[u>>>24]]^l[i[u>>>16&255]]^h[i[u>>>8&255]]^v[i[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,c,u,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,d,l,h,v,o),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,a,s){for(var c=this._nRounds,u=e[t]^r[0],d=e[t+1]^r[1],l=e[t+2]^r[2],h=e[t+3]^r[3],v=4,p=1;p<c;p++){var f=n[u>>>24]^i[d>>>16&255]^o[l>>>8&255]^a[255&h]^r[v++],_=n[d>>>24]^i[l>>>16&255]^o[h>>>8&255]^a[255&u]^r[v++],m=n[l>>>24]^i[h>>>16&255]^o[u>>>8&255]^a[255&d]^r[v++],g=n[h>>>24]^i[u>>>16&255]^o[d>>>8&255]^a[255&l]^r[v++];u=f,d=_,l=m,h=g}f=(s[u>>>24]<<24|s[d>>>16&255]<<16|s[l>>>8&255]<<8|s[255&h])^r[v++],_=(s[d>>>24]<<24|s[l>>>16&255]<<16|s[h>>>8&255]<<8|s[255&u])^r[v++],m=(s[l>>>24]<<24|s[h>>>16&255]<<16|s[u>>>8&255]<<8|s[255&d])^r[v++],g=(s[h>>>24]<<24|s[u>>>16&255]<<16|s[d>>>8&255]<<8|s[255&l])^r[v++],e[t]=f,e[t+1]=_,e[t+2]=m,e[t+3]=g},keySize:8});e.AES=t._createHelper(f)}(),r.AES)}(AN);var KN=AN.exports,XN={exports:{}};!function(e,t){e.exports=TN().enc.Hex}(XN);var WN=r(XN.exports),YN={exports:{}};!function(e,t){var r,n,i;e.exports=(i=TN(),zN(),i.mode.CTR=(r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,o=this._counter;i&&(o=this._counter=Am(i).call(i,0),this._iv=void 0);var a=Am(o).call(o,0);r.encryptBlock(a,0),o[n-1]=o[n-1]+1|0;for(var s=0;s<n;s++)e[t+s]^=a[s]}}),r.Decryptor=n,r),i.mode.CTR)}(YN);var qN=r(YN.exports),JN={exports:{}};!function(e,t){var r;e.exports=(r=TN(),zN(),r.pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)}(JN);var QN=r(JN.exports),ZN=new TextDecoder,$N=new TextEncoder,eD=function(){return mw()},tD=function(){return Date.now()};function rD(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 nD=function(){function e(){Hl(this,e)}var t,r;return jl(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(Ks(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=CA(t);n<i.length;n++){var o=aI(i[n],2),a=o[0],s=o[1];null!==s&&"object"===qd(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return ZN.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 $N.encode(e).buffer}},{key:"ab2b64str",value:(r=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new $_((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=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,".concat(t)).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function iD(){for(var e,t,r=Number(JA(e=Am(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=JA(r).call(r,28,"1").split(""),i=[];n.length;)i.push(ak(n).call(n,0,7));return Km(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return ZA(r+e.join(""),2)}))}var oD=function(){return Math.floor(65535*Math.random())};function aD(e){return"string"==typeof e&&DE(e).call(e,"__web__rtc__rtt__")>-1}var sD,cD,uD,dD,lD,hD,vD,pD,fD=function(){var e=xm(wm().mark((function e(){var t,r,n,i=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]&&i[0],(r=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"})).createDataChannel("default"),r.addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),t&&(r.addTransceiver("audio",{direction:"sendonly"}),r.addTransceiver("video",{direction:"sendonly"})),e.next=8,r.createOffer();case 8:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),_D=function(e){return new $_((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 mD(e){return Number(Math.max(-127,10*rw(Math.pow(e/255,2))).toFixed(2))}function gD(e){return(e&ll.AUDIO)===ll.AUDIO}function yD(e){return(e&ll.VIDEO)===ll.VIDEO}function SD(e){var t={};return cn(e).forEach((function(r){"object"===qd(e[r])?t[r]=SD(e[r]):fA(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 ED(e){return void 0===e}function kD(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Mm(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 TD(e){console.warn("[RTC WebSDK]: ".concat(e))}function ID(e){return"number"==typeof e?e:"number"==typeof(null==e?void 0:e.exact)?e.exact:"number"==typeof(null==e?void 0:e.ideal)?e.ideal:"number"==typeof(null==e?void 0:e.max)?e.max:"number"==typeof(null==e?void 0:e.min)?e.min:1}function RD(e){for(var t=atob(e),r=t.length,n=new Uint8Array(r),i=0;i<r;i++)n[i]=t.charCodeAt(i);return n}function AD(e){for(var t="",r=e.byteLength,n=0;n<r;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function wD(e,t,r){var n=CD(e),i=CD(t),o=CD(r);return function(e){for(var t=e.toString(WN),r=new Uint8Array(t.length/2),n=0;n<t.length;n+=2)r[n/2]=pg(t.substr(n,2),16);return r}(KN.encrypt(n,i,{iv:o,mode:qN,padding:QN}).ciphertext)}function CD(e){for(var t=[],r=0;r<e.length;r+=4)t.push(e[r]<<24|(e[r+1]||0)<<16|(e[r+2]||0)<<8|(e[r+3]||0));return RN.create(t,e.length)}var xD=function(){return"undefined"==typeof window},OD=xD()?"":window.navigator.userAgent;function PD(){var e="none";return xD()||(null!==OD.match("Firefox")?e="mozilla":null!==OD.match("Chrome")?(e="chrome-stable",null!==OD.match("Electron")&&(e="electron")):(null!==OD.match("Safari")||null!==OD.match("AppleWebKit"))&&(e="safari")),e}var ND,DD="mozilla"===PD(),MD="safari"===PD(),LD="chrome-stable"===PD(),UD=!xD()&&/CriOS/i.test(OD),VD=!xD()&&/Edg\//i.test(OD),FD=!xD()&&/EdgA/i.test(OD),BD=!xD()&&/EdgiOS/i.test(OD),jD=VD||FD||BD,HD=!xD()&&/DingTalk/i.test(navigator.userAgent),GD=!xD()&&(!!/(iPad)/i.exec(OD)||/Macintosh/i.test(OD)&&"ontouchend"in document),zD=!xD()&&/Macintosh/i.test(OD),KD=!xD()&&/MicroMessenger/i.test(OD),XD=!xD()&&bk(sD=OD.toLowerCase()).call(sD,"mobile"),WD=!xD()&&!!/(iPhone|iPad|iPod)/i.exec(OD),YD=!xD()&&/Android/i.test(OD),qD=!xD()&&/Windows/i.test(OD),JD=0,QD="0",ZD=!xD()&&(null===(cD=OD.match(/version\/(\d+)/i))||void 0===cD?void 0:cD[1]);MD&&ZD&&(JD=Number(ZD),QD=null===(ND=navigator.userAgent.match(/version\/(\d+\.\d+)/i))||void 0===ND?void 0:ND[1]);var $D=!xD()&&(null===(uD=OD.match(/Firefox\/(\d+)/i))||void 0===uD?void 0:uD[1]);DD&&$D&&(JD=Number($D));var eM=JD,tM=JD,rM=QD,nM=null!==(dD=!xD()&&(null===(lD=OD.match(/ ([\d_]+) like Mac OS X/i))||void 0===lD||null===(hD=lD[1])||void 0===hD?void 0:Km(vD=hD.split("_")).call(vD,(function(e){return pg(e)}))))&&void 0!==dD?dD:[],iM=0,oM=!xD()&&(null===(pD=OD.match(/Chrome\/(\d+)/i))||void 0===pD?void 0:pD[1]);oM&&(iM=Number(oM));var aM=iM,sM="BytePlus",cM="RTC_DEVICE_ID",uM="RTC_ACCESS_URLS",dM="ENGINE_WEB_CONFIG",lM="SERVER_CONFIG",hM=function(){function e(){Hl(this,e)}return jl(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,Fm(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}(),vM=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Mm(e=[this]).call(e,o))),"_accessVersion","v2"),n}return jl(r,[{key:"getDeviceId",value:function(){if(xD())return"";var e=this.get(cM);return e&&!/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e)||(e=function(e){for(var t="",r=0;r<e;r++)t+=Math.floor(10*Math.random());return t}(30)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return BP({device_id:e}),this.set(cM,e),e}},{key:"getAccessKey",value:function(e){var t,r;return Mm(t=Mm(r="".concat("RTC_ACCESS_NODE","_").concat(e,"-")).call(r,sM,"-")).call(t,this._accessVersion)}},{key:"getAccessNode",value:function(e){return this.get(this.getAccessKey(e))}},{key:"setAccessNode",value:function(e,t,r){return this.set(this.getAccessKey(e),t,1e3*r)}},{key:"deleteAccessNode",value:function(e,t){var r=this.getAccessNode(e),n=this.getTtl(this.getAccessKey(e));Array.isArray(r)&&r.length>0&&((r=Ks(r).call(r,(function(e){return e.mediaID!==t.mediaID&&e.msgKey!==t.msgKey}))).length>0?this.setAccessNode(e,r,n||0):this.clearAccessNode(e))}},{key:"clearAccessNode",value:function(e){this.delete(this.getAccessKey(e))}},{key:"getAccessUrls",value:function(){return this.get("".concat(uM,"-").concat(sM))}},{key:"setAccessUrls",value:function(e){var t=Km(e).call(e,(function(e){var t,r=e.host,n=e.path;return Mm(t="https://".concat(r)).call(t,n)}));return this.set("".concat(uM,"-").concat(sM),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(uM,"-").concat(sM))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Mm(r=Mm(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(dM);return(null==a||null===(i=kE(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=Mm(n=Mm(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(dM)||[];return(a=Ks(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(dM,Am(a).call(a,-5))}}},{key:"getServerConfig",value:function(e){var t,r="".concat(e),n=this.get(lM);return(null==n||null===(t=kE(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(lM)||[];return(n=Ks(n).call(n,(function(e){return e.key!==r}))).push({key:r,config:t}),this.set(lM,Am(n).call(n,-5))}}}]),r}(hM),pM=new vM,fM=new fN("JoinRoomConfig",0),_M=function(){function e(t){var r;Hl(this,e),Zd(this,"_useTcpAfterJoinTimeout",e.DEFAULT_CONF.useTcpAfterJoinTimeout),Zd(this,"_joinWithTcpOnly",e.DEFAULT_CONF.joinWithTcpOnly),Zd(this,"_joinWithTcpOnlyDelay",e.DEFAULT_CONF.joinWithTcpOnlyDelay),Zd(this,"_blackBrowserRegexList",[]),this._engineId=t,DE(r=location.search).call(r,"__rtc_tcp_only__")>-1&&(this._joinWithTcpOnly=!0,this._joinWithTcpOnlyDelay=0),this._report()}return jl(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 kE(e=this._blackBrowserRegexList).call(e,(function(e){return new RegExp(e).test(navigator.userAgent)}))}},{key:"setServerConfig",value:function(e){var t,r,n,i,o,a,s=!1;"boolean"==typeof(null==e||null===(t=e.use_tcp_after_join_timeout)||void 0===t?void 0:t.enable)&&(this._useTcpAfterJoinTimeout=null===(i=e.use_tcp_after_join_timeout)||void 0===i?void 0:i.enable,s=!0);"boolean"==typeof(null==e||null===(r=e.join_with_tcp_only)||void 0===r?void 0:r.enable)&&(this._joinWithTcpOnly=null===(o=e.join_with_tcp_only)||void 0===o?void 0:o.enable,s=!0);"number"==typeof(null==e||null===(n=e.join_with_tcp_only)||void 0===n?void 0:n.delay_ms)&&(this._joinWithTcpOnlyDelay=null===(a=e.join_with_tcp_only)||void 0===a?void 0:a.delay_ms,s=!0);e&&Array.isArray(e.black_browser_regex_list)&&(this._blackBrowserRegexList=e.black_browser_regex_list,s=!0),s&&this._report()}},{key:"toString",value:function(){return Fm({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(){fM.print("_report",this.toString()),$P(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}();Zd(_M,"DEFAULT_CONF",{useTcpAfterJoinTimeout:!0,joinWithTcpOnly:!1,joinWithTcpOnlyDelay:5e3});var mM="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function gM(){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 yM="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",SM="rtc.rtcplus.com".split(","),bM={VERSION:"4.56.16",ICE_CONFIG_REQUEST_URLS_INTERNAL:Km(mM).call(mM,gM),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:yM,CONFIG_REQUEST_DOMAINS:SM,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",FORCE_ENABLED_REPORT_CALLBACKS:[],SKIP_WEB_AUDIO_IN_TRACK:!1,AUDIO_STALL:!0,VIDEO_STALL:!0,STATS_SCALLBACK_SUPPORT:!0,JOIN_ROOM_CONFIG:_M.DEFAULT_CONF,SIGNAL_COMPRESSION:!0,SIGNAL_CROP_JOINROOM:!0,IOS_SAFARI_ORIENTATION:!1,ENABLE_FALLBACK_HANDLER:!1};function EM(e,t){var r;if(GP("setParameter",0,Mm(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("JOIN_ROOM_CONFIG"===e)return _M.setDefaulConf(t);if("ICE_CONFIG_REQUEST_URLS"!==e)if("PLATFORM"!==e||"string"!=typeof t)if("PRODUCT"!==e||"string"!=typeof t)if("FORCE_ENABLED_REPORT_CALLBACKS"!==e){if("LOG_SERVER_URL"===e){var n=t===ml.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===ml.domestic?yM:"string"==typeof t?t:void 0;n&&(bM.LOG_SERVER_URL=n,jP(n))}else if("OVERSEA"===e)return BP({extra_is_oversea:t?"1":"0"}),void(bM.OVERSEA=t);if("CONFIG_REQUEST_DOMAINS"===e&&Array.isArray(t)&&t.length>0)bM.CONFIG_REQUEST_DOMAINS=t;else{"DEVICE_ID"===e&&pM.setDeviceId(t);var i=Bw.getKeys();bk(i).call(i,e)?Bw.setParameter(e,t):bM[e]=t}}else{var o="string"==typeof t?[t]:t;bM.FORCE_ENABLED_REPORT_CALLBACKS=o}else BP({product:t});else BP({platform:t});else{var a="string"==typeof t?[t]:t;bM.ICE_CONFIG_REQUEST_URLS=Km(a).call(a,gM)}}}function kM(e){return"DEVICE_ID"===e?pM.getDeviceId():bM[e]}function TM(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)||Sl.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:Km(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 IM=[];function RM(e){IM=e}var AM={width:640,height:480,frameRate:15,maxKbps:600},wM={width:1920,height:1080,frameRate:15,maxKbps:3e3};function CM(e,t){if("boolean"!=typeof e)throw new SA(_A.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function xM(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 SA(_A.INVALID_PARAMS,Mm(r=Mm(n="Invalid ".concat(t,": the value range is [")).call(n,i,", ")).call(r,o,"]. integer only"))}function OM(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 SA(_A.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 SA(_A.INVALID_PARAMS,Mm(r=Mm(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function PM(e,t,r){var n;if(!bk(r).call(r,e))throw new SA(_A.INVALID_PARAMS,Mm(n="Invalid ".concat(t,": The value can only be set as ")).call(n,Fm(r)))}function NM(e){if(!(e instanceof MediaStreamTrack))throw new SA(_A.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function DM(e,t){if(UM(e))throw new SA(_A.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function MM(e,t){if(!(e instanceof ArrayBuffer))throw new SA(_A.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function LM(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=cn(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(o){}}function UM(e){return null==e}function VM(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new SA(_A.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function FM(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new SA(_A.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function BM(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new SA(_A.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function jM(e){DM(e,"userInfo"),FM(e.userId),UM(e.extraInfo)||OM(e.extraInfo,"userInfo.extraInfo",1,200)}function HM(e){DM(e,"roomConfig"),CM(e.isAutoPublish,"roomConfig.isAutoPublish"),CM(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),CM(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),UM(e.roomProfileType)||PM(e.roomProfileType,"roomConfig",[Il.communication,Il.chat,Il.chatRoom,Il.coHost,Il.meeting,Il.classRoom])}function GM(e){DM(e,"videoPlayerOption")}function zM(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 SA(_A.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:nD.str2ab(Fm(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new SA(_A.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function KM(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new SA(_A.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function XM(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 SA(_A.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function WM(e){var t,r=oI(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;xM(null==n?void 0:n.maxKbps,"maxKbps"),XM(null==n?void 0:n.width,"width"),XM(null==n?void 0:n.height,"height"),XM(null==n?void 0:n.frameRate,"frameRate")}}catch(i){r.e(i)}finally{r.f()}}function YM(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 xM(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var qM={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?Am(n).call(n,1):n);return Ns?Mm(i).call(i,Ns(e)):i},s.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a},s.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,d=this._events[s],l=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),l){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,i),!0;case 5:return d.fn.call(d.context,t,n,i,o),!0;case 6:return d.fn.call(d.context,t,n,i,o,a),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];d.fn.apply(d.context,c)}else{var h,v=d.length;for(u=0;u<v;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),l){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,n);break;case 4:d[u].fn.call(d[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];d[u].fn.apply(d[u].context,c)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var c=0,u=[],d=s.length;c<d;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(qM);var JM=qM.exports,QM=r(JM),ZM=new fN("VERTC",0),$M=function(e){UI(r,e);var t=eR(r);function r(){return Hl(this,r),t.apply(this,arguments)}return jl(r,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var n,i,o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return(n=MI(DI(r.prototype),"emit",this)).call.apply(n,Mm(i=[this,e]).call(i,a))}catch(Iq){return ZM.error("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,Iq),console.error(Iq),Boolean(t)}}}]),r}(JM.EventEmitter),eL=N,tL=nr,rL=te,nL=uI,iL=Zt,oL=C,aL=Sc,sL=B;Cr({target:"Reflect",stat:!0,forced:a((function(){var e=function(){},t=iL.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=oL.f(tL(t),r);if(!c){if(rL(o=aL(t)))return e(o,r,n,s);c=sL(0)}if(nL(c)){if(!1===c.writable||!rL(s))return!1;if(i=oL.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,iL.f(s,r,i)}else iL.f(s,r,sL(0,n))}else{if(void 0===(a=c.set))return!1;eL(a,s,n)}return!0}});var cL=r(re.Reflect.set),uL=r(fi.f("asyncIterator"));function dL(e){var t,r,n,i=2;for(void 0!==xd&&(r=uL,n=Yd);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new lL(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function lL(e){function t(e){if(Object(e)!==e)return $_.reject(new TypeError(e+" is not an object."));var t=e.done;return $_.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(lL=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?$_.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?$_.reject(e):t(r.apply(this.s,arguments))}},new lL(e)}var hL=[{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}];ty("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),gy);var vL=re.Set;Cr({target:"Set",stat:!0,forced:!0},{from:Ay}),Cr({target:"Set",stat:!0,forced:!0},{of:Cy});var pL=N,fL=Oe,_L=nr,mL=function(){for(var e=_L(this),t=fL(e.add),r=0,n=arguments.length;r<n;r++)pL(t,e,arguments[r]);return e};Cr({target:"Set",proto:!0,real:!0,forced:!0},{addAll:mL}),Cr({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:Ny});var gL=kh,yL=nr,SL=Qt,bL=gL,EL=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=yL(this),r=bL(t),n=SL(e,arguments.length>1?arguments[1]:void 0);return!EL(r,(function(e,r){if(!n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var kL=se,TL=N,IL=Oe,RL=nr,AL=xv,wL=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){var t=RL(this),r=new(AL(t,kL("Set")))(t),n=IL(r.delete);return wL(e,(function(e){TL(n,r,e)})),r}});var CL=se,xL=N,OL=Oe,PL=nr,NL=Qt,DL=xv,ML=gL,LL=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=PL(this),r=ML(t),n=NL(e,arguments.length>1?arguments[1]:void 0),i=new(DL(t,CL("Set"))),o=OL(i.add);return LL(r,(function(e){n(e,e,t)&&xL(o,i,e)}),{IS_ITERATOR:!0}),i}});var UL=nr,VL=Qt,FL=gL,BL=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=UL(this),r=FL(t),n=VL(e,arguments.length>1?arguments[1]:void 0);return BL(r,(function(e,r){if(n(e,e,t))return r(e)}),{IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var jL=se,HL=N,GL=Oe,zL=nr,KL=xv,XL=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){var t=zL(this),r=new(KL(t,jL("Set"))),n=GL(t.has),i=GL(r.add);return XL(e,(function(e){HL(n,t,e)&&HL(i,r,e)})),r}});var WL=N,YL=Oe,qL=nr,JL=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){var t=qL(this),r=YL(t.has);return!JL(e,(function(e,n){if(!0===WL(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var QL=se,ZL=N,$L=Oe,eU=w,tU=nr,rU=kh,nU=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){var t=rU(this),r=tU(e),n=r.has;return eU(n)||(r=new(QL("Set"))(e),n=$L(r.has)),!nU(t,(function(e,t){if(!1===ZL(n,r,e))return t()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var iU=N,oU=Oe,aU=nr,sU=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){var t=aU(this),r=oU(t.has);return!sU(e,(function(e,n){if(!1===iU(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var cU=Cr,uU=nr,dU=Sn,lU=gL,hU=jh,vU=T([].join),pU=[].push;cU({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=uU(this),r=lU(t),n=void 0===e?",":dU(e),i=[];return hU(r,pU,{that:i,IS_ITERATOR:!0}),vU(i,n)}});var fU=se,_U=Qt,mU=N,gU=Oe,yU=nr,SU=xv,bU=gL,EU=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=yU(this),r=bU(t),n=_U(e,arguments.length>1?arguments[1]:void 0),i=new(SU(t,fU("Set"))),o=gU(i.add);return EU(r,(function(e){mU(o,i,n(e,e,t))}),{IS_ITERATOR:!0}),i}});var kU=Oe,TU=nr,IU=gL,RU=jh,AU=TypeError;Cr({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=TU(this),r=IU(t),n=arguments.length<2,i=n?void 0:arguments[1];if(kU(e),RU(r,(function(r){n?(n=!1,i=r):i=e(i,r,r,t)}),{IS_ITERATOR:!0}),n)throw AU("Reduce of empty set with no initial value");return i}});var wU=nr,CU=Qt,xU=gL,OU=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=wU(this),r=xU(t),n=CU(e,arguments.length>1?arguments[1]:void 0);return OU(r,(function(e,r){if(n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var PU=se,NU=N,DU=Oe,MU=nr,LU=xv,UU=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){var t=MU(this),r=new(LU(t,PU("Set")))(t),n=DU(r.delete),i=DU(r.add);return UU(e,(function(e){NU(n,r,e)||NU(i,r,e)})),r}});var VU=se,FU=Oe,BU=nr,jU=xv,HU=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){var t=BU(this),r=new(jU(t,VU("Set")))(t);return HU(e,FU(r.add),{that:r}),r}});var GU=r(vL),zU=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!xD()&&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,$U();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,ZU();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)}}(),KU=function(){var e=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.next=3,$U();case 3:if(e.t0=e.sent,!e.t0){e.next=8;break}return e.next=7,ZU();case 7:e.t0=e.sent;case 8:if(!e.t0){e.next=10;break}t.push("H264");case 10:return e.next=12,tV();case 12:if(e.t1=e.sent,!e.t1){e.next=17;break}return e.next=16,eV();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)}}(),XU=function(){var e=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,KU();case 2:return t=e.sent,e.abrupt("return",Km(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),WU={};function YU(e){var t,r=!1,n=oI(e.split("\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value;if(bk(i).call(i,"level-asymmetry-allowed=1")&&bk(i).call(i,"packetization-mode=1")&&bk(i).call(i,"profile-level-id=42e0")){r=!0;break}}}catch(u){n.e(u)}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=xm(wm().mark((function e(t){var r,n;return wm().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)}}(),JU=function(){var e=xm(wm().mark((function e(){var t,r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,qU("sendonly");case 2:if(r=e.sent,!bk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,qU("sendonly");case 6:r=e.sent;case 7:return WU.h264encode=YU(r),WU.vp8encode=DE(r).call(r,"vp8")>-1,e.abrupt("return",WU);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),QU=function(){var e=xm(wm().mark((function e(){var t,r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,qU("recvonly");case 2:if(r=e.sent,!bk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,qU("recvonly");case 6:r=e.sent;case 7:return WU.h264decode=YU(r),WU.vp8decode=DE(r).call(r,"vp8")>-1,e.abrupt("return",WU);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ZU=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==WU.h264encode){e.next=9;break}return e.prev=1,e.next=4,JU();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",WU.h264encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),$U=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==WU.h264decode){e.next=9;break}return e.prev=1,e.next=4,QU();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",WU.h264decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),eV=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==WU.vp8encode){e.next=9;break}return e.prev=1,e.next=4,JU();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",WU.vp8encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),tV=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==WU.vp8decode){e.next=9;break}return e.prev=1,e.next=4,QU();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",WU.vp8decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),rV=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},nV=function(){return zD?LD&&aM>=70||DD&&tM>=80||MD&&eM>=14:qD?LD&&aM>=70||DD&&tM>=80:WD?nM[0]>=14:!!YD&&(LD&&aM>=86)},iV=LD&&aM<=114,oV=YD&&LD||WD&&(17===nM[0]||16===nM[0]),aV=new ib,sV=!0,cV=function(){var e=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new $_((function(e){var r={all:[],getTrackStats:function(){return[]}},n=kM("STATS_SCALLBACK_SUPPORT");if(sV&&LD&&void 0===window.InstallTrigger&&iV&&n)try{var i,o,a,s;null===(i=t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!bk(hV).call(hV,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(el(el({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return Ks(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(){sV=!1,e(r)}))}catch(c){sV=!1,e(r)}else e(r)})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),uV=function(){var e=xm(wm().mark((function e(t){var r,n,i,o,a,s,c;return wm().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 ib,n.forEach((function(e){var t=o.get(e.type)||new ib;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(lV.codec))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=o.get(lV.transport))||void 0===n||n.forEach((function(e){e.id===d&&(s=e,t.add(e))})),null===(i=o.get(lV.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(a=o.get(lV.mediaPlayout))||void 0===a||a.forEach((function(e){e.id===h&&t.add(e)})),s){var v,p,f=s,_=f.localCertificateId,m=f.remoteCertificateId,g=f.selectedCandidatePairId;null===(v=o.get(lV.certificate))||void 0===v||v.forEach((function(e){(e.id===_||e.id===m)&&t.add(e)})),null===(p=o.get(lV.candidatePair))||void 0===p||p.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(lV.localCandidate))||void 0===y||y.forEach((function(e){e.id===E&&t.add(e)})),null===(S=o.get(lV.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===k&&t.add(e)}))}}))},o.get(lV.mediaSource)?null===(s=o.get(lV.mediaSource))||void 0===s||s.forEach((function(e){var t,r=new GU;r.add(e);var n=[];null===(t=o.get(lV.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=o.get(lV.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=Zk(r)})):o.get(lV.track)&&(null===(c=o.get(lV.track))||void 0===c||c.forEach((function(e){var t,r=new GU;r.add(e);var n=[];null===(t=o.get(lV.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.trackId===e.id&&(r.add(t),n.push(t),null===(i=o.get(lV.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=Zk(r)}))),null===(r=o.get(lV.inboundRtp))||void 0===r||r.forEach((function(e){var t,r=new GU;r.add(e),null===(t=o.get(lV.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),a([e],r);var n,s=e.trackIdentifier;s||(null===(n=o.get(lV.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(s=t.trackIdentifier)})));i[s]=Zk(r)})),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),dV=function(){var e=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!DD&&!MD){e.next=10;break}return o=[],e.next=7,t.getStats(r);case 7:return e.sent.forEach((function(e){o.push(e)})),e.abrupt("return",o);case 10:return(!(a=aV.get(t))||Date.now()-a.timestamp>150)&&(a={timestamp:Date.now(),statsPromise:uV(t),extraStatsPromise:cV(t)},aV.set(t,a)),e.next=14,a.statsPromise;case 14:if(s=e.sent,c=(i?s[i]:s.all)||[],n){e.next=21;break}return e.next=19,a.extraStatsPromise;case 19:u=e.sent,c=Mm(c).call(c,(i?u.getTrackStats(i):u.all)||[]);case 21:return e.abrupt("return",c);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),lV=function(e){return e.codec="codec",e.inboundRtp="inbound-rtp",e.outboundRtp="outbound-rtp",e.remoteInboundRtp="remote-inbound-rtp",e.remoteOutboundRtp="remote-outbound-rtp",e.mediaSource="media-source",e.csrc="csrc",e.peerConnection="peer-connection",e.dataChannel="data-channel",e.stream="stream",e.track="track",e.transceiver="transceiver",e.sender="sender",e.receiver="receiver",e.transport="transport",e.sctpTransport="sctp-transport",e.candidatePair="candidate-pair",e.localCandidate="local-candidate",e.remoteCandidate="remote-candidate",e.certificate="certificate",e.iceServer="ice-server",e.mediaPlayout="media-playout",e}(lV||{}),hV=["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"],vV={},pV={},fV={exports:{}},_V=fV.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"]}]};cn(_V).forEach((function(e){_V[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}));var mV=fV.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=mV,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t,o={},a=[],s=o;return Ks(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=Am(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 gb(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return Km(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=Km(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 Km(t=e.split(" ")).call(t,(function(e){var t;return gb(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return Km(r=e.split(";")).call(r,(function(e){var r;return Km(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}}))}))}}(pV);var gV=mV,yV=/%[sdv%]/g,SV=function(e){var t=1,r=arguments,n=r.length;return e.replace(yV,(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""}}))},bV=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 SV.apply(null,n)},EV=["v","o","s","i","u","e","p","c","b","t","r","z","a"],kV=["i","c","b","a"],TV=pV,IV=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||EV,n=t.innerOrder||kV,i=[];return r.forEach((function(t){gV[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(bV(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(bV(t,r,e))}))}))})),e.media.forEach((function(e){i.push(bV("m",gV.m[0],e)),n.forEach((function(t){gV[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(bV(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(bV(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};vV.write=IV,vV.parse=TV.parse,vV.parseParams=TV.parseParams,vV.parseFmtpConfig=TV.parseFmtpConfig,vV.parsePayloads=TV.parsePayloads,vV.parseRemoteCandidates=TV.parseRemoteCandidates,vV.parseImageAttributes=TV.parseImageAttributes,vV.parseSimulcastStreamList=TV.parseSimulcastStreamList;var RV=qe,AV=Ur,wV=Hr,CV=function(e){for(var t=RV(this),r=wV(t),n=arguments.length,i=AV(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:AV(o,r);a>i;)t[i++]=e;return t};Cr({target:"Array",proto:!0},{fill:CV});var xV=Bs("Array").fill,OV=ce,PV=xV,NV=Array.prototype,DV=r((function(e){var t=e.fill;return e===NV||OV(NV,e)&&t===NV.fill?PV:t})),MV=new fN("FirefoxHandler",3),LV=Math.pow(2,32),UV="kp34Za0H+aVf862l";function VV(e){return e>LV-18?(MV.warn("generateAllSsrc","reset start id",e),VV(e=e-LV+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var FV=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:Mm(n=Mm(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Mm(o="".concat(e,"-")).call(o,t)}]},BV=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=gb(s).call(s,(function(t,r){return Mm(t).call(t,FV(e,"video",r,c))}),[]),h=[{semantics:"FID",ssrcs:Mm(r="".concat(i," ")).call(r,o)}];u&&h.push({semantics:"FEC-FR",ssrcs:Mm(d="".concat(i," ")).call(d,a)});return{ssrcs:l,ssrcGroups:h}};function jV(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 HV=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=el(el({},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,vV.write(i)};function GV(e){return zV.apply(this,arguments)}function zV(){return(zV=xm(wm().mark((function e(t){var r,n,i,o,a;return wm().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,XV(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=KV(n,a),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function KV(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(el(el({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(el(el({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var XV=function(){var e=xm(wm().mark((function e(t){var r,n,i,o,a,s,c;return wm().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,nD.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=rD(Uint8Array,n,i,o,a),e.next=15,nD.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)}}(),WV=function(e){return e[e.kICEConfigTypeSrtpDtlsType=0]="kICEConfigTypeSrtpDtlsType",e[e.kICEConfigTypeRenominationType=1]="kICEConfigTypeRenominationType",e[e.kICEConfigTypeTcpType=2]="kICEConfigTypeTcpType",e[e.kICEConfigTypeMultiSendType=3]="kICEConfigTypeMultiSendType",e[e.kICEConfigTypeKcpType=4]="kICEConfigTypeKcpType",e[e.kICEConfigTypeSrtpSdesType=5]="kICEConfigTypeSrtpSdesType",e}(WV||{});function YV(e){var t,r=e.random,n=e.serverUfrag,i=e.serverPwd,o=e.clientPwd,a=e.options,s=(new TextEncoder).encode("WPRE");r||(r=new Uint8Array(4),crypto.getRandomValues(r));var c=RD(n);c.byteLength;var u=wD(RD(o),RD(i).subarray(0,16),RD(n).subarray(0,16));u.byteLength;var d=new Uint8Array(gb(t=cn(a)).call(t,(function(e,t){var r=Number(t);return e.push(r),e.push(a[r]?1:0),e}),[]));d.byteLength;var l,h=rD(Uint8Array,s,r,[c.byteLength],c,[u.byteLength],u,d);h.byteLength%3!=0&&(h=rD(Uint8Array,h,DV(l=new Uint8Array(3-h.byteLength%3)).call(l,255)));return[AD(h),AD(rD(Uint8Array,r,c.subarray(0,20)))]}var qV=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=oI(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(bk(o=c.config).call(o,"level-asymmetry-allowed=1")&&bk(a=c.config).call(a,"packetization-mode=1")&&bk(s=c.config).call(s,"profile-level-id=42e0")){r=c.payload;break}}}catch(p){i.e(p)}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(ak(l=e.rtp).call(l,u,1)[0]);break}}else if(d.codec===t){var h;e.rtp.unshift(ak(h=e.rtp).call(h,u,1)[0]);break}}var v=[];e.rtp.forEach((function(e){return v.push(e.payload)})),e.payloads=v.join(" ")}},JV=function(e){var t,r=vV.parse(e);return r.media=Km(t=r.media).call(t,(function(e){return"audio"===e.type?ZV(e,r):QV(e,["H264","VP8"],r)})),vV.write(r)},QV=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(fA(r).call(r,"apt=")){var n=Am(r).call(r,4);u[t]=n}else bk(r).call(r,"42e0")&&bk(r).call(r,"packetization-mode=1")&&(l=t)})),Array.isArray(e.rtp))&&(e.rtp=Ks(n=e.rtp).call(n,(function(e){var r,n=e.codec,i=e.payload;switch(n){case"H264":return r=!1,Km(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":return d[i]=i,!0;default:return r=!1,Km(t).call(t,(function(e){e===n&&(d[i]=i,h.push(i),r=!0)})),r}})));Array.isArray(e.fmtp)&&(e.fmtp=Ks(i=e.fmtp).call(i,(function(e){return d[e.payload]})));Array.isArray(e.rtcpFb)?e.rtcpFb=Ks(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"})})),$V(e,r),Array.isArray(e.ext))&&(e.ext=Ks(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=Ks(s=e.payloads.split(" ")).call(s,(function(e){return d[e]})).join(" "));return e},ZV=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{rrtr:!1},i={};Array.isArray(e.rtp)&&(e.rtp=Ks(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&&cn(i).forEach((function(t){var r;null===(r=e.rtcpFb)||void 0===r||r.push({payload:Number(t),type:"rrtr"})})),$V(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},$V=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)},eF=function(e){UI(n,e);var t,r=eR(n);function n(e,t){var i;return Hl(this,n),Zd(sI(i=r.call(this)),"_peerConnection",void 0),Zd(sI(i),"_dataChannel",void 0),Zd(sI(i),"_context",void 0),Zd(sI(i),"peerConnectionMode",0),Zd(sI(i),"id",void 0),Zd(sI(i),"_monitor",void 0),Zd(sI(i),"logger",void 0),Zd(sI(i),"_nextSsrc",Math.floor(Math.random()*LV+1e4)),Zd(sI(i),"_aSendonlyAnswerTpl",void 0),Zd(sI(i),"_vSendonlyAnswerTpl",void 0),Zd(sI(i),"_enableSubFlexfec",!1),Zd(sI(i),"audioTrack4ff",void 0),Zd(sI(i),"setLocalDescription",void 0),Zd(sI(i),"setRemoteDescription",void 0),i.peer=t,i.id=e.id,i._monitor=YP(i.id),i.logger=new fN("BasicHandler",3,e.id),i._peerConnection=t.getOriginRTCPeerConnection(),i._dataChannel=t.getOriginRTCDataChannel(),i.setLocalDescription=t.setLocalDescription.bind(t),i.setRemoteDescription=t.setRemoteDescription.bind(t),i._context=e,i.peer.on("ontrack",(function(e){i.emit("ontrack",e)})),i}return jl(n,[{key:"destroy",value:function(){this.logger.info("destroy",this.peerConnectionId||""),MI(DI(n.prototype),"removeAllListeners",this).call(this)}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"getConnectionState",value:function(){return this._peerConnection.connectionState}},{key:"_simulcast",value:function(e,t,r,n,i){var o,a,s,c=[];1===e.videoEncodeConfig.length?(c=function(e,t){var r=[];if(t<=1)return r;var n=Math.min(e.width,e.height)/90;return r.push({scaleResolutionDownBy:n,width:Math.floor(e.width/n),height:Math.floor(e.height/n),maxkbps:100,frameRate:10}),t<=2||r.unshift({scaleResolutionDownBy:2,width:Math.floor(e.width/2),height:Math.floor(e.height/2),maxkbps:Math.floor(e.maxKbps/2),frameRate:e.frameRate>=30?Math.floor(e.frameRate/2):e.frameRate}),r}(t,i),this.logger.info("simulcast() ","simulcastLayers: %o",c)):(c=Km(o=Am(a=Am(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){var r=ID(e.width),n=t.width/r;return{width:r,height:Math.floor(t.height/n),scaleResolutionDownBy:n,frameRate:ID(e.frameRate)||15,maxkbps:e.maxKbps||600}})),this.logger.info("simulcast() ","simulcastLayers2: %o",c));var u=[!0];c.forEach((function(e,t){var i,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:e.scaleResolutionDownBy,rid:"".concat(t+1),maxFramerate:e.frameRate};null===(i=r.sendEncodings)||void 0===i||i.unshift(o),n.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)}),u.push(!0)})),this._context&&(this._context.activeSimStreams=u)}},{key:"internalPublish",value:function(e){var t=e.stream,r=e.videoTrack,n=e.audioTrack,i=e.enableSimulcast,o=e.pubAudio,a=e.pubVideo,s={direction:"sendonly",streams:[t]},c={direction:"sendonly",streams:[t]},u=[],d=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var l=null==r?void 0:r.getTrack(),h=el({},AM);if(l){var v=null==l?void 0:l.getSettings();h={width:Math.floor(v.width),height:Math.floor(v.height),frameRate:Math.floor(v.frameRate)}}"number"!=typeof h.frameRate&&(h.frameRate=30);var p=null==e?void 0:e.videoEncodeConfig[0],f={maxBitrate:1e3*p.maxKbps,rid:"0"};if(e.prevBitrate=p.maxKbps,c.sendEncodings=[f],u.push({width:h.width,height:h.height,framerate:h.frameRate,maxkbps:p.maxKbps,rid:"0"}),!DD&&i){var _,m,g=function(e){for(var t=0,r=e.width*e.height,n=0;n<hL.length;n++)if(r>=hL[n].totalPixels){t=n;break}if(0===t)return hL[t].maxLayers;var i=hL[t-1].totalPixels;return(i-r)/(i-hL[t].totalPixels)<.1?hL[t-1].maxLayers:hL[t].maxLayers}(h);if(this.logger.info("simulcast() ","maxLayers: %o",g),g>1)this._simulcast(e,el(el({},h),{},{maxKbps:p.maxKbps}),c,u,g),null!==(_=this._context)&&void 0!==_&&null!==(m=_.serverConfig)&&void 0!==m&&m.simulcastOnDemand&&(d=Km(u).call(u,(function(e,t){return el(el({},e),{},{video_index:t,sub_index:t})})))}}this.logger.info("publish videoTransceiverInit videoDescriptions","",c,u);var y=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==Ll.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(y=null==n?void 0:n.mixedAudioTrack),y=o&&y?y:"audio";var S=null==r?void 0:r.getTrack("preprocessing");S=a&&S?S:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",Fm({aTrack:Ew(y),vTrack:Ew(S),audioTransceiverInit:s,videoTransceiverInit:c}))}catch(Iq){}return{semantics:"unified-plan",videoDescriptions:u,subVideoDescriptions:d,audioTransceiverInit:{track:y,init:s},videoTransceiverInit:{track:S,init:c}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;this.logger.info("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.getTrack(),a=e.videoTransceiver;if(o&&e.pubVideo&&a){var s=null===(r=e.videoEncodeConfig)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.maxKbps;if(s){if(s===e.prevBitrate)return void 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:Km(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",Fm(c.encodings))}catch(Iq){}}}else this.logger.warn("updateMaxBitrate()","no pub")}},{key:"getStats",value:function(e,t){return dV(this._peerConnection,e,t)}},{key:"setCurrentDescription",value:(t=xm(wm().mark((function e(){return wm().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;vV.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:kE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:kE(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&&bk(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))}))}},{key:"pc",get:function(){return this._peerConnection}},{key:"peerConnectionId",get:function(){return this.peer.getConnectionId()||""}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n,i=r.codec,o=r.payload;if(bk(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=kE(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=Mm(s=[]).call(s,eT(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,el(el({},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}(JM.EventEmitter),tF=function(e){UI(v,e);var t,r,n,i,o,a,s,c,u,d,l,h=eR(v);function v(){var e,t,r;return Hl(this,v),Zd(sI(r=h.call(this)),"inited",!1),Zd(sI(r),"deviceMap",{audioinput:new ib,audiooutput:new ib,videoinput:new ib}),Zd(sI(r),"checkDeviceChangeTimer",null),Zd(sI(r),"isSupportedPermissionsQuery",!1),Zd(sI(r),"isGrantedMicrophonePermission",!1),Zd(sI(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!xD()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(sI(r)),!xD()&&r.refreshDevices(),r}return jl(v,[{key:"refreshDevices",value:(l=xm(wm().mark((function e(){var t,r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices){e.next=2;break}return e.abrupt("return");case 2:if(t=void 0,!DD){e.next=12;break}return e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:!0});case 7:t=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:return e.next=14,navigator.mediaDevices.enumerateDevices();case 14:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),r.forEach((function(e){var t;e.deviceId&&(null===(t=n.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))})),this.inited||this.initListener(),this.inited=!0;case 19:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return l.apply(this,arguments)})},{key:"initListener",value:(d=xm(wm().mark((function e(){var t,r,n,i,o=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.ondevicechange)&&"function"==typeof(null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)?navigator.mediaDevices.addEventListener("devicechange",(function(){o._handleDeviceChange(),setTimeout((function(){o._handleDeviceChange()}),300)})):this.checkDeviceChangeTimer=window.setInterval((function(){o._handleDeviceChange()}),3e3),!this.isSupportedPermissionsQuery){e.next=22;break}return e.prev=2,e.next=5,navigator.permissions.query({name:"microphone"});case 5:n=e.sent,this.isGrantedMicrophonePermission="granted"===n.state,n.addEventListener("change",(function(){o.isGrantedMicrophonePermission="granted"===n.state})),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.prev=12,e.next=15,navigator.permissions.query({name:"camera"});case 15:i=e.sent,this.isGrantedCameraPermission="granted"===i.state,i.addEventListener("change",(function(){o.isGrantedCameraPermission="granted"===i.state})),e.next=22;break;case 20:e.prev=20,e.t1=e.catch(12);case 22:case"end":return e.stop()}}),e,this,[[2,10],[12,20]])}))),function(){return d.apply(this,arguments)})},{key:"_handleDeviceChange",value:(u=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=void 0,!DD){e.next=5;break}return e.next=4,navigator.mediaDevices.getUserMedia({audio:!0});case 4:o=e.sent;case 5:return e.next=7,navigator.mediaDevices.enumerateDevices();case 7:a=e.sent,a=Ks(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=Zk(Mm(t=[]).call(t,eT(cR(r=this.deviceMap.audioinput).call(r)),eT(cR(n=this.deviceMap.videoinput).call(n)),eT(cR(i=this.deviceMap.audiooutput).call(i)))),(XD||GD)&&!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||(bk(t=e.kind).call(t,"video")?c.emit(Fl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):bk(r=e.kind).call(r,"audio")&&c.emit(Fl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;kE(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),bk(t=e.kind).call(t,"video")?c.emit(Fl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):bk(r=e.kind).call(r,"audio")&&c.emit(Fl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 14:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getUserMedia",value:(c=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia(t);case 2:return r=e.sent,null!=t&&t.audio&&(this.isGrantedMicrophonePermission=!0),null!=t&&t.video&&(this.isGrantedCameraPermission=!0),this.refreshDevices(),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(s=xm(wm().mark((function e(){var t,r;return wm().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=Ks(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=Ks(r).call(r,(function(e){return"videoinput"===e.kind&&e.label&&e.deviceId})).length>0,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"getPermissions",value:(a=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l=arguments;return wm().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:return e.next=72,this.refreshDevices();case 72:return e.abrupt("return",a);case 73:case"end":return e.stop()}}),e,this,[[31,38]])}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=xm(wm().mark((function e(){var t,r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions();case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Zk(Mm(t=[]).call(t,eT(cR(r=this.deviceMap.audioinput).call(r)),eT(cR(n=this.deviceMap.videoinput).call(n)),eT(cR(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=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Zk(cR(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=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({video:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Zk(cR(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=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Zk(cR(t=this.deviceMap.audiooutput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getDeviceById",value:(t=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateDevices();case 2:return r=e.sent,e.abrupt("return",kE(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}($M),rF=new tF;!xD()&&(window.__rtc_dd__=rF);var nF=new fN("InternalEventBus",1),iF=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}(iF||{}),oF=function(e){UI(r,e);var t=eR(r);function r(){return Hl(this,r),t.apply(this,arguments)}return jl(r,[{key:"emit",value:function(e){var t,n;nF.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=MI(DI(r.prototype),"emit",this)).call.apply(t,Mm(n=[this,e]).call(n,o))}}]),r}(JM.EventEmitter),aF=new oF,sF=new fN("AudioContext",1),cF=function(){function e(){var t=this;Hl(this,e),Zd(this,"_audioContextInstance",void 0),Zd(this,"_previousState",""),Zd(this,"_currentState",""),Zd(this,"_contextStuckAt",0);var r=0;xD()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,sF.info("currentTime resume"),XP("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,sF.warn("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),XP("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return jl(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;sF.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(),(WD||GD)&&("running"===e._previousState&&"interrupted"===e._currentState&&aF.emit(iF.ON_IOS_INTERRUPTION_START),"interrupted"===e._previousState&&"running"===e._currentState&&aF.emit(iF.ON_IOS_INTERRUPTION_END))}}return this._audioContextInstance}}]),e}(),uF=function(){function e(t){Hl(this,e),Zd(this,"_ctx",void 0),Zd(this,"_analyserNode",void 0),Zd(this,"_audioSource",void 0),Zd(this,"currentTrackId",void 0),this.currentTrackId=t.id;var r=dF.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 jl(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=xm(wm().mark((function e(){var t;return wm().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}(),dF=new cF,lF=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}(lF||{}),hF=function(){function e(t){Hl(this,e),Zd(this,"_plugins",new ib),this.id=t}var t;return jl(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(eA(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 kE(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=xm(wm().mark((function e(t){var r,n,i,o,a;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.getTrack(),i=oI(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}(),vF=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(vF||{}),pF=new fN("VERTC",0),fF=function(e){UI(r,e);var t=eR(r);function r(e,n){var i;return Hl(this,r),Zd(sI(i=t.call(this)),"sourceType",1),Zd(sI(i),"mediaType",void 0),Zd(sI(i),"_trackId",void 0),Zd(sI(i),"_ac",void 0),Zd(sI(i),"_sourceNode",void 0),Zd(sI(i),"_gainNode",void 0),Zd(sI(i),"_destNode",void 0),Zd(sI(i),"_channelCount",void 0),i._trackId=e,i.mediaType=n,"audio"===n&&nV()&&!kM("SKIP_WEB_AUDIO_IN_TRACK")&&(i._ac=dF.getAudioContextInstance(),i._gainNode=i._ac.createGain(),i._destNode=i._ac.createMediaStreamDestination(),i._gainNode.connect(i._destNode)),i}return jl(r,[{key:"getId",value:function(){return this._trackId}},{key:"setVolume",value:function(e){this._gainNode&&(this._gainNode.gain.value=e/100)}},{key:"getVolume",value:function(){return this._gainNode?Math.round(100*this._gainNode.gain.value):-1}},{key:"channelCount",get:function(){var e;return null!==(e=this._channelCount)&&void 0!==e?e:0}},{key:"connectAudioTrack",value:function(e){var t;if(this._channelCount=e.getSettings().channelCount,!nV()||kM("SKIP_WEB_AUDIO_IN_TRACK"))return e;this._sourceNode&&(this._sourceNode.mediaStream.getTracks().forEach((function(e){e.stop()})),delete this._sourceNode);var r,n=new MediaStream;(n.addTrack(e),this._sourceNode=null===(t=this._ac)||void 0===t?void 0:t.createMediaStreamSource(n),this._gainNode)&&(null===(r=this._sourceNode)||void 0===r||r.connect(this._gainNode));return this._destNode.stream.getTracks()[0]}},{key:"destroy",value:function(){var e,t,r,n;(null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),13!==eM)&&(null===(n=this._destNode)||void 0===n||n.stream.getTracks().forEach((function(e){e.stop()})));null===(t=this._sourceNode)||void 0===t||t.disconnect(),null===(r=this._gainNode)||void 0===r||r.disconnect(),delete this._sourceNode,delete this._gainNode,delete this._destNode}}]),r}($M),_F=function(e){UI(n,e);var t,r=eR(n);function n(e,t,i){var o;return Hl(this,n),Zd(sI(o=r.call(this,t,i)),"_mediaTrack",void 0),Zd(sI(o),"_preProcessingTrack",void 0),Zd(sI(o),"_originTrack",void 0),Zd(sI(o),"captureSessionId",""),Zd(sI(o),"handleTrackEnded",(function(){o.emit("track-ended",sI(o)),o.close()})),Zd(sI(o),"handleMute",(function(){o.emit("track-mute",sI(o))})),Zd(sI(o),"handleUnmute",(function(){o.emit("track-unmute",sI(o))})),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o._initListeners(),o}return jl(n,[{key:"getTrack",value:function(){return"origin"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"origin")?this._mediaTrack:this._preProcessingTrack||this._mediaTrack}},{key:"setTrack",value:function(e,t){this._mediaTrack="audio"===this.mediaType?this.connectAudioTrack(e):e,this._originTrack=e,t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._preProcessingTrack=void 0,e.prev=1,e.next=4,t.getPreProcessingTrack(this);case 4:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e){return t.apply(this,arguments)})},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){var e;return this._mediaTrack.onended=null,this._mediaTrack.onmute=null,this._mediaTrack.onunmute=null,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(),"audio"===this.mediaType?this.destroy():this._mediaTrack.stop()}},{key:"_initListeners",value:function(){this._originTrack instanceof MediaStreamTrack&&(this._originTrack.addEventListener("ended",this.handleTrackEnded),this._originTrack.addEventListener("mute",this.handleMute),this._originTrack.addEventListener("unmute",this.handleUnmute))}}]),n}(fF),mF=function(e){UI(r,e);var t=eR(r);function r(e,n,i){var o;return Hl(this,r),Zd(sI(o=t.call(this,n,i)),"_mediaTrack",void 0),Zd(sI(o),"_originTrack",void 0),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o}return jl(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){return this.destroy()}}]),r}(fF),gF=function(e){UI(n,e);var t,r=eR(n);function n(e,t){var i;return Hl(this,n),Zd(sI(i=r.call(this,e,t,"video")),"resolution",void 0),Zd(sI(i),"dummy",!1),i.resolution={width:0,height:0},i}return jl(n,[{key:"updateVideoCaptureConfig",value:(t=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return pF.info("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=el({},t)).contentHint,DD&&this.streamIndex===dl.STREAM_INDEX_MAIN&&(r.frameRate={ideal:30,max:30}),e.next=8,this.getTrack().applyConstraints(r);case 8:((n=this.getTrack().getSettings()).width&&n.width!==this.resolution.width||n.height&&n.height!==this.resolution.height)&&(this.resolution={width:n.width,height:n.height},this.emit("resolution-change",this.resolution));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){var t;this._mediaTrack&&"contentHint"in this._mediaTrack&&bk(t=["text","motion","detail"]).call(t,e)&&(this._mediaTrack.contentHint=e)}}]),n}(_F),yF=function(e){UI(n,e);var t,r=eR(n);function n(e,t){var i;return Hl(this,n),Zd(sI(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),Zd(sI(i),"mixedAudioTrack",void 0),Zd(sI(i),"mixType",Ll.PLAYOUT_AND_PUBLISH),Zd(sI(i),"_audioFetchMap",new ib),i}return jl(n,[{key:"getAudioLevel",value:function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_l.MICROPHONE,n=r===_l.AUDIOMIXING&&this.mixType!==Ll.PLAYOUT&&null!==(e=this.mixedAudioTrack)&&void 0!==e?e:this.getTrack("preprocessing"),i=this._audioFetchMap.get(r);i&&i.currentTrackId===n.id||(null===(t=i)||void 0===t||t.destroy(),i=new uF(n),this._audioFetchMap.set(r,i));return i.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=xm(wm().mark((function e(){return wm().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 pF.info("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,this.getOrgTrack().applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){this._audioFetchMap.forEach((function(e){return e.destroy()})),this._audioFetchMap.clear(),MI(DI(n.prototype),"close",this).call(this)}}]),n}(_F),SF=function(e){UI(r,e);var t=eR(r);function r(e,n){return Hl(this,r),t.call(this,e,n,"video")}return jl(r)}(mF),bF=function(e){UI(r,e);var t=eR(r);function r(e,n){var i;return Hl(this,r),Zd(sI(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return jl(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new uF(this.getOrgTrack())),this._audioLevelFetcher.getAudioLevel()}},{key:"close",value:function(){var e;null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),MI(DI(r.prototype),"close",this).call(this)}}]),r}(mF),EF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Mm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_MAIN),n}return jl(r)}(yF),kF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Mm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_MAIN),n}return jl(r)}(gF),TF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Mm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_MAIN),Zd(sI(n),"sourceType",0),n}return jl(r)}(gF),IF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Mm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_MAIN),Zd(sI(n),"sourceType",0),n}return jl(r)}(yF),RF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Mm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_SCREEN),n}return jl(r)}(gF),AF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Mm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_SCREEN),n}return jl(r)}(yF),wF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Mm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_SCREEN),Zd(sI(n),"sourceType",0),n}return jl(r)}(gF),CF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Mm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_SCREEN),Zd(sI(n),"sourceType",0),n}return jl(r)}(yF);function xF(e,t){return OF.apply(this,arguments)}function OF(){return(OF=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new kF(t,eD())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function PF(e,t){return NF.apply(this,arguments)}function NF(){return(NF=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new RF(t,eD())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function DF(e,t){return MF.apply(this,arguments)}function MF(){return(MF=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return wm().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=YP(r.id),s=eD(),e.prev=3,pF.info("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o,capture_session_id:s}),u=tD(),DD&&(t.frameRate={ideal:30,max:30}),e.next=10,rF.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:tD()-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 SA(_A.GET_VIDEO_TRACK_FAILED,Mm(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 kF(l,eD())).captureSessionId=s,e.next=23,h.generatePreProcessingTrack(r);case 23:return e.abrupt("return",h);case 24:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function LF(e,t){return UF.apply(this,arguments)}function UF(){return(UF=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return pF.info("createMicrophoneAudioTrack","constraints:",t),o=(null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=YP(r.id),s=eD(),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=tD(),(d=r.getPluginByName(lF.PRE_PROCESSING,"RTCAIAnsExtension"))&&(d.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=11,rF.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:tD()-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 SA(_A.GET_AUDIO_TRACK_FAILED,Mm(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],(v=new EF(h,eD())).captureSessionId=s,e.next=24,v.generatePreProcessingTrack(r);case 24:return e.abrupt("return",v);case 25:case"end":return e.stop()}}),e,null,[[4,15]])})))).apply(this,arguments)}function VF(e,t,r){return FF.apply(this,arguments)}function FF(){return(FF=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return pF.print("createCameraAndMicrophoneTrack","audioConstraints:",t,"videoConstraints:",r),a=YP(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=eD(),l=eD(),eD(),eD(),e.prev=8,null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:u,capture_session_id:d}),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_begin",media_device_id:c,event_session_id:l}),p=tD(),DD&&(r.frameRate={ideal:30,max:30}),(f=n.getPluginByName(lF.PRE_PROCESSING,"RTCAIAnsExtension"))&&(f.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=17,rF.getUserMedia({audio:t,video:r});case 17:s=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:u,media_device_name:(null===(h=s.getVideoTracks()[0])||void 0===h?void 0:h.label)||"",reason:"success",elapse:tD()-p,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===(v=s.getAudioTracks()[0])||void 0===v?void 0:v.label)||"",reason:"success",elapse:tD()-p,event_session_id:l}),e.next=27;break;case 22:throw e.prev=22,e.t0=e.catch(8),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:u,error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:d}),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_end",media_device_id:c,error_code:e.t0.code,reason:e.t0.name+e.t0.message,event_session_id:l}),new SA(_A.GET_VIDEO_TRACK_FAILED,Mm(_="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(_,e.t0.message||"unknown message","."),e.t0);case 27:return m=s.getVideoTracks()[0],(g=new kF(m,eD())).captureSessionId=d,e.next=32,g.generatePreProcessingTrack(n);case 32:return y=s.getAudioTracks()[0],(S=new EF(y,eD())).captureSessionId=l,e.next=37,S.generatePreProcessingTrack(n);case 37:return e.abrupt("return",{videoTrack:g,audioTrack:S});case 38:case"end":return e.stop()}}),e,null,[[8,22]])})))).apply(this,arguments)}function BF(){return jF.apply(this,arguments)}function jF(){return jF=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,v,p,f=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=f.length>0&&void 0!==f[0]&&f[0],r=f.length>1?f[1]:void 0,n=f.length>2?f[2]:void 0,pF.info("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=YP(r.id),a=eD(),e.prev=6,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen",capture_session_id:a}),d=tD(),e.next=11,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!MD||"16.1"!==rM))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!0,autoGainControl:!1}});case 11:i=e.sent,null==o||o.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",media_device_name:Mm(s="".concat((null===(c=i.getVideoTracks()[0])||void 0===c?void 0:c.label)||"",", ")).call(s,(null===(u=i.getAudioTracks()[0])||void 0===u?void 0:u.label)||""),reason:"success",elapse:tD()-d,capture_session_id:a}),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(6),null==o||o.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:"screen",error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:a}),new SA(_A.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 19:return l=i.getVideoTracks()[0],(h=new RF(l,eD())).captureSessionId=a,e.next=24,h.generatePreProcessingTrack(r);case 24:if(!(v=i.getAudioTracks()[0])){e.next=30;break}return p=new AF(v,eD()),e.next=29,p.generatePreProcessingTrack(r);case 29:return e.abrupt("return",[h,p]);case 30:return e.abrupt("return",[h,void 0]);case 31:case"end":return e.stop()}}),e,null,[[6,15]])}))),jF.apply(this,arguments)}function HF(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:eD();return new bF(e,t)}function GF(e,t){return zF.apply(this,arguments)}function zF(){return(zF=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new TF(t,eD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function KF(e,t){return XF.apply(this,arguments)}function XF(){return(XF=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new IF(t,eD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function WF(e,t){return YF.apply(this,arguments)}function YF(){return(YF=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new wF(t,eD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function qF(e,t){return JF.apply(this,arguments)}function JF(){return(JF=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new CF(t,eD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var QF=yF,ZF=bF,$F=function(e){return e[e.NONE=0]="NONE",e}($F||{}),eB={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)?eB.getAnnexbNals(e):eB.getAvccNals(e)},getAnnexbNals:function(e){for(var t=[],r=eB.getHeaderPositionAnnexB(e),n=r.pos,i=n;n<e.length-4;){var o,a,s=new Uint8Array(Am(o=e.buffer).call(o,n,n+r.headerLength));r.pos===e.position&&e.skip(r.headerLength),i=(r=eB.getHeaderPositionAnnexB(e)).pos;var c={header:s,body:new Uint8Array(Am(a=e.buffer).call(a,n+s.byteLength,i)),type:-1};eB.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(Am(n=e.buffer).call(n,e.position,e.position+4));e.skip(4);var a=new Uint8Array(Am(i=e.buffer).call(i,e.position,e.position+r));e.skip(r);var s={header:o,body:a,type:-1};eB.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}}},tB=function(){function e(t){Hl(this,e),Zd(this,"_position",0),Zd(this,"_dataview",void 0),this._dataview=new DataView(t)}return jl(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}(),rB=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(rB||{}),nB=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),iB=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]);function oB(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function aB(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 sB=function(){function e(){Hl(this,e)}return jl(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?nB:iB,s=oB(e.byteLength+a.byteLength),c=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]&&t.push(3),t.push(e[r]);return new Uint8Array(t)}(e);return new Uint8Array(Mm(t=[]).call(t,eT(n),eT(i),eT(o),eT(s),eT(a),eT(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=Am(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=aI(aB(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=iB.byteLength&&i>=iB.byteLength&&Am(t).call(t,r,r+iB.byteLength).toString()===iB.toString()?(r+=iB.byteLength,o=1):t.byteLength>=iB.byteLength&&i>=iB.byteLength&&Am(t).call(t,r,r+nB.byteLength).toString()===nB.toString()&&(r+=nB.byteLength,o=0),{type:o,payload:Am(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new ib,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=aI(aB(e.payload,r),2),i=n[0];r=n[1];var o,a=aI(aB(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,Am(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=oI(e);try{for(n.s();!(t=n.n()).done;){var i=aI(t.value,2),o=i[0],a=i[1],s=oB(o),c=oB(a.byteLength);r.push(s,c,a)}}catch(l){n.e(l)}finally{n.f()}var u=gb(r).call(r,(function(e,t){return e+t.byteLength}),0),d=new Uint8Array(u);return gb(r).call(r,(function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),cB=function(){function e(t){Hl(this,e),Zd(this,"player",void 0),Zd(this,"_timer",void 0),Zd(this,"handler",void 0),Zd(this,"_monitor",void 0),Zd(this,"logger",void 0),Zd(this,"_destroyed",!1),this._context=t,this._monitor=YP(t.id),this.logger=new fN("Stats",3,t.id)}return jl(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,$P(this._context.id,"del_media_statistics_timer",Mm(t="reason: ".concat(e,", stack: ")).call(t,(new Error).stack),0,this._stream.streamId||""))}},{key:"filterIllegal",value:function(e){var t={};return cn(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"),$P(this._context.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.stopReport("destroy"),this._destroyed=!0}}]),e}(),uB=function(e){UI(i,e);var t,r,n=eR(i);function i(e,t){var r;return Hl(this,i),(r=n.call(this,e))._stream=t,r}return jl(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.getTrack("preprocessing"),u=null===(n=s.videoTrack)||void 0===n?void 0:n.getTrack("preprocessing");this.getAudioStats(c,a,null===(i=s.audioTrack)||void 0===i?void 0:i.getAudioLevel()),this.getVideoStats(u,a);var d=function(){var e=xm(wm().mark((function e(){var t,r,n,i,c,u,d;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=s.audioTrack)||void 0===t?void 0:t.getTrack("preprocessing"),c=null===(r=s.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,o.getAudioStats(i,a,null===(n=s.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return u=e.sent,e.next=7,o.getVideoStats(c,a);case 7:return d=e.sent,e.abrupt("return",{audioStats:u,videoStats:d,isScreen:s.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),l=function(){var t=xm(wm().mark((function t(){var r;return wm().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=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,p,f,_,m,g;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s={},c={timestamp:Date.now()},u=this._stream,d=u.streamId,l=u.audioMid,h=u.isScreen,v=u.pubAttributes,p=u.pubAudio,f=u.audioTrack,_={media_type:"audio",is_screen:!!h,direction:"up",stream_id:d,vid:l,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:v.localaudio?"capture_state_on":"capture_state_off",mute_state:p?"mute_state_off":"mute_state_on"},f&&(_.playback_volume=f.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",s);case 7:return e.next=9,this.handler.getStats(t);case 9:if((m=e.sent).length){e.next=12;break}return e.abrupt("return",s);case 12:if(m.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,o=e.clockRate,a=e.roundTripTime,u=e.channels,d=e.audioLevel;e.googRtt;var l=e.mimeType,h=e.availableIncomingBitrate,v=e.availableOutgoingBitrate,p=e.bytesReceived,f=e.nominated,m=e.id,g=e.currentRoundTripTime,y=e.state,S=e.writable,b=e.requestsReceived,E=e.responsesReceived,k=e.requestsSent,T=e.consentRequestsSent,I=e.responsesSent,R=e.jitter,A=e.candidateType,w=e.ip,C=e.address,x=e.networkType,O=e.port,P=e.protocol,N=e.nackCount,D=e.retransmittedBytesSent,M=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(c.packetsSent=r,c.bytesSent=i,_.bytes=i,_.packetsSent=r,_.nackCount=N,_.ssrc=U,_.retransmitted_bytes_sent=D,_.retransmitted_packets_sent=M,c.retransmittedBytesSent=D,c.retransmittedPacketsSent=M):"remote-inbound-rtp"===t?(c.packetsLost=n,_.packetsLost=n,_.net_jitter=1e3*R,s.rtt=1e3*a,_.rtt=s.rtt,s._fractionLost=j||0):"codec"===t?(s.recordSampleRate=o,s.numChannels=u,_.codecName=l):"media-source"===t&&void 0!==d?(_.audio_level=d?-10*rw(Math.pow(d,2)):d,_.volume=255*d,_.total_audio_energy=V,_.totalInputDuration=F):"ssrc"===t&&"audio"===B?_.send_level=L:"candidate-pair"===t?(_.ice_available_incoming_bitrate=h,_.ice_available_outgoing_bitrate=v,_.ice_bytes_received=p,_.ice_bytes_sent=i,_.ice_nominated=Number(f),_.ice_pair_id=m,_.ice_pair_rtt=g,_.ice_pair_state=y,_.ice_pair_writable=S,_.recv_ping_requests=b,_.recv_ping_responses=E,_.sent_ping_requests_before_first_response=k,_.sent_ping_requests_total=k+(T||0),_.sent_ping_responses=I):"local-candidate"===t?(_.local_candidate_type=A,_.local_ip=w||C,_.local_network_type=x,_.local_port=O,_.protocol=P):"remote-candidate"===t&&(_.remote_candidate_type=A,_.remote_ip=w||C,_.remote_port=O);var H=kM("STATS_SCALLBACK_SUPPORT");iV&&H||"media-source"===t&&(_.send_level=d)})),void 0===_.volume&&void 0!==n&&(_.volume=n,_.audio_level=n?-10*rw(Math.pow(n/255,2)):n),(g=r.audio).timestamp){e.next=18;break}return r.audio=c,e.abrupt("return",this.filterIllegal(s));case 18:return void 0!==c.packetsLost&&(s.audioLossRate=(c.packetsLost-g.packetsLost)/(c.packetsSent-g.packetsSent),s.audioLossRate=Number.isNaN(s.audioLossRate)?0:s.audioLossRate,_.fraction_lost=s.audioLossRate),s.statsInterval=c.timestamp-g.timestamp,_.stats_interval=s.statsInterval,s.sendKBitrate=(c.bytesSent-g.bytesSent||0)/s.statsInterval*8,_.mediaBitratebps=Math.round(1e3*s.sendKBitrate),_.bandwidth=Math.round(_.mediaBitratebps/1024),void 0!==c.retransmittedBytesSent&&(_.retransmitBitratebps=(c.retransmittedBytesSent-g.retransmittedBytesSent||0)/s.statsInterval),r.audio=c,_.vendor_mode=(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,_.pc_session_id=null===(o=this.handler)||void 0===o?void 0:o.peerConnectionId,null===(a=this._monitor)||void 0===a||a.report("rtc_media_statistics",_),s._retransmittedRate=(c.retransmittedPacketsSent-g.retransmittedPacketsSent)/(c.packetsSent-g.packetsSent),void 0===s.audioLossRate&&(s.audioLossRate=s._retransmittedRate,_.fraction_lost=s.audioLossRate),s._fractionLost=Math.max(s._fractionLost,s.audioLossRate),e.abrupt("return",this.filterIllegal(s));case 33:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},i={timestamp:Date.now(),simulcast:{}},o=this._stream,a=o.streamId,s=o.videoMid,c=o.isScreen,u=o.pubAttributes,d=o.enableSimulcast,l=o.pubVideo,e.t0=el,e.t1={media_type:"video",is_screen:!!c,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:u.localvideo?"capture_state_on":"capture_state_off",mute_state:l?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,h=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",n);case 11:return h.cap_frame_width=t.getSettings().width,h.cap_frame_height=t.getSettings().height,h.frameRateSent=t.getSettings().frameRate,n.isScreen=c,e.next=17,this.handler.getStats(t);case 17:if((v=e.sent).length){e.next=20;break}return e.abrupt("return",n);case 20:if(p=0,v.forEach((function(e){var t=e.type,o=e.framesEncoded,a=e.packetsLost,s=e.bytesSent,c=e.framesSent,u=e.retransmittedBytesSent,l=e.totalPacketSendDelay,v=e.totalEncodeTime,f=e.firCount,_=e.targetBitrate,m=e.roundTripTime,g=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,D=e.currentRoundTripTime,M=e.state,L=e.writable,U=e.candidateType,V=e.ip,F=e.address,B=e.networkType,j=e.port,H=e.nackCount,G=e.pliCount,z=e.protocol,K=e.qpSum,X=e.requestsReceived,W=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,ve=e.framesPerSecond,pe=e.frames;"outbound-rtp"===t?(d&&(ie?i.simulcast[ie]=e:i.simulcast[p]=e,p++),i.framesEncoded=o||i.framesEncoded||0,h.key_frames_encoded=le||0,i.bytesSent=s||i.bytesSent||0,i.framesSent=c||i.framesSent,h.bytes=s||h.bytes||0,i.packetsSent=b||i.packetsSent||0,h.packetsSent=b||h.packetsSent||0,h.nackCount=H||h.nackCount||0,h.pli_count=G||h.pli_count||0,h.qp_sum=K||h.qp_sum||0,h.ssrc=Z||h.ssrc||0,h.retransmitted_packets_sent=te,i.retransmittedPacketsSent=te,i.retransmittedBytesSent=u,h.encoder_implementation=re,h.qualityLimitationReason=se,h.qualityLimitationDurations=ce,h.scalabilityMode=he,void 0!==y&&((!n.encodedFrameWidth||y>n.encodedFrameWidth)&&(n.encodedFrameWidth=y),(!n.encodedFrameHeight||S>n.encodedFrameHeight)&&(n.encodedFrameHeight=S),h.frame_size_height=S,h.frame_size_width=y)):"track"===t?(n.encodedFrameWidth=y,n.encodedFrameHeight=S,h.frame_size_height=S,h.frame_size_width=y):"remote-inbound-rtp"===t?(i.packetsLost=a,n.rtt=1e3*m,h.rtt=n.rtt,h.jitter=1e3*ne,h.packetsLost=a,n._fractionLost=oe||0):"codec"===t?(n.codecType=g,h.codecName=g):"candidate-pair"===t?(h.ice_available_incoming_bitrate=C,h.ice_available_outgoing_bitrate=x,h.ice_bytes_received=O,h.ice_bytes_sent=s,h.ice_nominated=Number(P),h.ice_pair_id=N,h.ice_pair_rtt=D,h.ice_pair_state=M,h.ice_pair_writable=L,h.recv_ping_requests=X,h.recv_ping_responses=W,h.sent_ping_requests_before_first_response=q,h.sent_ping_requests_total=q+J,h.sent_ping_responses=Q):"local-candidate"===t?(h.local_candidate_type=U,h.local_ip=V||F,h.local_network_type=B,h.local_port=j,h.protocol=z):"remote-candidate"===t?(h.remote_candidate_type=U,h.remote_ip=V||F,h.remote_port=j):"VideoBwe"===t?(h.encBitratebps=E,h.available_receive_bandwidth=k,h.available_send_bandwidth=T,h.bucket_delay=R,h.retransmitBitratebps=Y,h.targetEncBitratebps=$,h.transmit_bitrate=ee,n._sendBandWidth=Number(T)):"ssrc"===t&&(h.avg_encode_ms=I,h.encodeUsage=A,h.frame_rate_input=w,h.orignal_input_Framerate=Number(w),h.ddaptationChanges=ae,h.firsReceived=ue,h.frameRateSent=de);var fe=kM("STATS_SCALLBACK_SUPPORT");if(!iV||!fe){var _e=r.video,me=i.timestamp-_e.timestamp;if("outbound-rtp"===t){var ge=s-_e.bytesSent,ye=u-_e.retransmittedBytesSent;h.encBitratebps=Math.round(8e3*(ge-ye)/me),h.bucket_delay=l/b,h.retransmitBitratebps=Math.round(8e3*ye/me),h.targetEncBitratebps=_,h.transmit_bitrate=Math.round(1e3*(s-_e.bytesSent)*8/me),h.avg_encode_ms=1e3*v/o,h.firsReceived=f+G}else"candidate-pair"===t?(h.available_send_bandwidth=x,n._sendBandWidth=x):"media-source"===t&&(h.frame_rate_input=ve,h.orignal_input_Framerate=Number(ve),h.frame_input=pe)}})),(f=r.video).timestamp){e.next=26;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 26:return n.statsInterval=i.timestamp-f.timestamp,h.stats_interval=n.statsInterval,_=cn(i.simulcast),d?(h.sim_enc_width=[],h.sim_enc_height=[],h.sim_enc_bps=[],h.sim_enc_framerate=[],h.sim_enc_key_frames=[],h.sim_rids=[],h.sim_enc_bandwidth=[],h.sim_sent_framerate=[],h.sim_fraction_lost=[],h.sim_keyencoded=[],h.active_sim_streams=(null===(m=this._context)||void 0===m?void 0:m.activeSimStreams)||[],h.sim_retransmittedRate=[],b=!1,KR(_).call(_,(function(e,t){return Number(e)-Number(t)})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,v=t.qualityLimitationDurations,p=t.qualityLimitationResolutionChanges,_=t.retransmittedPacketsSent,m=t.pliCount,g=t.keyFramesEncoded;void 0!==l&&(h.sim_qualityLimitationReason||(h.sim_qualityLimitationReason=[],h.sim_qualityLimitationDurations=[],h.sim_qualityLimitationResolutionChanges=[]),h.sim_qualityLimitationReason.push(l),h.sim_qualityLimitationDurations.push(v),h.sim_qualityLimitationResolutionChanges.push(p));var y=f.simulcast[e];if(h.sim_enc_width.push(r||0),h.sim_enc_height.push(o||0),h.sim_enc_key_frames.push(g||0),y){var S=(a-y.bytesSent||0)/n.statsInterval;h.sim_enc_bps.push(Math.round(8e3*S)),h.sim_enc_bandwidth.push(Math.round(8e3*S/1024));var E=1e3*(s-y.framesEncoded)/n.statsInterval;h.sim_enc_framerate.push(Math.round(E)),h.sim_rids.push(e);var k=void 0!==c?c-y.framesSent:s-y.framesEncoded,T=1e3*k/n.statsInterval;h.sim_sent_framerate.push(Math.round(T));var I=(u-y.packetsLost)/(d-y.packetsSent);n._retransmittedRate=(_-y.retransmittedPacketsSent)/(d-y.packetsSent),I=Number.isNaN(I)?0:I,h.sim_fraction_lost.push(I),h.sim_keyencoded.push(m-y.pliCount>0),h.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!b&&(n.sentKBitrate=8*S,n.encoderOutputFrameRate=E,n.encodedFrameCount=k,n.sentFrameRate=T,n.videoLossRate=I,b=!0)}})),h.vendor_mode=(null===(g=this._stream)||void 0===g?void 0:g.vendorCode)||0,h.pc_session_id=null===(y=this.handler)||void 0===y?void 0:y.peerConnectionId,null===(S=this._monitor)||void 0===S||S.report("rtc_media_statistics",h)):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-f.framesSent:i.framesEncoded-f.framesEncoded,n.sentKBitrate=(i.bytesSent-f.bytesSent||0)/n.statsInterval*8,h.bitrate=Math.round(1e3*n.sentKBitrate),h.bandwidth=Math.round(h.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-f.framesEncoded)/n.statsInterval,h.frame_rate_encoded=Math.round(n.encoderOutputFrameRate),n.sentFrameRate=1e3*n.encodedFrameCount/n.statsInterval,h.frame_rate_sent=Math.round(n.sentFrameRate),n.videoLossRate=(i.packetsLost-f.packetsLost)/(i.packetsSent-f.packetsSent),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,h.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-f.retransmittedPacketsSent)/(i.packetsSent-f.packetsSent),h.vendor_mode=(null===(E=this._stream)||void 0===E?void 0:E.vendorCode)||0,h.pc_session_id=null===(k=this.handler)||void 0===k?void 0:k.peerConnectionId,null===(T=this._monitor)||void 0===T||T.report("rtc_media_statistics",h)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 33:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(cB),dB=function(e){UI(o,e);var t,r,n,i=eR(o);function o(e,t){var r;return Hl(this,o),Zd(sI(r=i.call(this,e)),"isPaused",void 0),Zd(sI(r),"pauseStart",void 0),Zd(sI(r),"pauseDuration",void 0),Zd(sI(r),"_audioStallCount",void 0),Zd(sI(r),"_setAudioStallCount",void 0),Zd(sI(r),"_audioStallTimer",void 0),Zd(sI(r),"_audioStallInterval",void 0),Zd(sI(r),"_audioStallRatio",void 0),Zd(sI(r),"_videoInWaiting",void 0),r._stream=t,r._videoInWaiting=!1,r.pauseDuration=0,r}return jl(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=xm(wm().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,v,p,f,_,m,g,y=this;return wm().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),this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,s={audio:{},video:{}},this._destroyed=!1,c=this._stream,u=null===(n=c.audioTrack)||void 0===n?void 0:n.getOrgTrack(),d=null===(i=c.videoTrack)||void 0===i?void 0:i.getTrack(),this.getRemoteVideoStats(d,s),e.next=14,this.getRemoteAudioStats(u,s,null===(a=this._stream.audioTrack)||void 0===a?void 0:a.getAudioLevel());case 14:this._stopAudioStallTimer(),l=0,h=0,p=[],f=0,_=tD(),this._setAudioStallCount=function(){if(bM.AUDIO_STALL&&y._audioStallInterval>0&&void 0!==s.audio.concealedSamples){var e=s.audio.concealedSamples,t=s.audio.totalSamplesReceived;_=tD();var r={isStall:!1,counted:!1,diff:0},n=.5*y._audioStallInterval;y._audioStallCount=xm(wm().mark((function i(){var o,a,s,u,d,v,m,g,S,b,E,k,T,I,R,A,w,C,x,O;return wm().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=c.hasAudio,s=c.subAudio,u=c.virtual,d=c.virtualOccupy,!c.removeTrack){i.next=4;break}return clearTimeout(y._audioStallTimer),i.abrupt("return");case 4:if(a&&s){i.next=10;break}return r.isStall=!1,r.counted=!1,p.push({reason:Mm(v="hasAudio: ".concat(a,", subAudio: ")).call(v,s)}),_=tD(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:p,stats_count:f});case 10:if(!u||d){i.next=16;break}return r.isStall=!1,r.counted=!1,p.push({reason:Mm(m="virtual: ".concat(u,", virtualOccupy: ")).call(m,d)}),_=tD(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:p,stats_count:f});case 16:return g=null===(o=c.audioTrack)||void 0===o?void 0:o.getOrgTrack(),S=Date.now(),i.next=20,y.handler.getStats(g,!0);case 20:if(b=i.sent,E=Date.now(),k=tD(),!((T=k-_)<n)){i.next=27;break}return p.push({diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:Mm(I="diff(".concat(T,") < minInterval(")).call(I,n,")")}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:p,stats_count:f});case 27:if(R=b.length,A=kE(b).call(b,(function(e){return"inbound-rtp"===e.type}))){i.next=32;break}return p.push({diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:R?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:p,stats_count:f});case 32:return w=A.concealedSamples,C=A.totalSamplesReceived,O=C-t,(x=w-e)>=0&&O>=0&&x>=y._audioStallRatio*O?(p.push({concealed:x,received:O,diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,is_stall:!0}),r.isStall?(r.counted?h+=T:(h=h+r.diff+T,l++),r.counted=!0):T>=200?(h+=T,l++,r.counted=!0):(r.counted=!1,r.diff=T),r.isStall=!0):(p.push({concealed:x,received:O,diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E}),r.isStall=!1,r.counted=!1),e=w,t=C,_=k,f++,i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:p,stats_count:f});case 41:case"end":return i.stop()}}),i)}))),v=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!y._audioStallCount&&y._setAudioStallCount&&y._setAudioStallCount(),!y._audioStallCount){e.next=6;break}return e.next=4,y._audioStallCount();case 4:y._audioStallTimer&&clearTimeout(y._audioStallTimer),y._audioStallTimer=setTimeout(v,y._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y._audioStallTimer&&clearTimeout(y._audioStallTimer),y._audioStallTimer=setTimeout(v,y._audioStallInterval)}},this._setAudioStallCount(),m=function(){var e=xm(wm().mark((function e(){var t,r,n,i,o,a,u;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=c.audioTrack)||void 0===t?void 0:t.getOrgTrack(),o=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,y.getRemoteAudioStats(i,s,null===(n=y._stream.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return a=e.sent,l=0,h=0,p=[],f=0,e.next=11,y.getRemoteVideoStats(o,s);case 11:return u=e.sent,e.abrupt("return",{audioStats:a,videoStats:u,isScreen:c.isScreen,userId:c.userId,streamId:c.streamId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),g=function(){var e=xm(wm().mark((function e(){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m();case 2:r=e.sent,t(r),v&&(_=tD(),y._audioStallTimer&&clearTimeout(y._audioStallTimer),y._audioStallTimer=setTimeout(v,y._audioStallInterval)),y._timer&&clearTimeout(y._timer),y._destroyed||(y._timer=setTimeout(g,2e3));case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(g,2e3);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_stopAudioStallTimer",value:function(){clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){this.logger.info("unsubscribe","invoke"),MI(DI(o.prototype),"stopReport",this).call(this,"unsubscribe"),this._stopAudioStallTimer(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d={},l={},h=this._stream,v=h.streamId,p=h.userId,f=h.isScreen,_=h.audioMid,m=h.subMediaType,g=h._attributes,y=h.virtual,S=h.audioTrack,b={media_type:"audio",is_screen:!!f,direction:"down",stream_id:v,stream_user_id:p,vid:_,audio_mux:y,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:gD(m)?"mute_state_off":"mute_state_on",remote_user_capture_state:g.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:g.localaudio&&g.audiostream?"mute_state_off":"mute_state_on"},S&&(b.playback_volume=S.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",d);case 7:return e.next=9,this.handler.getStats(t);case 9:if((E=e.sent).length){e.next=12;break}return e.abrupt("return",d);case 12:if(E.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,o=e.bytesReceived,a=e.jitterBufferDelay,s=e.jitterBufferEmittedCount,c=e.clockRate,u=e.channels,h=e.totalSamplesReceived,p=e.concealedSamples,f=e.silentConcealedSamples,_=e.concealmentEvents,m=e.totalRoundTripTime,g=e.packetsDiscarded,y=e.state,S=e.currentRoundTripTime,E=e.audioLevel,k=e.totalAudioEnergy,T=e.totalSamplesDuration,I=e.mimeType,R=e.googDecodingNormal,A=e.googDecodingMuted,w=e.availableIncomingBitrate,C=e.availableOutgoingBitrate,O=e.bytesSent,P=e.nominated,N=e.id,D=e.writable,M=e.jitter,L=e.candidateType,U=e.ip,V=e.address,F=e.networkType,B=e.port,j=e.protocol,H=e.audioOutputLevel,G=e.requestsReceived,z=e.responsesReceived,K=e.requestsSent,X=e.consentRequestsSent,W=e.responsesSent,Y=e.ssrc;e.kind;var 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=p,l.concealedSamples=p,l.silentConcealedSamples=f,b.concealedSamples=p,d.concealmentEvents=_,b.totalSamplesReceived=h),void 0!==Z&&(b.fec_packets_received=Z,l.fecPacketsReceived=Z),b.jitter=1e3*M,b.ssrc=Y,void 0!==E&&0!==E?(b.audio_level=E?-10*rw(Math.pow(E,2)):E,b.volume=255*E):(b.volume=null!=n?n:255*E,b.audio_level=n?-10*rw(Math.pow(n/255,2)):n),void 0!==k&&(b.total_audio_energy=k),void 0!==T&&(b.totalAudioDuration=T);else if("codec"===t)d.recordSampleRate=c,u&&(d.numChannels=u),b.codecName=I;else if("candidate-pair"===t){var $,ee,te;b.ice_available_incoming_bitrate=w,b.ice_available_outgoing_bitrate=C,b.ice_bytes_received=o,b.ice_bytes_sent=O,b.ice_nominated=Number(P),b.ice_pair_id=N,b.ice_pair_rtt=S,b.rtt=1e3*S,b.rtt&&null!==($=x._context)&&void 0!==$&&null!==(ee=$.streamRTT)&&void 0!==ee&&null!==(te=ee[v])&&void 0!==te&&te.audio&&(b.total_rtt_ms=Math.round(b.rtt+x._context.streamRTT[v].audio)),b.ice_pair_state=y,b.ice_pair_writable=D,b.recv_ping_requests=G,b.recv_ping_responses=z,b.sent_ping_requests_before_first_response=K,b.sent_ping_requests_total=K+(X||0),b.sent_ping_responses=W,"succeeded"===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*rw(Math.pow(n/255,2)):n):(b.audio_level=E?-10*rw(Math.pow(E,2)):E,b.volume=255*E),b.total_audio_energy=k,b.totalAudioDuration=T):"ssrc"===t?(b.decodingNormal=R,b.recvAudioLevel=H,b.decodingMuted=A):"local-candidate"===t?(b.local_candidate_type=L,b.local_ip=U||V,b.local_network_type=F,b.local_port=B,b.protocol=j):"remote-candidate"===t&&(b.remote_candidate_type=L,b.remote_ip=U||V,b.remote_port=B)})),(k=r.audio).timestamp){e.next=18;break}return l.timestamp=Date.now(),r.audio=l,e.abrupt("return",this.filterIllegal(d));case 18:if(T={},void 0!==l.concealedSamples&&(b.interval_concealed_samples=l.concealedSamples-k.concealedSamples,b.interval_samples_received=l.totalSamplesReceived-k.totalSamplesReceived,b.interval_silent_concealed_samples=l.silentConcealedSamples-k.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==k.concealedSamples)){e.next=38;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=36;break}return e.next=26,this._audioStallCount();case 26:I=e.sent,R=I.stall_count,A=I.stall_duration,w=I.stall_list,C=I.stats_count,T.stall_list=w,T.stats_count=C,b.concealedSamples===b.interval_concealed_samples&&b.totalSamplesReceived===b.interval_samples_received?(b.stall_count=0,b.stall_duration=0):(b.stall_count=R,b.stall_duration=A),d.stallCount=b.stall_count,d.stallDuration=b.stall_duration;case 36:e.next=42;break;case 38:b.stall_count=0,b.stall_duration=0,d.stallCount=b.stall_count,d.stallDuration=b.stall_duration;case 42:return l.timestamp=Date.now(),d.audioLossRate=(l.packetsLost-k.packetsLost)/(l.packetsReceived-k.packetsReceived+(l.packetsLost-k.packetsLost)),d.audioLossRate=Number.isNaN(d.audioLossRate)?0:d.audioLossRate,b.fraction_lost=d.audioLossRate,d.statsInterval=l.timestamp-k.timestamp,b.stats_interval=d.statsInterval,d.receivedKBitrate=(l.bytesReceived-k.bytesReceived||0)/d.statsInterval*8,b.bandwidth=Math.round(1e3*d.receivedKBitrate/1024),void 0!==l.concealedSamples&&(d.receivedSampleRate=1e3*b.interval_samples_received/d.statsInterval),void 0!==l.fecPacketsReceived&&(b.fecBitratebps=(l.fecPacketsReceived-k.fecPacketsReceived||0)/d.statsInterval),b.average_jitter_buffer_delay_ms&&b.total_rtt_ms&&(d.e2eDelay=b.average_jitter_buffer_delay_ms+b.total_rtt_ms),null!==(i=this._context)&&void 0!==i&&null!==(o=i.streamRTT)&&void 0!==o&&null!==(a=o[v])&&void 0!==a&&a.audio&&(d.totalRtt=(b.rtt?b.rtt:0)+this._context.streamRTT[v].audio),r.audio=l,b.vendor_mode=(null===(s=this._stream)||void 0===s?void 0:s.vendorCode)||0,b.pc_session_id=null===(c=this.handler)||void 0===c?void 0:c.peerConnectionId,null===(u=this._monitor)||void 0===u||u.report("rtc_media_statistics",b,T),e.abrupt("return",this.filterIllegal(d));case 59:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u={},d={timestamp:Date.now()},l=this._stream,h=l.streamId,v=l.userId,p=l.isScreen,f=l.subMediaType,_=l._attributes,e.t0=el,e.t1={media_type:"video",is_screen:!!p,direction:"down",stream_id:h,stream_user_id:v,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:yD(f)?"mute_state_off":"mute_state_on",remote_user_capture_state:_.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:_.localvideo&&_.videostream?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,m=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",u);case 11:return u.isScreen=p,e.next=14,this.handler.getStats(t);case 14:if((g=e.sent).length){e.next=17;break}return e.abrupt("return",u);case 17:if(g.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,i=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,s=e.framesDecoded,c=e.jitterBufferDelay,l=e.jitterBufferEmittedCount,v=e.mimeType,p=e.firCount,f=e.availableIncomingBitrate,_=e.availableOutgoingBitrate,g=e.bytesSent,y=e.nominated,S=e.id,E=e.currentRoundTripTime,k=e.state,T=e.writable,I=e.candidateType,R=e.ip,A=e.address,w=e.networkType,C=e.port,x=e.nackCount,O=e.pliCount,P=e.protocol,N=e.requestsReceived,D=e.responsesReceived,M=e.requestsSent,L=e.consentRequestsSent,U=e.responsesSent,V=e.ssrc,F=e.jitter,B=e.framesReceived,j=e.keyFramesDecoded,H=e.totalDecodeTime,G=e.decoderImplementation,z=e.lastPacketReceivedTimestamp,K=e.framesDropped;if("inbound-rtp"===t)d.packetsLost=i,m.packetsLost=i,d.packetsReceived=o,m.packetsReceived=o,d.bytesReceived=a,m.bytes=a,d.framesDecoded=s,d.totalDecodeTime=H,void 0!==c&&(d.jitterBufferDelay=c/l*1e3,m.average_jitter_buffer_delay_ms=d.jitterBufferDelay),m.fir_count=p,m.nackCount=x,d.nackCount=x,m.pli_count=O,m.ssrc=V,m.framesDropped=K,m.jitter=1e3*F,m.framesReceived=B,d.framesReceived=B,m.framesDecoded=s,m.key_frames_decoded=j,m.decoder_name=G,m.last_packet_received_timestamp=z,void 0!==n&&(u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r);else if("track"===t&&void 0!==n)u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r,void 0!==B&&(m.framesReceived=B,d.framesReceived=B);else if("codec"===t)m.codecName=v;else if("candidate-pair"===t){var X,W,Y;m.ice_available_incoming_bitrate=f,m.ice_available_outgoing_bitrate=_,m.ice_bytes_received=a,m.ice_bytes_sent=g,m.ice_nominated=Number(y),m.ice_pair_id=S,m.ice_pair_rtt=E,m.rtt=1e3*E,m.rtt&&null!==(X=b._context)&&void 0!==X&&null!==(W=X.streamRTT)&&void 0!==W&&null!==(Y=W[h])&&void 0!==Y&&Y.video&&(m.total_rtt_ms=Math.round(m.rtt+b._context.streamRTT[h].video)),u.rtt=m.rtt,m.ice_pair_state=k,m.ice_pair_writable=T,m.recv_ping_requests=N,m.recv_ping_responses=D,m.sent_ping_requests_before_first_response=M,m.sent_ping_requests_total=M+(L||0),m.sent_ping_responses=U}else"local-candidate"===t?(m.local_candidate_type=I,m.local_ip=R||A,m.local_network_type=w,m.local_port=C,m.protocol=P):"remote-candidate"===t&&(m.remote_candidate_type=I,m.remote_ip=R||A,m.remote_port=C)})),(y=r.video).timestamp){e.next=22;break}return r.video=d,e.abrupt("return",this.filterIllegal(u));case 22:return u.videoLossRate=(d.packetsLost-y.packetsLost)/(d.packetsReceived-y.packetsReceived+(d.packetsLost-y.packetsLost)),y.totalDecodeTime&&y.framesDecoded&&d.framesDecoded!==y.framesDecoded&&(m.decode_elapse_per_frame=Number(((d.totalDecodeTime-y.totalDecodeTime)/(d.framesDecoded-y.framesDecoded)*1e3).toFixed(2))),u._retransmittedRate=(d.nackCount-y.nackCount)/(d.packetsReceived-y.packetsReceived+(d.packetsLost-y.packetsLost)),u.videoLossRate=Number.isNaN(u.videoLossRate)?0:u.videoLossRate,m.fraction_lost=u.videoLossRate,u.statsInterval=d.timestamp-y.timestamp,m.stats_interval=u.statsInterval,u.receivedKBitrate=(d.bytesReceived-y.bytesReceived||0)/u.statsInterval*8,m.bitrate=Math.round(1e3*u.receivedKBitrate),m.bandwidth=Math.round(m.bitrate/1024),u.decoderOutputFrameRate=1e3*(d.framesDecoded-y.framesDecoded)/u.statsInterval,u.receivedFrameRate=1e3*(d.framesReceived-y.framesReceived)/u.statsInterval,m.frame_rate_decoded=Math.round(u.decoderOutputFrameRate),m.frame_rate_received=Math.round(u.receivedFrameRate),m.average_jitter_buffer_delay_ms&&m.total_rtt_ms&&(u.e2eDelay=m.average_jitter_buffer_delay_ms+m.total_rtt_ms),null!==(n=this._context)&&void 0!==n&&null!==(i=n.streamRTT)&&void 0!==i&&null!==(o=i[h])&&void 0!==o&&o.video&&(u.totalRtt=(m.rtt?m.rtt:0)+this._context.streamRTT[h].video),r.video=d,this.processStall(this._stream,m,u,p),this.isPaused?(S=d.timestamp-(this.pauseStart||0),m.pause_duration=this.pauseDuration+(S>500?S:0),this.pauseStart=d.timestamp):m.pause_duration=this.pauseDuration,m.pause_duration=Math.min(m.stall_duration||m.stuck_length||0,m.pause_duration),this.pauseDuration=0,m.vendor_mode=(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,m.pc_session_id=null===(s=this.handler)||void 0===s?void 0:s.peerConnectionId,null===(c=this._monitor)||void 0===c||c.report("rtc_media_statistics",m),e.abrupt("return",this.filterIllegal(u));case 47:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"processStall",value:function(e,t,r,n){var i=0,o=0,a=0;if(e.recordedVideoFrames&&this.player&&this.player.played){e.recordedVideoFrames.forEach((function(e){e.isStall&&(i+=e.stallCount,o+=e.stallDuration),a=e.playTime})),e.recordedVideoFrames.length||(o=2e3,i=this._videoInWaiting?0:1,this._videoInWaiting=!0);var s=e.recordedVideoFrames.pop();s&&(s.isStall?this._videoInWaiting=!0:this._videoInWaiting=!1),e.recordedVideoFrames=[]}t.stall_count=i,n?(t.stuck_length=Math.min(o,t.stats_interval),t.stall_duration=void 0):(t.stall_duration=Math.min(o,t.stats_interval),t.stuck_length=void 0),t.play_time=a,r.stallCount=i,r.stallDuration=o}},{key:"destroy",value:function(){MI(DI(o.prototype),"destroy",this).call(this),MI(DI(o.prototype),"stopReport",this).call(this,"destroy"),this._stopAudioStallTimer(),this._videoInWaiting=!1}}],[{key:"audioStallConfig",set:function(e){o.audioStallInterval=((null==e?void 0:e.audio_stall_interval)||200)/2,o.audioStallRatio=null==e?void 0:e.audio_stall_ratio}}]),o}(cB);Zd(dB,"audioStallInterval",void 0),Zd(dB,"audioStallRatio",void 0);var lB,hB,vB=function(e){UI(r,e);var t=eR(r);function r(e){var n;return Hl(this,r),Zd(sI(n=t.call(this)),"videoDom",void 0),Zd(sI(n),"audioMid",void 0),Zd(sI(n),"videoMid",void 0),Zd(sI(n),"videoTransceiver",void 0),Zd(sI(n),"audioTransceiver",void 0),Zd(sI(n),"vendorHandler",void 0),Zd(sI(n),"vendorCode",0),Zd(sI(n),"engineId",void 0),Zd(sI(n),"logger",void 0),n.engineId=e.id,n.logger=new fN("Stream",0,e.id),n}return jl(r,[{key:"requestVideoFrameCallback",value:function(){var e=this;return new $_((function(t){var r,n=null===(r=e.videoDom)||void 0===r?void 0:r.requestVideoFrameCallback;if("function"==typeof n){var i=function(e,r){var n={};cn(r).forEach((function(e){var t=e.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return Mm(t="".concat(e[0],"_")).call(t,e[1].toLowerCase())}));n["video_".concat(t)]=r[e]})),clearInterval(o),t(n)};n.call(e.videoDom,i);var o=setTimeout((function(){var r;null===(r=e.videoDom)||void 0===r||r.cancelVideoFrameCallback(i),t({})}),500)}else t({})}))}},{key:"stopReport",value:function(e){this.statsReport.stopReport(e)}},{key:"destroy",value:function(){var e,t;delete this.audioMid,delete this.videoMid,this.statsReport.destroy(),null===(e=this.observer)||void 0===e||e.reset(),delete this.videoTransceiver,delete this.audioTransceiver,null===(t=this.vendorHandler)||void 0===t||t.destroy(),this.vendorCode=0,delete this.vendorHandler}}]),r}($M),pB=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(pB||{}),fB=function(e){UI(r,e);var t=eR(r);function r(e){var n;return Hl(this,r),Zd(sI(n=t.call(this,e)),"id",void 0),Zd(sI(n),"isScreen",!1),Zd(sI(n),"stream",void 0),Zd(sI(n),"streamId",void 0),Zd(sI(n),"seiList",[]),Zd(sI(n),"videoTrack",void 0),Zd(sI(n),"audioTrack",void 0),Zd(sI(n),"videoEncodeConfig",[AM]),Zd(sI(n),"subVideoDescriptions",[]),Zd(sI(n),"enableSimulcast",!1),Zd(sI(n),"observer",void 0),Zd(sI(n),"statsReport",void 0),Zd(sI(n),"prevBitrate",0),Zd(sI(n),"pubAudio",!1),Zd(sI(n),"pubVideo",!1),Zd(sI(n),"pubAttributes",void 0),Zd(sI(n),"pcSessionId",void 0),n.stream=new MediaStream,n.id=yw(),n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},n.statsReport=new uB(e,sI(n)),n}return jl(r,[{key:"audioHasCapture",get:function(){return this.pubAttributes.localaudio}},{key:"audioHasPublish",get:function(){return this.pubAttributes.audiostream}},{key:"videoHasCapture",get:function(){return this.pubAttributes.localvideo}},{key:"videoHasPublish",get:function(){return this.pubAttributes.videostream}},{key:"hasPublished",get:function(){return!!this.audioMid&&!!this.videoMid}},{key:"isEmptyStream",get:function(){return!this.audioTrack&&!this.videoTrack}},{key:"initStreamId",get:function(){return this.stream.id}},{key:"startReport",value:function(e,t){this.statsReport.setLocalStreamStatsEvtInterval(e,t)}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if(rV()){var r=t.createEncodedStreams(),n=r.readable,i=r.writable,o=new TransformStream({transform:function(t,r){var n=e.seiList[0];if(n){var i,o=sB.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)ak(i=e.seiList).call(i,0,1);n.repeatCount--,a.set(new Uint8Array(t.data)),a.set(o,t.data.byteLength),t.data=a.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else this.logger.warn("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender){var e=this.audioTransceiver.sender.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else this.logger.warn("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){$P(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),MI(DI(r.prototype),"destroy",this).call(this),this.prevBitrate=0,this.subVideoDescriptions=[]}},{key:"switchTrackEnableState",value:function(e,t){var r,n;"audio"===e?n=this.audioTrack:"video"===e&&(n=this.videoTrack);var i=null===(r=n)||void 0===r?void 0:r.getTrack();return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}},{key:"resetStream",value:function(){this.stream=new MediaStream}}]),r}(vB),_B=function(e){UI(r,e);var t=eR(r);function r(e,n,i,o,a,s){var c;return Hl(this,r),Zd(sI(c=t.call(this,e)),"streamId",void 0),Zd(sI(c),"userId",void 0),Zd(sI(c),"isScreen",void 0),Zd(sI(c),"isPublic",void 0),Zd(sI(c),"hasVideo",void 0),Zd(sI(c),"hasAudio",void 0),Zd(sI(c),"_attributes",void 0),Zd(sI(c),"streamState",void 0),Zd(sI(c),"removeTrack",!1),Zd(sI(c),"observer",void 0),Zd(sI(c),"statsReport",void 0),Zd(sI(c),"subVideo",void 0),Zd(sI(c),"subAudio",void 0),Zd(sI(c),"subMediaType",void 0),Zd(sI(c),"subLayer",void 0),Zd(sI(c),"_sequenceId",void 0),Zd(sI(c),"stream",void 0),Zd(sI(c),"videoTrack",void 0),Zd(sI(c),"audioTrack",void 0),Zd(sI(c),"recordedVideoFrames",void 0),Zd(sI(c),"stillExist",void 0),Zd(sI(c),"originalMediaType",void 0),Zd(sI(c),"priority",void 0),Zd(sI(c),"originalStreamIndex",0),Zd(sI(c),"virtual",void 0),Zd(sI(c),"pcSessionId",void 0),Zd(sI(c),"_virtualOccupy",void 0),c.virtual=!1,c._virtualOccupy=!1,c.userId=n,c.isScreen=o,c.isPublic=a,c.streamId=i,c.hasAudio=s.audiostream&&s.localaudio,c.hasVideo=s.videostream&&s.localvideo,c._attributes=s,c.vendorCode=(null==s?void 0:s.vendorCode)||0,c.subVideo=!1,c.subAudio=!1,c._sequenceId=0,c.subMediaType=$F.NONE,c.subLayer={spatialLayer:0,spatialSubLayer:-1},c.streamState=0,c.statsReport=new dB(e,sI(c)),c.enableVendorMode&&(c.pcSessionId=yw()),c}return jl(r,[{key:"vendor",get:function(){return this._attributes.vendorCode}},{key:"audioHasCapture",get:function(){return this._attributes.localaudio}},{key:"audioHasPublish",get:function(){return this._attributes.audiostream}},{key:"videoHasCapture",get:function(){return this._attributes.localvideo}},{key:"videoHasPublish",get:function(){return this._attributes.videostream}},{key:"sequenceId",get:function(){return this._sequenceId||-1},set:function(e){"number"==typeof e&&(this._sequenceId=e)}},{key:"enableVendorMode",get:function(){return"number"==typeof this.attributes.vendorCode&&0!==this.attributes.vendorCode}},{key:"hasSubscribed",get:function(){return 2===this.streamState}},{key:"attributes",get:function(){return this._attributes},set:function(e){this.hasVideo=e.localvideo&&e.videostream,this.hasAudio=e.localaudio&&e.audiostream,this._attributes=e,this.vendorCode=e.vendorCode||0}},{key:"virtualOccupy",get:function(){return this._virtualOccupy},set:function(e){var t;if(this._virtualOccupy&&!e)null===(t=this.observer)||void 0===t||t.setPushTrack(!1);else if(!this._virtualOccupy&&e){var r;null===(r=this.observer)||void 0===r||r.setPushTrack(!0)}this._virtualOccupy=e}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){eB.getNalunits(new tB(t.data)).forEach((function(t){if(t.sei){var r=sB.decodeSeiBody(t.body);r&&r.type!==rB.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;$P(this.engineId,"Stream.ontrack",Fm({uid:this.userId,streamId:this.streamId,streams:gb(i=e.streams).call(i,(function(e,t){return e+kw(t)}),""),transceiver:Rw(e.transceiver),track:Ew(e.track)}),0,this.streamId||"")}catch(Iq){}if(this.enableVendorMode||null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&bk(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:"clean",value:function(){var e,t;this.logger.info("clean",Mm(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),$P(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),MI(DI(r.prototype),"destroy",this).call(this),this.subAudio=!1,this.subVideo=!1,this.sequenceId=0,this.videoTrack=void 0,null===(t=this.audioTrack)||void 0===t||t.close(),this.audioTrack=void 0,this.stream=void 0,this.recordedVideoFrames=void 0,delete this.priority}},{key:"destroy",value:function(){this.clean(),this.attributes={audiostream:!1,localaudio:!1,localvideo:!1,videostream:!1,extvideo:!1,extaudio:!1,videoDescriptions:[]}}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{key:"_setStream",value:function(e){var t=this;this.stream=e,e.onaddtrack=function(e){"video"===e.track.kind?t._setVideoTrack(e.track):"audio"===e.track.kind&&t._setAudioTrack(e.track)}}},{key:"_setAudioTrack",value:function(e){var t,r;(null===(t=this.audioTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.audioTrack=HF(e),this.emit("ontrack",this.audioTrack))}},{key:"_setVideoTrack",value:function(e){var t,r;(null===(t=this.videoTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.videoTrack=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:eD();return new SF(e,t)}(e),this.emit("ontrack",this.videoTrack))}}]),r}(vB),mB=new fN("queue",4),gB=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(gB||{}),yB=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(yB||{}),SB=(Zd(lB={},"publish","unpublish"),Zd(lB,"subscribe","unsubscribe"),Zd(lB,"pushtrack","removetrack"),lB),bB=(Zd(hB={},"publish",0),Zd(hB,"subscribe",0),Zd(hB,"pushtrack",0),Zd(hB,"unpublish",1),Zd(hB,"unsubscribe",1),Zd(hB,"removetrack",1),hB),EB=function(e){UI(r,e);var t=eR(r);function r(){var e;return Hl(this,r),Zd(sI(e=t.call(this)),"_queue",void 0),e._queue=[],e}return jl(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t,r=this._queue.length,n="";return this._queue=Ks(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==SB[t.action]||(n=t.streamId,mB.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;LD&&aM>=86&&aM<=92&&(t=Math.min(this._queue.length,5));for(var r=bB[this._queue[0].action],n=1;n<t;n++){var i;if(bB[this._queue[n].action]!==r)return{sdpStrategy:r,items:ak(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:ak(e=this._queue).call(e,0,t)}}}]),r}(QM),kB="object"==typeof global&&global&&global.Object===Object&&global,TB="object"==typeof self&&self&&self.Object===Object&&self,IB=kB||TB||Function("return this")(),RB=IB.Symbol,AB=Object.prototype,wB=AB.hasOwnProperty,CB=AB.toString,xB=RB?RB.toStringTag:void 0;var OB=Object.prototype.toString;var PB="[object Null]",NB="[object Undefined]",DB=RB?RB.toStringTag:void 0;function MB(e){return null==e?void 0===e?NB:PB:DB&&DB in Object(e)?function(e){var t=wB.call(e,xB),r=e[xB];try{e[xB]=void 0;var n=!0}catch(o){}var i=CB.call(e);return n&&(t?e[xB]=r:delete e[xB]),i}(e):function(e){return OB.call(e)}(e)}function LB(e){return null!=e&&"object"==typeof e}var UB=Array.isArray;function VB(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function FB(e){return e}var BB="[object AsyncFunction]",jB="[object Function]",HB="[object GeneratorFunction]",GB="[object Proxy]";function zB(e){if(!VB(e))return!1;var t=MB(e);return t==jB||t==HB||t==BB||t==GB}var KB,XB=IB["__core-js_shared__"],WB=(KB=/[^.]+$/.exec(XB&&XB.keys&&XB.keys.IE_PROTO||""))?"Symbol(src)_1."+KB:"";var YB=Function.prototype.toString;function qB(e){if(null!=e){try{return YB.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var JB=/^\[object .+?Constructor\]$/,QB=Function.prototype,ZB=Object.prototype,$B=QB.toString,ej=ZB.hasOwnProperty,tj=RegExp("^"+$B.call(ej).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function rj(e){return!(!VB(e)||(t=e,WB&&WB in t))&&(zB(e)?tj:JB).test(qB(e));var t}function nj(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return rj(r)?r:void 0}var ij=nj(IB,"WeakMap"),oj=Object.create,aj=function(){function e(){}return function(t){if(!VB(t))return{};if(oj)return oj(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();var sj=Date.now;var cj,uj,dj,lj=function(){try{var e=nj(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),hj=lj,vj=hj?function(e,t){return hj(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:FB,pj=(cj=vj,uj=0,dj=0,function(){var e=sj(),t=16-(e-dj);if(dj=e,t>0){if(++uj>=800)return arguments[0]}else uj=0;return cj.apply(void 0,arguments)}),fj=pj;var _j=9007199254740991,mj=/^(?:0|[1-9]\d*)$/;function gj(e,t){var r=typeof e;return!!(t=null==t?_j:t)&&("number"==r||"symbol"!=r&&mj.test(e))&&e>-1&&e%1==0&&e<t}function yj(e,t,r){"__proto__"==t&&hj?hj(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function Sj(e,t){return e===t||e!=e&&t!=t}var bj=Object.prototype.hasOwnProperty;function Ej(e,t,r){var n=e[t];bj.call(e,t)&&Sj(n,r)&&(void 0!==r||t in e)||yj(e,t,r)}function kj(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?yj(r,s,c):Ej(r,s,c)}return r}var Tj=Math.max;function Ij(e,t){return fj(function(e,t,r){return t=Tj(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=Tj(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,FB),e+"")}var Rj=9007199254740991;function Aj(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=Rj}function wj(e){return null!=e&&Aj(e.length)&&!zB(e)}var Cj=Object.prototype;function xj(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Cj)}function Oj(e){return LB(e)&&"[object Arguments]"==MB(e)}var Pj=Object.prototype,Nj=Pj.hasOwnProperty,Dj=Pj.propertyIsEnumerable,Mj=Oj(function(){return arguments}())?Oj:function(e){return LB(e)&&Nj.call(e,"callee")&&!Dj.call(e,"callee")},Lj=Mj;var Uj="object"==typeof exports&&exports&&!exports.nodeType&&exports,Vj=Uj&&"object"==typeof module&&module&&!module.nodeType&&module,Fj=Vj&&Vj.exports===Uj?IB.Buffer:void 0,Bj=(Fj?Fj.isBuffer:void 0)||function(){return!1},jj={};function Hj(e){return function(t){return e(t)}}jj["[object Float32Array]"]=jj["[object Float64Array]"]=jj["[object Int8Array]"]=jj["[object Int16Array]"]=jj["[object Int32Array]"]=jj["[object Uint8Array]"]=jj["[object Uint8ClampedArray]"]=jj["[object Uint16Array]"]=jj["[object Uint32Array]"]=!0,jj["[object Arguments]"]=jj["[object Array]"]=jj["[object ArrayBuffer]"]=jj["[object Boolean]"]=jj["[object DataView]"]=jj["[object Date]"]=jj["[object Error]"]=jj["[object Function]"]=jj["[object Map]"]=jj["[object Number]"]=jj["[object Object]"]=jj["[object RegExp]"]=jj["[object Set]"]=jj["[object String]"]=jj["[object WeakMap]"]=!1;var Gj="object"==typeof exports&&exports&&!exports.nodeType&&exports,zj=Gj&&"object"==typeof module&&module&&!module.nodeType&&module,Kj=zj&&zj.exports===Gj&&kB.process,Xj=function(){try{var e=zj&&zj.require&&zj.require("util").types;return e||Kj&&Kj.binding&&Kj.binding("util")}catch(t){}}(),Wj=Xj&&Xj.isTypedArray,Yj=Wj?Hj(Wj):function(e){return LB(e)&&Aj(e.length)&&!!jj[MB(e)]},qj=Object.prototype.hasOwnProperty;function Jj(e,t){var r=UB(e),n=!r&&Lj(e),i=!r&&!n&&Bj(e),o=!r&&!n&&!i&&Yj(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&&!qj.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||gj(u,c))||s.push(u);return s}function Qj(e,t){return function(r){return e(t(r))}}var Zj=Qj(Object.keys,Object),$j=Object.prototype.hasOwnProperty;function eH(e){return wj(e)?Jj(e):function(e){if(!xj(e))return Zj(e);var t=[];for(var r in Object(e))$j.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var tH=Object.prototype.hasOwnProperty;function rH(e){if(!VB(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=xj(e),r=[];for(var n in e)("constructor"!=n||!t&&tH.call(e,n))&&r.push(n);return r}function nH(e){return wj(e)?Jj(e,!0):rH(e)}var iH,oH=(iH=function(e,t){kj(t,nH(t),e)},Ij((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=iH.length>3&&"function"==typeof i?(n--,i):void 0,o&&function(e,t,r){if(!VB(r))return!1;var n=typeof t;return!!("number"==n?wj(r)&&gj(t,r.length):"string"==n&&t in r)&&Sj(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&&iH(e,a,r,i)}return e}))),aH=nj(Object,"create");var sH=Object.prototype.hasOwnProperty;var cH=Object.prototype.hasOwnProperty;function uH(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 dH(e,t){for(var r=e.length;r--;)if(Sj(e[r][0],t))return r;return-1}uH.prototype.clear=function(){this.__data__=aH?aH(null):{},this.size=0},uH.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},uH.prototype.get=function(e){var t=this.__data__;if(aH){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return sH.call(t,e)?t[e]:void 0},uH.prototype.has=function(e){var t=this.__data__;return aH?void 0!==t[e]:cH.call(t,e)},uH.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=aH&&void 0===t?"__lodash_hash_undefined__":t,this};var lH=Array.prototype.splice;function hH(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])}}hH.prototype.clear=function(){this.__data__=[],this.size=0},hH.prototype.delete=function(e){var t=this.__data__,r=dH(t,e);return!(r<0)&&(r==t.length-1?t.pop():lH.call(t,r,1),--this.size,!0)},hH.prototype.get=function(e){var t=this.__data__,r=dH(t,e);return r<0?void 0:t[r][1]},hH.prototype.has=function(e){return dH(this.__data__,e)>-1},hH.prototype.set=function(e,t){var r=this.__data__,n=dH(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var vH=nj(IB,"Map");function pH(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 fH(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 _H(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}fH.prototype.clear=function(){this.size=0,this.__data__={hash:new uH,map:new(vH||hH),string:new uH}},fH.prototype.delete=function(e){var t=pH(this,e).delete(e);return this.size-=t?1:0,t},fH.prototype.get=function(e){return pH(this,e).get(e)},fH.prototype.has=function(e){return pH(this,e).has(e)},fH.prototype.set=function(e,t){var r=pH(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};var mH=Qj(Object.getPrototypeOf,Object);function gH(e){var t=this.__data__=new hH(e);this.size=t.size}gH.prototype.clear=function(){this.__data__=new hH,this.size=0},gH.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},gH.prototype.get=function(e){return this.__data__.get(e)},gH.prototype.has=function(e){return this.__data__.has(e)},gH.prototype.set=function(e,t){var r=this.__data__;if(r instanceof hH){var n=r.__data__;if(!vH||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new fH(n)}return r.set(e,t),this.size=r.size,this};var yH="object"==typeof exports&&exports&&!exports.nodeType&&exports,SH=yH&&"object"==typeof module&&module&&!module.nodeType&&module,bH=SH&&SH.exports===yH?IB.Buffer:void 0,EH=bH?bH.allocUnsafe:void 0;function kH(){return[]}var TH=Object.prototype.propertyIsEnumerable,IH=Object.getOwnPropertySymbols,RH=IH?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}(IH(e),(function(t){return TH.call(e,t)})))}:kH;var AH=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)_H(t,RH(e)),e=mH(e);return t}:kH;function wH(e,t,r){var n=t(e);return UB(e)?n:_H(n,r(e))}function CH(e){return wH(e,eH,RH)}function xH(e){return wH(e,nH,AH)}var OH=nj(IB,"DataView"),PH=nj(IB,"Promise"),NH=nj(IB,"Set"),DH="[object Map]",MH="[object Promise]",LH="[object Set]",UH="[object WeakMap]",VH="[object DataView]",FH=qB(OH),BH=qB(vH),jH=qB(PH),HH=qB(NH),GH=qB(ij),zH=MB;(OH&&zH(new OH(new ArrayBuffer(1)))!=VH||vH&&zH(new vH)!=DH||PH&&zH(PH.resolve())!=MH||NH&&zH(new NH)!=LH||ij&&zH(new ij)!=UH)&&(zH=function(e){var t=MB(e),r="[object Object]"==t?e.constructor:void 0,n=r?qB(r):"";if(n)switch(n){case FH:return VH;case BH:return DH;case jH:return MH;case HH:return LH;case GH:return UH}return t});var KH=zH,XH=Object.prototype.hasOwnProperty;var WH=IB.Uint8Array;function YH(e){var t=new e.constructor(e.byteLength);return new WH(t).set(new WH(e)),t}var qH=/\w*$/;var JH=RB?RB.prototype:void 0,QH=JH?JH.valueOf:void 0;var ZH="[object Boolean]",$H="[object Date]",eG="[object Map]",tG="[object Number]",rG="[object RegExp]",nG="[object Set]",iG="[object String]",oG="[object Symbol]",aG="[object ArrayBuffer]",sG="[object DataView]",cG="[object Float32Array]",uG="[object Float64Array]",dG="[object Int8Array]",lG="[object Int16Array]",hG="[object Int32Array]",vG="[object Uint8Array]",pG="[object Uint8ClampedArray]",fG="[object Uint16Array]",_G="[object Uint32Array]";function mG(e,t,r){var n,i,o,a=e.constructor;switch(t){case aG:return YH(e);case ZH:case $H:return new a(+e);case sG:return function(e,t){var r=t?YH(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case cG:case uG:case dG:case lG:case hG:case vG:case pG:case fG:case _G:return function(e,t){var r=t?YH(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,r);case eG:return new a;case tG:case iG:return new a(e);case rG:return(o=new(i=e).constructor(i.source,qH.exec(i))).lastIndex=i.lastIndex,o;case nG:return new a;case oG:return n=e,QH?Object(QH.call(n)):{}}}var gG=Xj&&Xj.isMap,yG=gG?Hj(gG):function(e){return LB(e)&&"[object Map]"==KH(e)};var SG=Xj&&Xj.isSet,bG=SG?Hj(SG):function(e){return LB(e)&&"[object Set]"==KH(e)},EG=1,kG=2,TG=4,IG="[object Arguments]",RG="[object Function]",AG="[object GeneratorFunction]",wG="[object Object]",CG={};function xG(e,t,r,n,i,o){var a,s=t&EG,c=t&kG,u=t&TG;if(r&&(a=i?r(e,n,i,o):r(e)),void 0!==a)return a;if(!VB(e))return e;var d=UB(e);if(d){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&XH.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=KH(e),h=l==RG||l==AG;if(Bj(e))return function(e,t){if(t)return e.slice();var r=e.length,n=EH?EH(r):new e.constructor(r);return e.copy(n),n}(e,s);if(l==wG||l==IG||h&&!i){if(a=c||h?{}:function(e){return"function"!=typeof e.constructor||xj(e)?{}:aj(mH(e))}(e),!s)return c?function(e,t){return kj(e,AH(e),t)}(e,function(e,t){return e&&kj(t,nH(t),e)}(a,e)):function(e,t){return kj(e,RH(e),t)}(e,function(e,t){return e&&kj(t,eH(t),e)}(a,e))}else{if(!CG[l])return i?e:{};a=mG(e,l,s)}}o||(o=new gH);var v=o.get(e);if(v)return v;o.set(e,a),bG(e)?e.forEach((function(n){a.add(xG(n,t,r,n,e,o))})):yG(e)&&e.forEach((function(n,i){a.set(i,xG(n,t,r,i,e,o))}));var p=d?void 0:(u?c?xH:CH:c?nH:eH)(e);return function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););}(p||e,(function(n,i){p&&(n=e[i=n]),Ej(a,i,xG(n,t,r,i,e,o))})),a}CG[IG]=CG["[object Array]"]=CG["[object ArrayBuffer]"]=CG["[object DataView]"]=CG["[object Boolean]"]=CG["[object Date]"]=CG["[object Float32Array]"]=CG["[object Float64Array]"]=CG["[object Int8Array]"]=CG["[object Int16Array]"]=CG["[object Int32Array]"]=CG["[object Map]"]=CG["[object Number]"]=CG[wG]=CG["[object RegExp]"]=CG["[object Set]"]=CG["[object String]"]=CG["[object Symbol]"]=CG["[object Uint8Array]"]=CG["[object Uint8ClampedArray]"]=CG["[object Uint16Array]"]=CG["[object Uint32Array]"]=!0,CG["[object Error]"]=CG[RG]=CG["[object WeakMap]"]=!1;function OG(e){return xG(e,5)}function PG(e,t){return function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}(t,(function(t){return e[t]}))}function NG(e){return null==e?[]:PG(e,eH(e))}var DG,MG,LG=rV(),UG=function(e){UI(u,e);var t,r,n,i,o,a,s,c=eR(u);function u(e,t){var r;return Hl(this,u),Zd(sI(r=c.call(this,e,t)),"name","chrome"),Zd(sI(r),"_queueBusy",!1),Zd(sI(r),"_sdpQueue",void 0),Zd(sI(r),"_aSendonlyOfferTpl",void 0),Zd(sI(r),"_vSendonlyOfferTpl",void 0),Zd(sI(r),"_aRecvonlyOfferTpl",void 0),Zd(sI(r),"_vRecvonlyOfferTpl",void 0),Zd(sI(r),"_mid",10),Zd(sI(r),"_inactiveMlineIndex",[]),Zd(sI(r),"_mlinesCache",{}),Zd(sI(r),"setDescription",void 0),r.logger=new fN("ChromeHandler",3,e.id),r.setDescription=t.setDescription.bind(t),r._sdpQueue=new EB,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(r.logger.info("dequeue start"),r.dequeue())})),r}return jl(u,[{key:"destroy",value:function(){MI(DI(u.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(s=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,N,D,M,L,U,V,F,B;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d=t.stream,l=t.enableSimulcast,h=MI(DI(u.prototype),"internalPublish",this).call(this,t),v=h.videoDescriptions,p=h.subVideoDescriptions,f=h.audioTransceiverInit,_=h.videoTransceiverInit,m=VV(this._nextSsrc),this._nextSsrc=m.next,g="".concat(this._mid++),y="".concat(this._mid++),S=el(el(el({},this._aSendonlyOfferTpl),this.peer._offerIce),{},{mid:g,msid:Mm(r="".concat(d.id," ")).call(r,d.id,"-audio"),ssrcs:FV(d.id,"audio",m.audio,UV)}),b=el(el(el({},this._vSendonlyOfferTpl),this.peer._offerIce),{},{mid:y,msid:Mm(n="".concat(d.id," ")).call(n,d.id,"-video")}),l?(this.logger.info("subVideoDesc","desc: %o ",p),delete b.ssrcGroups,delete b.ssrcs,E=[],b.rids=Km(v).call(v,(function(e){var t=e.rid;return E.unshift(t),{id:t,direction:"send"}})),b.simulcast={dir1:"send",list1:E.join(";")}):(k=BV(d.id,m,{cname:UV}),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=eA(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(C=ak(w=S.rtp).call(w,A,1),x=aI(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&&qV(b,null===(N=this._context)||void 0===N||null===(D=N.serverConfig)||void 0===D?void 0:D.videoCodec),Array.isArray(b.ext)&&(kM("IOS_SAFARI_ORIENTATION")||!MD&&!WD||(b.ext=Ks(L=b.ext).call(L,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&bk(t).call(t,"video-orientation"))}))),b.ext=Ks(M=b.ext).call(M,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&bk(t).call(t,"framemarking"))}))),(U=null==S?void 0:kE(c=S.rtp).call(c,(function(e){return"opus"===e.codec})))&&S.fmtp&&(B=kE(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||MD||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:HV(this.peer._offerSession,S,b),audioMid:g,videoMid:y,type:"incroffer",semantics:"unified-plan",videoDescriptions:v,subVideoDescriptions:p,audioTransceiverInit:f,videoTransceiverInit:_,peerConnectionMode:this.peerConnectionMode});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"subscribe",value:(a=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,N,D,M,L,U;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("subscribe"),a="incroffer",s="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return c=e.sent,e.next=9,this.createAVMlineOfferTpl(c);case 9:return u="",d="",l=!1,h=!1,v=void 0,p=void 0,this._mlinesCache[t.streamId]=[v,p],t.virtual?(u="".concat(this._mid++),l=!0):r.multiChatMode?(u="".concat(this._mid++),d="".concat(this._mid++),h=!0):(l=!0,h=!0,u="".concat(this._mid++),d="".concat(this._mid++)),u&&(v=el(el({},OG(this._aRecvonlyOfferTpl)),{},{mid:u})),l&&(this._mlinesCache[t.streamId][0]=v,f={track:"audio",init:{direction:"recvonly"}}),d&&(p=el(el({},OG(this._vRecvonlyOfferTpl)),{},{mid:d})),h&&(this._mlinesCache[t.streamId][1]=p,_={track:"video",init:{direction:"recvonly"}}),m=HV(this.peer._offerSession,v,p),g=void 0,y=void 0,t.enableVendorMode||r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl||(g=VV(this._nextSsrc),this._nextSsrc=g.next,A=el(el(el({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Mm(S=Mm(b="".concat(t.streamId)).call(b,null!==(E=this._context)&&void 0!==E&&E.avSync?"":"-audio"," ")).call(S,t.streamId,"-audio"),ssrcs:FV(t.streamId,"audio",g.audio)}),w=el(el(el({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:d,msid:Mm(k=Mm(T="".concat(t.streamId)).call(T,null!==(I=this._context)&&void 0!==I&&I.avSync?"":"-video"," ")).call(k,t.streamId,"-video")},BV(t.streamId,g,{flexfec:this._enableSubFlexfec})),y={sdp:vV.write(el(el({},this.peer._answerSession),{},{media:[A,w]})),sequenceId:t.sequenceId?++t.sequenceId:0},null===(R=g)||void 0===R||delete R.next),(C=null===(n=v)||void 0===n?void 0:kE(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=v)&&void 0!==o&&o.fmtp&&(P=null===(x=v)||void 0===x?void 0:kE(O=x.fmtp).call(O,(function(e){return e.payload===C.payload})))&&this._context&&(P.config+=";stereo=1;sprop-stereo=1"),t.isPublic&&aM>=86&&null!=(L=null===(N=p)||void 0===N?void 0:Ks(D=N.rtp).call(D,(function(e){return"H264"===e.codec})))&&L.length&&null!==(M=p)&&void 0!==M&&M.fmtp&&(null===(U=p)||void 0===U||U.fmtp.forEach((function(e){kE(L).call(L,(function(t){return t.payload===e.payload}))&&(e.config+=";sps-pps-idr-in-keyframe=1")}))),e.abrupt("return",{partialSdp:m,audioMid:u,videoMid:d,type:a,semantics:s,audioTransceiverInit:f,videoTransceiverInit:_,allSsrc:g,peerConnectionMode:this.peerConnectionMode,signalingAck:y});case 29:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handleAck",value:(o=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("handleAck()","item: %o",t),e.abrupt("return",this._sdpQueue.enqueue(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"dequeue",value:(i=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m=this;return wm().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!==gB.ADD){e.next=16;break}return e.delegateYield(wm().mark((function e(){var t,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=el({},m.peer._answerIce)).candidates,c=!1,u=!1,e.prev=4,l=dL(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,v=h instanceof _B;if(i.onSuccess&&s.push(i.onSuccess),i.onFail&&r.push(i.onFail),v&&(null==l?void 0:l.sequenceId)<h.sequenceId)return"break";var p,f={},_={},g=vV.parse(l.sdp);Array.isArray(g.media)&&KR(p=g.media).call(p,(function(e,t){var r;return null==e||null===(r=e.type)||void 0===r?void 0:r.localeCompare(null==t?void 0:t.type)})).forEach((function(r){"audio"===(r=el(el({},r),t)).type?(f=r).mid=e:(_=r).mid=n}));var y,S=h.streamId;if(c===yB.publish&&(S=null===(y=h.stream)||void 0===y?void 0:y.id),!m._mlinesCache[S])return"break";var b=aI(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",Fm({audioStreamTrack:Ew(u.track)}));var T=m._inactiveMlineIndex.shift();T||(T=m.peer._offerMlines.length),m.peer._offerMlines[T]=el({},E),m.peer._answerMlines[T]=f,LG&&h.initAudioEncodedTransform()}if(d&&k){var I,R;h.videoTransceiver=m._peerConnection.addTransceiver(d.track,d.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",Fm({videoStreamTrack:Ew(d.track)}));var A,w,C=m._inactiveMlineIndex.shift();C||(C=m.peer._offerMlines.length),m.peer._offerMlines[C]=el({},k),c===yB.publish&&null!==(I=m._context)&&void 0!==I&&null!==(R=I.serverConfig)&&void 0!==R&&R.videoCodec&&qV(_,null===(A=m._context)||void 0===A||null===(w=A.serverConfig)||void 0===w?void 0:w.videoCodec),m.peer._answerMlines[C]=_,LG&&h.initVideoEncodedTransform()}o.push(h.streamId||""),a.push(v?h.userId:"local"),v&&(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:_={},n.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;_[t]=t,n!==yB.removetrack&&(_[r]=r),_[t]=t})),this.peer._offerMlines=Km(v=this.peer._offerMlines).call(v,(function(e,t){return _[e.mid]&&(e=jV(e),m._inactiveMlineIndex.push(t)),e})),KR(p=this._inactiveMlineIndex).call(p,(function(e,t){return e-t})),this.peer._answerMlines=Km(f=this.peer._answerMlines).call(f,(function(e){return _[e.mid]&&(e=jV(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(Iq){}this.logger.info("dequeue","loop"),e.next=40;break;case 36:e.prev=36,e.t2=e.catch(7),this.logger.error("dequeue","unknown error: %o",e.t2),r.forEach((function(t){return t(e.t2)}));case 40:return e.prev=40,this.dequeue(),e.finish(40);case 43:case"end":return e.stop()}}),e,this,[[7,36,40,43],[21,26]])}))),function(){return i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=xm(wm().mark((function e(){var t,r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._genOfferSdp();case 2:return r=e.sent,this.createAVMlineOfferTpl(r),n=vV.parse(r),i=[],n.media=Ks(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=Ks(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),i.push("".concat(e.mid)),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:vV.write(n),semantics:"unified-plan",type:"incroffer"});case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"rollback",value:(r=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.msid,delete this._mlinesCache[r];case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;vV.parse(e).media.forEach((function(e){if("audio"===e.type)if("sendonly"===e.direction)t._aSendonlyOfferTpl=e;else{var r;if(Array.isArray(e.ext))e.ext=Ks(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=Ks(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}}))}},{key:"_genOfferSdp",value:(t=xm(wm().mark((function e(){var t,r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fD(!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 SA(_A.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return t.apply(this,arguments)})}]),u}(eF),VG=function(e){UI(d,e);var t,r,n,i,o,a,s,c,u=eR(d);function d(e,t){var r;return Hl(this,d),Zd(sI(r=u.call(this,e,t)),"name","firefox"),Zd(sI(r),"_aRecvonlyOfferTpl",void 0),r.logger=new fN("FirefoxHandler",3,e.id),r}return jl(d,[{key:"publish",value:(c=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,v,p,f,_,m=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=MI(DI(d.prototype),"internalPublish",this).call(this,t),o=i.videoDescriptions,a=i.subVideoDescriptions,s=i.audioTransceiverInit,c=i.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(s.track,s.init),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),u=tD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=7,this._peerConnection.createOffer();case 7:return l=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:tD()-u}),(h=vV.parse(l.sdp)).media=null===(r=h.media)||void 0===r?void 0:Km(r).call(r,(function(e){return el(el({},e),m.peer._offerIce)})),e.next=13,this.setLocalDescription(vV.write(h));case 13:return v=t.audioTransceiver.mid,p=t.videoTransceiver.mid,f=null,_=null,h.media=null===(n=h.media)||void 0===n?void 0:Km(n).call(n,(function(e){if("".concat(e.mid)===v){var t,r,n=null===(t=f=e)||void 0===t?void 0:kE(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&f.fmtp){var i,o,a=kE(i=f.fmtp).call(i,(function(e){return e.payload===n.payload}));a&&null!==(o=m._context)&&void 0!==o&&o.audioProfileManager&&(a.config=m._context.audioProfileManager.getOpusConfigStr(a.config))}}else if("".concat(e.mid)===p){var s,c,u,d;null!==(s=m._context)&&void 0!==s&&null!==(c=s.serverConfig)&&void 0!==c&&c.videoCodec&&qV(e,null===(u=m._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec),_=e}return e})),this.addBitrateLimit(_,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(vV.write(h));case 21:return e.abrupt("return",{partialSdp:HV(h,f,_,!1),audioMid:v,videoMid:p,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:c,peerConnectionMode:this.peerConnectionMode});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,R,A,w=this;return wm().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,v=void 0,t.virtual?d=!0:(r.multiChatMode||(d=!0),l=!0),d&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),l&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),p=tD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return f=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:tD()-p}),(_=vV.parse(f.sdp)).media=null===(n=_.media)||void 0===n?void 0:Km(n).call(n,(function(e){return el(el({},e),w.peer._offerIce)})),Km(i=_.media).call(i,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Ks(t).call(t,(function(e){var t;return-1===DE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Ks(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=21,this.setLocalDescription(vV.write(_),{streamId:t.streamId||"",streamUserId:t.userId});case 21: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&&(v=e)})),c&&h||(c="audio_".concat(u),h=el(el({},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=VV(this._nextSsrc),this._nextSsrc=m.next,R=el(el(el({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:c,msid:Mm(y=Mm(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:FV(t.streamId,"audio",m.audio)}),A=el(el(el({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Mm(E=Mm(k="".concat(t.streamId)).call(k,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},BV(t.streamId,m,{flexfec:this._enableSubFlexfec})),g={sdp:vV.write(el(el({},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:HV(_,h,v,!1),audioMid:c,videoMid:u,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:m,peerConnectionMode:this.peerConnectionMode,signalingAck:g});case 31:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=xm(wm().mark((function e(t){var r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==yB.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==yB.unpublish&&i!==yB.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=vV.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=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=vV.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=el(el({},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 fB&&tM<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=Ks(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=Ks(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=Ks(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=Ks(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=vV.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=Km(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,Km(a=c.media).call(a,(function(e){var t,r,n;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Ks(t).call(t,(function(e){var t;return-1===DE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Ks(r).call(r,(function(e){return"goog-remb"!==e.type})),tM>=138&&(e.ext=null===(n=e.ext)||void 0===n?void 0:Ks(n).call(n,(function(e){var t;return!bk(t=e.uri).call(t,"sdes:mid")}))))})),e.next=11,this.setRemoteDescription(vV.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=xm(wm().mark((function e(){var t,r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=vV.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Ks(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:vV.write(i),semantics:"unified-plan",type:"incroffer"});case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=xm(wm().mark((function e(t){var r,n,i;return wm().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=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,p,f=this;return wm().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=vV.parse(null==l?void 0:l.sdp)).media=Km(i=h.media).call(i,(function(e){return u[e.mid]&&(e=jV(e)),"inactive"!==e.direction&&d.push(e.mid),el(el({},e),f.peer._offerIce)})),v=vV.parse(null===(o=this._peerConnection.remoteDescription)||void 0===o?void 0:o.sdp),p={},v.media.forEach((function(e){void 0!==e.mid&&(p[e.mid]=e)})),v.media=Km(a=h.media).call(a,(function(e){return"inactive"===e.direction?e:p[e.mid]})),h.groups&&v.groups&&(h.groups[0].mids=d.join(" "),v.groups[0].mids=d.join(" ")),e.next=19,this.setLocalDescription(vV.write(h));case 19:return e.next=21,this.setRemoteDescription(vV.write(v));case 21:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=xm(wm().mark((function e(){return wm().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;vV.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(eF),FG=function(e){UI(d,e);var t,r,n,i,o,a,s,c,u=eR(d);function d(e,t){var r;return Hl(this,d),Zd(sI(r=u.call(this,e,t)),"name","fallback"),Zd(sI(r),"_aRecvonlyOfferTpl",void 0),r.logger=new fN("FallbackHandler",3,e.id),r.logger.warn("ctor","using fallback handler"),r._report("rtc_error",{message:"using fallback handler",error_code:-1}),r}return jl(d,[{key:"publish",value:(c=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,v,p,f,_;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=MI(DI(d.prototype),"internalPublish",this).call(this,t),i=n.videoDescriptions,o=n.subVideoDescriptions,a=n.audioTransceiverInit,s=n.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(a.track,a.init),Array.isArray(s.init.sendEncodings)&&1===s.init.sendEncodings.length&&(s.init.sendEncodings=Km(c=s.init.sendEncodings).call(c,(function(e){return delete e.rid,e}))),t.videoTransceiver=this._peerConnection.addTransceiver(s.track,s.init),u=tD(),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 l=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:tD()-u}),h=vV.parse(l.sdp),e.next=13,this.setLocalDescription(l.sdp);case 13:return v=t.audioTransceiver.mid,p=t.videoTransceiver.mid,f=null,_=null,h.media=null===(r=h.media)||void 0===r?void 0:Km(r).call(r,(function(e){return"".concat(e.mid)===v?f=e:"".concat(e.mid)===p&&(_=e),e})),rV()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:HV(h,f,_),audioMid:v,videoMid:p,type:"incroffer",semantics:"unified-plan",videoDescriptions:i,subVideoDescriptions:o,audioTransceiverInit:a,videoTransceiverInit:s,peerConnectionMode:this.peerConnectionMode});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("subscribe()"),a="",s="",c=!1,u=!1,d=void 0,l=void 0,t.virtual?c=!0:(r.multiChatMode||(c=!0),u=!0),c&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),u&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),h=tD(),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 v=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:tD()-h}),p=vV.parse(v.sdp),e.next=19,this.setLocalDescription(v.sdp,{streamId:t.streamId||"",streamUserId:t.userId});case 19:return a=null===(n=t.audioTransceiver)||void 0===n?void 0:n.mid,s=null===(i=t.videoTransceiver)||void 0===i?void 0:i.mid,null===(o=p.media)||void 0===o||o.forEach((function(e){"".concat(e.mid)===a?d=e:"".concat(e.mid)===s&&(l=e)})),a&&d||(a="audio_".concat(s),d=el(el({},this._aRecvonlyOfferTpl),{},{mid:a})),t.audioMid=a,t.videoMid=s,f=void 0,_=void 0,!r.multiChatMode&&!t.virtual&&this._aSendonlyAnswerTpl&&this._aSendonlyAnswerTpl&&(f=VV(this._nextSsrc),this._nextSsrc=f.next,T=el(el(el({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:a,msid:Mm(m=Mm(g="".concat(t.streamId)).call(g,null!==(y=this._context)&&void 0!==y&&y.avSync?"":"-audio"," ")).call(m,t.streamId,"-audio"),ssrcs:FV(t.streamId,"audio",f.audio)}),I=el(el(el({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:s,msid:Mm(S=Mm(b="".concat(t.streamId)).call(b,null!==(E=this._context)&&void 0!==E&&E.avSync?"":"-video"," ")).call(S,t.streamId,"-video")},BV(t.streamId,f,{flexfec:this._enableSubFlexfec})),_={sdp:vV.write(el(el({},this.peer._answerSession),{},{media:[T,I]})),sequenceId:t.sequenceId?++t.sequenceId:0},null===(k=f)||void 0===k||delete k.next),rV()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:HV(p,d,l,!1),audioMid:a,videoMid:s,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:f,peerConnectionMode:this.peerConnectionMode,signalingAck:_});case 30:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=xm(wm().mark((function e(t){var r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==yB.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==yB.unpublish&&i!==yB.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=vV.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=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=vV.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){"audio"===(e=el(el({},e),l.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e)})),u=vV.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=Km(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,Km(a=c.media).call(a,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Ks(t).call(t,(function(e){var t;return-1===DE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Ks(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(vV.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=xm(wm().mark((function e(){var t,r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("getDefaultSdp"),i=vV.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=Ks(n=i.media).call(n,(function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,o.push("".concat(e.mid)),!0)})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:vV.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=xm(wm().mark((function e(t){var r,n,i;return wm().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=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,p,f=this;return wm().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=vV.parse(null==l?void 0:l.sdp)).media=Km(i=h.media).call(i,(function(e){return u[e.mid]&&(e=jV(e)),"inactive"!==e.direction&&d.push(e.mid),el(el({},e),f.peer._offerIce)})),v=vV.parse(null===(o=this._peerConnection.remoteDescription)||void 0===o?void 0:o.sdp),p={},v.media.forEach((function(e){void 0!==e.mid&&(p[e.mid]=e)})),v.media=Km(a=h.media).call(a,(function(e){return"inactive"===e.direction?e:p[e.mid]})),h.groups&&v.groups&&(h.groups[0].mids=d.join(" "),v.groups[0].mids=d.join(" ")),e.next=19,this.setLocalDescription(null==l?void 0:l.sdp);case 19:return e.next=21,this.setRemoteDescription(vV.write(v));case 21:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=xm(wm().mark((function e(){return wm().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;vV.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(eF),BG=function(e,t){return e.enableFallbackHandler?new FG(e,t):DD?new VG(e,t):new UG(e,t)},jG=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}(jG||{}),HG=function(e){return e.PushLimitWarn="PushLimitWarn",e}(HG||{}),GG=function(e){return e.ON_ADD_STREAM="onAddStream",e.ON_ADD_STREAM_LIST="onAddStreamList",e.ON_REMOVE_STREAM="onRemoveStream",e.ON_REMOVE_STREAM_LIST="onRemoveStreamList",e.USER_DISCONNECTION="userDisconnection",e.USER_DISCONNECTION_LIST="userDisconnectionList",e.USER_CONNECTION="userConnection",e.USER_CONNECTION_LIST="userConnectionList",e.ON_UPDATE_STREAM_ATTRIBUTES="onUpdateStreamAttributes",e.ON_UPDATE_ROOM_ATTRIBUTES="onUpdateRoomAttributes",e.ON_UPDATE_USER_ATTRIBUTES="onUpdateUserAttributes",e.ON_PUSH_TRACK="onPushTrack",e.ON_REMOVE_TRACK="onRemoveTrack",e.ON_CUSTOM_MESSAGE="onCustomMessage",e.NODE_CHANGE="nodeChange",e.USER_MESSAGE_RECEIVED="userMessageReceived",e.USER_BINARY_MESSAGE_RECEIVED="userBinaryMessageReceived",e.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM="userMessageReceivedOutsideRoom",e.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM="userBinaryMessageReceivedOutsideRoom",e.POST_PROCESSING_MESSAGE="postProcessingMessage",e.ON_USER_TOKEN_WILL_EXPIRE="onUserTokenWillExpire",e.STREAM_CONTROL_MESSAGE="streamControlMessage",e.ON_SPEAKER_CHANGE="onSpeakerChange",e.ON_STREAM_FAILED="streamFailed",e.ON_NOTIFY_RECONNECT="notifyReconnect",e.ON_FORWARD_DST_ROOM_USER_KICK="onForwardDstRoomUserKick",e}(GG||{}),zG=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(zG||{}),KG=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ON_VENDOR_CONNECTION_STATE_CHANGE="onVendorConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(KG||{}),XG=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(XG||{}),WG=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(WG||{}),YG=new fN("Locker",2),qG=1,JG=function(){function e(t){var r;Hl(this,e),Zd(this,"lockingPromise",$_.resolve()),Zd(this,"locks",0),Zd(this,"name",""),Zd(this,"lockId",void 0),this.lockId=qG++,t&&(this.name=t),YG.info(Mm(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return jl(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,YG.info(Mm(e=Mm(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new $_((function(e){r=function(){var t,r;n.locks-=1,YG.info(Mm(t=Mm(r="[lock-".concat(n.name,"-")).call(r,n.lockId,"] unlocked, current queue ")).call(t,n.locks,".")),e()}})),o=this.lockingPromise.then((function(){return r}));return this.lockingPromise=this.lockingPromise.then((function(){return i})),o}}]),e}(),QG=function(e){return e.RESUBSCRIBE="resubscribe",e.STREAM_FAILED="stream_failed",e.SUBSCRIBE_PUSH_TRACK="subscribe_push_track",e.REMOVE_PUSH_TRACK="remove_push_track",e.VIDEO_FIRST_FRAME="video_first_frame",e.ON_USER_PUBLISH_STATE_CHANGE="on_user_publish_state_change",e.ON_USER_START_AUDIO_CAPTURE="on_user_start_audio_capture",e.ON_USER_STOP_AUDIO_CAPTURE="on_user_stop_audio_capture",e.ON_USER_START_VIDEO_CAPTURE="on_user_start_video_capture",e.ON_USER_STOP_VIDEO_CAPTURE="on_user_stop_video_capture",e.ON_SEI_MESSAGED_RECEIVED="on_sei_messaged_received",e.ON_PUBLISH_RESULT="on_publish_result",e.ON_UPDATE_TOKEN_SUCCESS="on_update_token_success",e.ON_REMOTE_STREAM_STATS="ON_REMOTE_STREAM_STATS",e.ON_LOCAL_STREAM_STATS="ON_LOCAL_STREAM_STATS",e.ON_USER_LEAVE="on_user_leave",e.ON_ROOM_ERROR="on_room_error",e.ON_NETWORK_QUALITY="on_network_quality",e.ON_SIMULCAST_SUBSCRIBE_FALLBACK="on_simulcast_subscribe_fallback",e.ON_REMOTE_VIDEO_SIZE_CHANGED="on_remote_video_size_changed",e.RECONNECT_FAILED="reconnect_failed",e.ON_SUBTITLE_STATE_CHANGED="ON_SUBTITLE_STATE_CHANGED",e.ON_SUBTITLE_MESSAGE_RECEIVED="ON_SUBTITLE_MESSAGE_RECEIVED",e.ON_VIDEO_STREAM_BANNED="ON_VIDEO_STREAM_BANNED",e.ON_AUDIO_STREAM_BANNED="ON_AUDIO_STREAM_BANNED",e.ON_FORWARD_STREAM_ERROR="ON_FORWARD_STREAM_ERROR",e.ON_REJOIN_WITH_TCP="ON_REJOIN_WITH_TCP",e.ON_ICE_CONNECT_WITH_TCP="ON_ICE_CONNECT_WITH_TCP",e.PUB_RETRY="PUB_RETRY",e.SUB_RETRY="SUB_RETRY",e}(QG||{}),ZG=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}(ZG||{}),$G=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}($G||{}),ez=(Zd(DG={},Il.communication,[0]),Zd(DG,Il.chat,[0]),Zd(DG,Il.chatRoom,[1,"IES_chatroom"]),Zd(DG,Il.coHost,[1,"IES_PK"]),Zd(DG,Il.meeting,[16]),Zd(DG,Il.classRoom,[0]),DG),tz=rV(),rz=function(e){UI(s,e);var t,r,n,i,o,a=eR(s);function s(e,t){var r;return Hl(this,s),Zd(sI(r=a.call(this,e,t)),"_peerConnectionId",eD()),Zd(sI(r),"peerConnectionMode",1),Zd(sI(r),"name","vendor"),Zd(sI(r),"direction","up"),Zd(sI(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 jl(s,[{key:"publish",value:(o=xm(wm().mark((function e(t){var r,n,i,o,a,c,u,d,l,h,v=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.enableSimulcast=!1,this.stream=t,r=MI(DI(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),tz&&(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=tD(),d=vV.parse(c.sdp),Array.isArray(d.media)&&(d.media=Km(l=d.media).call(l,(function(e){var r,n,i,o,a;if("video"===e.type)null!==(r=v._context)&&void 0!==r&&null!==(n=r.serverConfig)&&void 0!==n&&n.videoCodec&&qV(e,null===(i=v._context)||void 0===i||null===(o=i.serverConfig)||void 0===o?void 0:o.videoCodec),(MD||WD)&&Array.isArray(e.ext)&&(e.ext=Ks(a=e.ext).call(a,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&bk(t).call(t,"video-orientation"))}))),MD||v.addBitrateLimit(e,t.videoEncodeConfig[0].maxKbps);else if("audio"===e.type){var s,c=null==e?void 0:kE(s=e.rtp).call(s,(function(e){return"opus"===e.codec}));if(c&&e.fmtp){var u,d,l=kE(u=e.fmtp).call(u,(function(e){return e.payload===c.payload}));l&&null!==(d=v._context)&&void 0!==d&&d.audioProfileManager&&(l.config=v._context.audioProfileManager.getOpusConfigStr(l.config))}}return e}))),h=new RTCSessionDescription({type:"offer",sdp:vV.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:tD()-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:tD()-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=xm(wm().mark((function e(t){var r,n,i,o,a,s=this;return wm().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"}),tz&&(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=tD(),i=vV.parse(r.sdp),Array.isArray(i.media)&&(i.media=Km(o=i.media).call(o,(function(e){if("audio"===e.type){var t,r=null==e?void 0:kE(t=e.rtp).call(t,(function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n,i=null==e?void 0:kE(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:vV.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:tD()-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:tD()-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=xm(wm().mark((function e(t){var r,n,i,o,a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.action!==yB.publish&&t.action!==yB.subscribe){e.next=16;break}return n=new RTCSessionDescription({sdp:null===(r=t.signalingAck)||void 0===r?void 0:r.sdp,type:"answer"}),i=tD(),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:tD()-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:tD()-i},{type:"offer"}),e.t0;case 13:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=17;break;case 16:t.action!==yB.unpublish&&t.action!==yB.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(),MI(DI(s.prototype),"destroy",this).call(this)}},{key:"getDefaultSdp",value:(r=xm(wm().mark((function e(){return wm().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=xm(wm().mark((function e(){return wm().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}(eF),nz=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}(nz||{}),iz={start_interval:100,multiplier:2,max_interval:3e4},oz=function(){function e(){Hl(this,e),Zd(this,"_times",0),Zd(this,"_config",iz),Zd(this,"initTs",tD())}return jl(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}(),az=function(){function e(t){Hl(this,e),Zd(this,"_reconnectTimer",void 0),Zd(this,"_abortControllers",[]),Zd(this,"_monitor",void 0),Zd(this,"logger",void 0),Zd(this,"_groupConfigId",eD()),Zd(this,"_retryLimiter",new oz),Zd(this,"_timer",void 0),this._ctx=t,this._monitor=YP(t.id),this.logger=new fN("ICERequest",4,t.id)}var t,r,n,i;return jl(e,[{key:"getICENode",value:(i=xm(wm().mark((function e(t){var r;return wm().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 SA(_A.ICE_SERVER_WRONG,"get ICE config failed: ".concat(e.t0.message),e.t0);case 13:return this.logger.success("getICENode","success"),this._reportRtcInvokeStatus("es.join.getNodeSuccess",r),e.abrupt("return",r);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return i.apply(this,arguments)})},{key:"_getAccessWithRetry",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 0!==r&&this.logger.info("_getAccessWithRetry()","invoke feedbackInfo: %o, 201count: %o",e,r),new $_((function(n,i){t._getAccessNode(e).then((function(e){t._retryLimiter.reset(),n(e)})).catch((function(o){if(Array.isArray(o)&&o.length>0){if(eA(o).call(o,(function(e){return 400<=e.code&&e.code<500}))>-1)return t._retryLimiter.reset(),i(new Error("HTTP request failed(4xx)"));if(o.every((function(e){var t;return 201===e.code||201===(null===(t=e.error)||void 0===t?void 0:t.code)}))&&r++,3===r)return t._retryLimiter.reset(),i(new Error("HTTP request failed(201)"))}var a=t._retryLimiter.getRetryDelay();t.logger.warn("_getAccessWithRetry()","_getAccessWithRetry error, will retry after ".concat(a,"ms"),o),t._reconnectTimer=self.setTimeout((function(){t._getAccessWithRetry(e,r).then(n).catch(i)}),a)}))}))}},{key:"_getAccessNode",value:(n=xm(wm().mark((function e(t){var r=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new $_((function(e,n){var i=pM.getAccessNode(r._ctx.appId);i?(r.logger.info("getAccessNode","use cache node."),e(Array.isArray(i)?i:[i]),r._timer=window.setTimeout((function(){r._getAccessNodeFromServer(t),r._reportRtcInvokeStatus("es.R.node.cache",i),delete r._timer}),0)):r._getAccessNodeFromServer(t).then(e).catch(n)})));case 1:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"_getAccessNodeFromServer",value:(r=xm(wm().mark((function e(t){var r,n,i,o=this;return wm().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&&pM.setAccessNode(o._ctx.appId,t,e.ttl||11200),e.dispatchDomains&&!o._ctx.useCloudProxy&&pM.setAccessUrls(e.dispatchDomains),t})).catch((function(e){if(i)return o._reportRtcInvokeStatus("es.R.req.fallback",""),pM.clearAccessUrls(),o._getAccessNodeFromServer(t);throw e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_getAccessUrls",value:function(){var e=pM.getAccessUrls()||[],t=!0;return this._reportRtcInvokeStatus("es.R.req.cache.urls",e),0===e.length&&(e=bM.ICE_CONFIG_REQUEST_URLS,t=!1,this._reportRtcInvokeStatus("es.R.req.external.urls",e)),0===e.length&&(e=bM.ICE_CONFIG_REQUEST_URLS_INTERNAL,t=!1,this._reportRtcInvokeStatus("es.R.req.internal.urls",e)),{urls:e,needFallback:t}}},{key:"getICEConfigFromServer",value:(t=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=eD(),o={appID:this._ctx.appId,deviceID:pM.getDeviceId(),connectSessionID:i,os:"web",sdkVersion:bM.VERSION,isOversea:bM.OVERSEA,expectedAddr:kM("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC,accessParams:Fm({requireICEUfragV2:!0})},r&&(o.feedbackInfo=r,"ICE_FAILED"!==(null===(a=r[0])||void 0===a||null===(s=a.feedbackReason)||void 0===s?void 0:s.type)&&delete o.expectedAddr),c=Date.now(),null===(n=this._monitor)||void 0===n||n.report("rtc_get_access",{error_code:0,message:Fm(o),elapse:0,type:"request",host:t.join(","),config_id:i,group_config_id:this._groupConfigId}),u=Km(t).call(t,function(){var e=xm(wm().mark((function e(t){var r,n,i,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new AbortController,d._abortControllers.push(n),e.prev=2,e.next=5,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:Fm(o),signal:n.signal});case 5:i=e.sent,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(2),bw(fetch)||null===(a=d._monitor)||void 0===a||a.report("rtc_error",{error_code:nz.Fetch_MODIFY,message:"get access failed, possibly due to modifying the browser's Fetch API."},{origin_error:e.t0}),e.t0;case 12:if(d._abortControllers=Ks(r=d._abortControllers).call(r,(function(e){return e!==n})),200===i.status){e.next=15;break}throw{message:i.statusText,code:i.status};case 15:return e.next=17,i.json();case 17:if(200===(s=e.sent).code){e.next=20;break}throw s;case 20:if(0!==s.nodes.length){e.next=22;break}throw{code:s.code,message:Fm(s)};case 22:return e.abrupt("return",{url:t,result:s});case 23:case"end":return e.stop()}}),e,null,[[2,8]])})));return function(t){return e.apply(this,arguments)}}()),e.abrupt("return",_D(u).then((function(e){var t,r=e.result,n=e.url;return null===(t=d._monitor)||void 0===t||t.report("rtc_get_access",{error_code:200,message:Fm(r),elapse:Date.now()-c,type:"response",host:n,config_id:i,group_config_id:d._groupConfigId}),r})).catch((function(e){var r,n,o,a;throw null===(r=d._monitor)||void 0===r||r.report("rtc_get_access",{error_code:Number((null===(n=e[0])||void 0===n?void 0:n.code)||(null===(o=e[0])||void 0===o?void 0:o.server_code)),message:null===(a=e[0])||void 0===a?void 0:a.message,elapse:Date.now()-c,type:"response",host:t.join(","),config_id:i,group_config_id:d._groupConfigId},{error:Fm(e)}),e})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._abortControllers.forEach((function(e){return e.abort()})),this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer),this._timer&&(window.clearTimeout(this._timer),delete this._timer)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r;null===(r=this._monitor)||void 0===r||r.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:0,stream_id:"",elapse:0,group_config_id:this._groupConfigId})}}]),e}(),sz={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!rV()||void 0},cz=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}(cz||{}),uz=0,dz=function(e){UI(s,e);var t,r,n,i,o,a=eR(s);function s(e,t){var r;return Hl(this,s),Zd(sI(r=a.call(this)),"uuid",(uz++).toString()),Zd(sI(r),"_peerConnectionId",""),Zd(sI(r),"audioTrack4ff",void 0),Zd(sI(r),"_pc",void 0),Zd(sI(r),"_dc",void 0),Zd(sI(r),"_iceNode",void 0),Zd(sI(r),"_initSctpEvents",!1),Zd(sI(r),"_monitor",void 0),Zd(sI(r),"_offerIce",{}),Zd(sI(r),"_answerIce",{}),Zd(sI(r),"_offerSession",void 0),Zd(sI(r),"_answerSession",void 0),Zd(sI(r),"_offerMlines",[]),Zd(sI(r),"_answerMlines",[]),Zd(sI(r),"_connectReject",void 0),Zd(sI(r),"_logger",void 0),r._ctx=e,r._groupConnectionId=t,r._monitor=YP(e.id),r._logger=new fN("PeerConnection_".concat(r.uuid),4,e.id),r._ctx.enableFallbackHandler&&r._logger.warn("ctor","PeerConnection running in fallback mode"),r._pc=new RTCPeerConnection(sz),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",Mm(i=Mm(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",Mm(e="".concat(r._pc.connectionState,". ice -> ")).call(e,r._pc.iceConnectionState)),"failed"!==r._pc.iceConnectionState&&"closed"!==r._pc.iceConnectionState&&"failed"!==r._pc.connectionState||r.emit("disconnect","ice failed")},r._pc.oniceconnectionstatechange=function(){var e=r._pc.iceConnectionState;r._report("rtc_pre_ice_state",{message:e,ice_state:e.toUpperCase()}),r.emit("ice_state",e)},r}return jl(s,[{key:"getOriginRTCPeerConnection",value:function(){return this._pc}},{key:"getOriginRTCDataChannel",value:function(){return this._dc}},{key:"getConnectionId",value:function(){return this._peerConnectionId}},{key:"getGroupConnectionId",value:function(){return this._groupConnectionId}},{key:"connect",value:(o=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b=this;return wm().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,DD&&tM<138&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=15,this._pc.createOffer();case 15:if((a=e.sent).sdp){e.next=18;break}throw new SA(_A.NOT_SUPPORTED,"create offer sdp failed.");case 18:if(s=vV.parse(a.sdp),this._peerConnectionId=o.iceUfrag||"",!i.iceUfrag&&!i.icePwd&&((l="renomination"===(null===(c=s.media[0])||void 0===c?void 0:c.iceOptions))||(delete i.iceOptions,delete o.iceOptions),delete i.iceUfrag,delete i.icePwd,h=YV({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(u=s.media[0])||void 0===u?void 0:u.icePwd,options:(d={},Zd(d,WV.kICEConfigTypeSrtpDtlsType,!0),Zd(d,WV.kICEConfigTypeRenominationType,l),d)}),v=aI(h,2),p=v[0],f=v[1],this._peerConnectionId=f,o.iceUfrag=p,this._logger.info("use serverUfrag v2",Fm({dtls:!0,renomination:l}))),_=aI(s.media,1),m=_[0],this._offerIce.fingerprint=s.fingerprint||m.fingerprint,!DD&&!this._ctx.enableFallbackHandler){e.next=40;break}if(s.media=Km(g=s.media).call(g,(function(e){var t,r,n=el(el({},e),b._offerIce);return"video"===n.type&&(n.ext=null===(t=n.ext)||void 0===t?void 0:Ks(t).call(t,(function(e){var t;return-1===DE(t=e.uri).call(t,"abs-send-time")})),n.rtcpFb=null===(r=n.rtcpFb)||void 0===r?void 0:Ks(r).call(r,(function(e){return"goog-remb"!==e.type}))),n})),(S=el({},s)).fingerprint=this._answerIce.fingerprint,S.media=Km(y=S.media).call(y,(function(e){return delete(e=el(el({},e),b._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),!this._ctx.enableFallbackHandler){e.next=34;break}return e.next=32,this.setLocalDescription(a.sdp);case 32:e.next=36;break;case 34:return e.next=36,this.setLocalDescription(vV.write(s));case 36:return e.next=38,this.setRemoteDescription(vV.write(S));case 38:e.next=48;break;case 40:delete s.media,this._offerSession=el({},s),this._answerSession=el({},s),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),this._offerMlines=[el(el(el({},m),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[el(el(el({},m),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription();case 48:return e.next=50,new $_((function(e,t){b._connectReject=t,r.onopen=function(){b._print("connect","dataChannel open"),b._reportRtcInvokeStatus("es.dc.open",""),e(""),delete b._connectReject},r.onerror=function(e){var t,r,n,i;b._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"}),b._reportRtcInvokeStatus("es.dc.error",""),null===(n=b._connectReject)||void 0===n||n.call(b,{message:"dc.onerror, ".concat(null===(i=e.error)||void 0===i?void 0:i.errorDetail),code:0}),b.emit("disconnect","dc onerror"),delete b._connectReject},r.onclose=function(){var e;b._reportRtcInvokeStatus("es.dc.close",""),null===(e=b._connectReject)||void 0===e||e.call(b,{message:"dc.onclose",code:1}),b.emit("disconnect","dc onclose"),delete b._connectReject},b._pc.addEventListener("connectionstatechange",(function(){var e,t;"failed"!==b._pc.iceConnectionState&&"closed"!==b._pc.iceConnectionState&&"failed"!==b._pc.connectionState||(null===(e=b._connectReject)||void 0===e||e.call(b,{message:Mm(t="pc.connectionstatechange -> ".concat(b._pc.connectionState,", ice -> ")).call(t,b._pc.iceConnectionState),code:2}),delete b._connectReject)})),setTimeout((function(){var e;null===(e=b._connectReject)||void 0===e||e.call(b,{code:4,message:"connect timeout"}),delete b._connectReject}),8e3)}));case 50:return this._print("connect","dataChannel establish success"),e.abrupt("return",r);case 52:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setDescription",value:(i=xm(wm().mark((function e(t){var r,n;return wm().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=tD(),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:tD()-n}),e.next=13,this.setLocalDescription(vV.write(this._offerSession),t);case 13:return e.next=15,this.setRemoteDescription(vV.write(this._answerSession),t);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setLocalDescription",value:(n=xm(wm().mark((function e(t,r){var n,i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=tD(),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:tD()-n},{type:"offer"}),this._initSctpEvents||(this._initSctpEvents=!0,(o=null===(i=this._pc)||void 0===i?void 0:i.sctp)&&(o.onstatechange=function(){a._reportRtcInvokeStatus("sctp","sctp state change TO: ".concat(o.state))},o.transport&&(o.transport.onstatechange=function(){var e;a._reportRtcInvokeStatus("dtls","dtls state change TO: ".concat(null==o||null===(e=o.transport)||void 0===e?void 0:e.state))}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:"",stream_user_id:"",elapse:tD()-n},{type:"offer"});case 12:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(r=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=tD(),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:tD()-n},{type:"answer"}),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(1),console.error("setRemote",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:tD()-n},{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"disconnect",value:function(){var e,t;null===(e=this._connectReject)||void 0===e||e.call(this,{code:3,message:"invoke destroy()"}),delete this._connectReject,this._pc.close(),null===(t=this._dc)||void 0===t||t.close(),this._pc.ontrack=null}},{key:"destroy",value:function(){this._print("destroy",this._peerConnectionId),MI(DI(s.prototype),"removeAllListeners",this).call(this),this.disconnect()}},{key:"_genIceInfo",value:(t=xm(wm().mark((function e(t){var r,n,i,o;return wm().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,GV(t);case 3:return o=e.sent,e.abrupt("return",{offerIce:i,answerIce:o});case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"_print",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];(t=this._logger).info.apply(t,Mm(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,el(el({},t),{},{connection_id:this._peerConnectionId,group_connection_id:this._groupConnectionId}),el(el({},r),{},{tcp_only:null===(i=this._iceNode)||void 0===i?void 0:i.iceConfig.tcpOnly,ms_addr:Fm((null===(o=this._iceNode)||void 0===o?void 0:Km(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 SA(_A.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 SA(_A.NOT_SUPPORTED,"missing peer.".concat(e," API."))}))}}]),s}($M);function lz(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],DE(t).call(t,r)>=0||(i[r]=e[r]);return i}(e,t);if(Ns){var o=Ns(e);for(n=0;n<o.length;n++)r=o[n],DE(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var hz=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(hz||{}),vz=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}(vz||{}),pz=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}(pz||{}),fz=(Zd(MG={},0,[0,"success"]),Zd(MG,1,[_A.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),Zd(MG,2,[_A.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),Zd(MG,3,[_A.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),Zd(MG,4,[_A.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),Zd(MG,5,[_A.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),Zd(MG,17,[_A.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),Zd(MG,18,[_A.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),Zd(MG,100,[_A.USER_MESSAGE_NOT_JOIN,"not join room"]),Zd(MG,105,[_A.USER_MESSAGE_NOT_LOGIN,"not login."]),Zd(MG,106,[_A.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),Zd(MG,1e3,[_A.USER_MESSAGE_UNKNOWN,"unknown."]),MG),_z=["msg"],mz=[],gz=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}(gz||{}),yz=function(e){UI(a,e);var t,r,n,i,o=eR(a);function a(e,t){var r;return Hl(this,a),Zd(sI(r=o.call(this)),"_singlingCache",new ib),Zd(sI(r),"_p2pCache",new ib),Zd(sI(r),"_rttIds",{}),Zd(sI(r),"_p2pMessageId",1),Zd(sI(r),"_clearDataChannelListener",void 0),Zd(sI(r),"_monitor",void 0),Zd(sI(r),"logger",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=YP(e),r.logger=new fN("DataChannelSignaling",3,e),r}return jl(a,[{key:"destroy",value:function(){var e=this;this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.forEach((function(t,r){t.error(new SA(_A.OPERATION_CANCEL,"disconnect")),e._singlingCache.delete(r)})),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=1,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n,i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:3e4;return null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:Fm(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new $_((function(n,a){var s,c=i._genHeader(r);c.id=iD();var u=c.id.join("-"),d="customMessage"===e;d&&VP.samplingOne2ManyMsg(i.id,Number(c.id.join("")),t);var l=setTimeout((function(){i._singlingCache.delete(u),a(new SA(_A.TIME_OUT,"".concat(e," message time out"))),d&&VP.updateOne2ManyMsgAck(i.id,t,999)}),o);i._singlingCache.set(u,{signalingType:e,success:function(e){clearTimeout(l),n(e),d&&VP.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(l),a(e),d&&VP.updateOne2ManyMsgAck(i.id,t,e.code)}}),i.logger.info("Signal",Mm(s=">>>>>> [".concat(e,"][")).call(s,u,"]"),t),i._sendMessage(e,c,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=xm(wm().mark((function e(t,r){var n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=lz(t,_z),o=n instanceof ArrayBuffer,e.t0=this,e.t1=VP,e.t2=this.id,e.t3=el,e.t4=el({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:hz.SEND,type:vz.P2P,err:pz.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,nD.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 aD(e.msg)?this._rttIds[e.id]=e.id:e.dir===hz.SEND&&this.logger.info("_sendP2PMessage [DC Signaling p2p >>]",Fm(e)),new $_((function(n,i){var o=t._genHeader(el(el({needAck:!0,functionType:1},r),{},{id:iD()}));if(e.dir===hz.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new SA(_A.USER_MESSAGE_TIMEOUT,"P2P message timeout")),VP.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),VP.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),VP.updateP2PMsgAck(t.id,e,r.err);var o=aI(fz[r.err]||[_A.USER_MESSAGE_UNKNOWN,Mm(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===_A.NOT_CONNECTED_YET&&(s.code=_A.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new SA(_A.NOT_CONNECTED_YET,"DataChannel not open");var i=kM("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=nD.str2ab(Fm([e,r])),c=rD(Uint8Array,Mm(n=[o,a]).call(n,eT(t.id||[])),i||t.zip?EP.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:nz.DC_SEND_ERROR}),d}"p2p"===e?VP.updateP2PMsgReq(this.id,r,c.buffer.byteLength):"customMessage"===e&&VP.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=Zk(Am(t).call(t,2,r))}return{header:o,data:Am(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:Km(n=e.split("-")).call(n,(function(e){return Number(e)}))});bk(mz).call(mz,t)||this.logger.info("Signal",Mm(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d;return wm().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 EP.Inflate).push(o,!0),o=s.result),c=nD.ab2str(o),u=[],e.prev=8,u=JSON.parse(c),e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(8),e.t0 instanceof Error&&(null===(d=this._monitor)||void 0===d||d.report("rtc_signaling_msg_error",{error_code:-1,message:e.t0.message,reason:"message parse failed"})),e.abrupt("return");case 16:e.t1=a.functionType,e.next=0===e.t1?19:1===e.t1?21:2===e.t1?23:25;break;case 19:return this.C2S(a,u,c,n,r),e.abrupt("break",26);case 21:return this.C2C(u,n,r),e.abrupt("break",26);case 23:return this.C2GW(a,u,c),e.abrupt("break",26);case 25:return e.abrupt("break",26);case 26:case"end":return e.stop()}}),e,this,[[8,12]])}))),function(e){return n.apply(this,arguments)})},{key:"C2S",value:(r=xm(wm().mark((function e(t,r,n,i,o){var a,s,c,u,d;return wm().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],bk(mz).call(mz,u)||this.logger.info("Signal","<<<<<< ".concat(u),r,s),this._feedbackSignaling(s,u,u===GG.ON_CUSTOM_MESSAGE?el(el({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,nD.b64str2ab(r.message);case 13:r.message=e.sent;case 14:d=Date.now(),this.emit(u,el({},r)),u===GG.ON_CUSTOM_MESSAGE&&VP.reportOne2ManyMsgRecv(this.id,r,{msg_size:i,recv_msg_ts:o,fwd_msg_ts:d}),null===(c=this._monitor)||void 0===c||c.report("rtc_signaling",{error_code:0,message:n,signaling_event:"on-".concat(u),signaling_type:"Recv",stream_id:r.streamId,stream_user_id:r.clientId,direction:"down"});case 18:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"C2C",value:(t=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,p,f,_;return wm().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)===hz.FEEDBACK||aD(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===hz.SEND?6:e.t0===hz.FEEDBACK?46:48;break;case 6:if(u=Date.now(),aD(null===(s=t)||void 0===s?void 0:s.msg)){e.next=43;break}if(l=(d=t).binary,h=d.msg,v=d.room,p=d.to,f=d.from,_=""===v?l?GG.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:GG.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:l?GG.USER_BINARY_MESSAGE_RECEIVED:GG.USER_MESSAGE_RECEIVED,p){e.next=27;break}if(e.t1=this,e.t2=GG.ON_CUSTOM_MESSAGE,e.t3=f,e.t4=l,!l){e.next=21;break}return e.next=18,nD.b64str2ab(h);case 18:e.t5=e.sent,e.next=22;break;case 21:e.t5=h;case 22:e.t6=e.t5,e.t7={clientId:e.t3,binary:e.t4,message:e.t6},e.t1.emit.call(e.t1,e.t2,e.t7),e.next=43;break;case 27:if(e.t8=this,e.t9=_,e.t10=el,e.t11=el({},t),e.t12={},!l){e.next=38;break}return e.next=35,nD.b64str2ab(h);case 35:e.t13=e.sent,e.next=39;break;case 38:e.t13=h;case 39:e.t14=e.t13,e.t15={msg:e.t14},e.t16=(0,e.t10)(e.t11,e.t12,e.t15),e.t8.emit.call(e.t8,e.t9,e.t16);case 43:return this._sendP2PMessage(el(el({},t),{},{dir:hz.FEEDBACK,msg:""})),VP.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=aI(t,2),a=o[0],s=o[1],c=void 0===s?{}:s;if("RXMediaMsg"===a){var u,d=c.type,l=c.data;switch(null===(u=this._monitor)||void 0===u||u.report("rtc_signaling",{error_code:0,message:r,signaling_event:"on-".concat(d),signaling_type:"Recv",stream_id:"",stream_user_id:"",direction:"down"}),d){case"RSCP":try{var h=JSON.parse(l);Array.isArray(h)&&this.emit(d,h)}catch(f){}break;case"RTT":try{var v=JSON.parse(l);v.length&&this.emit(d,v[0])}catch(f){}break;case"SSC":try{var p=JSON.parse(l);p.length&&this.emit(d,p[0])}catch(f){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(t){e.logger.warn("_handleHandler","dataChannel close",t)},r=function(t){e.logger.error("_handleHandler","dataChannel error",t)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){return el({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",Mm(i="<<<<<< [".concat(o.signalingType,"-ack] ")).call(i,e),t));null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:r,signaling_event:null==o?void 0:o.signalingType,signaling_type:"Ack",stream_id:"",stream_user_id:"",direction:"down"})}},{key:"_handleP2PMsgFeedback",value:function(e){var t=this._p2pCache.get(e.id);t&&(this._p2pCache.delete(e.id),e.err===pz.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(JM.EventEmitter),Sz=function(e){UI(o,e);var t,r,n,i=eR(o);function o(e){var t;return Hl(this,o),Zd(sI(t=i.call(this)),"id",void 0),Zd(sI(t),"_monitor",void 0),Zd(sI(t),"logger",void 0),Zd(sI(t),"_getAccessManager",void 0),Zd(sI(t),"_connectionPool",new ib),Zd(sI(t),"_curConnection",void 0),Zd(sI(t),"_hasReportBrowerWarning",!1),Zd(sI(t),"_reconnectTimer",void 0),Zd(sI(t),"_connecting",!1),Zd(sI(t),"_isFirstTimeConnected",!0),Zd(sI(t),"_feedbackNodes",[]),Zd(sI(t),"_preIceStartTime",-1),Zd(sI(t),"_tcpOnlyTimer",void 0),Zd(sI(t),"_destroyed",!1),t._ctx=e,t.id=e.id,t._monitor=YP(t.id),t.logger=new fN("ConnectionManager",3,t.id),t.logger.info("constructor","invoke"),t._getAccessManager=new az(e),t}return jl(o,[{key:"connect",value:function(){var e=this;this.logger.info("connect","invoke");try{dz.checkSupported()}catch(t){this.safeEmit("disconnected",t)}this._connecting||(this._onConnectStart("init"),$_.resolve().then((function(){return e.emit("__onGetIceConfigHook")})),this._getAccess())}},{key:"reconnectByNodeChange",value:(n=xm(wm().mark((function e(t){var r,n,i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.info("reconnectByNodeChange","invoke %o",t),o=t.nodes,a=t.reason,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:Fm(t),reason:Fm(a)}),pM.clearAccessNode(this._ctx.appId),s=(null===(n=this._curConnection)||void 0===n||null===(i=n.node.publicIPs[0])||void 0===i?void 0:i.ip)||"",this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart("node change"),Array.isArray(o)&&o.length>0?this._startIceConnect(o):this._getAccess([{feedbackIP:s,feedbackReason:{type:"NODE_CHANGED",reason:a}}]);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"reconnect",value:(r=xm(wm().mark((function e(t){var r,n=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.logger.info("reconnect","invoke. ".concat(r?"ICE over TCP":"")),this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart(t),this._getAccess(void 0,r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){this.logger.info("destroy","invoke"),this._destroyed=!0,this.safeEmit("disconnected",new SA(_A.OPERATION_CANCEL,"destroy")),MI(DI(o.prototype),"removeAllListeners",this).call(this),this._clearReconnectTimer(),this._clearConnectionPool(),this._getAccessManager.destroy(),this._closeCurrentConnection()}},{key:"_getAccess",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._getAccessManager.getICENode(e).then((function(e){t.emit("__onGetIceSuccessHook",e),t._startIceConnect(e,r)})).catch((function(e){t.safeEmit("disconnected",e)})).finally((function(){t._feedbackNodes=[]}))}},{key:"_startIceConnect",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this._destroyed){this.logger.info("_startIceConnect","invoke");var n=yw();this._preIceStartTime=tD();var i=this._ctx.joinRoomConfig.useTcpJoin,o=this._ctx.joinRoomConfig.useTcpJoinDelay,a=function(){var e=xm(wm().mark((function e(i){var o,a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r&&((i=OG(i)).iceConfig.tcpOnly=!0),o={node:i},e.prev=2,a=new dz(t._ctx,n),o.pc=a,t._connectionPool.set(a.uuid,o),e.next=8,a.connect(i);case 8:return s=e.sent,c=new yz(t.id,s),o.signaling=c,e.next=13,c.sendPingSignaling();case 13:t._onConnectSuccess({node:i,pc:a,signaling:c,dc:s}),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(2),t._onConnectionFailed(o,e.t0);case 19:case"end":return e.stop()}}),e,null,[[2,16]])})));return function(t){return e.apply(this,arguments)}}();this.emit("__onIceConnectStartHook"),e.forEach(a),i&&!r&&(this.logger.info("_startIceConnect","tcp-only will try after ".concat(o,"ms")),this._tcpOnlyTimer=window.setTimeout((function(){t.emit("connectWidthTcp"),e.forEach((function(e){(e=OG(e)).iceConfig.tcpOnly=!0,a(e)})),delete t._tcpOnlyTimer}),o))}}},{key:"_onConnectSuccess",value:function(e){var t,r,n,i=this;(this.logger.info("connect","peer_%s connect success.",e.pc.uuid),this.emit("__onIceConnectSuccessHook",e),this._curConnection)?(e.pc.destroy(),null===(t=e.signaling)||void 0===t||t.destroy(),this._connectionPool.delete(e.pc.uuid)):(this._curConnection=e,this._addConnectionHandler(e.pc),null===(r=this._monitor)||void 0===r||r.set({connection_id:e.pc.getConnectionId(),rtc_vid:(null===(n=e.node.iceConfig)||void 0===n?void 0:n._abtest_vid)||""}),this._connectionPool.delete(e.pc.uuid),this._feedbackNodes.forEach((function(e){return i._feedbackBySignaling(e)})),this._feedbackNodes=[],this._onConnectEnded(e))}},{key:"_onConnectionFailed",value:function(e,t){var r,n,i=this;(this.logger.info("connect","peer_%s connect failed. %s",(null===(r=e.pc)||void 0===r?void 0:r.uuid)||"",t.message),this.emit("__onIceConnectFailedHook",e),t.code!==cz.DESTROY&&t.code!==_A.OPERATION_CANCEL)&&(this._curConnection?this._feedbackBySignaling(e.node):this._feedbackNodes.push(e.node),this.logger.info("connect","remove cache node"),pM.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(),tD()-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=xm(wm().mark((function e(t){return wm().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(Km(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:nz.BLACK_BROWSER,message:"failed to establish data-channel, and the current browser is on the browser blacklist."}))}},{key:"_onConnectStart",value:function(e){var t;this.logger.info("_onConnectStart","invoke, reason: ".concat(e)),this._connecting=!0,this.safeEmit(this._isFirstTimeConnected?"connecting":"reconnecting");var r,n=yw();(null===(t=this._monitor)||void 0===t||t.set({connect_session_id:n}),this._isFirstTimeConnected)||(null===(r=this._monitor)||void 0===r||r.report("rtc_reconnect",{error_code:1002,message:"peerconnection reconnecting",reconnect_id:n,reconnect_type:"peerconnection"},{reason:e}))}},{key:"_onConnectEnded",value:function(e){var t;(this.logger.info("_onConnectEnded","invoke"),this._connecting=!1,this._isFirstTimeConnected)||(null===(t=this._monitor)||void 0===t||t.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"}));this._isFirstTimeConnected=!1,this.safeEmit("connected",e),e.node.iceConfig.tcpOnly&&(this.logger.info("_onConnectEnded","use tcp only"),$P(this._ctx.id,"connected_with_tcp_only",Fm(e.node))),this._tcpOnlyTimer&&(window.clearTimeout(this._tcpOnlyTimer),delete this._tcpOnlyTimer),this._clearConnectionPool()}},{key:"_addConnectionHandler",value:function(e){var t=this;e.on("disconnect",(function(e){t._closeCurrentConnection(),t._clearReconnectTimer(),navigator.onLine?t.reconnect(e):t._reconnectTimer=window.setTimeout((function(){return t.reconnect(e)}),3e3)}))}},{key:"_closeCurrentConnection",value:function(){var e,t;null===(e=this._curConnection)||void 0===e||e.pc.destroy(),null===(t=this._curConnection)||void 0===t||t.signaling.destroy(),delete this._curConnection}},{key:"_clearConnectionPool",value:function(){var e=this;this._connectionPool.forEach((function(t,r){var n,i;null===(n=t.pc)||void 0===n||n.destroy(),null===(i=t.signaling)||void 0===i||i.destroy(),e._connectionPool.delete(r)}))}},{key:"_clearReconnectTimer",value:function(){this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer)}}]),o}($M),bz=cd,Ez=ic,kz=function(e,t,r,n){for(var i,o=n>1?void 0:n?Ez(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&&bz(t,r,o),o},Tz=3e4,Iz=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(Iz||{}),Rz=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)},Az=function(e){UI(R,e);var t,r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I=eR(R);function R(e){var t;return Hl(this,R),Zd(sI(t=I.call(this)),"id",void 0),Zd(sI(t),"publicStream",!1),Zd(sI(t),"_token",void 0),Zd(sI(t),"_roomId",void 0),Zd(sI(t),"_roomAttributes",void 0),Zd(sI(t),"_vendorConfig",{enableMultiVendor:!1,vendorCode:0}),Zd(sI(t),"_clientId",void 0),Zd(sI(t),"_businessId",void 0),Zd(sI(t),"_userInfo",void 0),Zd(sI(t),"_authorization",void 0),Zd(sI(t),"_sessionId",""),Zd(sI(t),"_liveControlMessage",void 0),Zd(sI(t),"isReconnecting",!1),Zd(sI(t),"_ontrackCallbackMap",new ib),Zd(sI(t),"_subResolves",{}),Zd(sI(t),"supportConcurrent",!1),Zd(sI(t),"_handler",void 0),Zd(sI(t),"_pubSubLock",void 0),Zd(sI(t),"_joinLeaveLock",void 0),Zd(sI(t),"_state",void 0),Zd(sI(t),"_dataChannelSignal",void 0),Zd(sI(t),"_joinRoomStartTs",void 0),Zd(sI(t),"_monitor",void 0),Zd(sI(t),"logger",void 0),Zd(sI(t),"_roomProfile",Il.communication),Zd(sI(t),"_context",void 0),Zd(sI(t),"_connectionManager",void 0),Zd(sI(t),"_joinRoom5xxTimer",void 0),Zd(sI(t),"_joinResolve",void 0),Zd(sI(t),"_joinReject",void 0),Zd(sI(t),"_pubSubBackOff",{}),t.id=e.id,t._monitor=YP(t.id),t.logger=new fN("MediaServerClient",2,t.id),t.logger.info("constructor","invoke"),t._pubSubLock=new JG("pubSubLock"),t._joinLeaveLock=new JG("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._pubSubBackOff={},t._context=e,t._connectionManager=new Sz(e),t._addConnectHandler(),t}return jl(R,[{key:"_addSignalEventHandler",value:function(){var e,t,r=this;[GG.ON_ADD_STREAM,GG.ON_ADD_STREAM_LIST,GG.ON_REMOVE_STREAM,GG.ON_REMOVE_STREAM_LIST,GG.USER_CONNECTION,GG.USER_CONNECTION_LIST,GG.USER_DISCONNECTION,GG.USER_DISCONNECTION_LIST,GG.ON_UPDATE_STREAM_ATTRIBUTES,GG.ON_UPDATE_ROOM_ATTRIBUTES,GG.ON_PUSH_TRACK,GG.ON_REMOVE_TRACK,GG.ON_CUSTOM_MESSAGE,GG.USER_MESSAGE_RECEIVED,GG.USER_BINARY_MESSAGE_RECEIVED,GG.POST_PROCESSING_MESSAGE,GG.ON_USER_TOKEN_WILL_EXPIRE,GG.STREAM_CONTROL_MESSAGE,GG.ON_UPDATE_USER_ATTRIBUTES,GG.ON_SPEAKER_CHANGE,zG.RSCP,zG.RTT,GG.ON_STREAM_FAILED,GG.ON_NOTIFY_RECONNECT,zG.SSC,GG.ON_FORWARD_DST_ROOM_USER_KICK].forEach((function(e){var t;null===(t=r._dataChannelSignal)||void 0===t||t.on(e,(function(t){r.safeEmit(e,t)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.on(GG.NODE_CHANGE,(function(e){r._connectionManager.reconnectByNodeChange(e)})),null===(t=this._dataChannelSignal)||void 0===t||t.on(GG.ON_NOTIFY_RECONNECT,(function(){r._connectionManager.reconnect("recv notifyReconnect signaling")}))}},{key:"_removeSignalEventHandler",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.removeAllListeners(),null===(t=this._handler)||void 0===t||t.removeAllListeners()}},{key:"connectionState",get:function(){return this._state},set:function(e){this._state!==e&&(this.safeEmit(KG.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"businessId",set:function(e){this._businessId=e}},{key:"setLiveControlMessage",value:function(e){this._liveControlMessage=e}},{key:"connect",value:function(){var e=this;return new $_((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"join",value:(T=xm(wm().mark((function e(t){var r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("join()","info: %o",t),this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._roomProfile=t.roomProfile,this._reportJoinRoomStart(),e.next=10,new $_((function(e,t){n._joinResolve=e,n._joinReject=t,(n._handler?$_.resolve():n.connect()).then((function(){n._callJoinRoom()})).catch((function(e){var t=Array.isArray(e)&&e.length>0?e[0]:e;n._joinRoomFailed(t.message)}))}));case 10:return r=e.sent,e.abrupt("return",r);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"_callJoinRoom",value:(k=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y=this,S=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=S.length>0&&void 0!==S[0]&&S[0],this.logger.info("_callJoinRoom","invoke"),e.t0=nD.token2auth(this._context.appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId,e.t2=Date.now(),e.t3=this._liveControlMessage,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=9,null===(t=this._handler)||void 0===t?void 0:t.getDefaultSdp();case 9:return e.t5=e.sent,e.next=12,KU();case 12:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=bM.VERSION,e.t9=pM.getDeviceId(),e.t10=this._context.appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._context.useCloudProxy,e.t15=ez[this._roomProfile]?"".concat(ez[this._roomProfile][0]):"0",e.t16={supportedCodecs:e.t6,deviceType:"web",userAgent:e.t7,sdkVersion:e.t8,deviceId:e.t9,appId:e.t10,roomId:e.t11,userId:e.t12,businessId:e.t13,enableCloudProxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0,supportMultiVendor:!0},e.t18=Fm({requireICEUfragV2:!0}),i={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17,accessParams:e.t18},kM("SIGNAL_CROP_JOINROOM")&&null!==(r=i.sdpInfo)&&void 0!==r&&r.sdp&&(i.sdpInfo.sdp=JV(i.sdpInfo.sdp)),$_.resolve().then((function(){return y.emit("onSendingJoinMessageHook")})),e.prev=29,a=n?"reconnected":"joinRoom",e.next=33,this._joinRoomWithRetry(a,i);case 33:s=e.sent,this.logger.success("join","send join message success"),c=s.config||{},u=c.engine_WEB,this.connectionState="connected",this._authorization=i.Authorization,pM.setEngineWebConfig(this._context.appId,this._roomId,u),this._context&&(this._context.serverConfig={videoCodec:(null==u?void 0:u.video_codec)||"H264",audioRed:!(null==u||!u.pub_audio_red),muteReplaceUnsub:!(null===(d=s.config)||void 0===d||!d.mute_replace_unsub),simulcastOnDemand:!(DD||!1===(null===(l=s.config)||void 0===l||null===(h=l.engine_VPM)||void 0===h||null===(v=h.ondemand)||void 0===v?void 0:v.enable)),forceUniHandler:1===(null==s||null===(p=s.config)||void 0===p||null===(f=p.vendor_param)||void 0===f?void 0:f.vendor_stream_sub_mode)},"boolean"==typeof(null==u?void 0:u.av_sync)&&(this._context.avSync=u.av_sync)),s.vendorConfig&&(this._vendorConfig=s.vendorConfig),dB.audioStallConfig=u,null!=s&&null!==(o=s.relayMessage)&&void 0!==o&&o.sdp&&(null===(_=this._handler)||void 0===_||_.createAVMlineAnswerTpl(s.relayMessage.sdp)),this.emit("joinSuccess",{joinRes:s,reconnect:n}),this._joinRoomSuccess(s),e.next=51;break;case 47:e.prev=47,e.t19=e.catch(29),m={461:_A.ROOM_FORBIDDEN,462:_A.USER_FORBIDDEN},(null===e.t19||void 0===e.t19?void 0:e.t19.code)>=700&&(null===e.t19||void 0===e.t19?void 0:e.t19.code)<800?this._joinRoomFailed("token_error",_A.INVALID_TOKEN):m[null===e.t19||void 0===e.t19?void 0:e.t19.code]?this._joinRoomFailed((null===e.t19||void 0===e.t19?void 0:e.t19.message)||m[null===e.t19||void 0===e.t19?void 0:e.t19.code],m[null===e.t19||void 0===e.t19?void 0:e.t19.code]):(null===e.t19||void 0===e.t19?void 0:e.t19.code)===_A.TIME_OUT&&this._context.joinRoomConfig.useTcpAfterJoinTimeout?(g="joinRoom timeout, retry with tcp only",this.logger.error("join",g),this.safeEmit(QG.ON_REJOIN_WITH_TCP),this._connectionManager.reconnect(g,!0)):e.t19.code===_A.OPERATION_CANCEL&&"connecting"===this.connectionState||this._joinRoomFailed((null===e.t19||void 0===e.t19?void 0:e.t19.message)||"signaling_error");case 51:case"end":return e.stop()}}),e,this,[[29,47]])}))),function(){return k.apply(this,arguments)})},{key:"_getVendorPubSdpInfo",value:(E=xm(wm().mark((function e(t){var r,n,i,o=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new dz(this._context,""),t.vendorHandler=new rz(this._context,r),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),e.next=5,t.vendorHandler.publish(t);case 5:return n=e.sent,(i=t.vendorHandler).on("ice_state",(function(e){o.emit(KG.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:vl.CONNECTION_STATE_CONNECTING,connected:vl.CONNECTION_STATE_CONNECTED,disconnected:vl.CONNECTION_STATE_RECONNECTING}[e],userId:o._clientId})})),i.once("disconnect",xm(wm().mark((function e(){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i.removeAllListeners(),"connected"===(null===(r=o._handler)||void 0===r||null===(n=r.pc)||void 0===n?void 0:n.iceConnectionState)){e.next=4;break}return o.logger.info("vendor ice failed",t.streamId),e.abrupt("return");case 4:return e.next=6,o.unpublish(t);case 6:return e.next=8,o.publish(t);case 8:t.vendorHandler&&t.statsReport.setVar(t.vendorHandler);case 9:case"end":return e.stop()}}),e)})))),e.abrupt("return",[i,n]);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"publish",value:(b=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._publish(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"_publish",value:(S=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,N,D,M,L,U,V=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publish()","localStream: %o",t),g=t.videoTrack,y=t.audioTrack,S=tD(),b="",E="",k=this._handler,"H264"!==(null===(r=this._context)||void 0===r||null===(n=r.serverConfig)||void 0===n?void 0:n.videoCodec)){e.next=13;break}return e.next=10,ZU();case 10:if(e.sent){e.next=13;break}throw new SA(_A.PUBLISH_FAILED,"h264 is not supported");case 13:if(!this._vendorConfig.enableMultiVendor){e.next=22;break}return e.next=16,this._getVendorPubSdpInfo(t);case 16:I=e.sent,R=aI(I,2),k=R[0],T=R[1],e.next=25;break;case 22:return e.next=24,this._handler.publish(t);case 24:T=e.sent;case 25:return null===(i=t.observer)||void 0===i||i.setHandler(k),this.emit("_test_pub_sdpInfo_",T),b=T.audioMid,E=T.videoMid,t.pubAttributes={localaudio:!!y,localvideo:!!g,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(g instanceof TF),extaudio:!!(y instanceof IF)},A={attributes:el({videoDescriptions:T.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:b,videoMid:E,sdpInfo:{msid:t.stream.id,type:T.type,sdp:T.partialSdp,semantics:T.semantics},peerConnectionMode:null===(o=T)||void 0===o?void 0:o.peerConnectionMode,supportMultiVendor:!0},(w=!this._vendorConfig.enableMultiVendor&&t.enableSimulcast&&(null===(a=this._context)||void 0===a||null===(s=a.serverConfig)||void 0===s?void 0:s.simulcastOnDemand)&&(null===(c=T.subVideoDescriptions)||void 0===c?void 0:c.length))&&(A.attributes.subVideoDescriptions=T.subVideoDescriptions),null!==(u=T)&&void 0!==u&&u.peerConnectionId&&(A.peerConnectionId=T.peerConnectionId),e.prev=34,this.emit("_test_pub_body_",A),e.next=38,null===(x=this._dataChannelSignal)||void 0===x?void 0:x.sendSignaling("publish",A);case 38:C=e.sent,e.next=63;break;case 41:return e.prev=41,e.t0=e.catch(34),e.t0 instanceof Error?null===(P=this._monitor)||void 0===P||P.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:S,message:Mm(N="".concat(e.t0.name,": ")).call(N,e.t0.message)}):e.t0 instanceof SA&&(null===(D=this._monitor)||void 0===D||D.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:S,message:Mm(M="".concat(e.t0.code,": ")).call(M,e.t0.message)})),e.next=46,null===(O=k)||void 0===O?void 0:O.rollback({msid:t.stream.id,stream:t,audioMid:b,videoMid:E});case 46:if(!(e.t0.code>=500&&e.t0.code<600)){e.next=62;break}if(this.emit("_test_pub_5xx_"),!((L=this.getPubSubBackOff(t.id)).retryDuration<6e4)){e.next=60;break}return this.logger.info("pubRetry",t.id,L.retryDuration),e.next=53,new $_((function(e){return setTimeout(e,L.interval)}));case 53:return L.retryDuration+=L.interval,L.interval=L.interval>4e3?8e3:2*L.interval,t.resetStream(),this.emit(QG.PUB_RETRY,{screen:t.isScreen}),e.abrupt("return",this._publish(t));case 60:this.logger.info("pubRetry","end"),delete this._pubSubBackOff[t.id];case 62:throw e.t0;case 63:if(null===(d=this._monitor)||void 0===d||d.report("rtc_recv_answer",{error_code:0,answer_type:null===(l=C)||void 0===l?void 0:l.relayMessage.type,sequence_id:(null===(h=C)||void 0===h||null===(v=h.relayMessage)||void 0===v?void 0:v.sequenceId)||0,message:null===(p=C)||void 0===p||null===(f=p.relayMessage)||void 0===f?void 0:f.sdp,direction:"up",stream_id:"",stream_user_id:"",pc_session_id:(null===(_=k)||void 0===_?void 0:_.peerConnectionId)||""}),U=new $_((function(e,r){var n,i,o,a,s,c,u,d;null===(n=k)||void 0===n||n.handleAck({action:yB.publish,streamId:C.streamId,audioMid:b,videoMid:E,audioTransceiverInit:null===(i=T)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=T)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:{sdp:null===(a=C)||void 0===a||null===(s=a.relayMessage)||void 0===s?void 0:s.sdp,sequenceId:null===(c=C)||void 0===c||null===(u=c.relayMessage)||void 0===u?void 0:u.sequenceId},sdp:null===(d=T)||void 0===d?void 0:d.sdp,stream:t,onSuccess:function(){V.logger.info("publish()","publish success"),e(0)},onFail:function(e){V.logger.info("publish()","publish fail"),r(e)}})})),e.t1=!DD,!e.t1){e.next=69;break}return e.next=69,U;case 69:w&&this.emit(zG.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}],!0),t.streamId=C.streamId,t.videoMid=E,t.audioMid=b,t.subVideoDescriptions=T.subVideoDescriptions,null===(m=this._monitor)||void 0===m||m.report("rtc_publish_stat",{result:"success",is_screen:"0",start:S,message:"unknown"});case 75:case"end":return e.stop()}}),e,this,[[34,41]])}))),function(e){return S.apply(this,arguments)})},{key:"updatePubTrack",value:(y=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updatePubTrack()","localStream: %o",t),n=t.videoTrack,i=t.audioTrack,o=t.pubAudio,a=t.pubVideo,s=t.vendorHandler||this.handler,c=null==i?void 0:i.getTrack("preprocessing"),u=null==n?void 0:n.getTrack("preprocessing"),!a||!u){e.next=10;break}return e.next=8,null===(d=t.videoTransceiver)||void 0===d?void 0:d.sender.replaceTrack(u);case 8:e.next=12;break;case 10:return e.next=12,null===(l=t.videoTransceiver)||void 0===l?void 0:l.sender.replaceTrack(null);case 12:if(null==s||s.updateMaxBitrate(t),!o||!c){e.next=20;break}return v=i.mixType,(p=i.mixedAudioTrack)&&v!==Ll.PLAYOUT&&c.enabled&&(c=p),e.next=18,null===(h=t.audioTransceiver)||void 0===h?void 0:h.sender.replaceTrack(c);case 18:e.next=23;break;case 20:return e.next=22,null===(f=t.audioTransceiver)||void 0===f?void 0:f.sender.replaceTrack(null);case 22:$P(this.id,"MediaClient.updatePubTrack(audio)","null");case 23:try{$P(this.id,"MediaClient.updatePubTrack",Fm({audioStreamTrack:Ew(c),videoStreamTrack:Ew(u)}))}catch(Iq){}for(m={},g=0,y=CA(_={localaudio:!!i,localvideo:!!n,videostream:a,audiostream:o,extvideo:!!(n instanceof TF),extaudio:!!(i instanceof IF)});g<y.length;g++)S=aI(y[g],2),b=S[0],(E=S[1])!==_I(t.pubAttributes,b)&&cL(m,b,E);if(cn(m).length){e.next=29;break}return e.abrupt("return");case 29:return t.observer&&(k=t.observer,T=m.audiostream,I=m.videostream,R=m.localaudio,A=m.localvideo,w=m.extaudio,C=m.extvideo,void 0!==A?void 0!==C?k.setPushVideo(C):k.setEnableVideo(A):void 0!==I&&k.setUnmuteVideo(I),void 0!==R?void 0!==w?k.setPushAudio(w):k.setEnableAudio(R):void 0!==T&&k.setUnmuteAudio(T)),t.pubAttributes=_,x={roomId:this._roomId,streamId:t.streamId,attributes:m},e.next=34,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateStreamAttributes",x);case 34:if(!DD){e.next=37;break}return e.next=37,null==s?void 0:s.setCurrentDescription();case 37:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"updateToken",value:(g=xm(wm().mark((function e(t){var r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateToken()","newToken: %o",t),this._token=t,this._context.appId&&null!==(r=this._userInfo)&&void 0!==r&&r.userId&&this._roomId){e.next=4;break}return e.abrupt("return");case 4:return i={roomId:this._roomId,userId:null===(n=this._userInfo)||void 0===n?void 0:n.userId,appId:this._context.appId,token:"Bearer ".concat(t)},e.prev=5,e.next=8,null===(o=this._dataChannelSignal)||void 0===o?void 0:o.sendSignaling("updateToken",i);case 8:e.next=13;break;case 10:throw e.prev=10,e.t0=e.catch(5),new SA(_A.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 13:case"end":return e.stop()}}),e,this,[[5,10]])}))),function(e){return g.apply(this,arguments)})},{key:"unpublish",value:(m=xm(wm().mark((function e(t){var r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("unpublish()","localStream: %o",t),n={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",n),i=t.vendorHandler||this._handler,e.next=6,null==i?void 0:i.handleAck({action:yB.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 6:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"_getVendorSubSdpInfo",value:(_=xm(wm().mark((function e(t,r){var n,i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new dz(this._context,""),t.vendorHandler=new rz(this._context,n),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),(i=t.vendorHandler).on("ontrack",r),e.next=7,t.vendorHandler.subscribe(t);case 7:return o=e.sent,i.on("ice_state",(function(e){a.emit(KG.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:vl.CONNECTION_STATE_CONNECTING,connected:vl.CONNECTION_STATE_CONNECTED,disconnected:vl.CONNECTION_STATE_RECONNECTING}[e],userId:t.userId})})),i.once("disconnect",xm(wm().mark((function e(){var r,n,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==i||i.removeAllListeners(),"connected"===(null===(r=a._handler)||void 0===r||null===(n=r.pc)||void 0===n?void 0:n.iceConnectionState)){e.next=4;break}return a.logger.info("vendor ice failed",t.streamId),e.abrupt("return");case 4:return o=t.subMediaType,e.next=7,a.unsubscribe(t);case 7:return e.next=9,a.subscribe(t,o);case 9:t.vendorHandler&&t.statsReport.setVar(t.vendorHandler),a.emit(QG.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 _.apply(this,arguments)})},{key:"subscribe",value:(f=xm(wm().mark((function e(t,r,n){return wm().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 f.apply(this,arguments)})},{key:"_subscribe",value:(p=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,N,D,M,L,U,V,F,B,j,H,G,z,K,X,W,Y,q,J,Q,Z,$,ee,te,re,ne,ie=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("subscribe()","mediaType: %o",r),Rz("subscribe()",t,this.logger),t.streamState=pB.SUB_ING,I=!1,R=!1,gD(r)&&(R=!0),yD(r)&&(I=!0),I||!this.multiChatMode()){e.next=9;break}return t.streamState=pB.INIT,e.abrupt("return");case 9:if(A=tD(),w=t.subVideo,C=[],this._subResolves[t.streamId]||(this._subResolves[t.streamId]=[]),C.push(new $_((function(e,r){ie._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SA(_A.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),Tz);t.on("ontrack",(function r(i){"video"===i.mediaType&&(ie.logger.info("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),this.multiChatMode()||C.push(new $_((function(e,r){ie._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SA(_A.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),Tz);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(ie.logger.info("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),x=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",x),this._ontrackCallbackMap.set(t,x),O=this._handler,null!==(o=this._context.serverConfig)&&void 0!==o&&o.forceUniHandler||!t.enableVendorMode){e.next=28;break}return e.next=22,this._getVendorSubSdpInfo(t,x);case 22:N=e.sent,D=aI(N,2),O=D[0],P=D[1],e.next=31;break;case 28:return e.next=30,this._handler.subscribe(t,{multiChatMode:this.multiChatMode()});case 30:P=e.sent;case 31:if(null===(a=t.observer)||void 0===a||a.setHandler(O),L=(M=P).audioMid,U=M.videoMid,t.subVideo=I,V={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},F={audio:!this.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:U,audioMid:L,sdpInfo:{sdp:null===(s=P)||void 0===s?void 0:s.partialSdp,semantics:null===(c=P)||void 0===c?void 0:c.semantics,type:null===(u=P)||void 0===u?void 0:u.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!this.multiChatMode()||R,video:I},qualityLayer:V},extra:{enableSendRTT:!0},peerConnectionMode:null===(d=P)||void 0===d?void 0:d.peerConnectionMode,supportMultiVendor:!0},null!==(l=P)&&void 0!==l&&l.peerConnectionId&&(F.peerConnectionId=P.peerConnectionId),B=this._context||{},j=B.subscribeFallbackOption,H=B.userPriority,"number"==typeof j&&(F.config.fallbackOption=j),H.has(t.userId)&&(F.config.priority=H.get(t.userId)),null!==(h=P)&&void 0!==h&&h.allSsrc&&(F.extra.subscribeSSRC=P.allSsrc),null===(v=P)||void 0===v||!v.signalingAck){e.next=44;break}return e.next=44,new $_((function(e,r){var n,i,o,a;null===(n=O)||void 0===n||n.handleAck({action:yB.subscribe,streamId:t.streamId,audioMid:L,videoMid:U,audioTransceiverInit:null===(i=P)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=P)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:null===(a=P)||void 0===a?void 0:a.signalingAck,stream:t,sdp:P.sdp,onSuccess:function(){ie.logger.info("ssrc","success"),e(0)},onFail:function(e){ie.logger.info("ssrc","fail",e),r(e)}})}));case 44:return e.prev=44,this.emit("_test_sub_body_",F),e.next=48,null===(z=this._dataChannelSignal)||void 0===z?void 0:z.sendSignaling("subscribe",F);case 48:G=e.sent,e.next=78;break;case 51:if(e.prev=51,e.t0=e.catch(44),t.streamState=pB.INIT,e.t0 instanceof Error&&(null===(W=this._monitor)||void 0===W||W.report("rtc_subscribe_stat",{result:"fail",start:A,message:e.t0.message,stream_user_id:t.userId})),!(e.t0.code>=500&&e.t0.code<600)){e.next=70;break}if(this.emit("_test_sub_5xx_"),!((Y=this.getPubSubBackOff(t.streamId)).retryDuration<6e4)){e.next=68;break}return this.logger.info("subRetry",t.streamId,Y.retryDuration),e.next=62,new $_((function(e){return setTimeout(e,Y.interval)}));case 62:return Y.retryDuration+=Y.interval,Y.interval=Y.interval>4e3?8e3:2*Y.interval,this.emit(QG.SUB_RETRY,{screen:t.isScreen,userId:t.userId}),e.abrupt("return",this._subscribe(t,r,n));case 68:this.logger.info("subRetry","end",t.streamId),delete this._pubSubBackOff[t.streamId];case 70:return t.subVideo=w,e.next=73,null===(K=O)||void 0===K?void 0:K.rollback({msid:t.streamId,stream:t});case 73:return q={roomId:this._roomId,streamId:t.streamId,userId:t.userId},e.next=76,null===(X=this._dataChannelSignal)||void 0===X?void 0:X.sendSignaling("unsubscribe",q).catch((function(){}));case 76:throw t.streamState=pB.INIT,e.t0;case 78:if(G.relayMessage){e.next=81;break}throw null===(J=this._monitor)||void 0===J||J.report("rtc_error",{error_code:-1009,message:"relayMessage is null"}),new SA(_A.UNEXPECTED_ERROR,"unable to subscribe");case 81:if(Q=null===(p=G)||void 0===p?void 0:p.relayMessage,Z=Q.audioMid,$=Q.videoMid,Zd(f={},L,Z),Zd(f,U,$),ee=f,this.logger.info("sub midmap",t.userId,ee),t.videoMid=U,t.audioMid=L,t.subMediaType=r,t.streamState=pB.SUB_ED,t.subLayer=V,null===(_=this._monitor)||void 0===_||_.report("rtc_recv_answer",{error_code:0,answer_type:null===(m=G)||void 0===m||null===(g=m.relayMessage)||void 0===g?void 0:g.type,sequence_id:(null===(y=G)||void 0===y||null===(S=y.relayMessage)||void 0===S?void 0:S.sequenceId)||0,message:null===(b=G)||void 0===b||null===(E=b.relayMessage)||void 0===E?void 0:E.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:(null===(k=O)||void 0===k?void 0:k.peerConnectionId)||""}),e.prev=90,null!==(te=P)&&void 0!==te&&te.signalingAck){e.next=94;break}return e.next=94,new $_((function(e,r){var n,i,o,a,s,c,u;null===(n=O)||void 0===n||n.handleAck({action:yB.subscribe,streamId:t.streamId,audioMid:L,videoMid:U,audioTransceiverInit:null===(i=P)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=P)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:{sdp:null===(a=G)||void 0===a||null===(s=a.relayMessage)||void 0===s?void 0:s.sdp,sequenceId:null===(c=G)||void 0===c||null===(u=c.relayMessage)||void 0===u?void 0:u.sequenceId},stream:t,sdp:P.sdp,onSuccess:function(){ie.logger.info("sub ack","success"),e(0)},onFail:function(e){ie.logger.info("sub ack","fail",e),r(e)}})}));case 94:return e.next=96,$_.all(C);case 96:e.next=106;break;case 98:return e.prev=98,e.t1=e.catch(90),e.t1 instanceof Error&&(null===(ne=this._monitor)||void 0===ne||ne.report("rtc_subscribe_stat",{result:"fail",start:A,message:e.t1.message,stream_user_id:t.userId})),q={roomId:this._roomId,streamId:t.streamId,userId:t.userId},e.next=104,null===(re=this._dataChannelSignal)||void 0===re?void 0:re.sendSignaling("unsubscribe",q).catch((function(){}));case 104:throw t.streamState=pB.INIT,e.t1;case 106:this.multiChatMode()||(t.subAudio=R),null===(T=this._monitor)||void 0===T||T.report("rtc_subscribe_stat",{result:"success",start:A,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return ie.emit("onRemoteStreamStats",e)}),O);case 109:case"end":return e.stop()}}),e,this,[[44,51],[90,98]])}))),function(e,t,r){return p.apply(this,arguments)})},{key:"controlMessage",value:(v=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"updateUserAttributes",value:(h=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateUserAttributes()","attributes: %o",t),e.next=3,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateUserAttributes",{roomId:this._roomId,sessionId:this._sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(l=xm(wm().mark((function e(t,r){var n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return this.logger.warn("updateSubTrack()","subLayer no change"),e.abrupt("return");case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:return this.emit("___afterUpdateSubscribeSend"),t.subLayer=r,e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"updateSubPriority",value:(d=xm(wm().mark((function e(t,r){var n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return this.logger.warn("updateSubPriority()","priority no change"),e.abrupt("return",t);case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{priority:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:return t.priority=r,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"updateSubMediaType",value:(u=xm(wm().mark((function e(t,r){var n,i,o,a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=!1,a=!1,gD(r)&&(a=!0),yD(r)&&(o=!0),s={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:o,audio:!!this.multiChatMode()||a}}},e.next=6,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",s);case 6:return this.multiChatMode()||(null===(c=t.observer)||void 0===c||c.setUnmuteAudio(a),t.subAudio=a),null===(i=t.observer)||void 0===i||i.setUnmuteVideo(o),t.subVideo=o,t.subMediaType=r,e.abrupt("return",t);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(c=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("subscribe4pushTrack()","streamInfo: %o",r),Rz("subscribe4pushTrack()",t,this.logger),t.subAudio=!0,e.next=5,null===(n=this._handler)||void 0===n?void 0:n.subscribe(t,{multiChatMode:this.multiChatMode()});case 5:if(a=e.sent){e.next=8;break}throw new SA(_A.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 8:return s=a.audioMid,c=a.videoMid,(u=[]).push(new $_((function(e,r){var n=setTimeout((function(){return r(new SA(_A.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),Tz);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(l.logger.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),d=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",d),this._ontrackCallbackMap.set(t,d),e.next=17,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:yB.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,$_.all(u);case 19:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return l.emit("onRemoteStreamStats",e)}),this._handler);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(s=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Rz("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)&ll.AUDIO),d=!!(c&ll.VIDEO),e.next=10,null===(i=this._handler)||void 0===i?void 0:i.handleAck({action:yB.removetrack,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:null===(o=t.observer)||void 0===o||o.setPushTrack(!1),null===(a=t.observer)||void 0===a||a.setUnmuteAudio(!u),t.subAudio=!u,null===(s=t.observer)||void 0===s||s.setUnmuteVideo(!d),t.subVideo=!d,t.subMediaType=t.subMediaType-(t.subMediaType&c),t.virtual&&(t.clean(),t.resetHasSubscribed(),t.statsReport.unsubscribe());case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return s.apply(this,arguments)})},{key:"unsubscribe",value:(a=xm(wm().mark((function e(t){var r,n,i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Rz("unsubscribe()",t,this.logger),o={roomId:this._roomId,streamId:t.streamId,userId:t.userId},a=t.vendorHandler||this.handler,null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unsubscribe",o).catch((function(){})),t.streamState=pB.INIT,t.subVideo=!1,null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(i=t.observer)||void 0===i||i.setSubscribeAudio(!1)),e.next=10,null==a?void 0:a.handleAck({action:yB.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:s=e.sent,this._subResolves[s]&&this._subResolves[s].forEach((function(e){return e(0)})),this.logger.info("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),t.subMediaType=$F.NONE,this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t=this._ontrackCallbackMap.get(e);if(t){var r=e.vendorHandler||this._handler;null==r||r.off("ontrack",t),this._ontrackCallbackMap.delete(e)}}},{key:"handleRemoveStream",value:(o=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Rz("handleRemoveStream()",t,this.logger),t.subVideo=!1,t.streamState!==pB.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"leave",value:(i=xm(wm().mark((function e(){var t,r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("leave()"),this._stopJoinRoom5xxRetry(),this._joinRoomFailed("leave_room"),"connected"!==this.connectionState){e.next=20;break}return t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=7,this._joinLeaveLock.lock();case 7:return r=e.sent,e.prev=8,e.next=11,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 11:r(),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(8),r(),e.t0;case 18:e.next=21;break;case 20:return e.abrupt("return",$_.reject(new SA(_A.NOT_CONNECTED_YET,"server not connected")));case 21:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(){return i.apply(this,arguments)})},{key:"subscribePublicStream",value:(n=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._handler)||void 0===r?void 0:r.subscribe(t,{multiChatMode:!1});case 2:if(s=e.sent){e.next=5;break}throw new SA(_A.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=tD(),u=s.audioMid,d=s.videoMid,e.t0=this._context.appId,e.t1=t.streamId,e.t2=u,e.t3=d,e.t4={sdp:null==s?void 0:s.partialSdp,semantics:null==s?void 0:s.semantics,type:null==s?void 0:s.type},e.next=15,KU();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=bM.VERSION,e.t8=pM.getDeviceId(),e.t9=this._context.appId,e.t10=this._businessId,e.t11=this._context.useCloudProxy,e.t12={supportedCodecs:e.t5,deviceType:"web",userAgent:e.t6,sdkVersion:e.t7,deviceId:e.t8,appId:e.t9,businessId:e.t10,enableCloudProxy:e.t11},e.t13={enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}},l={appId:e.t0,streamId:e.t1,audio:!0,video:!0,data:!0,audioMid:e.t2,videoMid:e.t3,sdpInfo:e.t4,params:e.t12,config:e.t13},e.next=27,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",l);case 27:return h=e.sent,v=[],this._subResolves[t.streamId]=[],v.push(new $_((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SA(_A.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),Tz);t.on("ontrack",(function r(i){"video"===i.mediaType&&(g.logger.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v.push(new $_((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SA(_A.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),Tz);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(g.logger.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",p),this._ontrackCallbackMap.set(t,p),f=null==h?void 0:h.relayMessage,_=f.sequenceId,m=f.sdp,t.videoMid=d,t.audioMid=u,t.sequenceId=_,t.streamState=pB.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:yB.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:m,sequenceId:_},stream:t});case 44:return e.next=46,$_.all(v);case 46:null===(a=this._monitor)||void 0===a||a.report("rtc_subscribe_stat",{result:"success",start:c,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return g.emit("onRemoteStreamStats",e)}),this._handler);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(r=xm(wm().mark((function e(t){var r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Rz("unsubscribePublicStream()",t,this.logger),n={appId:this._context.appId,streamId:t.streamId},e.prev=2,e.next=5,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=pB.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:yB.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),t.subMediaType=$F.NONE,this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;this.logger.info("destroy()"),this._joinRoomFailed("leave_room"),this._token=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId="",this._pubSubBackOff={},this._stopJoinRoom5xxRetry(),null===(e=this._handler)||void 0===e||e.destroy(),this._handler=void 0,null===(t=this._dataChannelSignal)||void 0===t||t.destroy(),this._dataChannelSignal=void 0,this._connectionManager.destroy(),null===(r=this._monitor)||void 0===r||r.set({connection_id:""}),this._removeSignalEventHandler(),this.removeAllListeners(),this.connectionState="disconnected"}},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendP2PMessage({to:e,from:this._userInfo.userId,room:this._roomId,app:this._context.appId,msg:t})}},{key:"sendRoomMessage",value:function(e){var t;return null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("customMessage",e)}},{key:"_joinRoomWithRetry",value:function(e,t,r){var n=this;return new $_((function(i,o){n._dataChannelSignal.sendSignaling(e,t,void 0,1e4).then((function(e){n.emit("onJoinRoomAck",e),i(e)})).catch((function(a){if(r=r||new oz,a.code>=500&&a.code<600&&tD()-r.initTs<6e4){var s,c=r.getRetryDelay();return n.logger.warn("_joinRoomWithRetry",Mm(s="joinRoom failed(code: ".concat(a.code,"), will retry after ")).call(s,c,"ms")),void(n._joinRoom5xxTimer=window.setTimeout((function(){delete n._joinRoom5xxTimer,n._joinRoomWithRetry(e,t,r).then(i).catch(o)}),c))}o(a)}))}))}},{key:"_stopJoinRoom5xxRetry",value:function(){this._joinRoom5xxTimer&&(clearTimeout(this._joinRoom5xxTimer),delete this._joinRoom5xxTimer)}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n,i;e.logger.info("connectStateChange","connected"),e.connectionState="connected",null===(r=e._dataChannelSignal)||void 0===r||r.destroy(),null===(n=e._handler)||void 0===n||n.destroy(),e._handler=BG(e._context,t.pc),e._dataChannelSignal=t.signaling,e.supportConcurrent="chrome"===(null===(i=e._handler)||void 0===i?void 0:i.name),e._addSignalEventHandler(),e.isReconnecting&&(e.publicStream?e.emit("connectSuccess",{reconnect:!0}):(e._reportJoinRoomStart(),e._callJoinRoom(!0)))})),this._connectionManager.on("disconnected",(function(t){e.connectionState="disconnected",e.logger.error("connectStateChange","disconnected. %o",t),e.isReconnecting&&e.safeEmit(QG.RECONNECT_FAILED)})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",e.logger.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.connectionState="disconnected",e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",e.logger.warn("connectStateChange","reconnecting"),e.safeEmit("reconnecting")})),this._connectionManager.on("connectWidthTcp",(function(){e.safeEmit(QG.ON_ICE_CONNECT_WITH_TCP)})),["__onGetIceConfigHook","__onIceConnectSuccessHook"].forEach((function(t){e._connectionManager.on(t,(function(){return e.emit(t)}))}))}},{key:"_reportJoinRoomStart",value:function(){var e;this._joinRoomStartTs=tD(),this.emit("__joinRoomStartReport"),null===(e=this._monitor)||void 0===e||e.report("join_room",{type:"begin",start:this._joinRoomStartTs,result:!1,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC})}},{key:"getPubSubBackOff",value:function(e){return this._pubSubBackOff[e]||(this._pubSubBackOff[e]={interval:1e3,retryDuration:0}),this._pubSubBackOff[e]}},{key:"_joinRoomSuccess",value:function(e){var t,r;(this._joinReject&&this._joinResolve&&(this._joinResolve(e),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomSuccessReport"),null===(t=this._monitor)||void 0===t||t.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!0,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),null===(r=this._monitor)||void 0===r||r.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:tD()-this._joinRoomStartTs}),delete this._joinRoomStartTs)}},{key:"_joinRoomFailed",value:function(e,t){var r;(this._joinReject&&this._joinResolve&&(this._joinReject(new SA(t||_A.JOIN_ROOM_FAILED,e)),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomFailedReport"),null===(r=this._monitor)||void 0===r||r.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!1,reason:e},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),delete this._joinRoomStartTs)}},{key:"multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"sendForwardStreamSignal",value:(t=xm(wm().mark((function e(t,r,n){var i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o={forwardStreamType:t,roomId:r},("start"===t||"update"===t)&&(o.dstRoomInfos=null==n?void 0:Km(n).call(n,(function(e){return{dstRoomId:e.roomId,dstToken:nD.token2auth(a._context.appId,e.roomId,a._clientId,e.token)}}))),e.abrupt("return",null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("forwardStream",o));case 4:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}},{key:"vendorConfig",get:function(){return this._vendorConfig}}]),R}($M);function wz(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var r,i,o,a=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._handler||"connected"!==this._state){e.next=6;break}for(r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=4,n.apply(this,i);case 4:e.next=7;break;case 6:throw new SA(_A.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function Cz(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var t,r,i,o,a=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pubSubLock.lock();case 2:for(t=e.sent,this.supportConcurrent&&t(),e.prev=4,r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=8,n.apply(this,i);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,this.supportConcurrent||t(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[4,,9,12]])}))),r}kz([function(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var t,r,i,o,a=this,s=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=s.length,r=new Array(t),i=0;i<t;i++)r[i]=s[i];return o=!1,e.abrupt("return",new $_(function(){var e=xm(wm().mark((function e(t,i){var s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new SA(_A.OPERATION_CANCEL,"operation not finish when leave"))})),e.prev=1,e.next=4,n.apply(a,r);case 4:s=e.sent,t(s),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o||i(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)}))),r}],Az.prototype,"join",1),kz([Cz,wz],Az.prototype,"publish",1),kz([Cz,wz],Az.prototype,"updatePubTrack",1),kz([Cz,wz],Az.prototype,"unpublish",1),kz([Cz,wz],Az.prototype,"subscribe",1),kz([wz],Az.prototype,"controlMessage",1),kz([wz],Az.prototype,"updateUserAttributes",1),kz([wz],Az.prototype,"updateSubTrackLayer",1),kz([wz],Az.prototype,"updateSubPriority",1),kz([Cz,wz],Az.prototype,"subscribe4pushTrack",1),kz([Cz,wz],Az.prototype,"unsubscribe4removeTrack",1),kz([Cz,wz],Az.prototype,"unsubscribe",1),kz([wz],Az.prototype,"handleRemoveStream",1),kz([Cz],Az.prototype,"subscribePublicStream",1),kz([Cz],Az.prototype,"unsubscribePublicStream",1);var xz,Oz=function(){var e=xm(wm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,v,p,f,_,m,g;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getOrgTrack():null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getOrgTrack(),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.receiver:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.receiver,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,dV(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return p=e.t0,f=kE(v=p||[]).call(v,(function(e){return"inbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(_=e.sent,m=[],null==_||_.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==(null==p?void 0:p.length)||0===m.length){e.next=22;break}return e.next=21,dV(r.pc);case 21:g=e.sent;case 22:u=Fm({type:t,reports:Km(p).call(p,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==f?void 0:f.bytesReceived,framesReceived:null==f?void 0:f.framesReceived,packetsReceived:null==f?void 0:f.packetsReceived,allReports:g}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Fm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_recv_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),Pz=function(){var e=xm(wm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,v,p,f,_,m,g;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack("preprocessing"):null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.sender:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.sender,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,dV(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return p=e.t0,f=kE(v=p||[]).call(v,(function(e){return"outbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(_=e.sent,m=[],null==_||_.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==p.length||0===m.length){e.next=22;break}return e.next=21,dV(r.pc);case 21:g=e.sent;case 22:u=Fm({type:t,reports:Km(p).call(p,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==f?void 0:f.bytesSent,framesSent:null==f?void 0:f.framesSent,packetsSent:null==f?void 0:f.packetsSent,allReports:g}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Fm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_send_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),Nz=function(e){UI(a,e);var t,r,n,i,o=eR(a);function a(e,t){var r;return Hl(this,a),Zd(sI(r=o.call(this)),"_audioEventSessionId",oD()),Zd(sI(r),"_videoEventSessionId",oD()),Zd(sI(r),"_handler",void 0),Zd(sI(r),"_stream",void 0),Zd(sI(r),"_firstAudioFrameTimer",void 0),Zd(sI(r),"_firstVideoFrameTimer",void 0),Zd(sI(r),"_transportDelayInterval",void 0),Zd(sI(r),"_transportDelay",void 0),Zd(sI(r),"_firstVideoFrameInterval",void 0),Zd(sI(r),"_firstAudioFrameInterval",void 0),Zd(sI(r),"_isScreen",!1),Zd(sI(r),"_audioFirstFrameState",0),Zd(sI(r),"_videoFirstFrameState",0),Zd(sI(r),"_timeout",1e4),Zd(sI(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),Zd(sI(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),Zd(sI(r),"_login",!1),Zd(sI(r),"_unMuteAudio",!1),Zd(sI(r),"_enableAudio",!1),Zd(sI(r),"_unMuteVideo",!1),Zd(sI(r),"_enableVideo",!1),Zd(sI(r),"_remoteUnmuteAudio",!1),Zd(sI(r),"_remoteUnmuteVideo",!1),Zd(sI(r),"_audioExternal",!1),Zd(sI(r),"_pushAudio",!1),Zd(sI(r),"_videoExternal",!1),Zd(sI(r),"_pushVideo",!1),Zd(sI(r),"_autoSubscribeVideo",!1),Zd(sI(r),"_autoSubscribeAudio",!1),Zd(sI(r),"_autoSubscribe",!1),Zd(sI(r),"_publishVideo",!1),Zd(sI(r),"_publishAudio",!1),Zd(sI(r),"_subscribeAudio",!1),Zd(sI(r),"_subscribeVideo",!1),Zd(sI(r),"_subscribe",!1),Zd(sI(r),"_pushTrack",!1),Zd(sI(r),"_multiChatMode",!1),Zd(sI(r),"_monitor",void 0),Zd(sI(r),"logger",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=YP(e.engineId),r.logger=new fN("RecvFrameObserver",0,e.engineId),r}return jl(a,[{key:"beginRecvFrame",value:(i=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,DE(n=["login","unmute","subscribe","push_track"]).call(n,r)>=0&&(i=0,o=!1),"audio"===t?(o||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},v={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(a=this._stream)||void 0===a||!a.isScreen),start:null===(s=this._currentAudioRecv)||void 0===s?void 0:s.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,transport_delay:i,vendor_mode:(null===(u=this._stream)||void 0===u?void 0:u.vendorCode)||0,pc_session_id:(null===(d=this._stream)||void 0===d?void 0:d.pcSessionId)||(null===(l=this._handler)||void 0===l?void 0:l.peerConnectionId)},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){Oz("audio",E._handler,E._stream,E._monitor),E.stopRecvFrame("audio","timeout"),E._firstAudioFrameInterval&&window.clearInterval(E._firstAudioFrameInterval)}),this._timeout),this.logger.info("rtcFirstFrameRecv",Fm(v)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",v),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):"video"===t&&(o||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},b={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(p=this._stream)||void 0===p||!p.isScreen),start:null===(f=this._currentVideoRecv)||void 0===f?void 0:f.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,transport_delay:i,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(g=this._stream)||void 0===g?void 0:g.pcSessionId)||(null===(y=this._handler)||void 0===y?void 0:y.peerConnectionId)},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){Oz("video",E._handler,E._stream,E._monitor),E.stopRecvFrame("video","timeout"),E._firstVideoFrameInterval&&window.clearInterval(E._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),this.logger.info("rtcFirstFrameRecv",Fm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u;if(1!==this._audioFirstFrameState)return;var d={event_type:"recv_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioRecv)||void 0===n?void 0:n.startTime,reason:t,result:!1,stream_user_id:null===(i=this._stream)||void 0===i?void 0:i.userId,event_session_id:this._audioEventSessionId,type:null===(o=this._currentAudioRecv)||void 0===o?void 0:o.type,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,this.logger.info("rtcFirstFrameRecv",Fm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._audioFirstFrameState=2}else if("video"===e){var l,h,v,p,f,_,m,g;if(1!==this._videoFirstFrameState)return;var y={event_type:"recv_end",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),start:null===(h=this._currentVideoRecv)||void 0===h?void 0:h.startTime,reason:t,result:!1,stream_user_id:null===(v=this._stream)||void 0===v?void 0:v.userId,event_session_id:this._videoEventSessionId,type:null===(p=this._currentVideoRecv)||void 0===p?void 0:p.type,vendor_mode:(null===(f=this._stream)||void 0===f?void 0:f.vendorCode)||0,pc_session_id:(null===(_=this._stream)||void 0===_?void 0:_.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,this.logger.info("rtcFirstFrameRecv",Fm(y)),null===(g=this._monitor)||void 0===g||g.report("rtc_first_frame",y),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:if(r=this._transportDelay,"audio"!==t){e.next=19;break}if(1===this._audioFirstFrameState){e.next=6;break}return e.abrupt("return");case 6:if(this._currentAudioRecv){e.next=8;break}return e.abrupt("return");case 8:d=this._currentAudioRecv,l=d.type,h=d.startTime,DE(n=["login","unmute","subscribe","push_track"]).call(n,l)>=0&&(r=0),v={event_type:"recv_end",media_type:t,start:h,result:!0,is_screen:!(null===(i=this._stream)||void 0===i||!i.isScreen),stream_user_id:null===(o=this._stream)||void 0===o?void 0:o.userId,event_session_id:this._audioEventSessionId,type:l,transport_delay:r,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this.logger.info("rtcFirstFrameRecv",Fm(v)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",v),this.emit("recvAudioFirstFrame"),this._audioFirstFrameState=3,e.next=33;break;case 19:if("video"!==t){e.next=33;break}if(1===this._videoFirstFrameState){e.next=22;break}return e.abrupt("return");case 22:if(this._currentVideoRecv){e.next=24;break}return e.abrupt("return");case 24:b=this._currentVideoRecv,E=b.type,k=b.startTime,DE(p=["login","unmute","subscribe","push_track"]).call(p,E)>=0&&(r=0),T={event_type:"recv_end",media_type:t,is_screen:!(null===(f=this._stream)||void 0===f||!f.isScreen),start:k,result:!0,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,event_session_id:this._videoEventSessionId,type:E,transport_delay:r,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(g=this._stream)||void 0===g?void 0:g.pcSessionId)||(null===(y=this._handler)||void 0===y?void 0:y.peerConnectionId)},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this.logger.info("rtcFirstFrameRecv",Fm(T)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",T),this.emit("recvVideoFirstFrame"),this._videoFirstFrameState=3;case 33:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLogin",value:function(e){var t,r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};this._login!==e&&(this._login=e,e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&o.audio&&this.beginRecvFrame("audio","login"),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame("video","login"),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame("audio","leave_room"),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame("video","leave_room"))}},{key:"setUnmuteAudio",value:function(e){var t,r,n;if(this._unMuteAudio!==e){this._unMuteAudio=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasAudio);null!==(r=this._stream)&&void 0!==r&&r.audioHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.audioHasPublish&&(this._unMuteAudio&&i?this.beginRecvFrame("audio","unmute"):i&&this.stopRecvFrame("audio","mute"))}}},{key:"setRemoteUnmuteAudio",value:function(e){this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame("audio","remote_unmute"):this.stopRecvFrame("audio","remote_mute"))}},{key:"setEnableAudio",value:function(e){this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame("audio","enable"):this.stopRecvFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t,r,n;if(this._unMuteVideo!==e){this._unMuteVideo=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasVideo);null!==(r=this._stream)&&void 0!==r&&r.videoHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.videoHasPublish&&(this._unMuteVideo&&i?this.beginRecvFrame("video","unmute"):i&&this.stopRecvFrame("video","mute"))}}},{key:"setHandler",value:function(e){this._handler=e}},{key:"setRemoteUnmuteVideo",value:function(e){this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame("video","remote_unmute"):this.stopRecvFrame("video","remote_mute"))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame("video","enable"):this.stopRecvFrame("video","disable"))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal=e}},{key:"setPushAudio",value:function(e){var t;this._audioExternal&&this._pushAudio!==e&&(this._pushAudio=e),this._pushAudio&&this.beginRecvFrame("audio","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","stop_push")}},{key:"setExternalVideoSource",value:function(e){this._videoExternal=e}},{key:"setPushVideo",value:function(e){var t;this._videoExternal&&this._pushVideo!==e&&(this._pushVideo=e),this._pushVideo&&this.beginRecvFrame("video","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","stop_push")}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame("video","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unpublish")}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame("audio","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unpublish")}},{key:"setAutoSubscribe",value:function(e){this._autoSubscribe=e}},{key:"setAutoSubscribeVideo",value:function(e){this._autoSubscribeVideo=e}},{key:"setAutoSubscribeAudio",value:function(e){this._autoSubscribeAudio=e}},{key:"setSubscribeAudio",value:function(e){var t,r;this._autoSubscribeAudio||this._subscribeAudio===e||(this._subscribe=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasAudio&&this.beginRecvFrame("audio","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unsubscribe")}},{key:"setSubscribeVideo",value:function(e){var t,r;this._autoSubscribeVideo||this._subscribeVideo===e||(this._subscribeVideo=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&this.beginRecvFrame("video","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unsubscribe")}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(this._pushTrack=e,e&&!this._isScreen&&this.beginRecvFrame("audio","push_track"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","remove_track"))}},{key:"setMultiChatMode",value:function(e){this._multiChatMode=e}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"_watchForFirstVideoFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(xm(wm().mark((function n(){var i,o,a,s,c,u,d,l;return wm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a||!a.getTrack()){n.next=12;break}return n.next=3,dV(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.videoTrack)||void 0===u?void 0:u.getTrack());case 3:if(d=n.sent,!(l=kE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.framesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.framesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(xm(wm().mark((function n(){var i,o,a,s,c,u,d,l;return wm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a||!a.getOrgTrack()){n.next=12;break}return n.next=3,dV(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.getOrgTrack());case 3:if(d=n.sent,!(l=kE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.totalSamplesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.totalSamplesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"getTransportDelay",value:(r=xm(wm().mark((function e(){var t=this;return wm().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(xm(wm().mark((function e(){return wm().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=xm(wm().mark((function e(){var t,r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc){e.next=7;break}return e.next=3,dV(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=kE(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=kE(n).call(n,(function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==i?void 0:i.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*o.currentRoundTripTime/2));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"setDisconnect",value:function(){this.stopRecvFrame("audio","connection_lost"),this.stopRecvFrame("video","connection_lost"),this.reset()}},{key:"reset",value:function(){this._currentAudioRecv={startTime:0,eventSessionId:0,type:"login"},this._currentVideoRecv={startTime:0,eventSessionId:0,type:"login"},this._login=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._remoteUnmuteAudio=!1,this._remoteUnmuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoSubscribeVideo=!1,this._autoSubscribeAudio=!1,this._autoSubscribe=!1,this._subscribeAudio=!1,this._subscribeVideo=!1,this._subscribe=!1,this._pushTrack=!1,this._multiChatMode=!1,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._transportDelayInterval&&window.clearInterval(this._transportDelayInterval)}},{key:"audioFirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}},{key:"FirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}}]),a}(JM.EventEmitter),Dz=function(){function e(t,r){Hl(this,e),Zd(this,"_audioEventSessionId",oD()),Zd(this,"_videoEventSessionId",oD()),Zd(this,"_pcSessionId",void 0),Zd(this,"_handler",void 0),Zd(this,"_firstAudioFrameTimer",void 0),Zd(this,"_firstVideoFrameTimer",void 0),Zd(this,"_stream",void 0),Zd(this,"_firstVideoFrameInterval",void 0),Zd(this,"_firstAudioFrameInterval",void 0),Zd(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),Zd(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),Zd(this,"_login",!1),Zd(this,"_publisher",!1),Zd(this,"_unMuteAudio",!1),Zd(this,"_enableAudio",!1),Zd(this,"_unMuteVideo",!1),Zd(this,"_enableVideo",!1),Zd(this,"_audioExternal",!1),Zd(this,"_pushAudio",!1),Zd(this,"_videoExternal",!1),Zd(this,"_pushVideo",!1),Zd(this,"_autoPublish",!1),Zd(this,"_publish",!1),Zd(this,"_timeout",1e4),Zd(this,"_audioFirstFrameState",0),Zd(this,"_videoFirstFrameState",0),Zd(this,"_monitor",void 0),Zd(this,"logger",void 0),this._stream=t,this._handler=r,this._monitor=YP(t.engineId),this.logger=new fN("SendFrameObserver",0,t.engineId)}var t,r;return jl(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if("audio"===e){var n,i,o,a,s,c,u;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var d={event_type:"begin_send",media_type:e,is_screen:!(null===(n=this._stream)||void 0===n||!n.isScreen),type:t,start:this._currentAudioSend.startTime,event_session_id:this._audioEventSessionId,vendor_mode:(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,pc_session_id:(null===(o=this._stream)||void 0===o?void 0:o.pcSessionId)||(null===(a=this._handler)||void 0===a?void 0:a.peerConnectionId),capture_session_id:null===(s=this._stream)||void 0===s||null===(c=s.audioTrack)||void 0===c?void 0:c.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){Pz("audio",r._handler,r._stream,r._monitor),r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),this.logger.info("rtcFirstFrameSend",Fm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if("video"===e){var l,h,v,p,f,_,m;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var g={event_type:"begin_send",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),type:t,start:this._currentVideoSend.startTime,event_session_id:this._videoEventSessionId,vendor_mode:(null===(h=this._stream)||void 0===h?void 0:h.vendorCode)||0,pc_session_id:(null===(v=this._stream)||void 0===v?void 0:v.pcSessionId)||(null===(p=this._handler)||void 0===p?void 0:p.peerConnectionId),capture_session_id:null===(f=this._stream)||void 0===f||null===(_=f.videoTrack)||void 0===_?void 0:_.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){Pz("video",r._handler,r._stream,r._monitor),r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),this.logger.info("rtcFirstFrameSend",Fm(g)),null===(m=this._monitor)||void 0===m||m.report("rtc_first_frame",g),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u,d;if(1!==this._audioFirstFrameState)return;var l={event_type:"sent_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioSend)||void 0===i?void 0:i.type,vendor_mode:(null===(o=this._stream)||void 0===o?void 0:o.vendorCode)||0,pc_session_id:(null===(a=this._stream)||void 0===a?void 0:a.pcSessionId)||(null===(s=this._handler)||void 0===s?void 0:s.peerConnectionId),capture_session_id:null===(c=this._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,this.logger.info("rtcFirstFrameSend",Fm(l)),null===(d=this._monitor)||void 0===d||d.report("rtc_first_frame",l),this._audioFirstFrameState=2}else if("video"===e){var h,v,p,f,_,m,g,y,S;if(1!==this._videoFirstFrameState)return;var b={event_type:"sent_end",media_type:e,start:null===(h=this._currentVideoSend)||void 0===h?void 0:h.startTime,is_screen:!(null===(v=this._stream)||void 0===v||!v.isScreen),reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(p=this._currentVideoSend)||void 0===p?void 0:p.type,vendor_mode:(null===(f=this._stream)||void 0===f?void 0:f.vendorCode)||0,pc_session_id:(null===(_=this._stream)||void 0===_?void 0:_.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId),capture_session_id:null===(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",Fm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if("audio"===e){var t,r,n,i,o,a,s;if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var c=this._currentAudioSend,u=c.type,d=c.startTime,l={event_type:"sent_end",media_type:e,is_screen:!(null===(t=this._stream)||void 0===t||!t.isScreen),start:d,result:!0,event_session_id:this._audioEventSessionId,type:u,vendor_mode:(null===(r=this._stream)||void 0===r?void 0:r.vendorCode)||0,pc_session_id:(null===(n=this._stream)||void 0===n?void 0:n.pcSessionId)||(null===(i=this._handler)||void 0===i?void 0:i.peerConnectionId),capture_session_id:null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.captureSessionId};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this.logger.info("rtcFirstFrameSend",Fm(l)),null===(s=this._monitor)||void 0===s||s.report("rtc_first_frame",l),this._audioFirstFrameState=3}else if("video"===e){var h,v,p,f,_,m,g;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var y=this._currentVideoSend,S=y.type,b=y.startTime,E={event_type:"sent_end",media_type:e,is_screen:!(null===(h=this._stream)||void 0===h||!h.isScreen),start:b,result:!0,event_session_id:this._videoEventSessionId,type:S,vendor_mode:(null===(v=this._stream)||void 0===v?void 0:v.vendorCode)||0,pc_session_id:(null===(p=this._stream)||void 0===p?void 0:p.pcSessionId)||(null===(f=this._handler)||void 0===f?void 0:f.peerConnectionId),capture_session_id:null===(_=this._stream)||void 0===_||null===(m=_.videoTrack)||void 0===m?void 0:m.captureSessionId};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this.logger.info("rtcFirstFrameSend",Fm(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.pubVideo&&this._stream.videoTrack&&this.beginSendFrame("video","login"),null!==(r=this._stream)&&void 0!==r&&r.pubAudio&&this._stream.audioTrack&&this.beginSendFrame("audio","login");!e&&this._audioSending&&this.stopSendFrame("audio","leave_room"),!e&&this._videoSending&&this.stopSendFrame("video","leave_room")}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&this._stream.pubVideo&&this.beginSendFrame("video","publish"),(null===(r=this._stream)||void 0===r?void 0:r.audioTrack)&&this._stream.pubAudio&&this.beginSendFrame("audio","publish");!e&&this._audioSending&&this.stopSendFrame("audio","unpublish"),!e&&this._videoSending&&this.stopSendFrame("video","unpublish")}}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&(e&&this.beginSendFrame("audio","unmute"),!e&&this._audioSending&&this.stopSendFrame("audio","mute")))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubAudio&&(this._enableAudio=e,e&&this.beginSendFrame("audio","enable"),!e&&this._audioSending&&this.stopSendFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&(e&&this.beginSendFrame("video","unmute"),!e&&this._videoSending&&this.stopSendFrame("video","mute")))}},{key:"setEnableVideo",value:function(e){var t;this._enableVideo!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubVideo&&(this._enableVideo=e,e&&this.beginSendFrame("video","enable"),!e&&this._videoSending&&this.stopSendFrame("video","disable"))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame("audio","push"),!e&&this._audioSending&&this.stopSendFrame("audio","stop_push"))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame("video","push"),!e&&this._videoSending&&this.stopSendFrame("video","stop_push"))}},{key:"setAutoPublish",value:function(e){this._autoPublish=e}},{key:"setPublisher",value:function(e){this._publisher!==e&&(this._publisher=e,!e&&this._audioSending&&this.stopSendFrame("audio","audience"),!e&&this._videoSending&&this.stopSendFrame("video","audience"))}},{key:"setDisconnect",value:function(){this._audioSending&&this.stopSendFrame("audio","connection_lost"),this._videoSending&&this.stopSendFrame("video","connection_lost"),this.reset()}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"setPCSessionId",value:function(e){this._pcSessionId=e}},{key:"setHandler",value:function(e){this._handler=e}},{key:"_getFirstVideoFrameStats",value:(r=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.videoTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=6;break}return e.next=3,dV(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,c=Ks(s).call(s,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=xm(wm().mark((function e(){var t,r,n,i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.audioTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=5;break}return e.next=3,dV(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,e.abrupt("return",kE(s).call(s,(function(e){return"outbound-rtp"===e.type})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_watchForFirstVideoFrameSend",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(xm(wm().mark((function n(){var i,o,a;return wm().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||Km(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(xm(wm().mark((function r(){var n;return wm().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e._getFirstAudioFrameStats();case 2:if(!((n=r.sent)&&n.packetsSent>t)){r.next=9;break}if(-1!==t){r.next=7;break}return t=n.packetsSent,r.abrupt("return");case 7:e.sendFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 9:case"end":return r.stop()}}),r)}))),100)}},{key:"reset",value:function(){this._login=!1,this._publisher=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoPublish=!1,this._publish=!1,this._audioFirstFrameState=0,this._videoFirstFrameState=0,this._currentAudioSend={startTime:0,eventSessionId:0,type:"login"},this._currentVideoSend={startTime:0,eventSessionId:0,type:"login"},window.clearTimeout(this._firstAudioFrameTimer),window.clearTimeout(this._firstVideoFrameTimer),window.clearInterval(this._firstAudioFrameInterval),window.clearInterval(this._firstVideoFrameInterval)}},{key:"destroy",value:function(){this.reset(),delete this._stream,delete this._handler}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),Mz=(Zd(xz={},"audio",{delay:1200,stallRadio:.3}),Zd(xz,"video",{delay:1200,stallRadio:.6}),Zd(xz,"screen_audio",{delay:1600,stallRadio:.8}),Zd(xz,"screen_video",{delay:1600,stallRadio:.8}),xz),Lz=function(){function e(){Hl(this,e),Zd(this,"_preUplinkStats",new ib),Zd(this,"_preDownlinkStats",new ib),Zd(this,"_timer",void 0),Zd(this,"_delayTimer",void 0),Zd(this,"_msc",void 0),Zd(this,"reportor",void 0)}return jl(e,[{key:"updateUplinkStats",value:function(e){var t=e.audioStats,r=e.videoStats,n=e.isScreen;if(t.sendKBitrate>0&&t.rtt){var i,o,a=n?"screen_audio":"audio",s=t.rtt,c=t._fractionLost,u=t._retransmittedRate,d=this._getQosLevel(s,c||0,u||0),l=this._preUplinkStats.get(a)||[d];this._preUplinkStats.set(a,Am(i=Mm(o=[]).call(o,eT(l),[d])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var h,v,p=n?"screen_video":"video",f=r._fractionLost,_=r.rtt,m=r._sendBandWidth,g=r._retransmittedRate;0===m&&(f=Math.max(.65,f));var y=this._getQosLevel(_,f||0,g||0),S=this._preUplinkStats.get(p)||[y];this._preUplinkStats.set(p,Am(h=Mm(v=[]).call(v,eT(S),[y])).call(h,-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){var r;if(t){var n,i,o=this._getStreamActiveState(t),a=o.audioActive,s=o.videoActive,c=e.audioStats,u=e.videoStats,d=e.isScreen,l=e.userId,h=!0,v=!0;if(a)if(0===c.receivedKBitrate)h=!1;else{var p=c.rtt,f=c.audioLossRate,_=c.stallDuration,m=c.statsInterval,g=c.e2eDelay,y=_/m,S=d?"screen_audio":"audio",b=this._getQosLevel(p,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)v=!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=Mm(r="".concat(l)).call(r,d?"_screen":"");if(h||v){var D=n&&i?Math.ceil((n+i)/2):n||i;if(D){var M,L,U=this._preDownlinkStats.get(N)||[D];this._preDownlinkStats.set(N,Am(M=Mm(L=[]).call(L,eT(U),[D])).call(M,-2)),this._startNetworkQualityReport()}}else this._preDownlinkStats.delete(N)}}},{key:"setMSC",value:function(e){this._msc=e}},{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._delayTimer&&(window.clearTimeout(this._delayTimer),delete this._delayTimer),this._preUplinkStats.clear(),this._preDownlinkStats.clear()}},{key:"_startNetworkQualityReport",value:function(){var e=this;this._delayTimer||this._timer||(this._preUplinkStats.size>0||this._preDownlinkStats.size>0)&&(this._delayTimer=window.setTimeout((function(){delete e._delayTimer,e._reportNetworkQuality(),e._timer=window.setInterval((function(){e._reportNetworkQuality()}),2e3)}),300))}},{key:"_reportNetworkQuality",value:function(){var e,t,r,n,i,o=this;if(bk(e=["connected","connecting"]).call(e,null===(t=this._msc)||void 0===t||null===(r=t.handler)||void 0===r?void 0:r.getConnectionState())){var a,s,c,u=this._getBetterQualityAndRemoveOldest("audio","up"),d=this._getBetterQualityAndRemoveOldest("video","up");n=u&&d?Math.ceil((u+d)/2):u||d||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||kl.EXCELLENT;var l=Ks(a=Km(s=Zk(dw(c=this._preDownlinkStats).call(c))).call(s,(function(e){return o._getBetterQualityAndRemoveOldest(e,"down")}))).call(a,(function(e){return e}));i=Math.ceil(gb(l).call(l,(function(e,t){return t+e}),0)/l.length)||kl.UNKNOWN}else n=i=kl.DOWN;navigator.onLine||(n=kl.DOWN,i=kl.DOWN),"function"==typeof this.reportor&&this.reportor(n,i)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getQosLevel",value:function(e,t,r){var n;return n=(!e||e<=250)&&t<=.15?1:(!e||e<=500)&&t<=.3?2:(!e||e<=750)&&t<=.45?3:(!e||e<=1e3)&&t<=.6?4:5,r>.5?n=Math.max(n,4):r>.35?n=Math.max(n,3):r>.15&&(n=Math.max(n,2)),n}},{key:"_getUplinkQoE",value:function(e,t){var r=0;switch(e){case"audio":case"video":r=t<.05?1:t<.1?2:3;break;case"screen_video":case"screen_audio":r=t<.04?1:t<.08?2:3}return r}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=Mz[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=kl.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=Ks(i).call(i,(function(e){return e}));o.length>0&&(r=Math.min.apply(Math,eT(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&&gD(t)&&r.localaudio&&r.audiostream,videoActive:n&&yD(t)&&r.localvideo&&r.videostream}}}]),e}(),Uz=function(){function e(t){Hl(this,e),Zd(this,"_timer",void 0),Zd(this,"_remoteVideoSizeCache",{}),Zd(this,"_remoteScreenSizeCache",{}),Zd(this,"onchange",void 0),this._room=t,this._start()}return jl(e,[{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._remoteVideoSizeCache={},this._remoteScreenSizeCache={}}},{key:"_start",value:function(){var e=this;this._timer||(this._timer=window.setInterval((function(){var t={},r={};e._room.remoteStreams.forEach((function(n,i){n.forEach((function(n){var o,a=null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack();if(a){var s=n.isScreen?e._remoteScreenSizeCache:e._remoteVideoSizeCache,c=s[i]||{},u=c.width,d=void 0===u?0:u,l=c.height,h=void 0===l?0:l,v=a.getSettings(),p=v.width,f=void 0===p?0:p,_=v.height,m=void 0===_?0:_;h===m&&d===f||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,f,m),delete s[i],(n.isScreen?r:t)[i]={width:f,height:m}}}))})),cn(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),cn(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),Vz=Zk((new TextEncoder).encode("subt")),Fz={1:_A.SUBTITLE_ERR_POSTPROCESS,2:_A.SUBTITLE_ERR_CONNECTION_ERROR,3:_A.SUBTITLE_ERR_PROCESS_ERROR},Bz=new fN("SubtitleTool",1),jz=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&DE(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))||"";DE(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=Fm({source_language:o}))}},Hz=function(){function e(t){var r,n,i;Hl(this,e),Zd(this,"_taskId",void 0),Zd(this,"_appId",void 0),Zd(this,"_roomId",void 0),Zd(this,"_userId",void 0),Zd(this,"onEvent",void 0),Zd(this,"onMessage",void 0),Zd(this,"_preConfig",void 0),Zd(this,"_timer",void 0),this._room=t,this._appId=null===(r=this._room._roomInfo)||void 0===r?void 0:r.appId,this._roomId=null===(n=this._room._roomInfo)||void 0===n?void 0:n.roomId,this._userId=null===(i=this._room._roomInfo)||void 0===i?void 0:i.userInfo.userId}var t,r,n,i;return jl(e,[{key:"start",value:(i=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Bz.info("start","Invoke config: %o",t),PM(t.mode,"mode",[xl.ASR_ONLY,xl.ASR_AND_TRANSLATION]),t.mode!==xl.ASR_AND_TRANSLATION||-1!==DE(zz).call(zz,t.targetLanguage||"")){e.next=4;break}throw new SA(_A.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new SA(_A.SUBTITLE_ALREADY_ON,"Already turned on subtitle");case 6:return this._preConfig=t,this._taskId=(Date.now().toString()+this._roomId+this._userId).substring(0,20),e.next=10,this._sendSubtitleSignalingWithRetry(t,this._taskId);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"update",value:(n=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(PM(t.mode,"mode",[xl.ASR_ONLY,xl.ASR_AND_TRANSLATION]),t.mode!==xl.ASR_AND_TRANSLATION||-1!==DE(zz).call(zz,t.targetLanguage||"")){e.next=3;break}throw new SA(_A.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new SA(_A.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new SA(_A.SUBTITLE_NOT_TURNED_ON,"Start subtitle first.");case 7:if((null===(r=this._preConfig)||void 0===r?void 0:r.mode)===t.mode&&this._preConfig.targetLanguage===t.targetLanguage){e.next=11;break}return this._preConfig=t,e.next=11,this._room.subtitleControlMessage(this._genSubtitleSignaling("update",t,this._taskId));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"stop",value:function(){var e=this;Bz.info("stop","Invoke"),this._taskId&&this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId}).finally((function(){var t;delete e._taskId,null===(t=e.onEvent)||void 0===t||t.call(e,{event:Ol.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(r=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._taskId||!this._preConfig){e.next=5;break}return e.next=3,this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId});case 3:delete this._taskId,this.start(this._preConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getConfig",value:function(){return this._preConfig}},{key:"destroy",value:function(){Bz.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 SA(Fz[r]||_A.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:Ol.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:Ol.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]||this._taskId&&this._preConfig){var t=Gz(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){i===xl.ASR_ONLY?e.mode===i&&a.push(e):i===xl.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==xl.ASR_ONLY||a.push(e),e.mode===xl.ASR_ONLY&&e.language===o&&a.push(el(el({},e),{},{mode:xl.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=xm(wm().mark((function t(r,n){var i,o=this,a=arguments;return wm().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._room.subtitleControlMessage(this._genSubtitleSignaling("started",r,n));case 3:this._timer=self.setTimeout((function(){var e;2===i?(null===(e=o.onEvent)||void 0===e||e.call(o,{event:Ol.ERROR,errorCode:_A.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,r){return{taskId:r,type:"subtitle",action:e,roomId:this._roomId,appId:this._appId,userId:this._userId,subtitleMeta:{subtitleConfig:{mode:t.mode,usersConfig:[{userId:this._userId,targetLanguages:[t.targetLanguage||""]}]},vendorConfig:{type:0}}}}},{key:"_clearTimer",value:function(){this._timer&&(self.clearTimeout(this._timer),delete this._timer)}}]),e}();Zd(Hz,"retryIntervel",3e4);var Gz=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(Vz.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=nD.ab2str(Am(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(c){}return!1},zz=["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"],Kz=cd,Xz=ic,Wz=function(e,t,r,n){for(var i,o=n>1?void 0:n?Xz(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&&Kz(t,r,o),o},Yz=function(){function e(t){Hl(this,e),Zd(this,"_forwardDstRooms",new ib),Zd(this,"forwardStreamState","stopped"),Zd(this,"_monitor",void 0),this._room=t,this._monitor=YP(this._room.id)}var t,r,n,i,o,a;return jl(e,[{key:"startForwardStream2Rooms",value:(a=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!==this.forwardStreamState&&"paused"!==this.forwardStreamState){e.next=2;break}throw new SA(_A.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke startForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("start",this._room.roomInfo.roomId,t);case 4:return r=e.sent,this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),this.forwardStreamState="running",e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(o=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new SA(_A.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke updateForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult(t),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("update",this._room._roomInfo.roomId,t);case 6:r=e.sent;case 7:return this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(i=xm(wm().mark((function e(){var t,r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new SA(_A.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke stopForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult([]),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 6:r=e.sent;case 7:if(this._updateDstRooms([],r),!(eT(dw(t=this._forwardDstRooms).call(t)).length>0)){e.next=10;break}throw new SA(_A.UNEXPECTED_ERROR,"stopforwardstream failed: ".concat(Fm(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=xm(wm().mark((function e(){var t,r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("paused"!==this.forwardStreamState&&"stopped"!==this.forwardStreamState){e.next=2;break}throw new SA(_A.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke pauseForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 4:return t=e.sent,r=this._transformForwardStreamResult(t),this.forwardStreamState="paused",e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(r=xm(wm().mark((function e(){var t,r,n,i,o=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o.length>0&&void 0!==o[0]&&o[0]||!bk(t=["running","stopped"]).call(t,this.forwardStreamState)){e.next=3;break}throw new SA(_A.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke resumeForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 3:return r=this._getDstRooms(),e.next=6,this._sendForwardStreamSignaling("start",this._room._roomInfo.roomId,r);case 6:return n=e.sent,this._updateDstRooms(r,n),i=this._transformForwardStreamResult(n),this.forwardStreamState="running",e.abrupt("return",i);case 11:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"resumeFromReconnect",value:function(){var e=this;"running"===this.forwardStreamState&&this.resumeForwardStream2AllRooms(!0).then((function(t){t.forEach((function(t){t.state===Pl.FORWARD_STREAM_STATE_FAILURE&&e._room.safeEmit(QG.ON_FORWARD_STREAM_ERROR,t)}))}))}},{key:"onForwardDstRoomUserKick",value:function(e){var t=[{dstRoomId:e.dstRoomId,code:200,forwardStreamType:"stop"}];this._updateDstRooms([],t),this._room.safeEmit(QG.ON_FORWARD_STREAM_ERROR,{roomId:e.dstRoomId,state:Pl.FORWARD_STREAM_STATE_FAILURE,error:Nl.FORWARD_STREAM_ERROR_REMOTE_KICKED})}},{key:"clear",value:function(){this._forwardDstRooms.clear(),this.forwardStreamState="stopped"}},{key:"_mockForwardStreamResult",value:function(e){var t=this,r=[];return this._forwardDstRooms.forEach((function(e,t){r.push({dstRoomId:t,forwardStreamType:"stop",code:200})})),e.forEach((function(e){var n,i=eA(r).call(r,(function(t){return t.dstRoomId===e.roomId}));-1===i?r.push({dstRoomId:e.roomId,forwardStreamType:"start",code:e.roomId===(null===(n=t._room.roomInfo)||void 0===n?void 0:n.roomId)?400:200}):r[i].forwardStreamType="update"})),r}},{key:"_transformForwardStreamResult",value:function(e){e||(e=[]);var t,r=[],n=oI(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=i.dstRoomId,a=i.code,s={roomId:o,state:Pl.FORWARD_STREAM_STATE_SUCCESS,error:Nl.FORWARD_STREAM_ERROR_OK};200===a||(400===a?(s.state=Pl.FORWARD_STREAM_STATE_FAILURE,s.error=Nl.FORWARD_STREAM_ERROR_REMOTE_KICKED):a>=700&&a<800?(s.state=Pl.FORWARD_STREAM_STATE_FAILURE,s.error=Nl.FORWARD_STREAM_ERROR_INVALID_TOKEN):(s.state=Pl.FORWARD_STREAM_STATE_FAILURE,s.error=Nl.FORWARD_STREAM_ERROR_RESPONSE)),r.push(s)}}catch(c){n.e(c)}finally{n.f()}return r}},{key:"_updateDstRooms",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];0===(null==r?void 0:r.length)&&this._forwardDstRooms.clear(),r.forEach((function(r){var n=r.dstRoomId,i=r.code,o=r.forwardStreamType;if(200===i)if("stop"===o)t._forwardDstRooms.delete(n);else{var a,s=kE(e).call(e,(function(e){return e.roomId===n}));if(!s&&!t._forwardDstRooms.has(n))throw new SA(_A.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=Nb(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=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="".concat(oD()),"stop"!==t&&(a=Km(n).call(n,(function(e){return e.roomId})),null===(o=this._monitor)||void 0===o||o.report("rtc_forward_stream",{type:"begin",dst_rooms:"{ ".concat(Km(a).call(a,(function(e){return'"'.concat(e,'"')})).join(",")," }"),event_session_id:i})),e.next=4,this._room._mediaServerClient.sendForwardStreamSignal(t,r,n);case 4:if(s=e.sent,c=[],200===(null==s?void 0:s.code)){e.next=9;break}throw"stop"!==t&&(null==n||n.forEach((function(e){c.push({dst_room_id:e.roomId,result:"server error ".concat(null==s?void 0:s.code)})})),null===(u=this._monitor)||void 0===u||u.report("rtc_forward_stream",{type:"end",dst_rooms:Fm(c),event_session_id:i})),new SA(_A.UNEXPECTED_ERROR,"server side internal error, error code: ".concat(s));case 9:return"stop"!==t&&(null===(d=s.forwardStreamResults)||void 0===d||d.forEach((function(e){c.push({dst_room_id:e.dstRoomId,result:"dst room lost"})})),null===(l=s.forwardStreamResults)||void 0===l||l.forEach((function(e){var t=kE(c).call(c,(function(t){return t.dst_room_id===e.dstRoomId}));t&&(200===e.code?"update"===e.forwardStreamType?t.result="update":t.result="success":t.result="server error ".concat(e.code))})),null===(h=this._monitor)||void 0===h||h.report("rtc_forward_stream",{type:"end",dst_rooms:Fm(c),event_session_id:i})),e.abrupt("return",s.forwardStreamResults);case 11:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})}]),e}();function qz(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var r,i,o,a,s=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=this._room._roomInfo)||void 0===r||!r.roomId){e.next=7;break}for(i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=4,n.apply(this,o);case 4:return e.abrupt("return",e.sent);case 7:throw new SA(_A.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 8:case"end":return e.stop()}}),e,this)}))),r}Wz([qz],Yz.prototype,"startForwardStream2Rooms",1),Wz([qz],Yz.prototype,"updateForwardStream2Rooms",1),Wz([qz],Yz.prototype,"stopForwardStream2Rooms",1),Wz([qz],Yz.prototype,"pauseForwardStream2AllRooms",1),Wz([qz],Yz.prototype,"resumeForwardStream2AllRooms",1);var Jz={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},Qz=function(e){UI(x,e);var t,r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C=eR(x);function x(e,t){var r;return Hl(this,x),Zd(sI(r=C.call(this)),"id",void 0),Zd(sI(r),"_mediaServerClient",void 0),Zd(sI(r),"_localStream",void 0),Zd(sI(r),"_localScreenStream",void 0),Zd(sI(r),"_remoteUsers",new ib),Zd(sI(r),"_remoteStreams",new ib),Zd(sI(r),"_remoteStreamStreamIdUserIdMap",{}),Zd(sI(r),"_virtualStreams",[]),Zd(sI(r),"_context",void 0),Zd(sI(r),"_sessionId",void 0),Zd(sI(r),"_connectionLostTimer",void 0),Zd(sI(r),"_serverConfig",void 0),Zd(sI(r),"_roomConfig",void 0),Zd(sI(r),"_roomInfo",void 0),Zd(sI(r),"_userDuplicateLoginTimerMap",new ib),Zd(sI(r),"_networkQualityManager",void 0),Zd(sI(r),"_videoSizeObserver",void 0),Zd(sI(r),"_hasPublished",!1),Zd(sI(r),"_subtitleTool",void 0),Zd(sI(r),"_csrcUserIdMap",void 0),Zd(sI(r),"_publishOnDemandItem",void 0),Zd(sI(r),"_onceTriggerBySignal",!1),Zd(sI(r),"_pubTransceiverReady",!1),Zd(sI(r),"_publishOnDemandBusy",!1),Zd(sI(r),"_monitor",void 0),Zd(sI(r),"logger",void 0),Zd(sI(r),"_forwardStreamManager",void 0),r.id=t.id,r.logger=new fN("Room",1,t.id),r.logger.info("constructor","invoke"),r._roomConfig=e,r._mediaServerClient=new Az(t),r._networkQualityManager=new Lz,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(sI(r)),r._videoSizeObserver=new Uz(sI(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(sI(r)),r._context=t,r._csrcUserIdMap={},r._monitor=YP(r.id),r._forwardStreamManager=new Yz(sI(r)),r._addHandlerEventHandler(),r}return jl(x,[{key:"hasScreenPublished",get:function(){var e;return null===(e=this._localScreenStream)||void 0===e?void 0:e.hasPublished}},{key:"hasPublished",get:function(){var e;return null===(e=this._localStream)||void 0===e?void 0:e.hasPublished}},{key:"connectionState",get:function(){return this._mediaServerClient.connectionState}},{key:"remoteUsers",get:function(){return this._remoteUsers}},{key:"remoteStreams",get:function(){return this._remoteStreams}},{key:"localStream",get:function(){return this._localStream}},{key:"localScreenStream",get:function(){return this._localScreenStream}},{key:"roomInfo",get:function(){return this._roomInfo}},{key:"roomConfig",set:function(e){this._roomConfig=e}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,N,D,M=this;null===(e=this._mediaServerClient)||void 0===e||e.on(GG.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(GG.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return M._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(GG.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(GG.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return M._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(GG.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(GG.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return M._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(GG.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(GG.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return M._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(GG.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(GG.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(GG.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(GG.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(GG.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(GG.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(GG.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(GG.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(GG.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(GG.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(GG.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(GG.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(zG.RSCP,(function(e,t){!!kE(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:bk(t).call(t,null===(r=M._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(t?M._pubTransceiverReady=!0:M._onceTriggerBySignal=!0,t&&M._onceTriggerBySignal||(M._publishOnDemandItem=e),M._pubTransceiverReady&&M._onPublishOnDemand())})),null===(b=this._mediaServerClient)||void 0===b||b.on(zG.RTT,this._onRTT.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(zG.SSC,this._onSSC.bind(this)),null===(k=this._mediaServerClient)||void 0===k||k.on(KG.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(KG.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return M.emit(KG.ON_VENDOR_CONNECTION_STATE_CHANGE,e)})),null===(I=this._mediaServerClient)||void 0===I||I.on(GG.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){M._networkQualityManager.updateDownlinkStats(e,M._findRemoteStreamByScreen(e.userId,e.isScreen)),M.emit(QG.ON_REMOTE_STREAM_STATS,SD(e))})),null===(A=this._mediaServerClient)||void 0===A||A.on(QG.RESUBSCRIBE,(function(e){M.emit(QG.RESUBSCRIBE,e)})),null===(w=this._mediaServerClient)||void 0===w||w.on(QG.RECONNECT_FAILED,(function(){M.emit(QG.RECONNECT_FAILED)})),null===(C=this._mediaServerClient)||void 0===C||C.on("joinSuccess",this._onJoinSucc.bind(this)),null===(x=this._mediaServerClient)||void 0===x||x.on(GG.ON_FORWARD_DST_ROOM_USER_KICK,this._forwardStreamManager.onForwardDstRoomUserKick.bind(this._forwardStreamManager)),null===(O=this._mediaServerClient)||void 0===O||O.on(QG.ON_REJOIN_WITH_TCP,(function(){M.emit(QG.ON_REJOIN_WITH_TCP)})),null===(P=this._mediaServerClient)||void 0===P||P.on(QG.ON_ICE_CONNECT_WITH_TCP,(function(){M.emit(QG.ON_ICE_CONNECT_WITH_TCP)})),null===(N=this._mediaServerClient)||void 0===N||N.on(QG.PUB_RETRY,(function(e){M.emit(QG.PUB_RETRY,e)})),null===(D=this._mediaServerClient)||void 0===D||D.on(QG.SUB_RETRY,(function(e){M.emit(QG.SUB_RETRY,e)}))}},{key:"_onLocalStreamStats",value:function(e){this._networkQualityManager.updateUplinkStats(e),this.emit(QG.ON_LOCAL_STREAM_STATS,SD(e))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(w=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setSessionId(),e.next=3,this._mediaServerClient.connect();case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"join",value:(A=xm(wm().mark((function e(t,r,n,i,o){var a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(a=this._monitor)||void 0===a||a.set({rtc_app_id:t,room_id:r,user_id:i.userId}),this.logger.info("join()"),this._mediaServerClient.setLiveControlMessage(o),this._roomInfo={appId:t,roomId:r,token:n,userInfo:i,roomProfile:this._roomConfig.roomProfileType},this.setSessionId(),e.prev=5,e.next=8,this._mediaServerClient.join(this._roomInfo);case 8:return c=e.sent,null!==(s=c.roomAttributes)&&void 0!==s&&s.multiChatMode&&this._handleFFAudioTrack(),this._initSubtitleTool(),e.abrupt("return",{users:c.clients,streams:c.streams});case 14:if(e.prev=14,e.t0=e.catch(5),e.t0.code===_A.OPERATION_CANCEL){e.next=18;break}throw e.t0;case 18:case"end":return e.stop()}}),e,this,[[5,14]])}))),function(e,t,r,n,i){return A.apply(this,arguments)})},{key:"publishScreen",value:(R=xm(wm().mark((function e(t,r,n,i,o){var a,s,c,u,d,l,h,v,p,f,_,m;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishScreen()"),this._localScreenStream||(this._localScreenStream=new fB(this._context),null!==(a=this._mediaServerClient)&&void 0!==a&&null!==(s=a.vendorConfig)&&void 0!==s&&s.enableMultiVendor&&(this._localScreenStream.pcSessionId=yw()),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new Dz(this._localScreenStream,this._mediaServerClient.handler))),c=!1,u=!1,d=!1,l=!1,!this._localScreenStream.videoTrack&&r?(r instanceof TF&&(u=!0),c=!0):this._localScreenStream.videoTrack&&!r&&(c=!1),!this._localScreenStream.audioTrack&&n?(n instanceof IF&&(l=!0),d=!0):this._localScreenStream.audioTrack&&!n&&(d=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(gD(i)&&(this._localScreenStream.pubAudio=o===$G.PUB),yD(i)&&(this._localScreenStream.pubVideo=o===$G.PUB),this.logger.info("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(h=this._localScreenStream)||void 0===h||!h.hasPublished){e.next=17;break}return e.abrupt("return",this.unpublishScreen());case 17:return e.abrupt("return");case 18:if(this._localScreenStream.hasPublished){e.next=24;break}return null===(v=this._localScreenStream.observer)||void 0===v||v.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return u?null===(p=this._localScreenStream.observer)||void 0===p||p.setPushVideo(c):null===(f=this._localScreenStream.observer)||void 0===f||f.setEnableVideo(c),l?null===(_=this._localScreenStream.observer)||void 0===_||_.setPushAudio(d):null===(m=this._localScreenStream.observer)||void 0===m||m.setEnableAudio(d),e.next=28,this.updatePubScreenTrack();case 28:this._localScreenStream.pubAudio||this._localScreenStream.pubVideo?this._mediaServerClient.handler&&this._localScreenStream.startReport(this._onLocalStreamStats.bind(this),this._localScreenStream.vendorHandler||this._mediaServerClient.handler):this._localScreenStream.stopReport("unpublish screen");case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return R.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(I=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updatePubScreenTrack","Invoke updatePubScreenTrack"),!this._localScreenStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return I.apply(this,arguments)})},{key:"unpublishScreen",value:(T=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=8;break}return null===(t=this._localScreenStream.observer)||void 0===t||t.setPublish(!1),e.next=5,this._mediaServerClient.unpublish(this._localScreenStream);case 5:this._localScreenStream.stopReport("unpublish screen"),this._localScreenStream.clean(),this._localScreenStream=void 0;case 8:case"end":return e.stop()}}),e,this)}))),function(){return T.apply(this,arguments)})},{key:"liveControlMessage",value:(k=xm(wm().mark((function e(t){var r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),e.next=4,this._mediaServerClient.controlMessage(t);case 4:this._mediaServerClient.setLiveControlMessage("stopped"===t.action?void 0:t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(E=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._mediaServerClient.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"subtitleControlMessage",value:(b=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.controlMessage(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"updateUserAttributes",value:(S=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateUserAttributes","Invoke updateUserAttributes"),t.role&&this._roomInfo&&(this._roomInfo.userInfo.role=t.role),e.next=4,this._mediaServerClient.updateUserAttributes(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"publish",value:(y=xm(wm().mark((function e(t,r,n,i,o,a){var s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=E.length>6&&void 0!==E[6]&&E[6],this.logger.info("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new fB(this._context),null!==(u=this._mediaServerClient)&&void 0!==u&&null!==(d=u.vendorConfig)&&void 0!==d&&d.enableMultiVendor&&(this._localStream.pcSessionId=yw()),this._mediaServerClient.handler&&(this._localStream.observer=new Dz(this._localStream,this._mediaServerClient.handler)),c=!0,this._localStream.vendorCode=(null===(l=this._mediaServerClient.vendorConfig)||void 0===l?void 0:l.vendorCode)||0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,o&&(gD(o)&&(this._localStream.pubAudio=a===$G.PUB),yD(o)&&(this._localStream.pubVideo=a===$G.PUB),this.logger.info("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=26;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=12;break}return e.abrupt("return");case 12:return e.prev=12,s?null===(h=this._localStream.observer)||void 0===h||h.setLogin(!0):c&&(v=!!this._localStream.videoTrack,p=!!this._localStream.audioTrack,f=this._localStream.videoTrack instanceof TF,_=this._localStream.audioTrack instanceof IF,this._roomConfig.isAutoPublish&&!this._hasPublished?(v&&(f?null===(m=this._localStream.observer)||void 0===m||m.setPushVideo(!0):null===(g=this._localStream.observer)||void 0===g||g.setEnableVideo(!0)),p&&(_?null===(y=this._localStream.observer)||void 0===y||y.setPushAudio(!0):null===(S=this._localStream.observer)||void 0===S||S.setEnableAudio(!0))):null===(b=this._localStream.observer)||void 0===b||b.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(QG.ON_PUBLISH_RESULT,{isScreen:!1,state:sl.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(QG.ON_PUBLISH_RESULT,{isScreen:!1,state:sl.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:this._localStream.pubAudio||this._localStream.pubVideo?this._mediaServerClient.handler&&this._localStream.startReport(this._onLocalStreamStats.bind(this),this._localStream.vendorHandler||this._mediaServerClient.handler):this._localStream.stopReport("unpublish");case 29:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return y.apply(this,arguments)})},{key:"updatePubTrack",value:(g=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updatePubTrack","Invoke updatePubTrack"),!this._localStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"unpublish",value:(m=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("unpublish","Invoke unpublish"),!this._localStream){e.next=7;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.stopReport("unpublish"),this._localStream.clean(),this._localStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"subscribe",value:(_=xm(wm().mark((function e(t,r,n){var i,o,a;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("subscribe","remoteStream %o",t),!t.hasSubscribed){e.next=8;break}if((i=t.subMediaType|r)===t.subMediaType){e.next=7;break}return e.next=6,null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubMediaType(t,i);case 6:return e.abrupt("return",e.sent);case 7:return e.abrupt("return");case 8:return a=void 0,n&&(a=this._getSubLayer(n,t)),e.next=12,this._mediaServerClient.subscribe(t,r,a);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return _.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(f=xm(wm().mark((function e(t,r){var n,i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((a=this._findRemoteStreamByScreen(t,!1))&&a.hasSubscribed&&!((null==a||null===(n=a.attributes)||void 0===n||null===(i=n.videoDescriptions)||void 0===i?void 0:i.length)<=1)){e.next=3;break}return e.abrupt("return");case 3:return s=this._getSubLayer(r,a),a.originalStreamIndex=s.spatialLayer,e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrackLayer(a,s));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,c=s.videoDescriptions,u=s.subVideoDescriptions,d=Array.isArray(u)?u:c,l=-1,h=e.width*e.height,v=0;v<(null==d?void 0:d.length);v++){var p,f;if(h>=(null===(p=d[v])||void 0===p?void 0:p.width)*(null===(f=d[v])||void 0===f?void 0:f.height)){l=v;break}}var _=d[0];if(-1===l)_=d[l=d.length-1];else if(0!==l){var m=d[l-1].width*d[l-1].height,g=(m-h)/(m-d[l].width*d[l].height);_=g<.1?d[l-1]:d[l],l=g<.1?l-1:l}return a=null!==(r=null===(n=_)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=_)||void 0===o?void 0:o.video_index)&&void 0!==i?i:l,spatialSubLayer:a}}},{key:"unsubscribe",value:(p=xm(wm().mark((function e(t,r){var n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("unsubscribe","Invoke unsubscribe"),t.hasSubscribed){e.next=3;break}return e.abrupt("return");case 3:if(o=t.subMediaType-(t.subMediaType&r),null!==(n=this._context.serverConfig)&&void 0!==n&&n.muteReplaceUnsub||!(o===$F.NONE||this.multiChatMode&&o===ll.AUDIO)){e.next=8;break}return e.next=7,this._mediaServerClient.unsubscribe(t);case 7:return e.abrupt("return",e.sent);case 8:return e.next=10,null===(i=this._mediaServerClient)||void 0===i?void 0:i.updateSubMediaType(t,o);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"startSubtitle",value:(v=xm(wm().mark((function e(t){return wm().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 SA(_A.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"stopSubtitle",value:(h=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(t=this._subtitleTool)||void 0===t||t.stop();case 1:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"startForwardStream2Rooms",value:(l=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.startForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(d=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.updateForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(u=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.stopForwardStream2Rooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(c=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.pauseForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(s=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.resumeForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"leave",value:(a=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=h.length>0&&void 0!==h[0]&&h[0],this.logger.info("leave","Invoke leave"),n=tD(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,delete this._sessionId,e.prev=6,s=oI(cR(a=this._remoteStreams).call(a));try{for(s.s();!(c=s.n()).done;)u=c.value,Array.isArray(u)&&u.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(v){s.e(v)}finally{s.f()}return this._localStream&&(null===(d=this._localStream.observer)||void 0===d||d.setLogin(!1)),e.next=12,this._mediaServerClient.leave().catch((function(){}));case 12:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:tD()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=25;break;case 17:if(e.prev=17,e.t0=e.catch(6),!r){e.next=23;break}throw e.t0;case 23:this.destroy();case 24:e.t0 instanceof Error&&(null===(l=this._monitor)||void 0===l||l.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:tD()-n}));case 25:case"end":return e.stop()}}),e,this,[[6,17]])}))),function(){return a.apply(this,arguments)})},{key:"updateRemoteUserPriority",value:function(e){var t,r=this;null===(t=this.remoteStreams.get(e))||void 0===t||t.forEach((function(t){var n=(r._context||{}).userPriority;t.hasSubscribed&&n.has(e)&&r._mediaServerClient.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e;this.logger.info("destroy","Invoke destroy"),$P(this.id,"room_destroy","".concat((new Error).stack)),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._mediaServerClient.destroy(),this._removeHandlerEventHandler(),this._roomInfo=void 0,this._remoteUsers=new ib;var t,r,n,i=oI(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=aI(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.destroy()}))}}catch(a){i.e(a)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new ib,this._localStream)&&(null===(r=this._localStream)||void 0===r||r.clean(),this._localStream=void 0);this._localScreenStream&&(null===(n=this._localScreenStream)||void 0===n||n.clean(),this._localScreenStream=void 0);this._removeHandlerEventHandler(),clearTimeout(this._connectionLostTimer),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={},this._forwardStreamManager.clear()}},{key:"updateToken",value:(o=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateToken","Invoke updateToken"),this._roomInfo&&(this._roomInfo.token=t),e.prev=2,e.next=5,this._mediaServerClient.updateToken(t);case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(2),this.safeEmit(QG.ON_ROOM_ERROR,{errorCode:_A.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return o.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._mediaServerClient)||void 0===r?void 0:r.sendUserMessage(e,t)}},{key:"setSessionId",value:function(){var e;this._sessionId||(this._sessionId=mw(),this._mediaServerClient._sessionId=this._sessionId,null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId}))}},{key:"sendRoomMessage",value:(i=xm(wm().mark((function e(t){var r,n,i,o,a,s=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=s.length>1&&void 0!==s[1]&&s[1],a={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:o,message:"",roomId:null===(n=this._roomInfo)||void 0===n?void 0:n.roomId},!o){e.next=8;break}return e.next=5,nD.ab2b64str(t);case 5:a.message=e.sent,e.next=9;break;case 8:a.message=t;case 9:return e.abrupt("return",null===(i=this._mediaServerClient)||void 0===i?void 0:i.sendRoomMessage(a));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"_onJoinSucc",value:function(e){var t,r,n,i=this,o=e.joinRes,a=e.reconnect;this.logger.info("_onJoinSucc()","invoke. ".concat(a?"[reconnect]":"")),this._serverConfig=o.config,this._mediaServerClient.roomAttributes=o.roomAttributes;var s=[],c=[],u=[],d=[],l=[];null===(t=o.clientsDetail)||void 0===t||t.forEach((function(e){if(e.attributes&&(e.attributes.serverMuteVideo&&i.safeEmit(QG.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&i.safeEmit(QG.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio})),e.clientId!==o.clientId){var t=i._remoteUsers.get(e.clientId);t?t._stillExist=!0:s.push(e)}}));var h,v=oI(cR(r=this._remoteUsers).call(r));try{for(v.s();!(h=v.n()).done;){var p=h.value;p._stillExist||c.push({clientId:p.userId}),delete p._stillExist}}catch(g){v.e(g)}finally{v.f()}o.streams.forEach((function(e){var t=i._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,l.push(e)):d.push(e)}));var f,_=oI(cR(n=this._remoteStreams).call(n));try{for(_.s();!(f=_.n()).done;){var m=f.value;Array.isArray(m)&&m.forEach((function(e){e.stillExist?delete e.stillExist:u.push({clientId:e.userId,streamId:e.streamId,message:jG.clientDisconnected})}))}}catch(g){_.e(g)}finally{_.f()}c.forEach((function(e){return i._onUserDisconnection(e)})),s.forEach((function(e){return i._onUserConnection(e)})),u.forEach((function(e){return i._onRemoveStream(e)})),d.forEach((function(e){return i._onAddStream(e,{fromSignal:!1})})),l.forEach((function(e){return i._onUpdateStreamAttributes(e)})),a&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r,n,i,o=this;this._localStream&&(this._localStream.clean(),this._localStream.vendorCode=(null===(r=this._mediaServerClient.vendorConfig)||void 0===r?void 0:r.vendorCode)||0,null===(n=this._localStream.observer)||void 0===n||n.setLogin(!0),this._mediaServerClient.publish(this._localStream).catch((function(e){})));this._localScreenStream&&(this._localScreenStream.clean(),null===(i=this._localScreenStream.observer)||void 0===i||i.setLogin(!0),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var a,s=oI(cR(t=this._remoteStreams).call(t));try{for(s.s();!(a=s.n()).done;){var c=a.value;Array.isArray(c)&&c.forEach(function(){var e=xm(wm().mark((function e(t){var r,n,i,a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=17;break}return t.resetHasSubscribed(),e.prev=2,o.logger.info(Mm(r="start resubscribe ".concat(t.userId," with ")).call(r,t.subMediaType)),yD(t.subMediaType)&&(null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!0)),gD(t.subMediaType)&&(null===(i=t.observer)||void 0===i||i.setSubscribeAudio(!0)),e.next=8,o._mediaServerClient.subscribe(t,t.subMediaType);case 8:o.logger.info(Mm(a="success resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType)),o.safeEmit(QG.RESUBSCRIBE,{stream:t}),e.next=17;break;case 12:e.prev=12,e.t0=e.catch(2),o.logger.error(Mm(s=Mm(c="failed resubscribe ".concat(t.userId," with ")).call(c,t.subMediaType,", error:")).call(s,e.t0)),t.clean(),null==t||t.resetHasSubscribed();case 17:case"end":return e.stop()}}),e,null,[[2,12]])})));return function(t){return e.apply(this,arguments)}}())}}catch(u){s.e(u)}finally{s.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect(),this._forwardStreamManager.resumeFromReconnect()}},{key:"_handleFFAudioTrack",value:function(){var e,t,r,n,i=null===(e=this._mediaServerClient)||void 0===e||null===(t=e.handler)||void 0===t?void 0:t.audioTrack4ff,o=null===(r=this._mediaServerClient)||void 0===r||null===(n=r.handler)||void 0===n?void 0:n.getTransceivers();if(i&&Array.isArray(o)){var a=kE(o).call(o,(function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===i}));if(a){var s=new _B(this._context,"ff-stream","ff-stream",!1,!1,Jz);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=HF(i),this._virtualStreams.push(s),this.safeEmit(QG.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?kE(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)?kE(r).call(r,(function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.needEmit,i=void 0===n||n,o=r.fromSignal,a=void 0===o||o,s=r.virtual,c=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var u=this._roomConfig,d=u.isAutoSubscribeAudio,l=u.isAutoSubscribeVideo,h=this._findRemoteStreamByScreen(e.clientId,e.screen);if(h&&h.streamId!==e.streamId){var v,p=null===(v=this._remoteStreams.get(e.clientId))||void 0===v?void 0:Ks(v).call(v,(function(e){return e.streamId!==h.streamId}));h.clean(),this._remoteStreams.set(e.clientId,p||[])}var f=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,f)f.attributes=e.attributes;else if((f=new _B(this._context,e.clientId,e.streamId,e.screen,!1,e.attributes)).virtual=c,this._initStreamListeners(f),!c){var _=this._remoteStreams.get(e.clientId);_?_.push(f):this._remoteStreams.set(e.clientId,[f])}if(this._mediaServerClient.handler&&(f.observer=new Nz(f,this._mediaServerClient.handler)),!f.isScreen&&l){var m,g,y,S,b,E,k,T;if(a&&f.hasVideo)if(f.attributes.extvideo)null===(m=f.observer)||void 0===m||m.setExternalVideoSource(!0),null===(g=f.observer)||void 0===g||g.setPushVideo(!0);else null===(y=f.observer)||void 0===y||y.setExternalVideoSource(!1),null===(S=f.observer)||void 0===S||S.setPublishVideo(!0);if(a&&f.hasAudio&&d&&!this._mediaServerClient.roomAttributes.multiChatMode)if(f.attributes.extaudio)null===(b=f.observer)||void 0===b||b.setExternalAudioSource(!0),null===(E=f.observer)||void 0===E||E.setPushAudio(!0);else null===(k=f.observer)||void 0===k||k.setExternalAudioSource(!1),null===(T=f.observer)||void 0===T||T.setPublishAudio(!0);if(i&&!a){var I,R=this._roomConfig,A=R.isAutoSubscribeAudio,w=R.isAutoSubscribeVideo;null===(I=f.observer)||void 0===I||I.setLogin(!0,{audio:!!A&&!this.multiChatMode,video:!!w})}}return i&&this.safeEmit(GG.ON_ADD_STREAM,{stream:f}),f}}},{key:"_onUserConnection",value:function(e){var t;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var r=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof r)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(r);var n={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,el({},n)),this.safeEmit(GG.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(QG.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(QG.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code,a=e.forbiddenTime;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var s=null;i===XG.kickedByAdmin?s=_A.KICKED_OUT:i===XG.onUserTokenDidExpire?s=_A.TOKEN_EXPIRED:i===XG.userDuplicateLogin&&(s=_A.DUPLICATE_LOGIN),o===WG.roomDismissByAdmin&&(s=_A.ROOM_DISMISS),s&&this.safeEmit(QG.ON_ROOM_ERROR,{errorCode:s,forbiddenTime:a})}else{var c=nl.DROPPED;i===XG.userLeave?c=nl.QUIT:i===XG.kickedByAdmin?c=nl.KICKED_BY_ADMIN:i===XG.roleChanged&&(c=nl.SWITCH_TO_INVISIBLE);var u=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:jG.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(QG.ON_USER_LEAVE,{userInfo:{userId:n},reason:c})};if(i===XG.userDuplicateLogin){var d=this._userDuplicateLoginTimerMap.get(n);d&&self.clearTimeout(d);var l=self.setTimeout(u,5e3);this._userDuplicateLoginTimerMap.set(n,l)}else u()}}},{key:"_onRemoveStream",value:function(e){var t,r=this;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var n=this._remoteStreams.get(e.clientId);if(n){var i=kE(n).call(n,(function(t){return t.streamId===e.streamId}));if(i){var o,a,s;if(null===(o=this._mediaServerClient)||void 0===o||o.handleRemoveStream(i).then((function(){var t=r._remoteStreams.get(e.clientId);t&&(t=Ks(t).call(t,(function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),r._remoteStreams.set(e.clientId,t))})).finally((function(){r.safeEmit(GG.ON_REMOVE_STREAM,{stream:i,reason:e.message,callback:function(){return i.destroy()}})})),i.hasVideo)null===(a=i.observer)||void 0===a||a.setPublishVideo(!1);if(i.hasAudio&&!this._mediaServerClient.roomAttributes.multiChatMode)null===(s=i.observer)||void 0===s||s.setPublishAudio(!1)}}}}},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(QG.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(QG.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=el(el({},this._mediaServerClient.roomAttributes),e.roomAttributes)),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this._roomConfig,r=t.isAutoSubscribeAudio,n=t.isAutoSubscribeVideo,i=e.clientId,o=e.streamId,a=e.attributes,s=this._findRemoteStream(i,o);if(s){var c,u,d=s.attributes,l=el(el({},d),a),h=!1,v=l.localaudio!==d.localaudio,p=!1,f=!1,_=l.localvideo!==d.localvideo,m=!1,g=$F.NONE,y=$F.NONE;if(l.audiostream!==d.audiostream&&(h=l.localaudio,p=!!l.audiostream,l.audiostream?g|=ll.AUDIO:y|=ll.AUDIO),l.videostream!==d.videostream&&(f=l.localvideo,m=!!l.videostream,l.videostream?g|=ll.VIDEO:y|=ll.VIDEO),g&&this.safeEmit(QG.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:$G.PUB,remoteStream:s}),y&&this.safeEmit(QG.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:$G.UNPUB,remoteStream:s}),s.attributes=l,l.localaudio!==d.localaudio)if(l.localaudio){var S,b,E,k;if(r&&l.audiostream)if(l.extaudio)null===(S=s.observer)||void 0===S||S.setExternalAudioSource(!0),null===(b=s.observer)||void 0===b||b.setPushAudio(!0);else null===(E=s.observer)||void 0===E||E.setExternalAudioSource(!1),null===(k=s.observer)||void 0===k||k.setEnableAudio(!0);this.safeEmit(QG.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(QG.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(l.localvideo!==d.localvideo)if(l.localvideo){var w,C,x,O;if(n&&l.videostream)if(l.extvideo)null===(w=s.observer)||void 0===w||w.setExternalVideoSource(!0),null===(C=s.observer)||void 0===C||C.setPushVideo(!0);else null===(x=s.observer)||void 0===x||x.setExternalVideoSource(!1),null===(O=s.observer)||void 0===O||O.setEnableVideo(!0);this.safeEmit(QG.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var P,N,D,M;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===(D=s.observer)||void 0===D||D.setExternalVideoSource(!1),null===(M=s.observer)||void 0===M||M.setEnableVideo(!1);!s.isScreen&&this.safeEmit(QG.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!v&&r)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(p);if(f&&!_&&n)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteVideo(m)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&fA(t).call(t,"audio_mux")){var n=this._onAddStream(el(el({},e),{},{attributes:Jz}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(QG.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){r.logger.error("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:Mm(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:nz.TRACK_ERROR})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message,o=e.trackType;this.logger.info("_onRemoveTrack","remove track: %o",r);var a=this._findRemoteStream(r,n);a&&(a.removeTrack=!0,null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(a,i,o),this.emit(QG.REMOVE_PUSH_TRACK,{stream:a,mediaType:o+1}))}},{key:"_onMeetingSpeakerChange",value:function(e){if(Array.isArray(null==e?void 0:e.speakerCsrcInfo)){var t={};null==e||e.speakerCsrcInfo.forEach((function(e){var r=e.csrc,n=e.userId;e.isScreen||(t[r]=n)})),this._csrcUserIdMap=t}Array.isArray(e.muxStreamInUse)&&this._virtualStreams.forEach((function(t){var r;null!==(r=e.muxStreamInUse)&&void 0!==r&&bk(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=aI(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&&KR(t).call(t,(function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_onReconnecting",value:function(){var e,t,r,n,i,o,a,s=this;if(this._roomInfo){var c,u=oI(cR(a=this._remoteStreams).call(a));try{for(u.s();!(c=u.n()).done;){var d=c.value;Array.isArray(d)&&d.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()}))}}catch(l){u.e(l)}finally{u.f()}this._virtualStreams.forEach((function(e){var t;s.emit(QG.REMOVE_PUSH_TRACK,{stream:e,mediaType:ll.AUDIO}),null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()})),this._virtualStreams=[],null===(e=this.localStream)||void 0===e||null===(t=e.observer)||void 0===t||t.setDisconnect(),null===(r=this.localStream)||void 0===r||r.clean(),null===(n=this.localScreenStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setDisconnect(),null===(o=this.localScreenStream)||void 0===o||o.clean()}}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===Iz.DISCONNECTED)t=vl.CONNECTION_STATE_DISCONNECTED;else if(e.next===Iz.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._mediaServerClient.isReconnecting?vl.CONNECTION_STATE_RECONNECTED:vl.CONNECTION_STATE_CONNECTED;else{if(e.next!==Iz.CONNECTING)return;this._mediaServerClient.isReconnecting?(t=vl.CONNECTION_STATE_RECONNECTING,this._onReconnecting()):t=vl.CONNECTION_STATE_CONNECTING}e.prev===Iz.CONNECTED&&e.next===Iz.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(KG.ON_CONNECTION_STATE_CHANGE,{state:vl.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setMSC(this._mediaServerClient),this.safeEmit(KG.ON_CONNECTION_STATE_CHANGE,{state:t})}},{key:"_initStreamListeners",value:function(e){var t=this;e.on("ontrack",(function(e){e.track})),e.on("onSEIMessage",(function(r){var n;t.emit(QG.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:null===(n=t._roomInfo)||void 0===n?void 0:n.roomId,streamIndex:e.isScreen?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){var t;null!==(t=this._subtitleTool)&&void 0!==t&&t.onMessageRecv(e)||this.safeEmit(GG.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(GG.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(GG.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new Hz(this),this._subtitleTool.onEvent=function(t){e.emit(QG.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(QG.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=ZG.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=ZG.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?ZG.START_FAILED:ZG.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?ZG.STOP_FAILED:ZG.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?ZG.UPDATE_FAILED:ZG.UPDATE_SUCCESS}this.safeEmit(GG.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(GG.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(GG.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(n=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("publish"!==t.type){e.next=11;break}if(s=void 0,(null===(r=this.localStream)||void 0===r?void 0:r.streamId)===t.streamId?s=this.localStream:(null===(n=this.localScreenStream)||void 0===n?void 0:n.streamId)===t.streamId&&(s=this.localScreenStream),s){e.next=5;break}return e.abrupt("return");case 5:return null===(i=s)||void 0===i||i.clean(),e.next=8,null===(o=this._mediaServerClient)||void 0===o?void 0:o.unpublish(s).catch((function(){}));case 8:null===(a=this._mediaServerClient)||void 0===a||a.publish(s).catch((function(){})),e.next=22;break;case 11:if("subscribe"!==t.type){e.next=22;break}if(c=this._remoteStreamStreamIdUserIdMap[t.streamId],!(u=this._findRemoteStream(c,t.streamId))){e.next=22;break}return h=u.subMediaType,v=u.subLayer,e.next=19,null===(d=this._mediaServerClient)||void 0===d?void 0:d.unsubscribe(u);case 19:return e.next=21,null===(l=this._mediaServerClient)||void 0===l?void 0:l.subscribe(u,h,v);case 21:this.safeEmit(QG.RESUBSCRIBE,{stream:u});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===HG.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=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,v,p,f;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publishOnDemandItem&&!this._publishOnDemandBusy&&!1!==(null===(t=this._serverConfig)||void 0===t||null===(r=t.engine_VPM)||void 0===r||null===(n=r.ondemand)||void 0===n?void 0:n.enable)){e.next=2;break}return e.abrupt("return");case 2:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(o=this._localStream)||void 0===o||!o.videoTransceiver){e.next=16;break}return this._publishOnDemandBusy=!0,u=this._publishOnDemandItem,this._publishOnDemandItem=void 0,d=[],l=null===(s=this._localStream)||void 0===s?void 0:s.stream.id,h=null===(c=this._localStream)||void 0===c?void 0:c.videoTransceiver.sender,v=h.getParameters(),Array.isArray(v.encodings)&&Array.isArray(u)&&(f={},this.logger.info("_onPublishOnDemand exec","usedDescriptions: %o",u),u.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&bk(t).call(t,l)){var r=null==e?void 0:e.Metadata.VideoIndex;f[r]=!0}})),v.encodings=Km(p=v.encodings).call(p,(function(e){if(e.rid){f[e.rid]?e.active=!0:e.active=!1;var t=Number(e.rid);d[t]=e.active}return e})),this._context&&(this._context.activeSimStreams=d)),e.next=13,h.setParameters(v);case 13:this._publishOnDemandBusy=!1,e.next=18;break;case 16:if(null!==(a=this._localStream)&&void 0!==a&&a.videoTransceiver){e.next=18;break}return e.abrupt("return");case 18:this._onPublishOnDemand();case 19:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_onRTT",value:function(e){var t=e.StreamIds,r=e.Metadata;if(t.length&&r){var n,i=t[0];null!==(n=this._context)&&void 0!==n&&n.streamRTT&&(this._context.streamRTT[i]={audio:r.audio_rtt,video:r.video_rtt})}}},{key:"_onSSC",value:function(e){var t=e.StreamIds,r=e.Metadata,n=t[0],i=this._remoteStreamStreamIdUserIdMap[n],o=this._findRemoteStream(i,n),a={userId:i,isScreen:!!o&&o.isScreen,beforeVideoIndex:r.ssc_items[0].prev_layer_id,afterVideoIndex:r.ssc_items[0].cur_layer_id,beforeEnable:0!==r.ssc_items[0].prev_video_open,afterEnable:0!==r.ssc_items[0].cur_video_open,reason:r.ssc_items[0].change_reason};this.emit(QG.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(QG.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(QG.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"multiChatMode",get:function(){var e;return null===(e=this._mediaServerClient)||void 0===e?void 0:e.multiChatMode()}},{key:"setAudioEncodeMaxBitrate",value:(t=xm(wm().mark((function e(t,r){var n,i,o,a;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(n=t===dl.STREAM_INDEX_MAIN?this.localStream:this.localScreenStream)||!n.pubAudio){e.next=7;break}if(null==(o=null===(i=n.audioTransceiver)||void 0===i?void 0:i.sender.getParameters())||!o.encodings.length){e.next=7;break}return o.encodings[0].maxBitrate=1e3*r,e.next=7,null===(a=n.audioTransceiver)||void 0===a?void 0:a.sender.setParameters(o);case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),x}($M),Zz=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&&Nb(r.style,t.style),t.attributes&&CA(t.attributes).forEach((function(e){var t=aI(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},$z=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],eK={playsinline:"","webkit-playsinline":""},tK={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},rK=function(e){UI(n,e);var t,r=eR(n);function n(e,t){var i;Hl(this,n),Zd(sI(i=r.call(this)),"_containerDom",void 0),Zd(sI(i),"_videoDom",void 0),Zd(sI(i),"__cumulativeTime",void 0),Zd(sI(i),"userId",void 0),Zd(sI(i),"renderMode",void 0),Zd(sI(i),"mirrorType",pl.MIRROR_TYPE_NONE),Zd(sI(i),"isScreen",void 0),Zd(sI(i),"isLocal",void 0),Zd(sI(i),"played",!1),Zd(sI(i),"_needLoad",!1),Zd(sI(i),"_emitPlayFailed",!1),Zd(sI(i),"_videoContainer",void 0),Zd(sI(i),"_safari15VideoTimer",void 0),Zd(sI(i),"_monitor",void 0),Zd(sI(i),"logger",void 0),Zd(sI(i),"_onLocalTrackMute",void 0),Zd(sI(i),"_onInterruptionEnd",void 0),Zd(sI(i),"_needResume",!1),Zd(sI(i),"_rotate",0),Zd(sI(i),"_rotateDom",void 0),Zd(sI(i),"_resizeObserver",void 0),Zd(sI(i),"_hasManuallyPaused",!1),Zd(sI(i),"emitVideoEvent",(function(e){var t,r,n={type:"video",rawEvent:e,readyState:(null===(t=i._videoDom)||void 0===t?void 0:t.readyState)||0,userId:i.userId,eventName:e.type,currentTime:(null===(r=i._videoDom)||void 0===r?void 0:r.currentTime)||0,isScreen:i.isScreen};switch(i.emit("playback_event",n),e.type){case"canplay":i.refreshRenderSize("the video started playing."),i._internalPlay();break;case"loadeddata":i._internalPlay();break;case"playing":i.logger.info("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"));break;case"pause":i.logger.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element pause")),i._needResume&&(i.logger.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element resume")),i._internalPlay(),i._needResume=!1)}})),Zd(sI(i),"_internalPlay",(function(){var e,t;if($P(i.engineId,"video _internalPlay",{paused:null===(e=i._videoDom)||void 0===e?void 0:e.paused,hasManuallyPaused:i._hasManuallyPaused}),!i._hasManuallyPaused&&null!==(t=i._videoDom)&&void 0!==t&&t.paused){var r=i._videoDom.play();null!=r&&r.then&&r.then((function(){var e;i.isLocal&&UD&&!i._needLoad&&(null===(e=i._videoDom)||void 0===e||e.load(),i._needLoad=!0)})).catch((function(e){var t,r,n,o,a,s;i._emitPlayFailed||("AbortError"!==e.name?(i._emitPlayFailed=!0,null===(t=i._monitor)||void 0===t||t.report("rtc_error",{message:Mm(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:nz.AUTOPLAY_FAILED}),i.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(n=i._videoDom)||void 0===n?void 0:n.readyState)||0,userId:i.userId,eventName:"autoplay-error",currentTime:(null===(o=i._videoDom)||void 0===o?void 0:o.currentTime)||0,isScreen:i.isScreen})):null===(a=i._monitor)||void 0===a||a.report("rtc_error",{message:Mm(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:nz.AUTOPLAY_FAILED}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=YP(e),i.logger=new fN("Player",0,e);var a=t.userId,s=t.isScreen?ul.RENDER_MODE_FIT:ul.RENDER_MODE_HIDDEN;i.renderMode=void 0!==t.renderMode?t.renderMode:s,i._rotate=Number(t.rotation||0);var c="string"==typeof o?document.getElementById(o):o;if(!c)throw new SA(_A.CANT_FIND_DOM,"can't find dom");return i._videoContainer=document.createElement("div"),i._videoContainer.style.width="100%",i._videoContainer.style.height="100%",i._videoContainer.style.position="relative",i._videoContainer.style.overflow="hidden",i._containerDom=c,i.userId=a,i.isLocal=!!t.isLocal,i.isScreen=!!t.isScreen,i._initVideo(),!i.isLocal||15!==(null==nM?void 0:nM[0])&&15!==eM||(i._safari15VideoTimer=window.setTimeout((function(){try{i._videoContainer.style.display="block",setTimeout((function(){i._videoContainer.style.display="flex"}),500)}catch(Iq){}}),1e3)),i}return jl(n,[{key:"_initVideo",value:function(){var e,t,r=this;this._videoDom||(this._videoDom=Zz("video",{style:{width:"100%",height:"100%"},attributes:tK}),this._videoDom.id=Mm(t="".concat(this.userId,"_")).call(t,eD()),this.setRenderMode(this.renderMode),this.mirror(this.mirrorType===pl.MIRROR_TYPE_RENDER));this._containerDom.appendChild(this._videoContainer),DE(e=[90,270]).call(e,this._rotate)>-1?(this._rotateDom=this._createRotationDiv(),this._rotateDom.appendChild(this._videoDom),this._videoContainer.appendChild(this._rotateDom)):(180===this._rotate&&(this._videoContainer.style.transform="rotate(180deg)"),this._videoContainer.appendChild(this._videoDom)),this._initListeners(),this._onLocalTrackMute=function(){r._needResume=!0},this._onInterruptionEnd=function(){r.logger.warn("resume player after iOS interruption"),r._internalPlay()},aF.on(iF.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),aF.on(iF.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),aF.on(iF.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd)}},{key:"_createRotationDiv",value:function(){var e=this,t=document.createElement("div");return t.style.transform="rotate(".concat(this._rotate,"deg)"),180!==this._rotate&&(t.style.position="absolute",this.refreshRenderSize("init"),window.ResizeObserver&&(this._resizeObserver=new ResizeObserver((function(){e.refreshRenderSize("the container size has changed.")})),this._resizeObserver.observe(this._containerDom))),t}},{key:"refreshRenderSize",value:function(e){if(this._rotateDom){var t,r;this.logger.print("refreshRenderSize","Because ".concat(e));var n=Number(window.getComputedStyle(this._containerDom).width.replace("px","")),i=Number(window.getComputedStyle(this._containerDom).height.replace("px","")),o=null===(t=this._videoDom)||void 0===t?void 0:t.videoWidth,a=null===(r=this._videoDom)||void 0===r?void 0:r.videoHeight;if(n&&i&&a&&o){var s,c;if(this.renderMode===ul.RENDER_MODE_FILL)s=i,c=n;else{var u=this.renderMode===ul.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&&$z.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&&$z.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.removeEventListener(t,e.emitVideoEvent)}))}},{key:"_recordFrame",value:function(e){var t=this,r=e.isScreen?1.5:.55;if(MD){var n;if(null===(n=this._videoDom)||void 0===n||!n.requestVideoFrameCallback)return;this._videoDom.requestVideoFrameCallback((function n(i,o){var a=o.presentationTime;if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t.__cumulativeTime){var s,c=(a-t.__cumulativeTime)%2e3,u=c>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:u,stallCount:u?1:0,stallDuration:c})}t.__cumulativeTime=a,t._videoDom.requestVideoFrameCallback(n)}))}else this.on("playback_event",(function(n){var i;if("timeupdate"===n.eventName){if(0===(null===(i=t._videoDom)||void 0===i?void 0:i.currentTime))return;if(void 0===t.__cumulativeTime)return void(t.__cumulativeTime=t._videoDom.currentTime);if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t._videoDom.currentTime>t.__cumulativeTime){var o=Math.floor(1e3*(t._videoDom.currentTime-t.__cumulativeTime)),a=t._videoDom.currentTime-t.__cumulativeTime>r;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"_recordPause",value:function(e){var t=this;void 0===e.statsReport.isPaused&&this.on("playback_event",(function(r){if("pause"===r.eventName)e.statsReport.isPaused=!0,e.statsReport.pauseStart=tD();else if("timeupdate"===r.eventName){var n;if((null===(n=t._videoDom)||void 0===n||!n.paused)&&e.statsReport.isPaused){e.statsReport.isPaused=!1;var i=tD()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{key:"setRenderMode",value:function(e){this.renderMode=e,this._videoDom&&(this.renderMode===ul.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this.renderMode===ul.RENDER_MODE_FILL?this._videoDom.style.objectFit="fill":this._videoDom.style.objectFit="cover")}},{key:"playVideo",value:(t=xm(wm().mark((function e(t,r){var n,i,o,a,s=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,this.logger.info("playVideo","play video track: ".concat(this.userId)),!(o&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(n=t.getTrack())||void 0===n?void 0:n.id))){e.next=5;break}try{$P(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(Iq){}return e.abrupt("return");case 5:o||(this._initVideo(),o=this._videoDom),this.logger.info("playVideo","play video by dom: ".concat(null===(i=o)||void 0===i?void 0:i.id)),(a=new MediaStream).addTrack(t.getTrack("preprocessing")),o.srcObject=a,o&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),o&&!this._videoContainer.contains(o)&&this._videoContainer.appendChild(o),setTimeout((function(){return s._internalPlay()})),r&&bM.VIDEO_STALL&&(this._recordFrame(r),this._recordPause(r),r.statsReport.player=this),this.played=!0;case 15:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"updateSrcObject",value:function(e){var t=e.getTrack();if(t&&this._videoDom){var r=new MediaStream;r.addTrack(t),this._videoDom.srcObject=r}}},{key:"removeTrack",value:function(){var e,t=null===(e=this._videoDom)||void 0===e?void 0:e.srcObject;if(t){var r=t.getVideoTracks();null!=r&&r.length&&r.forEach((function(e){t.removeTrack(e)}))}}},{key:"manuallyPlay",value:function(){if(this.logger.info("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,this._hasManuallyPaused=!1,!this._videoDom)throw new SA(_A.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||KD?this._videoDom.play():$_.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 SA(_A.INVALID_PARAMS,"Player not found");return this._videoDom.pause()}}},{key:"mirror",value:function(e){var t;this.logger.info("mirror",Mm(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?pl.MIRROR_TYPE_RENDER:pl.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e,t,r=this,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=this._containerDom;(this.logger.info("stop","stop video track: ".concat(this.userId)),this._videoDom)&&(n||(this._videoDom.srcObject=null),null!=i&&i.contains(this._videoContainer)&&i.removeChild(this._videoContainer),null===(e=this._videoContainer)||void 0===e||e.childNodes.forEach((function(e){e!==r._videoDom&&e!==r._rotateDom||r._videoContainer.removeChild(e)})),null!==(t=this._rotateDom)&&void 0!==t&&t.contains(this._videoDom)&&this._rotateDom.removeChild(this._videoDom));this.__cumulativeTime=void 0,this._hasManuallyPaused=!1,this.played=!1}},{key:"destroy",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.logger.info("destroy","video player: ".concat(this.userId)),this.stop(t),null===(e=this._resizeObserver)||void 0===e||e.disconnect(),MI(DI(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),aF.off(iF.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),aF.off(iF.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),aF.off(iF.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}(JM.EventEmitter),nK=function(e){UI(i,e);var t,r,n=eR(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(Hl(this,i),Zd(sI(r=n.call(this)),"_containerDom",void 0),Zd(sI(r),"_audioDom",void 0),Zd(sI(r),"_fakeAudioDom",void 0),Zd(sI(r),"userId",void 0),Zd(sI(r),"muted",!1),Zd(sI(r),"_emitPlayFailed",!1),Zd(sI(r),"played",!1),Zd(sI(r),"isScreen",void 0),Zd(sI(r),"_wechatTimer",void 0),Zd(sI(r),"_edgeTimer",void 0),Zd(sI(r),"_monitor",void 0),Zd(sI(r),"logger",void 0),Zd(sI(r),"_pasued",!0),Zd(sI(r),"emitAudioEvent",(function(e){var t,n,i={type:"audio",rawEvent:e,readyState:(null===(t=r._audioDom)||void 0===t?void 0:t.readyState)||0,userId:r.userId,eventName:e.type,currentTime:(null===(n=r._audioDom)||void 0===n?void 0:n.currentTime)||0};"playing"===e.type&&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||r._internalPlay()),YD&&KD&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),XD&&jD&&"error"===e.type&&(clearTimeout(r._edgeTimer),r._edgeTimer=window.setTimeout((function(){var e;0===(null===(e=r._audioDom)||void 0===e?void 0:e.currentTime)&&r._autoPlayError("edge")}),500)),r.emit("playback_event",i)})),Zd(sI(r),"_internalPlay",(function(){var e,t;if($P(r.engineId,"audio _internalPlay",{paused:null===(e=r._audioDom)||void 0===e?void 0:e.paused}),null!==(t=r._audioDom)&&void 0!==t&&t.paused)try{var n,i=r._audioDom.play(),o=dF.getAudioContextInstance();if("suspended"===o.state){var a=o.resume(),s=setTimeout((function(){var e;"suspended"===o.state&&(r._autoPlayError("AudioContext cannot resume"),null===(e=r._monitor)||void 0===e||e.report("rtc_error",{message:"audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - timeout"),error_code:-1e3}));clearTimeout(s)}));a.catch((function(e){var t,n,i;r._autoPlayError("AudioContext cannot resume"),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Mm(n=Mm(i="audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - rejected by: [")).call(i,null==e?void 0:e.name,"]")).call(n,null==e?void 0:e.message),error_code:-1e3})})).finally((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(YD&&XD&&(i=i.then((function(){return new $_((function(e){setTimeout(xm(wm().mark((function t(){var n;return wm().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(){$P(r.engineId,"_internalPlay successfully",{userId:r.userId}),r._pasued=!1})).catch((function(e){var t,n,i;r._autoPlayError(e),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Mm(n=Mm(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:nz.AUTOPLAY_FAILED})})))}catch(l){var c,u,d;r._autoPlayError(l),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:Mm(u=Mm(d="audio autoplay failed, userId: ".concat(r.userId,": ")).call(d,l.message," ")).call(u,l.name),error_code:nz.AUTOPLAY_FAILED})}})),r.engineId=e,a){var u=document.getElementById(a);if(!u)throw new SA(_A.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=YP(e),r.logger=new fN("Player",0,e),r._initAudio(),r}return jl(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=Zz("audio",{style:{display:"none"},attributes:eK}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Mm(e="".concat(this.userId,"_")).call(e,eD()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&$z.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&&($z.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=xm(wm().mark((function e(t){var r,n,i,o,a,s=this;return wm().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.getTrack())||void 0===r?void 0:r.id))){e.next=4;break}return e.abrupt("return");case 4:o||(this._initAudio(),o=this._audioDom),a=new MediaStream,t instanceof ZF?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.getOrgTrack()]),a.addTrack(t.getTrack())):a.addTrack(t.getTrack("preprocessing")),YD&&XD&&(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 SA(_A.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 SA(_A.INVALID_PARAMS,"Player not found");if(!this.played)return $_.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=dF.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?$_.all(r):$_.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,rF.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=Km(r).call(r,(function(e){return e.deviceId})),bk(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(),MI(DI(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom),this._edgeTimer&&clearTimeout(this._edgeTimer)}}]),i}(JM.EventEmitter);function iK(e,t,r,n){var i=function(){var e=xm(wm().mark((function e(t,i){var o,a;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null==n?void 0:n.get(i),Array.isArray(o)&&(o=null===(a=o)||void 0===a?void 0:kE(a).call(a,(function(e){return e.isScreen===r}))),!t){e.next=9;break}if(!t.played){e.next=8;break}return e.next=6,t.manuallyPlay();case 6:e.next=9;break;case 8:o&&(t instanceof rK&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof nK&&o.audioTrack&&t.playAudio(o.audioTrack));case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();if(t)return i(e.get(t),t);var o=[];return e.forEach((function(e,t){return o.push(i(e,t))})),$_.all(o)}var oK=a,aK=vt("iterator"),sK=!oK((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),!e.toJSON||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[aK]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==r||"x"!==new URL("http://x",void 0).host})),cK=Zt,uK=T,dK=2147483647,lK=/[^\0-\u007E]/,hK=/[.\u3002\uFF0E\uFF61]/g,vK="Overflow: input needs wider integers to process",pK=RangeError,fK=uK(hK.exec),_K=Math.floor,mK=String.fromCharCode,gK=uK("".charCodeAt),yK=uK([].join),SK=uK([].push),bK=uK("".replace),EK=uK("".split),kK=uK("".toLowerCase),TK=function(e){return e+22+75*(e<26)},IK=function(e,t,r){var n=0;for(e=r?_K(e/700):e>>1,e+=_K(e/t);e>455;)e=_K(e/35),n+=36;return _K(n+36*e/(e+38))},RK=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=gK(e,r++);if(i>=55296&&i<=56319&&r<n){var o=gK(e,r++);56320==(64512&o)?SK(t,((1023&i)<<10)+(1023&o)+65536):(SK(t,i),r--)}else SK(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&&SK(t,mK(n));var c=t.length,u=c;for(c&&SK(t,"-");u<i;){var d=dK;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=u+1;if(d-o>_K((dK-a)/l))throw pK(vK);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>dK)throw pK(vK);if(n==o){for(var h=a,v=36;;){var p=v<=s?1:v>=s+26?26:v-s;if(h<p)break;var f=h-p,_=36-p;SK(t,mK(TK(p+f%_))),h=_K(f/_),v+=36}SK(t,mK(TK(h))),s=IK(a,l,u==c),a=0,u++}}a++,o++}return yK(t,"")},AK=Cr,wK=o,CK=N,xK=T,OK=x,PK=sK,NK=pi,DK=ny,MK=Vi,LK=Uc,UK=eo,VK=bv,FK=w,BK=Ze,jK=Qt,HK=mn,GK=nr,zK=te,KK=Sn,XK=Xn,WK=B,YK=kh,qK=_h,JK=Pv,QK=pR,ZK=vt("iterator"),$K="URLSearchParams",eX=$K+"Iterator",tX=UK.set,rX=UK.getterFor($K),nX=UK.getterFor(eX),iX=Object.getOwnPropertyDescriptor,oX=function(e){if(!OK)return wK[e];var t=iX(wK,e);return t&&t.value},aX=oX("fetch"),sX=oX("Request"),cX=oX("Headers"),uX=sX&&sX.prototype,dX=cX&&cX.prototype,lX=wK.RegExp,hX=wK.TypeError,vX=wK.decodeURIComponent,pX=wK.encodeURIComponent,fX=xK("".charAt),_X=xK([].join),mX=xK([].push),gX=xK("".replace),yX=xK([].shift),SX=xK([].splice),bX=xK("".split),EX=xK("".slice),kX=/\+/g,TX=Array(4),IX=function(e){return TX[e-1]||(TX[e-1]=lX("((?:%[\\da-f]{2}){"+e+"})","gi"))},RX=function(e){try{return vX(e)}catch(Iq){return e}},AX=function(e){var t=gX(e,kX," "),r=4;try{return vX(t)}catch(Iq){for(;r;)t=gX(t,IX(r--),RX);return t}},wX=/[!'()~]|%20/g,CX={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},xX=function(e){return CX[e]},OX=function(e){return gX(pX(e),wX,xX)},PX=LK((function(e,t){tX(this,{type:eX,iterator:YK(rX(e).entries),kind:t})}),"Iterator",(function(){var e=nX(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),NX=function(e){this.entries=[],this.url=null,void 0!==e&&(zK(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===fX(e,0)?EX(e,1):e:KK(e)))};NX.prototype={type:$K,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=qK(e);if(c)for(r=(t=YK(e,c)).next;!(n=CK(r,t)).done;){if(o=(i=YK(GK(n.value))).next,(a=CK(o,i)).done||(s=CK(o,i)).done||!CK(o,i).done)throw hX("Expected sequence with length 2");mX(this.entries,{key:KK(a.value),value:KK(s.value)})}else for(var u in e)BK(e,u)&&mX(this.entries,{key:u,value:KK(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=bX(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=bX(t,"="),mX(this.entries,{key:AX(yX(r)),value:AX(_X(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],mX(r,OX(e.key)+"="+OX(e.value));return _X(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var DX=function(){VK(this,MX),tX(this,new NX(arguments.length>0?arguments[0]:void 0))},MX=DX.prototype;if(DK(MX,{append:function(e,t){JK(arguments.length,2);var r=rX(this);mX(r.entries,{key:KK(e),value:KK(t)}),r.updateURL()},delete:function(e){JK(arguments.length,1);for(var t=rX(this),r=t.entries,n=KK(e),i=0;i<r.length;)r[i].key===n?SX(r,i,1):i++;t.updateURL()},get:function(e){JK(arguments.length,1);for(var t=rX(this).entries,r=KK(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){JK(arguments.length,1);for(var t=rX(this).entries,r=KK(e),n=[],i=0;i<t.length;i++)t[i].key===r&&mX(n,t[i].value);return n},has:function(e){JK(arguments.length,1);for(var t=rX(this).entries,r=KK(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){JK(arguments.length,1);for(var r,n=rX(this),i=n.entries,o=!1,a=KK(e),s=KK(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?SX(i,c--,1):(o=!0,r.value=s));o||mX(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=rX(this);QK(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=rX(this).entries,n=jK(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 PX(this,"keys")},values:function(){return new PX(this,"values")},entries:function(){return new PX(this,"entries")}},{enumerable:!0}),NK(MX,ZK,MX.entries,{name:"entries"}),NK(MX,"toString",(function(){return rX(this).serialize()}),{enumerable:!0}),MK(DX,$K),AK({global:!0,constructor:!0,forced:!PK},{URLSearchParams:DX}),!PK&&FK(cX)){var LX=xK(dX.has),UX=xK(dX.set),VX=function(e){if(zK(e)){var t,r=e.body;if(HK(r)===$K)return t=e.headers?new cX(e.headers):new cX,LX(t,"content-type")||UX(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),XK(e,{body:WK(0,KK(r)),headers:WK(0,t)})}return e};if(FK(aX)&&AK({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return aX(e,arguments.length>1?VX(arguments[1]):{})}}),FK(sX)){var FX=function(e){return VK(this,uX),new sX(e,arguments.length>1?VX(arguments[1]):{})};uX.constructor=FX,FX.prototype=uX,AK({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:FX})}}var BX,jX=Cr,HX=x,GX=sK,zX=o,KX=Qt,XX=T,WX=pi,YX=function(e,t,r){return cK.f(e,t,r)},qX=bv,JX=Ze,QX=Ob,ZX=Jk,$X=ai,eW=Fd.codeAt,tW=function(e){var t,r,n=[],i=EK(bK(kK(e),hK,"."),".");for(t=0;t<i.length;t++)r=i[t],SK(n,fK(lK,r)?"xn--"+RK(r):r);return yK(n,".")},rW=Sn,nW=Vi,iW=Pv,oW={URLSearchParams:DX,getState:rX},aW=eo,sW=aW.set,cW=aW.getterFor("URL"),uW=oW.URLSearchParams,dW=oW.getState,lW=zX.URL,hW=zX.TypeError,vW=zX.parseInt,pW=Math.floor,fW=Math.pow,_W=XX("".charAt),mW=XX(/./.exec),gW=XX([].join),yW=XX(1..toString),SW=XX([].pop),bW=XX([].push),EW=XX("".replace),kW=XX([].shift),TW=XX("".split),IW=XX("".slice),RW=XX("".toLowerCase),AW=XX([].unshift),wW="Invalid scheme",CW="Invalid host",xW="Invalid port",OW=/[a-z]/i,PW=/[\d+-.a-z]/i,NW=/\d/,DW=/^0x/i,MW=/^[0-7]+$/,LW=/^\d+$/,UW=/^[\da-f]+$/i,VW=/[\0\t\n\r #%/:<>?@[\\\]^|]/,FW=/[\0\t\n\r #/:<>?@[\\\]^|]/,BW=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,jW=/[\t\n\r]/g,HW=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)AW(t,e%256),e=pW(e/256);return gW(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+=yW(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},GW={},zW=QX({},GW,{" ":1,'"':1,"<":1,">":1,"`":1}),KW=QX({},zW,{"#":1,"?":1,"{":1,"}":1}),XW=QX({},KW,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),WW=function(e,t){var r=eW(e,0);return r>32&&r<127&&!JX(t,e)?e:encodeURIComponent(e)},YW={ftp:21,file:null,http:80,https:443,ws:80,wss:443},qW=function(e,t){var r;return 2==e.length&&mW(OW,_W(e,0))&&(":"==(r=_W(e,1))||!t&&"|"==r)},JW=function(e){var t;return e.length>1&&qW(IW(e,0,2))&&(2==e.length||"/"===(t=_W(e,2))||"\\"===t||"?"===t||"#"===t)},QW=function(e){return"."===e||"%2e"===RW(e)},ZW={},$W={},eY={},tY={},rY={},nY={},iY={},oY={},aY={},sY={},cY={},uY={},dY={},lY={},hY={},vY={},pY={},fY={},_Y={},mY={},gY={},yY=function(e,t,r){var n,i,o,a=rW(e);if(t){if(i=this.parse(a))throw hW(i);this.searchParams=null}else{if(void 0!==r&&(n=new yY(r,!0)),i=this.parse(a,null,n))throw hW(i);(o=dW(new uW)).bindURL(this),this.searchParams=o}};yY.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||ZW,d=0,l="",h=!1,v=!1,p=!1;for(e=rW(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=EW(e,BW,"")),e=EW(e,jW,""),n=ZX(e);d<=n.length;){switch(i=n[d],u){case ZW:if(!i||!mW(OW,i)){if(t)return wW;u=eY;continue}l+=RW(i),u=$W;break;case $W:if(i&&(mW(PW,i)||"+"==i||"-"==i||"."==i))l+=RW(i);else{if(":"!=i){if(t)return wW;l="",u=eY,d=0;continue}if(t&&(c.isSpecial()!=JX(YW,l)||"file"==l&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=l,t)return void(c.isSpecial()&&YW[c.scheme]==c.port&&(c.port=null));l="","file"==c.scheme?u=lY:c.isSpecial()&&r&&r.scheme==c.scheme?u=tY:c.isSpecial()?u=oY:"/"==n[d+1]?(u=rY,d++):(c.cannotBeABaseURL=!0,bW(c.path,""),u=_Y)}break;case eY:if(!r||r.cannotBeABaseURL&&"#"!=i)return wW;if(r.cannotBeABaseURL&&"#"==i){c.scheme=r.scheme,c.path=$X(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=gY;break}u="file"==r.scheme?lY:nY;continue;case tY:if("/"!=i||"/"!=n[d+1]){u=nY;continue}u=aY,d++;break;case rY:if("/"==i){u=sY;break}u=fY;continue;case nY:if(c.scheme=r.scheme,i==BX)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=$X(r.path),c.query=r.query;else if("/"==i||"\\"==i&&c.isSpecial())u=iY;else if("?"==i)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=$X(r.path),c.query="",u=mY;else{if("#"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=$X(r.path),c.path.length--,u=fY;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=$X(r.path),c.query=r.query,c.fragment="",u=gY}break;case iY:if(!c.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=fY;continue}u=sY}else u=aY;break;case oY:if(u=aY,"/"!=i||"/"!=_W(l,d+1))continue;d++;break;case aY:if("/"!=i&&"\\"!=i){u=sY;continue}break;case sY:if("@"==i){h&&(l="%40"+l),h=!0,o=ZX(l);for(var f=0;f<o.length;f++){var _=o[f];if(":"!=_||p){var m=WW(_,XW);p?c.password+=m:c.username+=m}else p=!0}l=""}else if(i==BX||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(h&&""==l)return"Invalid authority";d-=ZX(l).length+1,l="",u=cY}else l+=i;break;case cY:case uY:if(t&&"file"==c.scheme){u=vY;continue}if(":"!=i||v){if(i==BX||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(c.isSpecial()&&""==l)return CW;if(t&&""==l&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(l))return a;if(l="",u=pY,t)return;continue}"["==i?v=!0:"]"==i&&(v=!1),l+=i}else{if(""==l)return CW;if(a=c.parseHost(l))return a;if(l="",u=dY,t==uY)return}break;case dY:if(!mW(NW,i)){if(i==BX||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()||t){if(""!=l){var g=vW(l,10);if(g>65535)return xW;c.port=c.isSpecial()&&g===YW[c.scheme]?null:g,l=""}if(t)return;u=pY;continue}return xW}l+=i;break;case lY:if(c.scheme="file","/"==i||"\\"==i)u=hY;else{if(!r||"file"!=r.scheme){u=fY;continue}if(i==BX)c.host=r.host,c.path=$X(r.path),c.query=r.query;else if("?"==i)c.host=r.host,c.path=$X(r.path),c.query="",u=mY;else{if("#"!=i){JW(gW($X(n,d),""))||(c.host=r.host,c.path=$X(r.path),c.shortenPath()),u=fY;continue}c.host=r.host,c.path=$X(r.path),c.query=r.query,c.fragment="",u=gY}}break;case hY:if("/"==i||"\\"==i){u=vY;break}r&&"file"==r.scheme&&!JW(gW($X(n,d),""))&&(qW(r.path[0],!0)?bW(c.path,r.path[0]):c.host=r.host),u=fY;continue;case vY:if(i==BX||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&qW(l))u=fY;else if(""==l){if(c.host="",t)return;u=pY}else{if(a=c.parseHost(l))return a;if("localhost"==c.host&&(c.host=""),t)return;l="",u=pY}continue}l+=i;break;case pY:if(c.isSpecial()){if(u=fY,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=BX&&(u=fY,"/"!=i))continue}else c.fragment="",u=gY;else c.query="",u=mY;break;case fY:if(i==BX||"/"==i||"\\"==i&&c.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=RW(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"==i||"\\"==i&&c.isSpecial()||bW(c.path,"")):QW(l)?"/"==i||"\\"==i&&c.isSpecial()||bW(c.path,""):("file"==c.scheme&&!c.path.length&&qW(l)&&(c.host&&(c.host=""),l=_W(l,0)+":"),bW(c.path,l)),l="","file"==c.scheme&&(i==BX||"?"==i||"#"==i))for(;c.path.length>1&&""===c.path[0];)kW(c.path);"?"==i?(c.query="",u=mY):"#"==i&&(c.fragment="",u=gY)}else l+=WW(i,KW);break;case _Y:"?"==i?(c.query="",u=mY):"#"==i?(c.fragment="",u=gY):i!=BX&&(c.path[0]+=WW(i,GW));break;case mY:t||"#"!=i?i!=BX&&("'"==i&&c.isSpecial()?c.query+="%27":c.query+="#"==i?"%23":WW(i,GW)):(c.fragment="",u=gY);break;case gY:i!=BX&&(c.fragment+=WW(i,zW))}d++}},parseHost:function(e){var t,r,n;if("["==_W(e,0)){if("]"!=_W(e,e.length-1))return CW;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 _W(e,l)};if(":"==h()){if(":"!=_W(e,1))return;l+=2,d=++u}for(;h();){if(8==u)return;if(":"!=h()){for(t=r=0;r<4&&mW(UW,h());)t=16*t+vW(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(!mW(NW,h()))return;for(;mW(NW,h());){if(o=vW(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}(IW(e,1,-1)),!t)return CW;this.host=t}else if(this.isSpecial()){if(e=tW(e),mW(VW,e))return CW;if(t=function(e){var t,r,n,i,o,a,s,c=TW(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"==_W(i,0)&&(o=mW(DW,i)?16:8,i=IW(i,8==o?1:2)),""===i)a=0;else{if(!mW(10==o?LW:8==o?MW:UW,i))return e;a=vW(i,o)}bW(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=fW(256,5-t))return null}else if(a>255)return null;for(s=SW(r),n=0;n<r.length;n++)s+=r[n]*fW(256,3-n);return s}(e),null===t)return CW;this.host=t}else{if(mW(FW,e))return CW;for(t="",r=ZX(e),n=0;n<r.length;n++)t+=WW(r[n],GW);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return JX(YW,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&qW(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+=HW(i),null!==o&&(u+=":"+o)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+gW(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw hW(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new SY(e.path[0]).origin}catch(Iq){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+HW(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(rW(e)+":",ZW)},getUsername:function(){return this.username},setUsername:function(e){var t=ZX(rW(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=WW(t[r],XW)}},getPassword:function(){return this.password},setPassword:function(e){var t=ZX(rW(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=WW(t[r],XW)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?HW(e):HW(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,cY)},getHostname:function(){var e=this.host;return null===e?"":HW(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,uY)},getPort:function(){var e=this.port;return null===e?"":rW(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=rW(e))?this.port=null:this.parse(e,dY))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+gW(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,pY))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=rW(e))?this.query=null:("?"==_W(e,0)&&(e=IW(e,1)),this.query="",this.parse(e,mY)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=rW(e))?("#"==_W(e,0)&&(e=IW(e,1)),this.fragment="",this.parse(e,gY)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var SY=function(e){var t=qX(this,bY),r=iW(arguments.length,1)>1?arguments[1]:void 0,n=sW(t,new yY(e,!1,r));HX||(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())},bY=SY.prototype,EY=function(e,t){return{get:function(){return cW(this)[e]()},set:t&&function(e){return cW(this)[t](e)},configurable:!0,enumerable:!0}};if(HX&&(YX(bY,"href",EY("serialize","setHref")),YX(bY,"origin",EY("getOrigin")),YX(bY,"protocol",EY("getProtocol","setProtocol")),YX(bY,"username",EY("getUsername","setUsername")),YX(bY,"password",EY("getPassword","setPassword")),YX(bY,"host",EY("getHost","setHost")),YX(bY,"hostname",EY("getHostname","setHostname")),YX(bY,"port",EY("getPort","setPort")),YX(bY,"pathname",EY("getPathname","setPathname")),YX(bY,"search",EY("getSearch","setSearch")),YX(bY,"searchParams",EY("getSearchParams")),YX(bY,"hash",EY("getHash","setHash"))),WX(bY,"toJSON",(function(){return cW(this).serialize()}),{enumerable:!0}),WX(bY,"toString",(function(){return cW(this).serialize()}),{enumerable:!0}),lW){var kY=lW.createObjectURL,TY=lW.revokeObjectURL;kY&&WX(SY,"createObjectURL",KX(kY,lW)),TY&&WX(SY,"revokeObjectURL",KX(TY,lW))}nW(SY,"URL"),jX({global:!0,constructor:!0,forced:!GX,sham:!HX},{URL:SY});var IY=r(re.URL),RY=function(){var e=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(IY.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)}}(),AY=cd,wY=ic,CY=function(e,t,r,n){for(var i,o=n>1?void 0:n?wY(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&&AY(t,r,o),o},xY=function(){function e(t,r){Hl(this,e),Zd(this,"_sharedAudioContext",new AudioContext),Zd(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),Zd(this,"_localGainNode",this._sharedAudioContext.createGain()),Zd(this,"_bufferGainNode",this._sharedAudioContext.createGain()),Zd(this,"_audioBufferSource",void 0),Zd(this,"_localSource",void 0),Zd(this,"_context",void 0),Zd(this,"_failedAudioList",[]),Zd(this,"_startingIds",new ib),Zd(this,"_revokeURLs",new GU),Zd(this,"mixingMap",new ib),Zd(this,"resourcesCache",new ib),Zd(this,"volumeConfig",new ib),Zd(this,"cachedBuffer",[]),Zd(this,"id","AudioMixingManager"),this.engineId=r,this._context=t,this._localGainNode.gain.value=1}var t,r,n;return jl(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=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,p,f,_,m=this;return wm().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,PM(o=n.type,"mixingType",NG(Ll)),a=this._context.getLocalAudioTrack()){e.next=9;break}return e.abrupt("return");case 9:if((s=a.getTrack("preprocessing"))&&this.mixMediaStream(new MediaStream([s])),null!=(c=this.mixingMap.get(t))&&c.audioNode){c.audioNode.pause(),this._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_STOPPED,error:mA.AUDIO_MIXING_ERROR_OK});try{c.gainNode.disconnect(this._audioDestination),c.audioSource.disconnect(c.gainNode)}catch(g){}}if(!(d=this.resourcesCache.get(t))||d.filePath!==r){e.next=18;break}u=d.getAudioNode(),e.next=31;break;case 18:return e.next=20,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw m._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_FAILED,error:mA.AUDIO_MIXING_ERROR_START_FAILED}),new SA(_A.LOAD_RESOURCES_FAILED,e.statusText)}));case 20:return l=e.sent,rE(r).call(r,"mp3")?h={type:"audio/mpeg"}:rE(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=24,RY(l,h);case 24:if(e.sent){e.next=28;break}throw this._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_FAILED,error:mA.AUDIO_MIXING_ERROR_START_FAILED}),new SA(_A.LOAD_RESOURCES_FAILED,"invalid audio resource");case 28:(u=new Audio).crossOrigin="anonymous",u.src=IY.createObjectURL(new Blob([l],h));case 31:return i<=0?u.loop=!0:i>0&&(v=i,u.onended=function(){--v>0?u.play():(m.mixingMap.delete(t),m._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_FINISHED,error:mA.AUDIO_MIXING_ERROR_OK}))}),e.prev=32,e.next=35,u.play();case 35:e.next=42;break;case 37:e.prev=37,e.t0=e.catch(32),console.error(e.t0),this._failedAudioList.push(u),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:dl.STREAM_INDEX_MAIN,mediaType:ll.AUDIO});case 42:if(this._startingIds.delete(t),p=this._sharedAudioContext.createMediaElementSource(u),f=this._sharedAudioContext.createGain(),_=this.volumeConfig.get(t),f.gain.value=_?_/100:1,p.connect(f).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:p,audioNode:u,gainNode:f,type:"file"}),o===Ll.PUBLISH)try{f.disconnect(this._sharedAudioContext.destination)}catch(g){}else f.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_PLAYING,error:mA.AUDIO_MIXING_ERROR_OK});case 52:case"end":return e.stop()}}),e,this,[[32,37]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"stopAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&"file"===t.type&&(this.mixingMap.delete(e),t.audioNode.pause(),t.audioSource.disconnect(t.gainNode),t.gainNode.disconnect(this._audioDestination),this._context.emitMessage({mixId:e,state:Ul.AUDIO_MIXING_STATE_STOPPED,error:mA.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Ul.AUDIO_MIXING_STATE_PAUSED,error:mA.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:Ul.AUDIO_MIXING_STATE_PLAYING,error:mA.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=xm(wm().mark((function e(t,r){var n,i,o=this;return wm().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 SA(_A.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_FAILED,error:mA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof SA)throw e;throw new SA(_A.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,rE(r).call(r,"mp3")?i={type:"audio/mpeg"}:rE(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,RY(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_FAILED,error:mA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new SA(_A.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_PRELOADED,error:mA.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=IY.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new $_((function(e){var r=IY.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)),IY.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){PM(e,"type",NG(Ll));var t=this._context.getLocalAudioTrack();if(t){var r=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([r])),e===Ll.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:Ul.AUDIO_MIXING_STATE_PCM_ENABLED,error:mA.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:Ul.AUDIO_MIXING_STATE_PCM_DISABLED,error:mA.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=xm(wm().mark((function e(){var t,r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=oI(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:dl.STREAM_INDEX_MAIN,mediaType:ll.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 ib,this._revokeURLs.forEach((function(e){IY.revokeObjectURL(e)}))}}]),e}();CY([JP("id","filePath","options")],xY.prototype,"startAudioMixing",1),CY([JP("id")],xY.prototype,"stopAudioMixing",1),CY([JP("id")],xY.prototype,"pauseAudioMixing",1),CY([JP("id")],xY.prototype,"resumeAudioMixing",1),CY([JP("id")],xY.prototype,"preloadAudioMixing",1),CY([JP("id")],xY.prototype,"unloadAudioMixing",1),CY([JP("id")],xY.prototype,"getAudioMixingVolume",1),CY([JP("id","volume")],xY.prototype,"setAudioMixingVolume",1),CY([JP("id")],xY.prototype,"getAudioMixingDuration",1),CY([JP("id")],xY.prototype,"getAudioMixingCurrentPosition",1),CY([JP("id","position")],xY.prototype,"setAudioMixingPosition",1),CY([JP("type")],xY.prototype,"enableAudioMixingBuffer",1),CY([JP()],xY.prototype,"disableAudioMixingBuffer",1),CY([JP("buffer")],xY.prototype,"pushAudioMixingBuffer",1);var OY=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(OY||{}),PY=function(e){UI(c,e);var t,r,n,i,o,a,s=eR(c);function c(e){var t;return Hl(this,c),Zd(sI(t=s.call(this)),"_dataChannelSignal",void 0),Zd(sI(t),"_handler",void 0),Zd(sI(t),"_dataChannelSignalState",Iz.DISCONNECTED),Zd(sI(t),"_loginSessionId",null),Zd(sI(t),"_userId",null),Zd(sI(t),"_token",null),Zd(sI(t),"_loginResolveCallback",void 0),Zd(sI(t),"_loginRejectCallback",void 0),Zd(sI(t),"_wait_login_token",!1),Zd(sI(t),"_serverParamsCache",void 0),Zd(sI(t),"id",void 0),Zd(sI(t),"_connectionManager",void 0),Zd(sI(t),"isReconnecting",!1),Zd(sI(t),"logger",void 0),t._ctx=e,t.id=e.id,t.logger=new fN("RTMClient",1,e.id),t._connectionManager=new Sz(e),t._addConnectHandler(),t}return jl(c,[{key:"login",value:function(e,t){var r=this;return new $_((function(n,i){var o;if(r.logger.info("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new SA(_A.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new SA(_A.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=YP(r.id))||void 0===o||o.set({rtm_user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():r.connect().then((function(){r._login()}))}))}},{key:"logout",value:(a=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SA(_A.NOT_LOGIN,"login first");case 2:return e.next=4,null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId},{functionType:gz.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=xm(wm().mark((function e(t){var r=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new $_((function(e,t){r._wait_login_token?(r._loginResolveCallback=e,r._loginRejectCallback=t,r._login()):e()})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(i=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SA(_A.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,peerUserId:t},{functionType:gz.C2RTM});case 5:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(n=xm(wm().mark((function e(t,r){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SA(_A.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"setServerParams",value:(r=xm(wm().mark((function e(t,r){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,OM(t,"signature"),OM(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new SA(_A.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,signature:t,url:r},{functionType:gz.C2RTM}).catch((function(e){throw new SA(_A.UNEXPECTED_ERROR,e.msg)}));case 8:this._serverParamsCache={signature:t,url:r},this.emit("onServerParamsSetResult"),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(0),this.emit("onServerParamsSetResult",e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,12]])}))),function(e,t){return r.apply(this,arguments)})},{key:"sendServerMessage",value:(t=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SA(_A.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:"",room:"",type:vz.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e;this.logger.info("destroy","invoke."),MI(DI(c.prototype),"removeAllListeners",this).call(this),this._loginResolveCallback&&this._loginRejectCallback&&(this._loginRejectCallback(new SA(_A.LOGIN_FAILED,"logout")),delete this._loginResolveCallback,delete this._loginRejectCallback),null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),delete this._dataChannelSignal,this._clearState(),this._connectionManager.destroy(),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=eD();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:nD.token2auth(this._ctx.appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:bM.VERSION,deviceId:pM.getDeviceId(),appId:this._ctx.appId,userId:this._userId},accessParams:Fm({requireICEUfragV2:!0})},{functionType:gz.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,VP.setRtsSessionId(e.id,t),e._wait_login_token=!1,e._serverParamsCache&&e.setServerParams(e._serverParamsCache.signature,e._serverParamsCache.url)})).catch((function(t){var r,n,i=t||{},o=i.code,a=i.message;e._wait_login_token=!1,o>=700&&o<800?708===o?(r=_A.INVALID_PARAMS,n="Invalid userId"):(r=_A.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=_A.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new SA(r,a||n))})).finally((function(){delete e._loginResolveCallback,delete e._loginRejectCallback}))}}},{key:"connect",value:function(){var e=this;return new $_((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==Iz.CONNECTED)throw new SA(_A.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n;e._dataChannelSignalState=Iz.CONNECTED,e.logger.info("connectStateChange","connected"),null===(r=e._handler)||void 0===r||r.destroy(),null===(n=e._dataChannelSignal)||void 0===n||n.destroy(),e._handler=BG(e._ctx,t.pc),e._dataChannelSignal=t.signaling,e._addSignalEventHandler(),e.isReconnecting&&e._login()})),this._connectionManager.on("disconnected",(function(t){e._dataChannelSignalState=Iz.DISCONNECTED,e.logger.warn("connectStateChange","disconnected. %o",t),e.isReconnecting&&(e.emit("onUserDisconnection"),e._clearState())})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=Iz.CONNECTING,e.logger.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=Iz.CONNECTING,e.logger.warn("connectStateChange","reconnecting")}))}},{key:"_addSignalEventHandler",value:function(){var e,t,r,n=this;null===(e=this._dataChannelSignal)||void 0===e||e.on(GG.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(t=this._dataChannelSignal)||void 0===t||t.on(GG.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(r=this._dataChannelSignal)||void 0===r||r.on(GG.USER_DISCONNECTION,(function(){n.emit("onUserDisconnection"),n._clearState()}))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,VP.setRtsSessionId(this.id,"")}}]),c}(JM.EventEmitter),NY=function(){function e(t){Hl(this,e),Zd(this,"_roomId",void 0),Zd(this,"_constraints",{}),Zd(this,"_profile",void 0),Zd(this,"_customMaxBitrate",0),this._appId=t}return jl(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=pM.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=pM.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=aI(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),Km(e=cn(c)).call(e,(function(e){var t;return Mm(t="".concat(e,"=")).call(t,c[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=el(el({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=el({},this._constraints),t=pM.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;ED(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),ED(null==t?void 0:t.channel)||(e.channelCount=t.channel),ED(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),ED(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),ED(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return ED(e.sampleRate)&&!ED(n)&&(e.sampleRate=n),ED(e.channelCount)&&!ED(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case Rl.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case Rl.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case Rl.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case Rl.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case Rl.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),DY=function(e){UI(o,e);var t,r,n,i=eR(o);function o(e,t,r){var n,a=r.businessId;return Hl(this,o),Zd(sI(n=i.call(this)),"_mediaServerClient",void 0),Zd(sI(n),"_appId",void 0),Zd(sI(n),"remoteStreams",void 0),Zd(sI(n),"_businessId",void 0),Zd(sI(n),"_ctx",void 0),n.id=e,n._appId=t,n.remoteStreams=new ib,n._businessId=a,n._ctx={id:n.id,appId:n._appId,avSync:!0,audioProfileManager:new NY(n._appId),useCloudProxy:!1,userPriority:new ib,joinRoomConfig:new _M(n.id),enableFallbackHandler:rq(t)},n}return jl(o,[{key:"connect",value:(n=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new Az(this._ctx),this._mediaServerClient.publicStream=!0,this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=6,this._mediaServerClient.connect();case 6:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=xm(wm().mark((function e(t){var r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new SA(_A.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new _B(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.emit(QG.ON_SEI_MESSAGED_RECEIVED,{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._mediaServerClient.subscribePublicStream(r);case 6:return this.remoteStreams.set(t,r),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopPlayPublicStream",value:function(e){var t=this.remoteStreams.get(e);if(t)return this.remoteStreams.delete(e),this._mediaServerClient.unsubscribePublicStream(t)}},{key:"destroy",value:function(){var e;this.remoteStreams.forEach((function(e){e.clean()})),this.remoteStreams=new ib,null===(e=this._mediaServerClient)||void 0===e||e.destroy(),this.removeAllListeners()}},{key:"_handleReconnected",value:(t=xm(wm().mark((function e(){var t,r,n,i=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=oI(this.remoteStreams);try{for(n=function(){var e=aI(r.value,2),t=e[0],n=e[1];n.clean(),n.statsReport.unsubscribe(),i.remoteStreams.delete(t),i.startPlayPublicStream(t).then((function(){var e=i.remoteStreams.get(t);i.safeEmit(QG.RESUBSCRIBE,{stream:e})}))},t.s();!(r=t.n()).done;)n()}catch(o){t.e(o)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on("connectSuccess",(function(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).reconnect&&r._handleReconnected()})),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}($M),MY=new fN("AudioDeviceManager",1),LY=function(e){UI(c,e);var t,r,n,i,o,a,s=eR(c);function c(e,t){var r;return Hl(this,c),Zd(sI(r=s.call(this)),"_audioLevelFetcher",void 0),Zd(sI(r),"_playbackDeviceTestTimer",void 0),Zd(sI(r),"_audioElement",void 0),Zd(sI(r),"_audioTrack",void 0),Zd(sI(r),"_mediaRecorder",void 0),Zd(sI(r),"_recoderTimer",void 0),Zd(sI(r),"_isAudioPlaybackDeviceTesting",!1),Zd(sI(r),"_isAudioDeviceRecordTesting",!1),Zd(sI(r),"_audioCaptureAndRecoderResolve",void 0),Zd(sI(r),"_onAutoplayFailed",void 0),Zd(sI(r),"_audioPlaybackDeviceId",void 0),r._ctx=e,r._extensionManager=t,r}return jl(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=xm(wm().mark((function e(t,r){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new SA(_A.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,MY.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),MY.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&&(MY.info("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=xm(wm().mark((function e(t,r,n){var i,o=this,a=arguments;return wm().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 SA(_A.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 3:if(!this._isAudioDeviceRecordTesting&&!this._isAudioPlaybackDeviceTesting){e.next=5;break}throw new SA(_A.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 5:return this._isAudioDeviceRecordTesting=!0,MY.info("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){MY.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(){MY.info("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(MY.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=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MY.info("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new SA(_A.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,rF.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new SA(_A.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(){MY.info("destroy()","Invoke"),MI(DI(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=xm(wm().mark((function e(t,r){var n,i=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MY.info("_playAudioFile()",Mm(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new $_((function(e,n){var o=Zz("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new uF(o),o.onplaying=function(){o.onplaying=null,MY.info("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=xm(wm().mark((function e(t){var r,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:MY.error("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new SA(_A.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;MY.warn("_playAudioFile()","autoplay error",e);var r=Mm(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return $_.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new SA(_A.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&&(MY.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&&(MY.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&&(MY.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=xm(wm().mark((function e(t,r){var n,i=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,LF(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r),n=new MediaStream([this._audioTrack.getTrack("preprocessing")]),MY.info("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new $_((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=kE(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),MY.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=xm(wm().mark((function n(o){var a,c;return wm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return MY.info("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(IY.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 SA(_A.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},i._audioCaptureAndRecoderResolve=e,i._mediaRecorder.start()})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_stopAudioCaptureAndRecoder",value:function(){var e;this._mediaRecorder&&("recording"===this._mediaRecorder.state&&this._mediaRecorder.stop(),delete this._mediaRecorder),null===(e=this._audioTrack)||void 0===e||e.close(),delete this._audioTrack}},{key:"_setAudioCtxSinkId",value:(t=xm(wm().mark((function e(){var t,r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=dF.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),MY.info("setSinkId","ctx.sinkId=".concat(t))}catch(o){MY.error("setSinkId",Mm(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}(JM.EventEmitter),UY=new fN("VideoSnapshot",1),VY=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},FY=function(){var e=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=document.createElement("canvas"),o=i.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(a=function(e,t,n){return t=t||e.width,n=n||e.height,i.width=t,i.height=n,r?o.setTransform(-1,0,0,1,t,0):o.setTransform(1,0,0,1,0,0),o.drawImage(e,0,0,t,n),o.getImageData(0,0,t,n)},s=Date.now(),!(c=VY(n))){e.next=16;break}return UY.info("takeSnapshot","VideoPlayer already set."),e.next=11,a(c,c.videoWidth,c.videoHeight);case 11:return u=e.sent,UY.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",u);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(d=new window.ImageCapture(t)).track.readyState||!d.track.enabled||d.track.muted){e.next=29;break}return UY.info("takeSnapshot","use ImageCapture"),e.t0=a,e.next=23,d.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return l=e.sent,UY.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 29:return UY.info("takeSnapshot","use temp video"),e.abrupt("return",new $_((function(e,r){var n=new MediaStream([t]),i=document.createElement("video");i.setAttribute("playsinline",""),i.muted=!0,document.body.appendChild(i),i.onplaying=function(){var r=a(i,i.videoWidth,i.videoHeight);UY.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e(r),n.removeTrack(t),i.srcObject=null,i.load()},i.onerror=r,i.srcObject=n,i.play()})));case 31:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),BY=function(){return{url:"",video:{codec:Cl.H264,width:640,height:360,fps:15,gop:2,kBitRate:jY(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:wl.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function jY(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 HY(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new SA(_A.INVALID_PARAMS,"Invalid rtmp address")}function GY(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new SA(_A.INVALID_PARAMS,"regions should not be empty.");var t,r=oI(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new SA(_A.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new SA(_A.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(i){r.e(i)}finally{r.f()}}function zY(e,t){var r,n,i,o=function(e,r){var n=gb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=gb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),BY());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!!kE(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 bk(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return bk(t=[wl.LC,wl.HEv1,wl.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return bk(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:jY(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:Km(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&&bk(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&bk(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 KY,XY={getDefaultValue:BY,checkStartParams:function(e){var t;HY(e.url),GY(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&HY(e.url),GY(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return zY("started",e)},getUpdateParams:function(e){return zY("layoutChanged",e)}},WY=cd,YY=ic,qY=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&&WY(t,r,o),o},JY=function(e){UI(Ie,e);var t,r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,N,D,M,L,U,V,F,B,j,H,G,z,K,X,W,Y,q,J,Q,Z,$,ee,te,re,ne,ie,oe,ae,se,ce,ue,de,le,he,ve,pe,fe,_e,me,ge,ye,Se,be,Ee,ke,Te=eR(Ie);function Ie(e,t,r){var n;return Hl(this,Ie),Zd(sI(n=Te.call(this)),"monitor",void 0),Zd(sI(n),"logger",void 0),Zd(sI(n),"_room",void 0),Zd(sI(n),"_publicStreamManager",void 0),Zd(sI(n),"_appId",void 0),Zd(sI(n),"_businessId",void 0),Zd(sI(n),"_visibility",!0),Zd(sI(n),"_localVideoTrack",void 0),Zd(sI(n),"_localAudioTrack",void 0),Zd(sI(n),"_localImgVideoTrack",void 0),Zd(sI(n),"_localImgScreenTrack",void 0),Zd(sI(n),"_localScreenVideoTrack",void 0),Zd(sI(n),"_localScreenAudioTrack",void 0),Zd(sI(n),"_tempMixingAudioTrack",void 0),Zd(sI(n),"_localAudioVolume",100),Zd(sI(n),"_localScreenAudioVolume",100),Zd(sI(n),"_remoteAudioVolume",new ib),Zd(sI(n),"_remoteScreenAudioVolume",new ib),Zd(sI(n),"_publicAudioVolume",new ib),Zd(sI(n),"_videoPlayer",void 0),Zd(sI(n),"_screenPlayer",void 0),Zd(sI(n),"_remoteVideoPlayer",new ib),Zd(sI(n),"_remoteScreenPlayer",new ib),Zd(sI(n),"_remoteAudioPlayer",new ib),Zd(sI(n),"_remoteScreenAudioPlayer",new ib),Zd(sI(n),"_publicStreamAudioPlayer",new ib),Zd(sI(n),"_publicStreamVideoPlayer",new ib),Zd(sI(n),"_publicStreamIds",new ib),Zd(sI(n),"_roomConfig",void 0),Zd(sI(n),"_videoStreamConstraints",el({},AM)),Zd(sI(n),"_audioStreamConstraints",{}),Zd(sI(n),"_enableSimulcast",!1),Zd(sI(n),"_videoStreamEncodeConfig",[el({},AM)]),Zd(sI(n),"_screenStreamEncodeConfig",[el({},wM)]),Zd(sI(n),"_dummyMainImage",void 0),Zd(sI(n),"_dummyScreenImage",void 0),Zd(sI(n),"_trackSourceType",void 0),Zd(sI(n),"_liveTranscodeConfig",void 0),Zd(sI(n),"_startCloudProxyTimestamp",void 0),Zd(sI(n),"_localVideoDeviceId",void 0),Zd(sI(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),Zd(sI(n),"_audioVolumeIndicationTimer",void 0),Zd(sI(n),"_dummyMainTimer",void 0),Zd(sI(n),"_dummyScreenTimer",void 0),Zd(sI(n),"_audioPropertiesReportTimer",null),Zd(sI(n),"_mirrorType",pl.MIRROR_TYPE_RENDER),Zd(sI(n),"_audioMixingManager",void 0),Zd(sI(n),"_pubLock",void 0),Zd(sI(n),"_subLocks",void 0),Zd(sI(n),"_audioCaptureLock",void 0),Zd(sI(n),"_videoCaptureLock",void 0),Zd(sI(n),"_screenCaptureLock",void 0),Zd(sI(n),"_subScreenLocks",void 0),Zd(sI(n),"_rtmClient",void 0),Zd(sI(n),"_messageStatisticsObserver",void 0),Zd(sI(n),"_tempRoomInfo",void 0),Zd(sI(n),"_originIceConfigRequestUrls",void 0),Zd(sI(n),"_originConfigServerUrls",void 0),Zd(sI(n),"_originLogServerUrl",void 0),Zd(sI(n),"_extensionManager",void 0),Zd(sI(n),"_audioDeviceManager",void 0),Zd(sI(n),"_remoteVideoConfig",new ib),Zd(sI(n),"_config",void 0),Zd(sI(n),"_needClosePreTrack",!1),Zd(sI(n),"_ctx",void 0),Zd(sI(n),"_updateMixAudioTrack",function(){var e=xm(wm().mark((function e(t){var r,i,o=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:Ll.PLAYOUT_AND_PUBLISH,n.logger.info("_updateMixAudioTrack()"),n._localAudioTrack){e.next=5;break}return t&&(n._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(n._localAudioTrack.mixType=i,n._localAudioTrack.mixedAudioTrack=t):(delete n._localAudioTrack.mixType,delete n._localAudioTrack.mixedAudioTrack),null===(r=n._room)||void 0===r||!r.hasPublished){e.next=9;break}return e.next=9,n._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),Zd(sI(n),"_onAudioMixingMessage",(function(e){n.safeEmit(Fl.onAudioMixingStateChanged,e)})),Zd(sI(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(Fl.onAutoplayFailed,e)})),n.id=t,n._appId=e,n.monitor=YP(t),n._ctx={id:t,appId:e,avSync:!0,streamRTT:{},useCloudProxy:!1,audioProfileManager:new NY(e),userPriority:new ib,expectedIDC:null==r?void 0:r.expectedIDC,joinRoomConfig:new _M(t),enableFallbackHandler:rq(e)},n._pubLock=new JG("pubLock"),n._subLocks=new ib,n._subScreenLocks=new ib,n._audioCaptureLock=new JG("audioCap"),n._videoCaptureLock=new JG("videoCap"),n._screenCaptureLock=new JG("screenCap"),n._addDeviceEventHandler(),n._extensionManager=new hF(t),n._audioDeviceManager=new LY(n._ctx,n._extensionManager),n._audioMixingManager=new xY({getLocalAudioTrack:function(){return n._localAudioTrack},updateLocalAudioTrack:n._updateMixAudioTrack,emitMessage:n._onAudioMixingMessage,onAutoPlayFailed:n._onAudioMixingAutoplayFailed},t),window.__rtc_engine__=sI(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=sI(n),n._trackSourceType={video:tl.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:tl.VIDEO_SOURCE_TYPE_INTERNAL,audio:rl.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:rl.AUDIO_SOURCE_TYPE_INTERNAL},n._config=r,n._rtmClient=new PY(n._ctx),n._handleRTMClient(n._rtmClient),n._handleAudioDeviceManager(),n._messageStatisticsObserver=new FP(t),n.logger=new fN("Engine",0,t),VP.createRTSMsgReportor(n.id),n._getServerConfig(),n}return jl(Ie,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(ke=xm(wm().mark((function e(t){var r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateToken()","token: %s",t),OM(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return r=this._tempRoomInfo,n=r.config,i=r.userInfo,o=r.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,o,i,n);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new SA(_A.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,this._room.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return ke.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(Ee=xm(wm().mark((function e(t){var r,n,i,o,a,s=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setVideoCaptureDevice()","deviceId: %s",t),OM(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:if(!KD||!YD){e.next=9;break}if(this._localVideoTrack.getTrack().getSettings().deviceId!==t){e.next=9;break}return e.abrupt("return");case 9:return n=oH({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete n.deviceId,n.facingMode=t):!HD||WD?n.deviceId={exact:t}:delete n.deviceId,YD&&LD&&aM>=85&&aM<=91&&(null===(i=this._videoPlayer)||void 0===i||i.removeTrack()),this._needClosePreTrack=this._needClosePreTrack||oV,this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),this.logger.info("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=17,DF(n,this._extensionManager).catch((function(e){if(s._localVideoTrack&&!s._localVideoTrack.dummy)return s.logger.warn("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),s._removeLocalTrackEvents(s._localVideoTrack),s._localVideoTrack.close(),delete s._localVideoTrack,DF(n,s._extensionManager).then((function(e){return s._needClosePreTrack=!0,e})).catch(xm(wm().mark((function t(){var r;return wm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.logger.error("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,DF(s._videoStreamConstraints,s._extensionManager);case 3:throw r=t.sent,s._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 17:return o=e.sent,this.logger.success("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=n,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null!==(r=this._videoStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&o.setContentHint(null===(a=this._videoStreamEncodeConfig[0])||void 0===a?void 0:a.contentHint),e.next=24,this._switchTrack(o);case 24:case"end":return e.stop()}}),e,this)}))),function(e){return Ee.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(be=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setAudioCaptureDevice()","deviceId: %s",t),OM(t,"deviceId"),this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.next=9,LF(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 be.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){rF.on(Fl.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),rF.on(Fl.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,N,D,M,L,U=this;null===(e=this._room)||void 0===e||e.on(GG.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(GG.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(GG.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(QG.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(QG.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(QG.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(GG.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(GG.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(GG.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(GG.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(GG.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?U._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?U._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&U._onLiveTranscodingResult(e)})),null===(l=this._room)||void 0===l||l.on(KG.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(KG.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return U.safeEmit(Fl.onVendorConnectionStateChanged,e)})),null===(v=this._room)||void 0===v||v.on(QG.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(p=this._room)||void 0===p||p.on(QG.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(QG.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(_=this._room)||void 0===_||_.on(QG.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=U._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&U.safeEmit(Fl.onAutoPublishResult,e)})),null===(m=this._room)||void 0===m||m.on(QG.ON_REMOTE_STREAM_STATS,(function(e){U.safeEmit(Fl.onRemoteStreamStats,e)})),null===(g=this._room)||void 0===g||g.on(QG.ON_LOCAL_STREAM_STATS,(function(e){U.safeEmit(Fl.onLocalStreamStats,e)})),null===(y=this._room)||void 0===y||y.on(QG.ON_SUBTITLE_STATE_CHANGED,(function(e){U.safeEmit(Fl.onSubtitleStateChanged,e)})),null===(S=this._room)||void 0===S||S.on(QG.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){U.safeEmit(Fl.onSubtitleMessageReceived,e)})),null===(b=this._room)||void 0===b||b.on(QG.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(E=this._room)||void 0===E||E.on(QG.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;U._updateAudioPlayerState(t),U.safeEmit(Fl.onUserStartAudioCapture,{userId:r})})),null===(k=this._room)||void 0===k||k.on(QG.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;U.safeEmit(Fl.onUserStopAudioCapture,{userId:t})})),null===(T=this._room)||void 0===T||T.on(QG.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;U.safeEmit(Fl.onUserStartVideoCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(QG.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;U.safeEmit(Fl.onUserStopVideoCapture,{userId:t})})),null===(R=this._room)||void 0===R||R.on(QG.ON_SEI_MESSAGED_RECEIVED,(function(e){U.safeEmit(Fl.onSEIMessageReceived,e)})),null===(A=this._room)||void 0===A||A.on(QG.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){U.safeEmit(Fl.onRemoteVideoSizeChanged,e,t)})),null===(w=this._room)||void 0===w||w.on(QG.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return U.safeEmit(Fl.onSimulcastSubscribeFallback,e)})),null===(C=this._room)||void 0===C||C.on(QG.RECONNECT_FAILED,(function(){U.safeEmit(Fl.onError,{errorCode:_A.RECONNECT_FAILED})})),null===(x=this._room)||void 0===x||x.on(QG.ON_VIDEO_STREAM_BANNED,(function(e){U.safeEmit(Fl.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(O=this._room)||void 0===O||O.on(QG.ON_AUDIO_STREAM_BANNED,(function(e){U.safeEmit(Fl.onAudioStreamBanned,{uid:e.uid,banned:e.banned})})),null===(P=this._room)||void 0===P||P.on(QG.ON_FORWARD_STREAM_ERROR,(function(e){U.safeEmit(Fl.onForwardStreamError,e)})),null===(N=this._room)||void 0===N||N.on(QG.ON_REJOIN_WITH_TCP,(function(){U.safeEmit(Fl.onRejoinWithTcp)})),null===(D=this._room)||void 0===D||D.on(QG.ON_ICE_CONNECT_WITH_TCP,(function(){U.safeEmit(Fl.onIceConnectWithTcp)})),null===(M=this._room)||void 0===M||M.on(QG.PUB_RETRY,(function(e){U.safeEmit(Fl.onPublishRetry,e)})),null===(L=this._room)||void 0===L||L.on(QG.SUB_RETRY,(function(e){U.safeEmit(Fl.onSubscribeRetry,e)}))}},{key:"safeEmit",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return function(e){var t,r=kM("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!bk(r).call(r,e))||!bk(t=[Fl.onRemoteStreamStats,Fl.onLocalStreamStats,Fl.onAudioVolumeIndication,Fl.onLocalAudioPropertiesReport,Fl.onRemoteAudioPropertiesReport]).call(t,e)}(e)&&ZP(this.id,e,i),(t=MI(DI(Ie.prototype),"safeEmit",this)).call.apply(t,Mm(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(Se=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._room){e.next=2;break}return e.abrupt("return",!1);case 2:return this._room=new Qz({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:Il.communication},this._ctx),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return Se.apply(this,arguments)})},{key:"joinRoom",value:(ye=xm(wm().mark((function e(t,r,n,i){var o,a,s,c,u;return wm().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),UM(t)||OM(t,"token"),VM(r),jM(n),HM(i=oH({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:Il.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==Iz.CONNECTED){e.next=8;break}throw new SA(_A.REPEAT_JOIN,"Already joined");case 8:return this._room||(this._room=new Qz(i,this._ctx),this._addHandlerEventHandler()),this._room.roomConfig=i,a=this._liveTranscodeConfig&&XY.getStartParams(this._liveTranscodeConfig),s=el(el({},n),{},{businessId:this._businessId,role:this._visibility?OY.NORMAL_USER:OY.SILENT_USER}),e.prev=12,this._ctx.useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),jz(s),e.next=17,this._room.join(this._appId,r,t,s,a);case 17:return c=e.sent,this._roomConfig=i,this._ctx.audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,i.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:ll.AUDIO_AND_VIDEO}):this.safeEmit(Fl.onAutoPublishResult,{isScreen:!1,state:sl.PUBLISH_FAIL})),VP.setRoomId(this.id,r),VP.setUserId(this.id,n.userId),e.abrupt("return",c);case 27:throw e.prev=27,e.t0=e.catch(12),e.t0.code===_A.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:s}),null===(u=this._room)||void 0===u||u.destroy(),delete this._room,e.t0;case 33:case"end":return e.stop()}}),e,this,[[12,27]])}))),function(e,t,r,n){return ye.apply(this,arguments)})},{key:"leaveRoom",value:(ge=xm(wm().mark((function e(){var t,r,n,i=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],this.logger.info("leaveRoom()"),!t){e.next=7;break}return e.next=5,null===(r=this._room)||void 0===r?void 0:r.leave(t);case 5:e.next=8;break;case 7:null===(n=this._room)||void 0===n||n.leave(t).catch();case 8:this._removeHandlerEventHandler(),this._subLocks=new ib,this._subScreenLocks=new ib,this._ctx.audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new ib,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new ib,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new ib,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new ib,this._roomConfig=void 0,this._publicStreamIds=new ib,VP.setRoomId(this.id,""),VP.setUserId(this.id,"");case 26:case"end":return e.stop()}}),e,this)}))),function(){return ge.apply(this,arguments)})},{key:"_destroyLocalTrack",value:function(){this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localScreenVideoTrack=void 0),this._localImgVideoTrack&&(this._localImgVideoTrack.stop(),this._localImgVideoTrack=void 0),this._localImgScreenTrack&&(this._localImgScreenTrack.stop(),this._localImgScreenTrack=void 0)}},{key:"destroy",value:function(){var e,t,r;this.logger.info("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,null===(t=this._videoPlayer)||void 0===t||t.destroy(),this._subLocks=new ib,this._subScreenLocks=new ib,this._audioCaptureLock=new JG("audioCap"),this._videoCaptureLock=new JG("videoCap"),this._screenCaptureLock=new JG("screenCap"),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._videoStreamEncodeConfig=[AM],this._screenStreamEncodeConfig=[wM],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),VP.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._destroyLocalTrack(),aF.on("".concat(this.id,"capture-end"),this._destroyLocalTrack.bind(this)),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new ib,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new ib,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new ib,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new ib,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new ib,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new ib,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new ib,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new ib,this._ctx.userPriority.clear(),this._extensionManager.destroy(),this._ctx.avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(me=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!yD(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,xF(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return me.apply(this,arguments)})},{key:"unpublishStream",value:(_e=xm(wm().mark((function e(t,r){var n;return wm().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:$G.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return _e.apply(this,arguments)})},{key:"publishScreen",value:(fe=xm(wm().mark((function e(t){return wm().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,!yD(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,PF(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:$G.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof SA)){e.next=18;break}throw e.t0;case 18:throw new SA(_A.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return fe.apply(this,arguments)})},{key:"unpublishScreen",value:(pe=xm(wm().mark((function e(t){return wm().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:$G.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return pe.apply(this,arguments)})},{key:"subscribeStream",value:(ve=xm(wm().mark((function e(t,r){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("subscribeStream()","userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!1,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ve.apply(this,arguments)})},{key:"_subscribe",value:(he=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n!==ll.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=3;break}return this.logger.warn("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 3:if(u=this._room.remoteStreams.get(r),d=null==u?void 0:kE(u).call(u,(function(e){return e.isScreen===t}))){e.next=7;break}throw new SA(_A.STREAM_NOT_EXIST,"stream not exist");case 7:return l=this._pauseAllSubscribeState.audio,h=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&ll.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&ll.VIDEO),this.logger.warn("subscribeStream()","due to pauseAll mediaType: %o",n),v=d.hasSubscribed,p=this._remoteVideoConfig.get(r)||(null===(o=this._roomConfig)||void 0===o?void 0:o.remoteVideoConfig),d.originalMediaType=n,e.next=17,this._room.subscribe(d,n,p);case 17:gD(n)&&this._updateAudioPlayerState(d),yD(n)&&this._updateVideoPlayerState(d),f=0,_=0,l!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?f|=ll.AUDIO:_|=ll.AUDIO),h!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?f|=ll.VIDEO:_|=ll.VIDEO),f&&this.pauseAllSubscribedStream(f),_&&this.resumeAllSubscribedStream(_),this._pauseAllSubscribeState.resumeStreamIds[d.streamId]=d.streamId,!t&&(null!==(a=this._roomConfig)&&void 0!==a&&a.isAutoSubscribeAudio||null!==(s=this._roomConfig)&&void 0!==s&&s.isAutoSubscribeVideo)&&(d.audioTrack||d.videoTrack)&&(m={userId:r,isScreen:!1,state:al.SUBSCRIBE_SUCC},this.safeEmit(Fl.onAutoSubscribeResult,m)),null!==(c=this._room)&&void 0!==c&&c.multiChatMode||v||!gD(n)||!d.hasAudio||null===(g=d.observer)||void 0===g||g.setSubscribeAudio(!0),!v&&yD(n)&&d.hasVideo&&(null===(y=d.observer)||void 0===y||y.setSubscribeVideo(!0));case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return he.apply(this,arguments)})},{key:"unsubscribeStream",value:(le=xm(wm().mark((function e(t,r){return wm().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 le.apply(this,arguments)})},{key:"subscribeScreen",value:(de=xm(wm().mark((function e(t,r){return wm().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 de.apply(this,arguments)})},{key:"unsubscribeScreen",value:(ue=xm(wm().mark((function e(t,r){return wm().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 ue.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(r!==ll.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a,s=this._room.remoteStreams.get(t),c=null==s?void 0:kE(s).call(s,(function(t){return t.isScreen===e}));if(!c)throw new SA(_A.STREAM_NOT_EXIST,"stream not exist");if(YD&&aM&&aM>=85&&aM<=91&&r!==ll.AUDIO)null===(a=e?this._remoteScreenPlayer.get(t):this._remoteVideoPlayer.get(t))||void 0===a||a.stop();return this._room.unsubscribe(c,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[c.streamId]}))}this.logger.warn("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(ce=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),FM(t),KM(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 ce.apply(this,arguments)})},{key:"startVideoCapture",value:(se=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v,p=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startVideoCapture()","deviceId: %s",t),UM(t)||OM(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==tl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!this._localVideoTrack||this._localVideoTrack.dummy){e.next=8;break}throw new SA(_A.REPEAT_CAPTURE,"Has already capture");case 8:return s=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?(s.facingMode=t,delete s.deviceId):!HD||WD?s.deviceId={exact:t}:delete s.deviceId,this._videoStreamConstraints=s),c={},e.next=13,DF(s,this._extensionManager);case 13:if(u=e.sent,null!==(r=this._videoStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&u.setContentHint(null===(d=this._videoStreamEncodeConfig[0])||void 0===d?void 0:d.contentHint),this._initLocalTrackEvents(u),this._localVideoTrack=u,null===(n=this._videoPlayer)||void 0===n||n.playVideo(u),(l=u.getTrack())&&(c=l.getSettings(),h={width:c.width,height:c.height},this._localVideoTrack.resolution=h,this.autoResetVideoEncoderConfig(c),setTimeout((function(){return p.safeEmit(Fl.onLocalVideoSizeChanged,{streamIndex:dl.STREAM_INDEX_MAIN,info:h})}))),aF.emit("".concat(this.id,"capture-end")),this._room){e.next=23;break}return e.abrupt("return",c);case 23:return v=this._room._roomConfig.isAutoPublish,(null!==(i=this._room.localStream)&&void 0!==i&&i.pubVideo||v)&&(this._visibility?this._updatePublish():this.safeEmit(Fl.onAutoPublishResult,{isScreen:!1,state:sl.PUBLISH_FAIL})),null===(o=this._room.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setEnableVideo(!0),e.abrupt("return",c);case 27:case"end":return e.stop()}}),e,this)}))),function(e){return se.apply(this,arguments)})},{key:"stopVideoCapture",value:(ae=xm(wm().mark((function e(){var t,r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopVideoCapture()"),this._trackSourceType.video!==tl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=3;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 3:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),this._localVideoTrack&&(this._localVideoTrack.dummy||((o=this._extensionManager.getPluginByName(lF.PRE_PROCESSING,"RTCBeautyExtension"))&&o.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(this._localVideoTrack.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=7;break}return e.abrupt("return");case 7:if(null===(r=this._room.localStream)||void 0===r||!r.pubVideo){e.next=10;break}return e.next=10,this._updatePublish();case 10:null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableVideo(!1);case 11:case"end":return e.stop()}}),e,this)}))),function(){return ae.apply(this,arguments)})},{key:"startAudioCapture",value:(oe=xm(wm().mark((function e(t){var r,n,i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startAudioCapture()","deviceId: $o",t),UM(t)||OM(t,"deviceId"),t&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._trackSourceType.audio!==rl.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 5:if(!this._localAudioTrack){e.next=7;break}throw new SA(_A.REPEAT_CAPTURE,"Has already capture");case 7:return o={},e.next=10,LF(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 10:if((a=e.sent).getOrgTrack()&&(o=a.getOrgTrack().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),aF.emit("".concat(this.id,"capture-end")),this._room){e.next=19;break}return e.abrupt("return",o);case 19:return s=this._room._roomConfig.isAutoPublish,(null!==(r=this._room.localStream)&&void 0!==r&&r.pubAudio||s)&&(this._visibility?this._updatePublish():this.safeEmit(Fl.onAutoPublishResult,{isScreen:!1,state:sl.PUBLISH_FAIL})),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 oe.apply(this,arguments)})},{key:"stopAudioCapture",value:(ie=xm(wm().mark((function e(){var t,r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopAudioCapture()"),this._trackSourceType.audio!==rl.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=3;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 3:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._room){e.next=8;break}return e.abrupt("return");case 8:if(null===(t=this._room.localStream)||void 0===t||!t.pubAudio){e.next=11;break}return e.next=11,this._updatePublish();case 11:null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableAudio(!1);case 12:case"end":return e.stop()}}),e,this)}))),function(){return ie.apply(this,arguments)})},{key:"checkAudioAndVideoDeviceId",value:function(e,t){var r;return this.logger.print("startAudioAndVideoCapture","optionsOrAudioDeviceId: $o",e,"videoDeviceId: $o",t),UM(t)||OM(t,"videoDeviceId"),UM(e)||("string"==typeof e?(OM(e,"audioDeviceId"),r=e):(r=null==e?void 0:e.audioDeviceId,t=null==e?void 0:e.videoDeviceId,OM(r,"audioDeviceId"),OM(t,"videoDeviceId"))),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,{audioDeviceId:r,videoDeviceId:t}}},{key:"startAudioAndVideoCapture",value:(ne=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("startAudioAndVideoCapture","optionsOrAudioDeviceId: $o",t,"videoDeviceId: $o",r),l=this.checkAudioAndVideoDeviceId(t,r),h=l.audioDeviceId,v=l.videoDeviceId,r=v,h&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:h}}),this._trackSourceType.video!==tl.VIDEO_SOURCE_TYPE_EXTERNAL&&this._trackSourceType.audio!==rl.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,this._trackSourceType.video===tl.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 SA(_A.REPEAT_CAPTURE,"video has already capture");case 8:if(!this._localAudioTrack){e.next=10;break}throw new SA(_A.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):!HD||WD?p.deviceId={exact:r}:delete p.deviceId,this._videoStreamConstraints=p),f={},_={},e.next=16,VF(this._ctx.audioProfileManager.getConstraints(),p,this._extensionManager);case 16:if(m=e.sent,g=m.audioTrack,y=m.videoTrack,null!==(n=this._videoStreamEncodeConfig[0])&&void 0!==n&&n.contentHint&&y.setContentHint(null===(S=this._videoStreamEncodeConfig[0])||void 0===S?void 0:S.contentHint),this._initLocalTrackEvents(y),this._localVideoTrack=y,null===(i=this._videoPlayer)||void 0===i||i.playVideo(y),this._initLocalTrackEvents(g),this._localAudioTrack=g,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),b=y.getTrack(),f=b.getSettings(),E={width:f.width||0,height:f.height||0},this._localVideoTrack.resolution=E,this.autoResetVideoEncoderConfig(f),setTimeout((function(){return T.safeEmit(Fl.onLocalVideoSizeChanged,{streamIndex:dl.STREAM_INDEX_MAIN,info:E})})),b=g.getOrgTrack(),_=b.getSettings(),aF.emit("".concat(this.id,"capture-end")),this._room){e.next=38;break}return e.abrupt("return",{audioTrackSettings:_,videoTrackSettings:f});case 38:return k=this._room._roomConfig.isAutoPublish,(null!==(o=this._room.localStream)&&void 0!==o&&o.pubVideo||null!==(a=this._room.localStream)&&void 0!==a&&a.pubAudio||k)&&(this._visibility?this._updatePublish():this.safeEmit(Fl.onAutoPublishResult,{isScreen:!1,state:sl.PUBLISH_FAIL})),null===(s=this._room.localStream)||void 0===s||null===(c=s.observer)||void 0===c||c.setEnableVideo(!0),null===(u=this._room.localStream)||void 0===u||null===(d=u.observer)||void 0===d||d.setEnableAudio(!0),e.abrupt("return",{audioTrackSettings:_,videoTrackSettings:f});case 43:case"end":return e.stop()}}),e,this)}))),function(e,t){return ne.apply(this,arguments)})},{key:"startVideoAndAudioCapture",value:(re=xm(wm().mark((function e(t,r){return wm().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 re.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return this.logger.info("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(te=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m=this,g=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=g.length>0&&void 0!==g[0]?g[0]:{},this.logger.info("startScreenCapture()","config: %o",c),u=c.enableAudio,d=void 0!==u&&u,this._trackSourceType.screenVideo!==tl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==rl.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,BF(d,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(l=e.sent,h=aI(l,2),v=h[0],null==(p=h[1])||p.setVolume(this._localScreenAudioVolume),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(t=this._localScreenAudioTrack)||void 0===t||t.close(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=v,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&v.setContentHint(null===(f=this._screenStreamEncodeConfig[0])||void 0===f?void 0:f.contentHint),(_=v.getTrack())&&setTimeout((function(){var e=_.getSettings(),t={width:e.width,height:e.height};v.resolution=t,m.safeEmit(Fl.onLocalVideoSizeChanged,{streamIndex:dl.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),p&&(this._localScreenAudioTrack=p,this._initLocalTrackEvents(p)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),!(null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubAudio||null!==(a=this._room)&&void 0!==a&&null!==(s=a.localScreenStream)&&void 0!==s&&s.pubVideo)){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return te.apply(this,arguments)})},{key:"stopScreenCapture",value:(ee=xm(wm().mark((function e(){var t,r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localImgScreenTrack&&(this._localScreenVideoTrack.setTrack(this._localImgScreenTrack,this._extensionManager),this._localScreenVideoTrack.dummy=!0))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,!(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localScreenStream)&&void 0!==n&&n.pubAudio||null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubVideo)){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return ee.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(this.logger.info("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),PM(e,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,i,o,a=el(el({userId:this._getUserId()},t),{},{isLocal:!0});if(delete a.rotation,GM(a),e===dl.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new rK(this.id,a),this._initPlayerEvents(this._videoPlayer,!1,e),this._videoPlayer.mirror(!!this._mirrorType),this._localVideoTrack&&!this._localVideoTrack.dummy&&(null===(r=this._config)||void 0===r?void 0:r.autoPlayPolicy)!==Al.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),(null===(n=this._room)||void 0===n?void 0:n.localStream)&&(this._room.localStream.videoDom=this._videoPlayer.domElement),this._videoPlayer.domElement;if(e===dl.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new rK(this.id,el(el({},a),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==Al.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),(null===(o=this._room)||void 0===o?void 0:o.localScreenStream)&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),this._screenPlayer.domElement;if(t&&void 0!==t.renderMode){var s=e===dl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer;null==s||s.setRenderMode(t.renderMode)}}else{var c,u;e===dl.STREAM_INDEX_MAIN?(null===(c=this._videoPlayer)||void 0===c||c.destroy(!0),delete this._videoPlayer):(null===(u=this._screenPlayer)||void 0===u||u.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:($=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startLiveTranscoding()","transcode: %o",t),XY.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.roomInfo)&&n.roomId.length+n.userInfo.userId.length>126)){e.next=6;break}throw new SA(_A.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(Fl.onStreamMixingEvent,{event:ZG.START,error:0,message:""}),!this._room||this._room.connectionState!==Iz.CONNECTED){e.next=11;break}return e.next=11,this._room.liveControlMessage(XY.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof SA)){e.next=19;break}throw e.t0;case 19:throw new SA(_A.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return $.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(Z=xm(wm().mark((function e(t){var r,n,i,o;return wm().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=oH({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,XY.checckUpdateParams(i),this._liveTranscodeConfig=oH(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(Fl.onStreamMixingEvent,{event:ZG.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(XY.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof SA)){e.next=21;break}throw e.t0;case 21:throw new SA(_A.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return Z.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(Q=xm(wm().mark((function e(){var t;return wm().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(Fl.onStreamMixingEvent,{event:ZG.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 SA)){e.next=16;break}throw e.t0;case 16:throw new SA(_A.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return Q.apply(this,arguments)})},{key:"startSubtitle",value:(J=xm(wm().mark((function e(t){var r;return wm().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 J.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;this.logger.info("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return this.logger.info("setBusinessId()","businessId: %s",e),!function(e){return"string"!=typeof e}(e)&&!this._room&&(this.monitor.set({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(q=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setUserVisibility()","enable: %o",t),t=!!t,this._visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._visibility=t,e.abrupt("return");case 7:return this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),t||(this._room.unpublish(),this._room.unpublishScreen()),e.next=12,this._room.updateUserAttributes({role:t?OY.NORMAL_USER:OY.SILENT_USER});case 12:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:ll.AUDIO_AND_VIDEO});case 14:case"end":return e.stop()}}),e,this)}))),function(e){return q.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]:dl.STREAM_INDEX_MAIN)===dl.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:kE(a).call(a,(function(e){return e.isScreen===n})),u=function(){r?t.safeEmit(Fl.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(Fl.onAudioFirstFrameDecoded,{userId:s,isScreen:n}),t.safeEmit(Fl.onRemoteAudioFirstFrame,{userId:s,isScreen:n})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:n})};c&&c.observer&&!c.observer.audioFirstFrameReceived?c.observer.once("recvAudioFirstFrame",u):u()}else{var d,l,h={userId:e.userId,height:(null===(d=e.domElement)||void 0===d?void 0:d.videoHeight)||0,width:(null===(l=e.domElement)||void 0===l?void 0:l.videoWidth)||0,isScreen:n};r?(h.publicStreamId=h.userId,delete h.userId,delete h.isScreen,t.safeEmit(Fl.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(Fl.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(Fl.onVideoFirstFrameRendered,h),t.safeEmit(Fl.onVideoFirstFrameDecoded,h),t.safeEmit(Fl.onRemoteVideoFirstFrame,h)),t.monitor.report("first_remote_video_render",{stream_id:"",stream_user_id:i.userId||""},{isScreen:n})}break;case"autoplay-error":return r&&(i.publicStreamId=i.userId),$P(t.id,"autoplay-error",e instanceof rK?"video":"audio",0,i.userId||""),void t.safeEmit(Fl.onAutoplayFailed,{userId:i.userId,kind:e instanceof rK?"video":"audio",mediaType:e instanceof rK?ll.VIDEO:ll.AUDIO,streamIndex:e.isScreen?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN})}t.safeEmit(Fl.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=xm(wm().mark((function e(n){var i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.monitor.report("rtc_error",{message:Mm(i="track-".concat(r," mediaType: ")).call(i,n.getTrack().kind),error_code:nz.TRACK_ERROR,capture_session_id:n.captureSessionId,media_type:r,reason:r}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),a=n.getTrack(),s=a.kind,t.safeEmit({"track-ended":Fl.onTrackEnded,"track-mute":Fl.onTrackMute,"track-unmute":Fl.onTrackUnmute}[r],{kind:s,isScreen:o}),!WD&&!GD){e.next=13;break}if("track-mute"!==r){e.next=12;break}if(aF.emit(iF.ON_IOS_LOCAL_TRACK_MUTE,s),"audio"!==s){e.next=12;break}return e.next=11,t.stopAudioCapture();case 11:t.startAudioCapture();case 12:"track-unmute"===r&&aF.emit(iF.ON_IOS_LOCAL_TRACK_UNMUTE,s);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),e.on("resolution-change",(function(e){t._extensionManager.getPluginsByType(lF.PRE_PROCESSING).forEach((function(t){var n;null==t||null===(n=t.applyConstraints)||void 0===n||n.call(t,r?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN,e)})),t.safeEmit(Fl.onLocalVideoSizeChanged,{streamIndex:r?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN,info:e})}))}},{key:"_removeLocalTrackEvents",value:function(e){e.removeAllListeners("track-ended"),e.removeAllListeners("track-mute"),e.removeAllListeners("track-unmute"),e.removeAllListeners("resolution-change")}},{key:"setRemoteVideoPlayer",value:function(e,t){this.logger.info("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),PM(e,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),GM(t);var r,n,i,o=t.userId;if(e===dl.STREAM_INDEX_MAIN){var a,s,c;if(null===(a=this._remoteVideoPlayer.get(o))||void 0===a||a.destroy(),!t.renderDom)return;var u=new rK(this.id,t);this._initPlayerEvents(u,!1,e),this._remoteVideoPlayer.set(o,u);var d=null===(s=this._room)||void 0===s||null===(c=s.remoteStreams.get(o))||void 0===c?void 0:kE(c).call(c,(function(e){return!e.isScreen}));return d&&(this._updateVideoPlayerState(d),d.videoDom=u.domElement),u.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var l=new rK(this.id,el(el({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(o,l),this._initPlayerEvents(l,!1,e);var h=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(o))||void 0===i?void 0:kE(i).call(i,(function(e){return e.isScreen}));return h&&(this._updateVideoPlayerState(h),h.videoDom=l.domElement),l.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){this.logger.info("setLocalVideoMirrorType()","mirrorType: %o",e),PM(e,"mirrorType",[pl.MIRROR_TYPE_NONE,pl.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(Y=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setAudioPlaybackDevice()","deviceId: %s",t),OM(t,"deviceId"),e.next=4,this._audioDeviceManager.setSinkId(t);case 4:r=e.sent,this._remoteAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._remoteScreenAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this.safeEmit(Fl.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:Fm(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return Y.apply(this,arguments)})},{key:"play",value:(W=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v,p,f,_,m=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=m.length>1&&void 0!==m[1]?m[1]:ll.AUDIO_AND_VIDEO,o=m.length>2?m[2]:void 0,this.logger.info("play()","userId: %s, mediaType: %s, streamIndex: %s",t,i,o),a=!t||t===this._getUserId()||"local_user"===t,s=void 0===o||o===dl.STREAM_INDEX_MAIN,c=void 0===o||o===dl.STREAM_INDEX_SCREEN,u=i!==ll.VIDEO,d=i!==ll.AUDIO,l=[],a&&d&&(s&&this._localVideoTrack&&(null===(h=this._videoPlayer)||void 0===h||h.mirror(!!this._mirrorType),l.push(null===(v=this._videoPlayer)||void 0===v?void 0:v.manuallyPlay())),c&&this._localScreenVideoTrack&&l.push(null===(p=this._screenPlayer)||void 0===p?void 0:p.manuallyPlay())),t===this._audioMixingManager.id&&l.push(this._audioMixingManager.resumeLocalPlay()),f=null===(r=this._room)||void 0===r?void 0:r.remoteStreams,d&&s&&l.push(iK(this._remoteVideoPlayer,t,!1,f)),d&&c&&l.push(iK(this._remoteScreenPlayer,t,!0,f)),u&&s&&l.push(iK(this._remoteAudioPlayer,t,!1,f)),d&&c&&l.push(iK(this._remoteScreenAudioPlayer,t,!0,f)),_=null===(n=this._publicStreamManager)||void 0===n?void 0:n.remoteStreams,u&&l.push(iK(this._publicStreamVideoPlayer,t,!1,_)),d&&l.push(iK(this._publicStreamAudioPlayer,t,!1,_)),e.abrupt("return",$_.all(l).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return W.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(X=xm(wm().mark((function e(t){var r,n,i,o,a,s=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),gD(t)&&(s._pauseAllSubscribeState.audio=!0),yD(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",$_.resolve());case 6:n=[],i=oI(cR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(e.hasSubscribed){s._pauseAllSubscribeState.resumeStreamIds[e.streamId]=e.streamId;var r=s._unsubscribe(e.isScreen,e.userId,t,!0);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",$_.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return X.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(K=xm(wm().mark((function e(t){var r,n,i,o,a,s=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),gD(t)&&(s._pauseAllSubscribeState.audio=!1),yD(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",$_.resolve());case 6:n=[],i=oI(cR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(s._pauseAllSubscribeState.resumeStreamIds[e.streamId]){delete s._pauseAllSubscribeState.resumeStreamIds[e.streamId];var r=s._subscribe(e.isScreen,e.userId,t);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",$_.all(n).then((function(){var e;null===(e=s._room)||void 0===e||e.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){s._updateAudioPlayerState(e),s._updateVideoPlayerState(e)}))}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return K.apply(this,arguments)})},{key:"sendUserMessage",value:(z=xm(wm().mark((function e(t,r){var n,i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FM(t),zM(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!1,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!1,o,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return z.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(G=xm(wm().mark((function e(t,r){var n,i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FM(t),MM(r,"message"),zM(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!0,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!0,o,e),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return G.apply(this,arguments)})},{key:"sendRoomMessage",value:(H=xm(wm().mark((function e(t){var r,n,i,o=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return zM(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return H.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(j=xm(wm().mark((function e(t){var r,n,i,o=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return zM(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t,!0))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return j.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(B=xm(wm().mark((function e(){var t,r=arguments;return wm().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,LM(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._ctx.audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return B.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(F=xm(wm().mark((function e(){var t,r=arguments;return wm().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 F.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(V=xm(wm().mark((function e(){var t,r,n,i=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,LM(r),n=el(el({},r),{},{deviceId:this._videoStreamConstraints.deviceId}),!this._localVideoTrack){e.next=7;break}return e.next=7,this._localVideoTrack.updateVideoCaptureConfig(n);case 7:return this._videoStreamConstraints=n,e.abrupt("return",(null===(t=this._localVideoTrack)||void 0===t?void 0:t.getTrack().getSettings())||{});case 9:case"end":return e.stop()}}),e,this)}))),function(){return V.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return this.logger.info("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==nM[0]&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&TD("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(U=xm(wm().mark((function e(t){var r,n,i,o,a;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(this.logger.info("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),WM(t=Ks(t).call(t,(function(e){return!!e}))),t.length>3&&(TD("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=Am(t).call(t,0,3)),n=1;n<t.length;n++)i=ID(t[0].width)/ID(t[n].width)||1,Math.floor(i)!==i&&TD("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");KR(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),this._setVideoCaptureConfig(el({},t[0])),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(dl.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 12:case"end":return e.stop()}}),e,this)}))),function(e){return U.apply(this,arguments)})},{key:"setVideoEncoderAutoConfigList",value:function(e){if(Array.isArray(e))return KR(e).call(e,(function(e,t){return e.maxKbps-t.maxKbps})),RM(e)}},{key:"autoResetVideoEncoderConfig",value:function(e){var t,r=IM;if(r.length){this._videoStreamEncodeConfig.length||(this._videoStreamEncodeConfig=[AM]);var n=this._videoStreamEncodeConfig[0],i=e.width||ID(n.width),o=e.height||ID(n.height),a=i*o;if(!(ID(n.width)*ID(n.height)<=a)){var s,c,u=r[0];r.forEach((function(e){var t=ID(e.width)*ID(e.height);s||(a<t?s=e:u=e)})),c=s&&ID(s.width)*ID(s.height)-a<a-ID(u.width)*ID(u.height)?Nb({},s):Nb({},u),this._videoStreamEncodeConfig=Ks(t=this._videoStreamEncodeConfig).call(t,(function(e){return!(c&&ID(e.width)*ID(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",Fm(this._videoStreamEncodeConfig)),$P(this.id,"autoResetVideoEncoderConfig",Fm(this._videoStreamEncodeConfig))}}}},{key:"setScreenEncoderConfig",value:(L=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.info("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&("16.1"!==rM&&this._localScreenVideoTrack.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(dl.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(this.logger.info("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!rV())throw new SA(_A.NOT_SUPPORTED,"Browser does not support sending SEI");PM(e,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),xM(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(nD.str2ab(t)):t;if(t.length){var i;if(e===dl.STREAM_INDEX_MAIN){var o,a;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=this._room.localStream}else{var s,c;if(null===(s=this._room)||void 0===s||null===(c=s.localScreenStream)||void 0===c||!c.hasPublished)return;i=this._room.localScreenStream}if(n.byteLength>4096)this.logger.warn("sei size must not bigger than 4KB");else{var u=eD();i.seiList.push({content:n,uuid:u,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=eA(e=i.seiList).call(e,(function(e){return e.uuid===u}));if(r>=0)ak(t=i.seiList).call(t,r,1)}}),2e3)}}else this.logger.warn("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;this.logger.info("setAudioVolumeIndicationInterval()","interval %o: ",e),("number"!=typeof e||e<200)&&(e=200);var r=[];this._audioVolumeIndicationTimer&&clearInterval(this._audioVolumeIndicationTimer),this._audioVolumeIndicationTimer=setInterval((function(){var e,n;r=[],null===(e=t._room)||void 0===e||e.remoteStreams.forEach((function(e,t){var n;if(0!==e.length){var i=kE(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(Fl.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=gb(t).call(t,(function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=n?i?n.audioPropertiesInfo.nonlinearVolume>i.audioPropertiesInfo.nonlinearVolume?n:i:n:i)&&r.audioPropertiesInfo.nonlinearVolume>-35){var o,a;if(r.streamKey)o=this._room.remoteUsers.get(r.streamKey.userId);else o=null===(a=this._room._roomInfo)||void 0===a?void 0:a.userInfo;o&&this.safeEmit(Fl.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger.info("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.localMainReportMode,o=void 0===i?fl.NORMAL:i,a=t.audioReportMode,s=void 0===a?_l.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=mD(d),h={streamIndex:dl.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:d,nonlinearVolume:l}};if(c||u)t.push(h);else switch(o){case fl.DISCONNECT:break;case fl.RESET:h.audioPropertiesInfo.linearVolume=0,h.audioPropertiesInfo.nonlinearVolume=-127,t.push(h);break;case fl.NORMAL:t.push(h);break;default:throw new SA(_A.INVALID_PARAMS,"invalid localMainReportMode: ".concat(o," in config"))}}if(e._localScreenAudioTrack){var v=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:dl.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:v,nonlinearVolume:mD(v)}})}if(e.safeEmit(Fl.onLocalAudioPropertiesReport,t),e._room){var p=[];if(e._room.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i,o=255*t.audioLevel;p.push({streamKey:{userId:t.userId,streamIndex:dl.STREAM_INDEX_MAIN,roomId:null!==(r=null===(n=e._room)||void 0===n||null===(i=n._roomInfo)||void 0===i?void 0:i.roomId)&&void 0!==r?r:""},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:mD(o)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o,a=t.audioTrack.getAudioLevel();p.push({streamKey:{userId:r,streamIndex:t.isScreen?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN,roomId:null!==(n=null===(i=e._room)||void 0===i||null===(o=i.roomInfo)||void 0===o?void 0:o.roomId)&&void 0!==n?n:""},audioPropertiesInfo:{linearVolume:a,nonlinearVolume:mD(a)}})}}))}));e.safeEmit(Fl.onRemoteAudioPropertiesReport,p),e._sendActiveSpeaker(t,Ks(p).call(p,(function(e){return e.streamKey.streamIndex!==dl.STREAM_INDEX_SCREEN})))}}}),u))}},{key:"setVideoSourceType",value:(M=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,R,A;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),PM(t,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),PM(r,"VideoSourceType",[tl.VIDEO_SOURCE_TYPE_EXTERNAL,tl.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===dl.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,this.logger.print("setVideoSourceType",Mm(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==dl.STREAM_INDEX_MAIN){e.next=17;break}if(u=!1,r===tl.VIDEO_SOURCE_TYPE_EXTERNAL&&(u=!0,(d=this._extensionManager.getPluginByName(lF.PRE_PROCESSING,"RTCBeautyExtension"))&&d.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(o=this._videoPlayer)||void 0===o||o.stop(),this._localVideoTrack=void 0,l=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,u?null===(h=this._room)||void 0===h||null===(v=h.localStream)||void 0===v||null===(p=v.observer)||void 0===p||p.setEnableVideo(!1):null===(f=this._room)||void 0===f||null===(_=f.localStream)||void 0===_||null===(m=_.observer)||void 0===m||m.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubVideo||l)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==dl.STREAM_INDEX_SCREEN){e.next=26;break}if(b=!1,r===tl.VIDEO_SOURCE_TYPE_EXTERNAL&&(b=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(g=this._screenPlayer)||void 0===g||g.stop(),this._localScreenVideoTrack=void 0,b?null===(E=this._room)||void 0===E||null===(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 M.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(D=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,p,f;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setExternalVideoTrack()","index: %o, track: %o",t,r),PM(t,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),NM(r),t!==dl.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.video===tl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,GF(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,!r.contentHint&&null!==(n=this._videoStreamEncodeConfig[0])&&void 0!==n&&n.contentHint&&this._localVideoTrack.setContentHint(null===(c=this._videoStreamEncodeConfig[0])||void 0===c?void 0:c.contentHint),this._initLocalTrackEvents(this._localVideoTrack),null===(i=this._videoPlayer)||void 0===i||i.playVideo(this._localVideoTrack),u=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubVideo||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==dl.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenVideo===tl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 19:return e.next=21,WF(r,this._extensionManager);case 21:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(d=this._screenPlayer)||void 0===d||d.playVideo(this._localScreenVideoTrack),null===(l=this._room)||void 0===l||null===(h=l.localScreenStream)||void 0===h||null===(v=h.observer)||void 0===v||v.setPushVideo(!0),null===(p=this._room)||void 0===p||null===(f=p.localScreenStream)||void 0===f||!f.pubVideo){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return D.apply(this,arguments)})},{key:"setAudioSourceType",value:(N=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),PM(t,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),PM(r,"audioSourceType",[rl.AUDIO_SOURCE_TYPE_EXTERNAL,rl.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===dl.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,this.logger.print("setVideoSourceType",Mm(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==dl.STREAM_INDEX_MAIN){e.next=16;break}if(c=!1,this._trackSourceType.audio===rl.AUDIO_SOURCE_TYPE_EXTERNAL&&(c=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,u=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,c?null===(d=this._room)||void 0===d||null===(l=d.localStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setEnableAudio(!1):null===(v=this._room)||void 0===v||null===(p=v.localStream)||void 0===p||null===(f=p.observer)||void 0===f||f.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==dl.STREAM_INDEX_SCREEN){e.next=24;break}if(g=!1,this._trackSourceType.audio===rl.AUDIO_SOURCE_TYPE_EXTERNAL&&(g=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,g?null===(y=this._room)||void 0===y||null===(S=y.localScreenStream)||void 0===S||null===(b=S.observer)||void 0===b||b.setEnableAudio(!1):null===(E=this._room)||void 0===E||null===(k=E.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setPushAudio(!1),null===(_=this._room)||void 0===_||null===(m=_.localScreenStream)||void 0===m||!m.pubAudio){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return N.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(P=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,p;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setExternalAudioTrack()","index: %o, track: %o",t,r),PM(t,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),NM(r),t!==dl.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===rl.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,KF(r,this._extensionManager);case 8:if(this._localAudioTrack=e.sent,this._localAudioTrack.setVolume(this._localAudioVolume),this._initLocalTrackEvents(this._localAudioTrack),u=null===(n=this._room)||void 0===n?void 0:n._roomConfig.isAutoPublish,null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setPushAudio(!0),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==dl.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===rl.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,qF(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(d=this._room)||void 0===d||null===(l=d.localScreenStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setPushAudio(!0),null===(v=this._room)||void 0===v||null===(p=v.localScreenStream)||void 0===p||!p.pubAudio){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return P.apply(this,arguments)})},{key:"login",value:(O=xm(wm().mark((function e(t,r){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("login()","token: %o, userInfo: %o",t,r),UM(t)||OM(t,"token"),FM(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return O.apply(this,arguments)})},{key:"logout",value:(x=xm(wm().mark((function e(){return wm().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 x.apply(this,arguments)})},{key:"updateLoginToken",value:(C=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateLoginToken()","token: %o",t),UM(t)||OM(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(w=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("getPeerOnlineStatus()","userId: %o",t),FM(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(A=xm(wm().mark((function e(t,r){var n,i=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FM(t),zM(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!1,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return A.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(R=xm(wm().mark((function e(t,r){var n,i=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FM(t),MM(r,"message"),zM(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!0,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"setServerParams",value:(I=xm(wm().mark((function e(t,r){return wm().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 I.apply(this,arguments)})},{key:"sendServerMessage",value:(T=xm(wm().mark((function e(t){var r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OM(t,"message"),zM(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!1,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(k=xm(wm().mark((function e(t){var r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MM(t,"message"),zM(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!0,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new SA(_A.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");this.logger.info("startCloudProxy()",e),OM(e.logProxy,"logProxy"),OM(e.accessProxy,"accessProxy"),OM(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=kM("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=kM("LOG_SERVER_URL"),this._originConfigServerUrls=kM("CONFIG_REQUEST_DOMAINS"),EM("ICE_CONFIG_REQUEST_URLS",e.accessProxy),EM("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)),EM("CONFIG_REQUEST_DOMAINS",[e.configProxy]),pM.clearAccessNode(this._appId),pM.clearAccessUrls(),this._ctx.useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){var e,t,r;if(this._room)throw new SA(_A.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:Km(e).call(e,(function(e){return e.replace("https://","").replace("/dispatch/v1/AccessInfo?Action=GetAccessInfo","")}));EM("ICE_CONFIG_REQUEST_URLS",null!=n?n:[]),EM("LOG_SERVER_URL",null!==(t=this._originLogServerUrl)&&void 0!==t?t:""),EM("CONFIG_REQUEST_DOMAINS",null!==(r=this._originConfigServerUrls)&&void 0!==r?r:[]),pM.clearAccessNode(this._appId),pM.clearAccessUrls(),this._ctx.useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(E=xm(wm().mark((function e(t,r){var n,i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),BM(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new SA(_A.REPEAT_PUSH,"repeat push public media stream");case 5:return o=TM(t,"started",r),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.publicStreamControlMessage(o))||void 0===i?void 0:i.then((function(){a._publicStreamIds.set(t,t)})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return E.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(b=xm(wm().mark((function e(t,r){var n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),BM(t),this._assertNotInRoom(),i=TM(t,"layoutChanged",r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.publicStreamControlMessage(i));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"stopPushPublicStream",value:(S=xm(wm().mark((function e(t){var r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startPushPublicStream()","publicStreamId: %o",t),BM(t),this._assertNotInRoom(),e.abrupt("return",null===(r=this._room)||void 0===r?void 0:r.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){n._publicStreamIds.delete(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"startPlayPublicStream",value:(y=xm(wm().mark((function e(t){var r,n,i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BM(t),this._publicStreamManager){e.next=8;break}return this._publicStreamManager=new DY(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.on(QG.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=a._publicStreamAudioPlayer.get(t.streamId);n&&t.audioTrack&&(n.stop(),n.playAudio(null===(r=e.stream)||void 0===r?void 0:r.audioTrack));var i,o=a._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),this._publicStreamManager.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,a.safeEmit(Fl.onPublicStreamStats,e)})),this._publicStreamManager.on(QG.ON_SEI_MESSAGED_RECEIVED,(function(e){a.safeEmit(Fl.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._publicStreamManager.connect();case 8:return e.next=10,this._publicStreamManager.startPlayPublicStream(t);case 10:r=e.sent,(n=this._publicStreamVideoPlayer.get(t))&&r.videoTrack&&n.playVideo(r.videoTrack,r),!(i=this._publicStreamAudioPlayer.get(t))&&r.audioTrack&&(i=new nK(this.id,t,{muted:(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)===Al.VIDEO_ONLY,isScreen:!1}),this._initPlayerEvents(i,!0),i.playAudio(r.audioTrack),this._publicStreamAudioPlayer.set(t,i));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(g=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publicStreamManager){e.next=2;break}return e.abrupt("return");case 2:this._publicStreamManager.stopPlayPublicStream(t),(r=this._publicStreamAudioPlayer.get(t))&&(r.destroy(),this._publicStreamAudioPlayer.delete(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"setAudioProfile",value:(m=xm(wm().mark((function e(t){return wm().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 m.apply(this,arguments)})},{key:"setAudioEncodeMaxBitrate",value:(_=xm(wm().mark((function e(t){var r,n,i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setAudioEncodeMaxBitrate()",t),xM(t,"maxBitrate",6,256),this._ctx.audioProfileManager.setCustomMaxBitrate(t),!this._ctx.audioProfileManager.customMaxBitrate){e.next=10;break}if(!DD||!(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 SA(_A.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(dl.STREAM_INDEX_MAIN,t);case 8:return e.next=10,null===(s=this._room)||void 0===s?void 0:s.setAudioEncodeMaxBitrate(dl.STREAM_INDEX_SCREEN,t);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i;this.logger.print("setPublicStreamVideoPlayer()","publicStreamId: %o, videoPlayerOption: %o",e,t);var o=this._publicStreamVideoPlayer.get(e);if(null===(r=o)||void 0===r||r.destroy(),t.renderDom){o=new rK(this.id,el(el({},t),{},{userId:e})),this._initPlayerEvents(o,!0),this._publicStreamVideoPlayer.set(e,o);var a=null===(n=this._publicStreamManager)||void 0===n?void 0:n.remoteStreams.get(e);null!=a&&a.videoTrack&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==Al.PLAY_MANUALLY&&o.playVideo(a.videoTrack,a)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(f=xm(wm().mark((function e(t,r){var n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new $_((function(e,i){OM(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===dl.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new SA(_A.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new SA(_A.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return f.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===dl.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=ID(r.width),c=ID(r.height);if(!a)throw new SA(_A.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===dl.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===dl.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=xm(wm().mark((function e(r,n){var i,o,a;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=17;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.prev=2,e.next=5,t._localVideoTrack.generatePreProcessingTrack(t._extensionManager);case 5:e.next=10;break;case 7:e.prev=7,e.t0=e.catch(2),n(e.t0);case 10:if(t._initLocalTrackEvents(t._localVideoTrack),null!==(i=t._videoPlayer)&&void 0!==i&&i.played&&(t._videoPlayer.stop(),t._videoPlayer.playVideo(t._localVideoTrack),t._videoPlayer.mirror(!!t._mirrorType)),t.safeEmit(Fl.onLocalStreamTrackChangedByExtension,{streamIndex:dl.STREAM_INDEX_MAIN,type:"video"}),r(),null===(o=t._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.pubVideo){e.next=17;break}return e.next=17,t._updatePublish();case 17:r();case 18:case"end":return e.stop()}}),e,null,[[2,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"registerExtension",value:(p=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.monitor=this.monitor,e.prev=1,e.next=4,t.isSupported();case 4:if(e.sent){e.next=7;break}throw new Error("This extension is not supported.");case 7:e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(1),new Error("This extension is not supported.");case 12:return e.next=14,t.init({videoCaptureConfig:this._videoStreamConstraints});case 14:this._extensionManager.register(t),this._addListenExtensionEvent(t);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return p.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(Fm(XY.getDefaultValue()))}},{key:"_updatePublish",value:(v=xm(wm().mark((function e(){var t,r,n,i=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},this.logger.info("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:$G.PUB},t=el(el({},r),t),this._visibility){e.next=6;break}throw new SA(_A.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===Iz.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 15:this._videoPlayer&&this._room.localStream&&(this._room.localStream.videoDom=this._videoPlayer.domElement),e.next=25;break;case 18:if(e.prev=18,e.t0=e.catch(12),!(e.t0 instanceof SA)){e.next=24;break}throw e.t0;case 24:throw new SA(_A.UNEXPECTED_ERROR,"unexpected error",e.t0);case 25:return e.prev=25,n(),e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[12,18,25,28]])}))),function(){return v.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(h=xm(wm().mark((function e(t,r){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),OM(t,"filePath"),xM(r,"indicationInterval"),e.next=5,this._audioDeviceManager.startAudioPlaybackDeviceTest(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this.logger.info("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(l=xm(wm().mark((function e(t,r){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),xM(t,"indicationInterval"),e.next=4,this._audioDeviceManager.startAudioDeviceRecordTest(t,r,this._localAudioVolume);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){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{FM(e),PM(t,"priority",[El.HIGH,El.MEDIUM,El.LOW])}catch(n){return console.warn(n),!1}return this._ctx.userPriority.set(e,t),null===(r=this._room)||void 0===r||r.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(d=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("takeLocalSnapshot()","streamIndex: %o",t),PM(t,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),r=t===dl.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new SA(_A.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===dl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",FY(r.getTrack("preprocessing"),(null==n?void 0:n.mirrorType)===pl.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(u=xm(wm().mark((function e(t,r){var n,i,o,a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),OM(t,"id"),PM(r,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),c=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=kE(i).call(i,(function(e){return e.isScreen===(r===dl.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._publicStreamManager)||void 0===a||null===(s=a.remoteStreams.get(t))||void 0===s?void 0:s.videoTrack)){e.next=6;break}throw new SA(_A.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",FY(c.getTrack(),!1,r===dl.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){this.logger.info("setSubscribeFallbackOption()","option: %o",e);try{PM(e,"option",[bl.DISABLE,bl.VIDEO_STREAM_LOW,bl.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===dl.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 QF&&r.mixedAudioTrack?r.mixedAudioTrack:r.getTrack("preprocessing");if(o){var a=n();return this._reportMsTrackEvent(o,(null==a?void 0:a.stream.id)||"local"),o}}}},{key:"getRemoteStreamTrack",value:function(e,t,r){var n,i,o=(null===(n=this._room)||void 0===n?void 0:n.remoteStreams.get(e))||[];if(o&&o.length){var a,s,c,u,d;if(t===dl.STREAM_INDEX_MAIN)a=kE(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=kE(o).call(o,(function(e){return e.isScreen})),i="video"===r?null===(u=a)||void 0===u?void 0:u.videoTrack:null===(d=a)||void 0===d?void 0:d.audioTrack;if(i){var l=i.getTrack();if(l&&a){var h=a.streamId;return this._reportMsTrackEvent(l,h),l}}}}},{key:"getPublicStreamTrack",value:function(e,t){if(this._publicStreamManager&&this._publicStreamManager.remoteStreams){var r=this._publicStreamManager.remoteStreams.get(e);if(r){var n="video"===t?r.videoTrack:r.audioTrack;if(n){var i=n.getTrack();if(i){var o=r.streamId;return this._reportMsTrackEvent(i,o),i}}}}}},{key:"setRemoteStreamRenderSync",value:function(e){return!this._room&&(this._ctx.avSync=!!e,!0)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i;(PM(e,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),t=YM(t,"volume",0,400),e===dl.STREAM_INDEX_SCREEN)?(null===(r=this._localScreenAudioTrack)||void 0===r||r.setVolume(t),this._localScreenAudioVolume=t):(null===(n=this._localAudioTrack)||void 0===n||n.setVolume(t),null===(i=this._audioDeviceManager.audioTrack)||void 0===i||i.setVolume(t),this._localAudioVolume=t)}},{key:"setPlaybackVolume",value:function(e,t,r){var n,i,o;if(FM(e),PM(t,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),r=YM(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)TD("setPlaybackVolume is not supported in Conference mode");else{var a=t===dl.STREAM_INDEX_SCREEN;a?this._remoteScreenAudioVolume.set(e,r):this._remoteAudioVolume.set(e,r),null===(i=this._room)||void 0===i||null===(o=i.remoteStreams.get(e))||void 0===o||o.forEach((function(e){var t;e.isScreen===a&&(null===(t=e.audioTrack)||void 0===t||t.setVolume(r))}))}}},{key:"setPublicStreamVolume",value:function(e,t){var r,n,i;OM(e,"publicStreamId"),t=YM(t,"volume",0,400),this._publicAudioVolume.set(e,t),null===(r=this._publicStreamManager)||void 0===r||null===(n=r.remoteStreams.get(e))||void 0===n||null===(i=n.audioTrack)||void 0===i||i.setVolume(t)}},{key:"startForwardStreamToRooms",value:(c=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){VM(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.startForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"updateForwardStreamToRooms",value:(s=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){VM(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.updateForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"stopForwardStreamToRooms",value:(a=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.stopForwardStream2Rooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"pauseForwardStreamToAllRooms",value:(o=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.pauseForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"resumeForwardStreamToAllRooms",value:(i=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.resumeForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_reportMsTrackEvent",value:function(e,t){var r=this;if(!e.hookStop){e.hookStop=!0;var n=e.stop;e.stop=function(){$P(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=xm(wm().mark((function e(){var t,r,n,i=arguments;return wm().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:$G.PUB},t=el(el({},r),t),this._visibility){e.next=6;break}throw new SA(_A.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===Iz.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 15:this._screenPlayer&&this._room.localScreenStream&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),e.next=25;break;case 18:if(e.prev=18,e.t0=e.catch(12),!(e.t0 instanceof SA)){e.next=24;break}throw e.t0;case 24:throw new SA(_A.UNEXPECTED_ERROR,"unexpected error",e.t0);case 25:return e.prev=25,n(),e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[12,18,25,28]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){this.logger.info("_updateAudioPlayerState()");var t,r=e.userId,n=e.isScreen,i=n?this._remoteScreenAudioPlayer:this._remoteAudioPlayer,o=i.get(r);if(e.audioTrack&&e.attributes.audiostream&&e.subAudio){var a,s,c,u=n?null!==(a=this._remoteScreenAudioVolume.get(r))&&void 0!==a?a:100:null!==(s=this._remoteAudioVolume.get(r))&&void 0!==s?s:100;if(e.audioTrack.setVolume(u),!o){var d;o=new nK(this.id,r,{muted:(null===(d=this._config)||void 0===d?void 0:d.autoPlayPolicy)===Al.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN),i.set(r,o);var l=this._audioDeviceManager.getSinkId();l&&o.setPlaybackDevice(l)}(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)!==Al.PLAY_MANUALLY&&o.playAudio(e.audioTrack),MD&&GD&&(t=this._remoteAudioPlayer,KY&&clearTimeout(KY),KY=setTimeout((function(){var e,r=oI(t);try{for(r.s();!(e=r.n()).done;){var n=aI(e.value,2),i=n[0],o=n[1];null!=i&&fA(i).call(i,"mux")&&o.pause()}}catch(l){r.e(l)}finally{r.f()}var a,s=oI(t);try{for(s.s();!(a=s.n()).done;){var c=aI(a.value,2),u=c[0],d=c[1];null!=u&&fA(u).call(u,"mux")&&d.manuallyPlay()}}catch(l){s.e(l)}finally{s.f()}}),2e3))}else{var h;null===(h=o)||void 0===h||h.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;this.logger.info("_updateVideoPlayerState()");var r,n,i=e.userId;if(r=e.isScreen?this._remoteScreenPlayer.get(i):this._remoteVideoPlayer.get(i),e.videoTrack)r&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==Al.PLAY_MANUALLY&&r.playVideo(e.videoTrack,e);else if(null!==(t=r)&&void 0!==t&&t.played){var o;null===(o=r)||void 0===o||o.stop()}}},{key:"_onAddStream",value:(r=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.stream).videoDom=null===(r=this._remoteVideoPlayer.get(n.userId))||void 0===r?void 0:r.domElement,i=n.attributes,o=i.localaudio,a=i.audiostream,s=i.localvideo,c=i.videostream,u=$F.NONE,a&&(u|=ll.AUDIO),c&&(u|=ll.VIDEO),!u){e.next=12;break}return e.next=9,new $_((function(e){return setTimeout(e)}));case 9:n.isScreen?this.safeEmit(Fl.onUserPublishScreen,{userId:n.userId,mediaType:u}):(this.safeEmit(Fl.onUserPublishStream,{userId:n.userId,mediaType:u,videoStreamDescriptions:n.attributes.videoDescriptions}),this._handleAutoSubscribe(n,!0)),this.safeEmit("onAddStream",{userId:n.userId,mediaType:u,isScreen:!!n.isScreen}),n.isScreen||(o&&this.safeEmit(Fl.onUserStartAudioCapture,{userId:n.userId}),s&&this.safeEmit(Fl.onUserStartVideoCapture,{userId:n.userId}));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=$F.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=ll.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=ll.VIDEO),i){var o,a;if(t&&gD(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&yD(i))null===(a=e.observer)||void 0===a||a.setAutoSubscribeVideo(!0);this._subscribe(!1,e.userId,i)}}},{key:"_onRemoveStream",value:function(e){var t,r=this,n=e.stream,i=null!==(t=QY[e.reason])&&void 0!==t?t:hl.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?Fl.onUserUnpublishScreen:Fl.onUserUnpublishStream,a=$F.NONE;n.attributes.audiostream&&(a|=ll.AUDIO),n.attributes.videostream&&(a|=ll.VIDEO),a!==$F.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),"function"==typeof e.callback&&e.callback(),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){n.isScreen?(r._remoteScreenPlayer.delete(n.userId),r._remoteScreenAudioPlayer.delete(n.userId)):(r._remoteAudioPlayer.delete(n.userId),r._remoteVideoPlayer.delete(n.userId)),null==e||e.destroy()}))}},{key:"_onUserConnection",value:function(e){var t=this;setTimeout((function(){return t.safeEmit(Fl.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){var t=this,r=e.userInfo;this._getRemotePlayer(r.userId,!0).forEach((function(e){t._remoteScreenAudioPlayer.delete(r.userId),t._remoteScreenPlayer.delete(r.userId),null==e||e.destroy()})),this._getRemotePlayer(r.userId,!1).forEach((function(e){t._remoteAudioPlayer.delete(r.userId),t._remoteVideoPlayer.delete(r.userId),null==e||e.destroy()})),this.safeEmit(Fl.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(Fl.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,Mm(e=[Fl.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._ctx.useCloudProxy&&e.state===vl.CONNECTION_STATE_CONNECTED&&this.safeEmit(Fl.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(Fl.onConnectionStateChanged,e),e.state===vl.CONNECTION_STATE_RECONNECTING){var t,r=oI(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=aI(t.value,2),i=n[0],o=n[1];fA(i).call(i,"mux")&&o.stop()}}catch(a){r.e(a)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ll.AUDIO_AND_VIDEO,n=(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),i=(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e),o=[];return r&ll.AUDIO&&o.push(n),r&ll.VIDEO&&o.push(i),o}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){e.stream&&(this._getRemotePlayer(e.stream.userId,e.stream.isScreen).forEach((function(e){return null==e?void 0:e.stop()})),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){var t=this;if(e.stream){this._updateAudioPlayerState(e.stream);var r=e.stream;this._getRemotePlayer(r.userId,r.isScreen,e.mediaType).forEach((function(n){e.mediaType&ll.AUDIO&&(r.isScreen?t._remoteScreenAudioPlayer.delete(r.userId):t._remoteAudioPlayer.delete(r.userId)),r.isScreen?e.mediaType&ll.VIDEO&&t._remoteScreenPlayer.delete(r.userId):e.mediaType&ll.VIDEO&&t._remoteVideoPlayer.delete(r.userId),null==n||n.destroy()}))}}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(Fl.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(Fl.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&ll.AUDIO&&setTimeout((function(){t._updateAudioPlayerState(a)})),n?o===$G.PUB?this.safeEmit(Fl.onUserPublishScreen,s):this.safeEmit(Fl.onUserUnpublishScreen,el(el({},s),{},{reason:hl.STREAM_REMOVE_REASON_UNPUBLISH})):o===$G.PUB?(s.videoStreamDescriptions=a.attributes.videoDescriptions,this.safeEmit(Fl.onUserPublishStream,s),this._handleAutoSubscribe(a,!0)):this.safeEmit(Fl.onUserUnpublishStream,el(el({},s),{},{reason:hl.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(Fl.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(Fl.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Fl.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Fl.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(Fl.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(Fl.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Fl.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(Fl.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Fl.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Fl.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(Fl.onError,{errorCode:_A.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(Fl.onError,{errorCode:_A.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(Fl.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"waitForNewToken",get:function(){return!!this._tempRoomInfo}},{key:"getSubLock",value:function(e,t){var r,n=e?this._subScreenLocks:this._subLocks,i=n.get(t);i||(i=new JG(Mm(r="sub_".concat(e?1:0,"_")).call(r,t)),n.set(t,i));return i}},{key:"localAudioTrack",get:function(){return this._localAudioTrack}},{key:"localVideoTrack",get:function(){return this._localVideoTrack}},{key:"localScreenAudioTrack",get:function(){return this._localScreenAudioTrack}},{key:"localScreenVideoTrack",get:function(){return this._localScreenVideoTrack}},{key:"remoteStreams",get:function(){var e,t=[];return null!==(e=this._room)&&void 0!==e&&e.remoteStreams&&this._room.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){t.push({userId:e.userId,isScreen:e.isScreen,hasVideo:e.hasVideo,hasAudio:e.hasAudio,videoStreamDescriptions:e.attributes.videoDescriptions})}))})),t}},{key:"iceState",get:function(){var e,t,r;return null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient.handler)||void 0===t||null===(r=t._peerConnection)||void 0===r?void 0:r.iceConnectionState}},{key:"remoteUsers",get:function(){var e,t=[];return null!==(e=this._room)&&void 0!==e&&e.remoteUsers&&this._room.remoteUsers.forEach((function(e){t.push({userId:e.userId})})),t}},{key:"multiChatMode",get:function(){var e;return!(null===(e=this._room)||void 0===e||!e._mediaServerClient.roomAttributes.multiChatMode)}},{key:"checkMediaType",get:function(){return this._checkMediaType}},{key:"assertNotInRoom",get:function(){return this._assertNotInRoom}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(Fl.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==Iz.CONNECTED)throw new SA(_A.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){PM(e,"mediaType",[ll.AUDIO,ll.VIDEO,ll.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e,t;return(null===(e=this._room)||void 0===e||null===(t=e.roomInfo)||void 0===t?void 0:t.userInfo.userId)||"local_user"}},{key:"_switchTrack",value:(t=xm(wm().mark((function e(t){var r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,null!==(r=this._videoPlayer)&&void 0!==r&&r.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(t),this._videoPlayer.mirror(!!this._mirrorType)),null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||!i.pubVideo){e.next=6;break}return e.next=6,this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_shouldUpdateAudioConf",value:function(e){var t,r,n,i=(null===(t=this._room)||void 0===t?void 0:t.hasPublished)||(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n?void 0:n.pubAudio)||this._localAudioTrack&&this._localAudioTrack.sourceType===vF.INTERNAL;if(i){var o="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: ".concat(o)),$P(this.id,e,o)}return!i}},{key:"_getServerConfig",value:function(){var e=this,t=pM.getServerConfig(this.appId);t.rts_report&&VP.setConfig(t.rts_report),this._ctx.joinRoomConfig.setServerConfig(t.web_join_room),this._getServerConfigExecutor(t),_N({engineId:this.id,appId:this.appId,sdkVersion:kM("VERSION"),requestDomains:kM("CONFIG_REQUEST_DOMAINS"),keys:["rts_report","web_join_room","web_rtc_config"],deviceId:kM("DEVICE_ID")}).then((function(t){pM.setServerConfig(e.appId,t)}))}},{key:"_getServerConfigExecutor",value:function(e){var t,r,n,i;Bw.setParameter("UPLOAD_CONSOLE_ON",!(null==e||null===(t=e.web_rtc_config)||void 0===t||!t.upload_console_on)),Bw.setParameter("UPLOAD_CONSOLE_LENGTH_CUT",null==e||null===(r=e.web_rtc_config)||void 0===r?void 0:r.upload_console_length_cut),Bw.setParameter("UPLOAD_REPORT_LIMIT",null==e||null===(n=e.web_rtc_config)||void 0===n?void 0:n.upload_report_limit),Bw.setParameter("ENABLE_REPORT_IDB_BUFFER",!(null==e||null===(i=e.web_rtc_config)||void 0===i||!i.enable_report_idb_buffer))}}]),Ie}($M);qY([JP()],JY.prototype,"updateToken",1),qY([JP(),eq("video")],JY.prototype,"setVideoCaptureDevice",1),qY([JP(),eq("audio")],JY.prototype,"setAudioCaptureDevice",1),qY([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=YP(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)}}},JP()],JY.prototype,"connect",1),qY([JP()],JY.prototype,"joinRoom",1),qY([JP()],JY.prototype,"leaveRoom",1),qY([JP()],JY.prototype,"destroy",1),qY([JP()],JY.prototype,"publishStream",1),qY([JP()],JY.prototype,"unpublishStream",1),qY([JP()],JY.prototype,"publishScreen",1),qY([JP()],JY.prototype,"unpublishScreen",1),qY([JP()],JY.prototype,"subscribeStream",1),qY([ZY],JY.prototype,"_subscribe",1),qY([JP()],JY.prototype,"unsubscribeStream",1),qY([JP()],JY.prototype,"subscribeScreen",1),qY([JP()],JY.prototype,"unsubscribeScreen",1),qY([ZY],JY.prototype,"_unsubscribe",1),qY([JP(),$Y],JY.prototype,"setRemoteVideoConfig",1),qY([JP(),eq("video")],JY.prototype,"startVideoCapture",1),qY([JP(),eq("video")],JY.prototype,"stopVideoCapture",1),qY([JP(),eq("audio")],JY.prototype,"startAudioCapture",1),qY([JP(),eq("audio")],JY.prototype,"stopAudioCapture",1),qY([JP(),eq("all")],JY.prototype,"startAudioAndVideoCapture",1),qY([JP()],JY.prototype,"startVideoAndAudioCapture",1),qY([JP()],JY.prototype,"getAudioMixingManager",1),qY([JP(),tq],JY.prototype,"startScreenCapture",1),qY([JP(),tq],JY.prototype,"stopScreenCapture",1),qY([JP()],JY.prototype,"setLocalVideoPlayer",1),qY([JP()],JY.prototype,"startLiveTranscoding",1),qY([JP()],JY.prototype,"updateLiveTranscoding",1),qY([JP()],JY.prototype,"stopLiveTranscoding",1),qY([JP()],JY.prototype,"startSubtitle",1),qY([JP()],JY.prototype,"stopSubtitle",1),qY([JP()],JY.prototype,"setBusinessId",1),qY([JP()],JY.prototype,"setUserVisibility",1),qY([JP()],JY.prototype,"setRemoteVideoPlayer",1),qY([JP()],JY.prototype,"setLocalVideoMirrorType",1),qY([JP()],JY.prototype,"setAudioPlaybackDevice",1),qY([JP()],JY.prototype,"play",1),qY([JP()],JY.prototype,"pauseAllSubscribedStream",1),qY([JP()],JY.prototype,"resumeAllSubscribedStream",1),qY([JP()],JY.prototype,"sendUserMessage",1),qY([JP()],JY.prototype,"sendUserBinaryMessage",1),qY([JP()],JY.prototype,"sendRoomMessage",1),qY([JP()],JY.prototype,"sendRoomBinaryMessage",1),qY([JP()],JY.prototype,"setAudioCaptureConfig",1),qY([kD("4.51"),JP()],JY.prototype,"setVideoCaptureConfig",1),qY([JP()],JY.prototype,"enableSimulcastMode",1),qY([JP()],JY.prototype,"setVideoEncoderConfig",1),qY([JP()],JY.prototype,"setScreenEncoderConfig",1),qY([JP()],JY.prototype,"sendSEIMessage",1),qY([kD("4.42"),JP()],JY.prototype,"setAudioVolumeIndicationInterval",1),qY([JP()],JY.prototype,"enableAudioPropertiesReport",1),qY([JP()],JY.prototype,"setVideoSourceType",1),qY([JP()],JY.prototype,"setExternalVideoTrack",1),qY([JP()],JY.prototype,"setAudioSourceType",1),qY([JP()],JY.prototype,"setExternalAudioTrack",1),qY([JP()],JY.prototype,"login",1),qY([JP()],JY.prototype,"logout",1),qY([JP()],JY.prototype,"updateLoginToken",1),qY([JP()],JY.prototype,"getPeerOnlineStatus",1),qY([JP()],JY.prototype,"sendUserMessageOutsideRoom",1),qY([JP()],JY.prototype,"sendUserBinaryMessageOutsideRoom",1),qY([JP()],JY.prototype,"setServerParams",1),qY([JP()],JY.prototype,"sendServerMessage",1),qY([JP()],JY.prototype,"sendServerBinaryMessage",1),qY([JP()],JY.prototype,"startCloudProxy",1),qY([JP()],JY.prototype,"stopCloudProxy",1),qY([JP()],JY.prototype,"startPushPublicStream",1),qY([JP()],JY.prototype,"updatePublicStreamParam",1),qY([JP()],JY.prototype,"stopPushPublicStream",1),qY([JP("streamId")],JY.prototype,"startPlayPublicStream",1),qY([JP("streamId")],JY.prototype,"stopPlayPublicStream",1),qY([JP()],JY.prototype,"setAudioProfile",1),qY([JP()],JY.prototype,"setAudioEncodeMaxBitrate",1),qY([JP()],JY.prototype,"setPublicStreamVideoPlayer",1),qY([JP()],JY.prototype,"setDummyCaptureImagePath",1),qY([JP()],JY.prototype,"registerExtension",1),qY([JP()],JY.prototype,"startAudioPlaybackDeviceTest",1),qY([JP()],JY.prototype,"stopAudioPlaybackDeviceTest",1),qY([JP()],JY.prototype,"startAudioDeviceRecordTest",1),qY([JP()],JY.prototype,"stopAudioDeviceRecordAndPlayTest",1),qY([JP()],JY.prototype,"stopAudioDevicePlayTest",1),qY([JP(),$Y],JY.prototype,"setRemoteUserPriority",1),qY([JP()],JY.prototype,"takeLocalSnapshot",1),qY([JP()],JY.prototype,"takeRemoteSnapshot",1),qY([JP()],JY.prototype,"setSubscribeFallbackOption",1),qY([JP()],JY.prototype,"getLocalStreamTrack",1),qY([JP()],JY.prototype,"getRemoteStreamTrack",1),qY([JP()],JY.prototype,"getPublicStreamTrack",1),qY([JP()],JY.prototype,"setRemoteStreamRenderSync",1),qY([JP()],JY.prototype,"startForwardStreamToRooms",1),qY([JP()],JY.prototype,"updateForwardStreamToRooms",1),qY([JP()],JY.prototype,"stopForwardStreamToRooms",1),qY([JP()],JY.prototype,"pauseForwardStreamToAllRooms",1),qY([JP()],JY.prototype,"resumeForwardStreamToAllRooms",1);var QY={"client unpublished":hl.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":hl.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":hl.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":hl.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":hl.STREAM_REMOVE_REASON_REPUBLISH};function ZY(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var t,r,i,o,a,s,c,u=arguments;return wm().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 $Y(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var t,r,i,o,a,s=arguments;return wm().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 eq(e){return function(t,r,n){var i=n.value;return n.value=xm(wm().mark((function t(){var r,n,o,a,s,c=arguments;return wm().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,$_.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 tq(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var t,r,i,o,a=arguments;return wm().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}function rq(e){var t=pM.getServerConfig(e).web_rtc_config;return!(null==t||!t.fallback)||!!kM("ENABLE_FALLBACK_HANDLER")}var nq,iq=cd,oq=ic,aq=function(e,t,r,n){for(var i,o=n>1?void 0:n?oq(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&&iq(t,r,o),o},sq=function(e){UI(i,e);var t,r,n=eR(i);function i(e,t,r){var o;return Hl(this,i),Zd(sI(o=n.call(this,e,t,r)),"singleStreamRenderMode",!1),o.id=t,o.logger=new fN("BLWEngine",0,t),RM([{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 jl(i,[{key:"subscribeStream",value:(r=xm(wm().mark((function e(t,r){var n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("subscribeStream()","userId: %o, mediaType: %o",t,r),this.singleStreamRenderMode&&yD(r)&&MI(DI(i.prototype),"subscribeScreen",this).call(this,t,ll.VIDEO).catch((function(e){n.logger.error("singleStreamRenderMode subscribeScreen()",e)})),e.abrupt("return",MI(DI(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=xm(wm().mark((function e(t,r){var n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this.singleStreamRenderMode&&yD(r)&&MI(DI(i.prototype),"unsubscribeScreen",this).call(this,t,ll.VIDEO).catch((function(e){n.logger.error("singleStreamRenderMode unsubscribeScreen()",e)})),e.abrupt("return",MI(DI(i.prototype),"unsubscribeStream",this).call(this,t,r));case 3:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"setRemoteScreenVideoStreamIndex",value:function(e){var t;return this.logger.print("setRemoteScreenVideoStreamIndex()","streamIndex: %o",e),(null===(t=this._room)||void 0===t?void 0:t.connectionState)!==Iz.CONNECTED&&(this.singleStreamRenderMode=e===dl.STREAM_INDEX_MAIN,!0)}},{key:"setRemoteVideoPlayer",value:function(e,t){if(this.logger.print("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),!this.singleStreamRenderMode||e!==dl.STREAM_INDEX_SCREEN)return MI(DI(i.prototype),"setRemoteVideoPlayer",this).call(this,e,t)}},{key:"destroy",value:function(){this.singleStreamRenderMode=!1,MI(DI(i.prototype),"destroy",this).call(this)}},{key:"_updateVideoPlayerState",value:function(e){var t,r;if(!this.singleStreamRenderMode)return MI(DI(i.prototype),"_updateVideoPlayerState",this).call(this,e);var n,o=e.userId,a=null===(t=this._room)||void 0===t?void 0:t.remoteStreams.get(o);Array.isArray(a)&&a.forEach((function(e){e.isScreen&&(n=e)}));var s=this._remoteVideoPlayer.get(o);if(s){if(!e.isScreen&&null!==(r=n)&&void 0!==r&&r.videoTrack)return this.logger.print("_updateVideoPlayerState","prevent play main stream"),void s.playVideo(n.videoTrack,n);var c;if(e.videoTrack)(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)!==Al.PLAY_MANUALLY&&s.playVideo(e.videoTrack,e);else s.played&&s.stop()}}},{key:"_handleEngineEvents",value:function(){var e=this;this.on(Fl.onUserPublishScreen,(function(t){if(e.singleStreamRenderMode&&yD(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:kE(i).call(i,(function(e){return!e.isScreen})),a=null==i?void 0:kE(i).call(i,(function(e){return e.isScreen}));null!=a&&a.hasSubscribed?(e.logger.info("onUserPublishScreen","singleStreamRenderMode screen hasSubscribed"),e._updateVideoPlayerState(a)):(null!==(n=e._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo||null!=o&&o.hasSubscribed&&yD(o.subMediaType))&&(e.logger.info("onUserPublishScreen","singleStreamRenderMode subscribeScreen"),e.subscribeScreen(t.userId,ll.VIDEO))}})),this.on(Fl.onUserUnpublishScreen,(function(t){if(e.singleStreamRenderMode&&yD(t.mediaType)){var r,n=e._remoteVideoPlayer.get(t.userId),i=null===(r=e._room)||void 0===r?void 0:r.remoteStreams.get(t.userId),o=null==i?void 0:kE(i).call(i,(function(e){return!e.isScreen}));if(null==o||!o.videoTrack||!n)return;n.playVideo(o.videoTrack)}}))}}]),i}(JY);aq([JP()],sq.prototype,"subscribeStream",1),aq([JP()],sq.prototype,"unsubscribeStream",1),aq([JP()],sq.prototype,"setRemoteScreenVideoStreamIndex",1),aq([JP()],sq.prototype,"setRemoteVideoPlayer",1),aq([JP()],sq.prototype,"destroy",1);var cq=new fN("VERTC",0);xw.storeKey=Mm(nq="".concat(Date.now(),"-")).call(nq,pM.getDeviceId()),BP({rtc_sdk_version:bM.VERSION,device_id:pM.getDeviceId(),log_cache_key:xw.storeKey}),jP(bM.LOG_SERVER_URL);var uq=1,dq=function(e,t){cq.info("createEngine","Invoke VERTC.createEngine"),OM(e,"appId");var r=(uq++).toString();return qP(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new JY(e,r,t)},lq=function(e,t){cq.print("createBLWEngine","Invoke VERTC.createBLWEngine"),OM(e,"appId");var r=(uq++).toString();return qP(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new sq(e,r,t)},hq=function(e){if(cq.info("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof JY))throw new SA(_A.INVALID_ENGINE,"Invalid engine object");var t;e.destroy(),(t=e.monitor).report("sdk_init_engine",{start:Date.now(),type:"end"}),WP.delete(t.id)},vq=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",rF.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),pq=function(){var e=xm(wm().mark((function e(){var t,r,n,i,o,a,s=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=(t=s.length>0&&void 0!==s[0]?s[0]:{video:!0,audio:!0}).video,n=t.audio,i={video:!1,audio:!1},!r){e.next=14;break}return e.prev=4,e.next=7,rF.getPermissions({video:!0,force:!0});case 7:o=e.sent,i.video=o.video,o.video||(i.videoExceptionError=o.reason),e.next=14;break;case 12:e.prev=12,e.t0=e.catch(4);case 14:if(!n){e.next=25;break}return e.prev=15,e.next=18,rF.getPermissions({audio:!0,force:!0});case 18:a=e.sent,i.audio=a.audio,a.audio||(i.audioExceptionError=a.reason),e.next=25;break;case 23:e.prev=23,e.t1=e.catch(15);case 25:return e.abrupt("return",i);case 26:case"end":return e.stop()}}),e,null,[[4,12],[15,23]])})));return function(){return e.apply(this,arguments)}}(),fq=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",rF.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),_q=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",rF.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),mq=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",rF.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),gq=function(){return bM.VERSION},yq=function(){return GP("isSupported",0,""),zU()},Sq=function(){return GP("getSupportedCodecs",0,""),XU()},bq=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(xw.logLevel=t),r&&(xw.LogfileSize=r)},Eq=function(e){xw.download(e)};function kq(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Fm(Km(t).call(t,(function(e){return e instanceof JY?"[ENGINE]":e})))}function Tq(e,t){return function(){GP(t,0,kq.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 zP(t,0,kq(e)),e})).catch((function(e){throw zP(t,e.code,e.message),e})):(zP(t,0,kq(r)),r)}}return el(el(el(el({},new(jl((function e(){Hl(this,e),Zd(this,"getSdkVersion",Tq(gq,"getSdkVersion")),Zd(this,"createEngine",Tq(dq,"createEngine")),Zd(this,"createBLWEngine",Tq(lq,"createBLWEngine")),Zd(this,"destroyEngine",Tq(hq,"destroyEngine")),Zd(this,"enumerateDevices",Tq(vq,"enumerateDevices")),Zd(this,"enableDevices",Tq(pq,"enableDevices")),Zd(this,"enumerateAudioCaptureDevices",Tq(fq,"enumerateAudioCaptureDevices")),Zd(this,"enumerateVideoCaptureDevices",Tq(_q,"enumerateVideoCaptureDevices")),Zd(this,"enumerateAudioPlaybackDevices",Tq(mq,"enumerateAudioPlaybackDevices")),Zd(this,"getParameter",kM),Zd(this,"setParameter",EM),Zd(this,"isSupported",Tq(yq,"isSupported")),Zd(this,"getSupportedCodecs",Tq(Sq,"getSupportedCodecs")),Zd(this,"events",Fl),Zd(this,"ErrorCode",_A),Zd(this,"platform","BytePlus"),Zd(this,"commitInfo","release_456<1c6a257*>"),Zd(this,"downloadLog",Tq(Eq,"downloadLog")),Zd(this,"setLogConfig",Tq(bq,"setLogConfig"))})))),Dl),Vl),{},{events:Fl})}));
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}function n(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];return r.push.apply(r,arguments),new(Function.bind.apply(t,r))}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var i=function(e){return e&&e.Math==Math&&e},o=i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof t&&t)||function(){return this}()||Function("return this")(),a=function(e){try{return!!e()}catch(t){return!0}},s=!a((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),c=s,u=Function.prototype,d=u.apply,l=u.call,h="object"==typeof Reflect&&Reflect.apply||(c?l.bind(d):function(){return l.apply(d,arguments)}),p=s,v=Function.prototype,f=v.call,_=p&&v.bind.bind(f,f),m=p?_:function(e){return function(){return f.apply(e,arguments)}},g=m,y=g({}.toString),S=g("".slice),b=function(e){return S(y(e),8,-1)},E=b,k=m,T=function(e){if("Function"===E(e))return k(e)},I="object"==typeof document&&document.all,R={all:I,IS_HTMLDDA:void 0===I&&void 0!==I},A=R.all,w=R.IS_HTMLDDA?function(e){return"function"==typeof e||e===A}:function(e){return"function"==typeof e},C={},x=!a((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),O=s,P=Function.prototype.call,M=O?P.bind(P):function(){return P.apply(P,arguments)},D={},N={}.propertyIsEnumerable,L=Object.getOwnPropertyDescriptor,U=L&&!N.call({1:2},1);D.f=U?function(e){var t=L(this,e);return!!t&&t.enumerable}:N;var V,F,B=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},j=a,H=b,G=Object,z=T("".split),K=j((function(){return!G("z").propertyIsEnumerable(0)}))?function(e){return"String"==H(e)?z(e,""):G(e)}:G,X=function(e){return null==e},W=X,q=TypeError,Y=function(e){if(W(e))throw q("Can't call method on "+e);return e},J=K,Q=Y,Z=function(e){return J(Q(e))},$=w,ee=R.all,te=R.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:$(e)||e===ee}:function(e){return"object"==typeof e?null!==e:$(e)},re={},ne=re,ie=o,oe=w,ae=function(e){return oe(e)?e:void 0},se=function(e,t){return arguments.length<2?ae(ne[e])||ae(ie[e]):ne[e]&&ne[e][t]||ie[e]&&ie[e][t]},ce=T({}.isPrototypeOf),ue=se("navigator","userAgent")||"",de=o,le=ue,he=de.process,pe=de.Deno,ve=he&&he.versions||pe&&pe.version,fe=ve&&ve.v8;fe&&(F=(V=fe.split("."))[0]>0&&V[0]<4?1:+(V[0]+V[1])),!F&&le&&(!(V=le.match(/Edge\/(\d+)/))||V[1]>=74)&&(V=le.match(/Chrome\/(\d+)/))&&(F=+V[1]);var _e=F,me=_e,ge=a,ye=!!Object.getOwnPropertySymbols&&!ge((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&me&&me<41})),Se=ye&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,be=se,Ee=w,ke=ce,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=w,Ce=Ae,xe=TypeError,Oe=function(e){if(we(e))return e;throw xe(Ce(e)+" is not a function")},Pe=Oe,Me=X,De=function(e,t){var r=e[t];return Me(r)?void 0:Pe(r)},Ne=M,Le=w,Ue=te,Ve=TypeError,Fe={exports:{}},Be=o,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=o[Ge]||He(Ge,{}),Ke=ze;(Fe.exports=function(e,t){return Ke[e]||(Ke[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.0",mode:"pure",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Xe=Fe.exports,We=Y,qe=Object,Ye=function(e){return qe(We(e))},Je=Ye,Qe=T({}.hasOwnProperty),Ze=Object.hasOwn||function(e,t){return Qe(Je(e),t)},$e=T,et=0,tt=Math.random(),rt=$e(1..toString),nt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+rt(++et+tt,36)},it=o,ot=Ze,at=nt,st=ye,ct=Se,ut=Xe("wks"),dt=it.Symbol,lt=dt&&dt.for,ht=ct?dt:dt&&dt.withoutSetter||at,pt=function(e){if(!ot(ut,e)||!st&&"string"!=typeof ut[e]){var t="Symbol."+e;st&&ot(dt,e)?ut[e]=dt[e]:ut[e]=ct&&lt?lt(t):ht(t)}return ut[e]},vt=M,ft=te,_t=Ie,mt=De,gt=function(e,t){var r,n;if("string"===t&&Le(r=e.toString)&&!Ue(n=Ne(r,e)))return n;if(Le(r=e.valueOf)&&!Ue(n=Ne(r,e)))return n;if("string"!==t&&Le(r=e.toString)&&!Ue(n=Ne(r,e)))return n;throw Ve("Can't convert object to primitive value")},yt=TypeError,St=pt("toPrimitive"),bt=function(e,t){if(!ft(e)||_t(e))return e;var r,n=mt(e,St);if(n){if(void 0===t&&(t="default"),r=vt(n,e,t),!ft(r)||_t(r))return r;throw yt("Can't convert object to primitive value")}return void 0===t&&(t="number"),gt(e,t)},Et=Ie,kt=function(e){var t=bt(e,"string");return Et(t)?t:t+""},Tt=te,It=o.document,Rt=Tt(It)&&Tt(It.createElement),At=function(e){return Rt?It.createElement(e):{}},wt=At,Ct=!x&&!a((function(){return 7!=Object.defineProperty(wt("div"),"a",{get:function(){return 7}}).a})),xt=x,Ot=M,Pt=D,Mt=B,Dt=Z,Nt=kt,Lt=Ze,Ut=Ct,Vt=Object.getOwnPropertyDescriptor;C.f=xt?Vt:function(e,t){if(e=Dt(e),t=Nt(t),Ut)try{return Vt(e,t)}catch(r){}if(Lt(e,t))return Mt(!Ot(Pt.f,e,t),e[t])};var Ft=a,Bt=w,jt=/#|\.prototype\./,Ht=function(e,t){var r=zt[Gt(e)];return r==Xt||r!=Kt&&(Bt(t)?Ft(t):!!t)},Gt=Ht.normalize=function(e){return String(e).replace(jt,".").toLowerCase()},zt=Ht.data={},Kt=Ht.NATIVE="N",Xt=Ht.POLYFILL="P",Wt=Ht,qt=Oe,Yt=s,Jt=T(T.bind),Qt=function(e,t){return qt(e),void 0===t?e:Yt?Jt(e,t):function(){return e.apply(t,arguments)}},Zt={},$t=x&&a((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),er=te,tr=String,rr=TypeError,nr=function(e){if(er(e))return e;throw rr(tr(e)+" is not an object")},ir=x,or=Ct,ar=$t,sr=nr,cr=kt,ur=TypeError,dr=Object.defineProperty,lr=Object.getOwnPropertyDescriptor,hr="enumerable",pr="configurable",vr="writable";Zt.f=ir?ar?function(e,t,r){if(sr(e),t=cr(t),sr(r),"function"==typeof e&&"prototype"===t&&"value"in r&&vr in r&&!r[vr]){var n=lr(e,t);n&&n[vr]&&(e[t]=r.value,r={configurable:pr in r?r[pr]:n[pr],enumerable:hr in r?r[hr]:n[hr],writable:!1})}return dr(e,t,r)}:dr:function(e,t,r){if(sr(e),t=cr(t),sr(r),or)try{return dr(e,t,r)}catch(n){}if("get"in r||"set"in r)throw ur("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var fr=Zt,_r=B,mr=x?function(e,t,r){return fr.f(e,t,_r(1,r))}:function(e,t,r){return e[t]=r,e},gr=o,yr=h,Sr=T,br=w,Er=C.f,kr=Wt,Tr=re,Ir=Qt,Rr=mr,Ar=Ze,wr=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 yr(e,this,arguments)};return t.prototype=e.prototype,t},Cr=function(e,t){var r,n,i,o,a,s,c,u,d=e.target,l=e.global,h=e.stat,p=e.proto,v=l?gr:h?gr[d]:(gr[d]||{}).prototype,f=l?Tr:Tr[d]||Rr(Tr,d,{})[d],_=f.prototype;for(i in t)r=!kr(l?i:d+(h?".":"#")+i,e.forced)&&v&&Ar(v,i),a=f[i],r&&(s=e.dontCallGetSet?(u=Er(v,i))&&u.value:v[i]),o=r&&s?s:t[i],r&&typeof a==typeof o||(c=e.bind&&r?Ir(o,gr):e.wrap&&r?wr(o):p&&br(o)?Sr(o):o,(e.sham||o&&o.sham||a&&a.sham)&&Rr(c,"sham",!0),Rr(f,i,c),p&&(Ar(Tr,n=d+"Prototype")||Rr(Tr,n,{}),Rr(Tr[n],i,o),e.real&&_&&!_[i]&&Rr(_,i,o)))},xr=Math.ceil,Or=Math.floor,Pr=Math.trunc||function(e){var t=+e;return(t>0?Or:xr)(t)},Mr=function(e){var t=+e;return t!=t||0===t?0:Pr(t)},Dr=Mr,Nr=Math.max,Lr=Math.min,Ur=function(e,t){var r=Dr(e);return r<0?Nr(r+t,0):Lr(r,t)},Vr=Mr,Fr=Math.min,Br=function(e){return e>0?Fr(Vr(e),9007199254740991):0},jr=Br,Hr=function(e){return jr(e.length)},Gr=Z,zr=Ur,Kr=Hr,Xr=function(e){return function(t,r,n){var i,o=Gr(t),a=Kr(o),s=zr(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:Xr(!0),indexOf:Xr(!1)},qr={},Yr=Ze,Jr=Z,Qr=Wr.indexOf,Zr=qr,$r=T([].push),en=function(e,t){var r,n=Jr(e),i=0,o=[];for(r in n)!Yr(Zr,r)&&Yr(n,r)&&$r(o,r);for(;t.length>i;)Yr(n,r=t[i++])&&(~Qr(o,r)||$r(o,r));return o},tn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],rn=en,nn=tn,on=Object.keys||function(e){return rn(e,nn)},an=Ye,sn=on;Cr({target:"Object",stat:!0,forced:a((function(){sn(1)}))},{keys:function(e){return sn(an(e))}});var cn=r(re.Object.keys),un={};un[pt("toStringTag")]="z";var dn="[object z]"===String(un),ln=dn,hn=w,pn=b,vn=pt("toStringTag"),fn=Object,_n="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=fn(e),vn))?r:_n?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=x,kn=$t,Tn=Zt,In=nr,Rn=Z,An=on;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=se("document","documentElement"),xn=nt,On=Xe("keys"),Pn=function(e){return On[e]||(On[e]=xn(e))},Mn=nr,Dn=bn,Nn=tn,Ln=qr,Un=Cn,Vn=At,Fn="prototype",Bn="script",jn=Pn("IE_PROTO"),Hn=function(){},Gn=function(e){return"<"+Bn+">"+e+"</"+Bn+">"},zn=function(e){e.write(Gn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Kn=function(){try{wn=new ActiveXObject("htmlfile")}catch(i){}var e,t,r;Kn="undefined"!=typeof document?document.domain&&wn?zn(wn):(t=Vn("iframe"),r="java"+Bn+":",t.style.display="none",Un.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(Gn("document.F=Object")),e.close(),e.F):zn(wn);for(var n=Nn.length;n--;)delete Kn[Fn][Nn[n]];return Kn()};Ln[jn]=!0;var Xn=Object.create||function(e,t){var r;return null!==e?(Hn[Fn]=Mn(e),r=new Hn,Hn[Fn]=null,r[jn]=e):r=Kn(),void 0===t?r:Dn.f(r,t)},Wn={},qn=en,Yn=tn.concat("length","prototype");Wn.f=Object.getOwnPropertyNames||function(e){return qn(e,Yn)};var Jn={},Qn=kt,Zn=Zt,$n=B,ei=function(e,t,r){var n=Qn(t);n in e?Zn.f(e,n,$n(0,r)):e[n]=r},ti=Ur,ri=Hr,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=b,ci=Z,ui=Wn.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=mr,vi=function(e,t,r,n){return n&&n.enumerable?e[t]=r:pi(e,t,r),e},fi={},_i=pt;fi.f=_i;var mi,gi,yi,Si=re,bi=Ze,Ei=fi,ki=Zt.f,Ti=function(e){var t=Si.Symbol||(Si.Symbol={});bi(t,e)||ki(t,e,{value:Ei.f(e)})},Ii=M,Ri=se,Ai=pt,wi=vi,Ci=function(){var e=Ri("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=Ai("toPrimitive");t&&!t[n]&&wi(t,n,(function(e){return Ii(r,this)}),{arity:1})},xi=mn,Oi=dn?{}.toString:function(){return"[object "+xi(this)+"]"},Pi=dn,Mi=Zt.f,Di=mr,Ni=Ze,Li=Oi,Ui=pt("toStringTag"),Vi=function(e,t,r,n){if(e){var i=r?e:e.prototype;Ni(i,Ui)||Mi(i,Ui,{configurable:!0,value:t}),n&&!Pi&&Di(i,"toString",Li)}},Fi=w,Bi=o.WeakMap,ji=Fi(Bi)&&/native code/.test(String(Bi)),Hi=o,Gi=te,zi=mr,Ki=Ze,Xi=ze,Wi=Pn,qi=qr,Yi="Object already initialized",Ji=Hi.TypeError,Qi=Hi.WeakMap;if(ji||Xi.state){var Zi=Xi.state||(Xi.state=new Qi);Zi.get=Zi.get,Zi.has=Zi.has,Zi.set=Zi.set,mi=function(e,t){if(Zi.has(e))throw Ji(Yi);return t.facade=e,Zi.set(e,t),t},gi=function(e){return Zi.get(e)||{}},yi=function(e){return Zi.has(e)}}else{var $i=Wi("state");qi[$i]=!0,mi=function(e,t){if(Ki(e,$i))throw Ji(Yi);return t.facade=e,zi(e,$i,t),t},gi=function(e){return Ki(e,$i)?e[$i]:{}},yi=function(e){return Ki(e,$i)}}var eo={set:mi,get:gi,has:yi,enforce:function(e){return yi(e)?gi(e):mi(e,{})},getterFor:function(e){return function(t){var r;if(!Gi(t)||(r=gi(t)).type!==e)throw Ji("Incompatible receiver, "+e+" required");return r}}},to=b,ro=Array.isArray||function(e){return"Array"==to(e)},no=w,io=ze,oo=T(Function.toString);no(io.inspectSource)||(io.inspectSource=function(e){return oo(e)});var ao=io.inspectSource,so=T,co=a,uo=w,lo=mn,ho=ao,po=function(){},vo=[],fo=se("Reflect","construct"),_o=/^\s*(?:class|function)\b/,mo=so(_o.exec),go=!_o.exec(po),yo=function(e){if(!uo(e))return!1;try{return fo(po,vo,e),!0}catch(t){return!1}},So=function(e){if(!uo(e))return!1;switch(lo(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return go||!!mo(_o,ho(e))}catch(t){return!0}};So.sham=!0;var bo=!fo||co((function(){var e;return yo(yo.call)||!yo(Object)||!yo((function(){e=!0}))||e}))?So:yo,Eo=ro,ko=bo,To=te,Io=pt("species"),Ro=Array,Ao=function(e){var t;return Eo(e)&&(t=e.constructor,(ko(t)&&(t===Ro||Eo(t.prototype))||To(t)&&null===(t=t[Io]))&&(t=void 0)),void 0===t?Ro:t},wo=function(e,t){return new(Ao(e))(0===t?0:t)},Co=Qt,xo=K,Oo=Ye,Po=Hr,Mo=wo,Do=T([].push),No=function(e){var t=1==e,r=2==e,n=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,d,l){for(var h,p,v=Oo(c),f=xo(v),_=Co(u,d),m=Po(f),g=0,y=l||Mo,S=t?y(c,m):r||a?y(c,0):void 0;m>g;g++)if((s||g in f)&&(p=_(h=f[g],g,v),e))if(t)S[g]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return g;case 2:Do(S,h)}else switch(e){case 4:return!1;case 7:Do(S,h)}return o?-1:n||i?i:S}},Lo={forEach:No(0),map:No(1),filter:No(2),some:No(3),every:No(4),find:No(5),findIndex:No(6),filterReject:No(7)},Uo=Cr,Vo=o,Fo=M,Bo=T,jo=x,Ho=ye,Go=a,zo=Ze,Ko=ce,Xo=nr,Wo=Z,qo=kt,Yo=Sn,Jo=B,Qo=Xn,Zo=on,$o=Wn,ea=Jn,ta=hi,ra=C,na=Zt,ia=bn,oa=D,aa=vi,sa=Xe,ca=qr,ua=nt,da=pt,la=fi,ha=Ti,pa=Ci,va=Vi,fa=eo,_a=Lo.forEach,ma=Pn("hidden"),ga="Symbol",ya="prototype",Sa=fa.set,ba=fa.getterFor(ga),Ea=Object[ya],ka=Vo.Symbol,Ta=ka&&ka[ya],Ia=Vo.TypeError,Ra=Vo.QObject,Aa=ra.f,wa=na.f,Ca=ea.f,xa=oa.f,Oa=Bo([].push),Pa=sa("symbols"),Ma=sa("op-symbols"),Da=sa("wks"),Na=!Ra||!Ra[ya]||!Ra[ya].findChild,La=jo&&Go((function(){return 7!=Qo(wa({},"a",{get:function(){return wa(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=Aa(Ea,t);n&&delete Ea[t],wa(e,t,r),n&&e!==Ea&&wa(Ea,t,n)}:wa,Ua=function(e,t){var r=Pa[e]=Qo(Ta);return Sa(r,{type:ga,tag:e,description:t}),jo||(r.description=t),r},Va=function(e,t,r){e===Ea&&Va(Ma,t,r),Xo(e);var n=qo(t);return Xo(r),zo(Pa,n)?(r.enumerable?(zo(e,ma)&&e[ma][n]&&(e[ma][n]=!1),r=Qo(r,{enumerable:Jo(0,!1)})):(zo(e,ma)||wa(e,ma,Jo(1,{})),e[ma][n]=!0),La(e,n,r)):wa(e,n,r)},Fa=function(e,t){Xo(e);var r=Wo(t),n=Zo(r).concat(Ga(r));return _a(n,(function(t){jo&&!Fo(Ba,r,t)||Va(e,t,r[t])})),e},Ba=function(e){var t=qo(e),r=Fo(xa,this,t);return!(this===Ea&&zo(Pa,t)&&!zo(Ma,t))&&(!(r||!zo(this,t)||!zo(Pa,t)||zo(this,ma)&&this[ma][t])||r)},ja=function(e,t){var r=Wo(e),n=qo(t);if(r!==Ea||!zo(Pa,n)||zo(Ma,n)){var i=Aa(r,n);return!i||!zo(Pa,n)||zo(r,ma)&&r[ma][n]||(i.enumerable=!0),i}},Ha=function(e){var t=Ca(Wo(e)),r=[];return _a(t,(function(e){zo(Pa,e)||zo(ca,e)||Oa(r,e)})),r},Ga=function(e){var t=e===Ea,r=Ca(t?Ma:Wo(e)),n=[];return _a(r,(function(e){!zo(Pa,e)||t&&!zo(Ea,e)||Oa(n,Pa[e])})),n};Ho||(ka=function(){if(Ko(Ta,this))throw Ia("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Yo(arguments[0]):void 0,t=ua(e),r=function(e){this===Ea&&Fo(r,Ma,e),zo(this,ma)&&zo(this[ma],t)&&(this[ma][t]=!1),La(this,t,Jo(1,e))};return jo&&Na&&La(Ea,t,{configurable:!0,set:r}),Ua(t,e)},aa(Ta=ka[ya],"toString",(function(){return ba(this).tag})),aa(ka,"withoutSetter",(function(e){return Ua(ua(e),e)})),oa.f=Ba,na.f=Va,ia.f=Fa,ra.f=ja,$o.f=ea.f=Ha,ta.f=Ga,la.f=function(e){return Ua(da(e),e)},jo&&wa(Ta,"description",{configurable:!0,get:function(){return ba(this).description}})),Uo({global:!0,constructor:!0,wrap:!0,forced:!Ho,sham:!Ho},{Symbol:ka}),_a(Zo(Da),(function(e){ha(e)})),Uo({target:ga,stat:!0,forced:!Ho},{useSetter:function(){Na=!0},useSimple:function(){Na=!1}}),Uo({target:"Object",stat:!0,forced:!Ho,sham:!jo},{create:function(e,t){return void 0===t?Qo(e):Fa(Qo(e),t)},defineProperty:Va,defineProperties:Fa,getOwnPropertyDescriptor:ja}),Uo({target:"Object",stat:!0,forced:!Ho},{getOwnPropertyNames:Ha}),pa(),va(ka,ga),ca[ma]=!0;var za=ye&&!!Symbol.for&&!!Symbol.keyFor,Ka=Cr,Xa=se,Wa=Ze,qa=Sn,Ya=Xe,Ja=za,Qa=Ya("string-to-symbol-registry"),Za=Ya("symbol-to-string-registry");Ka({target:"Symbol",stat:!0,forced:!Ja},{for:function(e){var t=qa(e);if(Wa(Qa,t))return Qa[t];var r=Xa("Symbol")(t);return Qa[t]=r,Za[r]=t,r}});var $a=Cr,es=Ze,ts=Ie,rs=Ae,ns=za,is=Xe("symbol-to-string-registry");$a({target:"Symbol",stat:!0,forced:!ns},{keyFor:function(e){if(!ts(e))throw TypeError(rs(e)+" is not a symbol");if(es(is,e))return is[e]}});var os=T([].slice),as=Cr,ss=se,cs=h,us=M,ds=T,ls=a,hs=ro,ps=w,vs=te,fs=Ie,_s=os,ms=ye,gs=ss("JSON","stringify"),ys=ds(/./.exec),Ss=ds("".charAt),bs=ds("".charCodeAt),Es=ds("".replace),ks=ds(1..toString),Ts=/[\uD800-\uDFFF]/g,Is=/^[\uD800-\uDBFF]$/,Rs=/^[\uDC00-\uDFFF]$/,As=!ms||ls((function(){var e=ss("Symbol")();return"[null]"!=gs([e])||"{}"!=gs({a:e})||"{}"!=gs(Object(e))})),ws=ls((function(){return'"\\udf06\\ud834"'!==gs("\udf06\ud834")||'"\\udead"'!==gs("\udead")})),Cs=function(e,t){var r=_s(arguments),n=t;if((vs(t)||void 0!==e)&&!fs(e))return hs(t)||(t=function(e,t){if(ps(n)&&(t=us(n,this,e,t)),!fs(t))return t}),r[1]=t,cs(gs,null,r)},xs=function(e,t,r){var n=Ss(r,t-1),i=Ss(r,t+1);return ys(Is,e)&&!ys(Rs,i)||ys(Rs,e)&&!ys(Is,n)?"\\u"+ks(bs(e,0),16):e};gs&&as({target:"JSON",stat:!0,arity:3,forced:As||ws},{stringify:function(e,t,r){var n=_s(arguments),i=cs(As?Cs:gs,null,n);return ws&&"string"==typeof i?Es(i,Ts,xs):i}});var Os=hi,Ps=Ye;Cr({target:"Object",stat:!0,forced:!ye||a((function(){Os.f(1)}))},{getOwnPropertySymbols:function(e){var t=Os.f;return t?t(Ps(e)):[]}});var Ms=r(re.Object.getOwnPropertySymbols),Ds=a,Ns=_e,Ls=pt("species"),Us=function(e){return Ns>=51||!Ds((function(){var t=[];return(t.constructor={})[Ls]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Vs=Lo.filter;Cr({target:"Array",proto:!0,forced:!Us("filter")},{filter:function(e){return Vs(this,e,arguments.length>1?arguments[1]:void 0)}});var Fs=re,Bs=function(e){return Fs[e+"Prototype"]},js=Bs("Array").filter,Hs=ce,Gs=js,zs=Array.prototype,Ks=r((function(e){var t=e.filter;return e===zs||Hs(zs,e)&&t===zs.filter?Gs:t})),Xs={exports:{}},Ws=Cr,qs=a,Ys=Z,Js=C.f,Qs=x,Zs=qs((function(){Js(1)}));Ws({target:"Object",stat:!0,forced:!Qs||Zs,sham:!Qs},{getOwnPropertyDescriptor:function(e,t){return Js(Ys(e),t)}});var $s=re.Object,ec=Xs.exports=function(e,t){return $s.getOwnPropertyDescriptor(e,t)};$s.getOwnPropertyDescriptor.sham&&(ec.sham=!0);var tc,rc,nc,ic=r(Xs.exports),oc={},ac=x,sc=Ze,cc=Function.prototype,uc=ac&&Object.getOwnPropertyDescriptor,dc=sc(cc,"name"),lc={EXISTS:dc,PROPER:dc&&"something"===function(){}.name,CONFIGURABLE:dc&&(!ac||ac&&uc(cc,"name").configurable)},hc=!a((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),pc=Ze,vc=w,fc=Ye,_c=hc,mc=Pn("IE_PROTO"),gc=Object,yc=gc.prototype,Sc=_c?gc.getPrototypeOf:function(e){var t=fc(e);if(pc(t,mc))return t[mc];var r=t.constructor;return vc(r)&&t instanceof r?r.prototype:t instanceof gc?yc:null},bc=a,Ec=w,kc=te,Tc=Xn,Ic=Sc,Rc=vi,Ac=pt("iterator"),wc=!1;[].keys&&("next"in(nc=[].keys())?(rc=Ic(Ic(nc)))!==Object.prototype&&(tc=rc):wc=!0);var Cc=!kc(tc)||bc((function(){var e={};return tc[Ac].call(e)!==e}));Ec((tc=Cc?{}:Tc(tc))[Ac])||Rc(tc,Ac,(function(){return this}));var xc={IteratorPrototype:tc,BUGGY_SAFARI_ITERATORS:wc},Oc=xc.IteratorPrototype,Pc=Xn,Mc=B,Dc=Vi,Nc=oc,Lc=function(){return this},Uc=function(e,t,r,n){var i=t+" Iterator";return e.prototype=Pc(Oc,{next:Mc(+!n,r)}),Dc(e,i,!1,!0),Nc[i]=Lc,e},Vc=w,Fc=String,Bc=TypeError,jc=T,Hc=nr,Gc=function(e){if("object"==typeof e||Vc(e))return e;throw Bc("Can't set "+Fc(e)+" as a prototype")},zc=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=jc(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return Hc(r),Gc(n),t?e(r,n):r.__proto__=n,r}}():void 0),Kc=Cr,Xc=M,Wc=lc,qc=Uc,Yc=Sc,Jc=Vi,Qc=vi,Zc=oc,$c=xc,eu=Wc.PROPER,tu=$c.BUGGY_SAFARI_ITERATORS,ru=pt("iterator"),nu="keys",iu="values",ou="entries",au=function(){return this},su=function(e,t,r,n,i,o,a){qc(r,t,n);var s,c,u,d=function(e){if(e===i&&f)return f;if(!tu&&e in p)return p[e];switch(e){case nu:case iu:case ou:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,p=e.prototype,v=p[ru]||p["@@iterator"]||i&&p[i],f=!tu&&v||d(i),_="Array"==t&&p.entries||v;if(_&&(s=Yc(_.call(new e)))!==Object.prototype&&s.next&&(Jc(s,l,!0,!0),Zc[l]=au),eu&&i==iu&&v&&v.name!==iu&&(h=!0,f=function(){return Xc(v,this)}),i)if(c={values:d(iu),keys:o?f:d(nu),entries:d(ou)},a)for(u in c)(tu||h||!(u in p))&&Qc(p,u,c[u]);else Kc({target:t,proto:!0,forced:tu||h},c);return a&&p[ru]!==f&&Qc(p,ru,f,{name:i}),Zc[t]=f,c},cu=function(e,t){return{value:e,done:t}},uu=Z,du=oc,lu=eo;Zt.f;var hu=su,pu=cu,vu="Array Iterator",fu=lu.set,_u=lu.getterFor(vu);hu(Array,"Array",(function(e,t){fu(this,{type:vu,target:uu(e),index:0,kind:t})}),(function(){var e=_u(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,pu(void 0,!0)):pu("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values"),du.Arguments=du.Array;var mu={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},gu=o,yu=mn,Su=mr,bu=oc,Eu=pt("toStringTag");for(var ku in mu){var Tu=gu[ku],Iu=Tu&&Tu.prototype;Iu&&yu(Iu)!==Eu&&Su(Iu,Eu,ku),bu[ku]=bu.Array}var Ru=a,Au=function(e,t){var r=[][e];return!!r&&Ru((function(){r.call(null,t||function(){return 1},1)}))},wu=Lo.forEach,Cu=Au("forEach")?[].forEach:function(e){return wu(this,e,arguments.length>1?arguments[1]:void 0)};Cr({target:"Array",proto:!0,forced:[].forEach!=Cu},{forEach:Cu});var xu=Bs("Array").forEach,Ou=mn,Pu=Ze,Mu=ce,Du=xu,Nu=Array.prototype,Lu={DOMTokenList:!0,NodeList:!0},Uu=r((function(e){var t=e.forEach;return e===Nu||Mu(Nu,e)&&t===Nu.forEach||Pu(Lu,Ou(e))?Du:t})),Vu=se,Fu=Wn,Bu=hi,ju=nr,Hu=T([].concat),Gu=Vu("Reflect","ownKeys")||function(e){var t=Fu.f(ju(e)),r=Bu.f;return r?Hu(t,r(e)):t},zu=Gu,Ku=Z,Xu=C,Wu=ei;Cr({target:"Object",stat:!0,sham:!x},{getOwnPropertyDescriptors:function(e){for(var t,r,n=Ku(e),i=Xu.f,o=zu(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&Wu(a,t,r);return a}});var qu=r(re.Object.getOwnPropertyDescriptors),Yu={exports:{}},Ju=Cr,Qu=x,Zu=bn.f;Ju({target:"Object",stat:!0,forced:Object.defineProperties!==Zu,sham:!Qu},{defineProperties:Zu});var $u=re.Object,ed=Yu.exports=function(e,t){return $u.defineProperties(e,t)};$u.defineProperties.sham&&(ed.sham=!0);var td=r(Yu.exports),rd={exports:{}},nd=Cr,id=x,od=Zt.f;nd({target:"Object",stat:!0,forced:Object.defineProperty!==od,sham:!id},{defineProperty:od});var ad=re.Object,sd=rd.exports=function(e,t,r){return ad.defineProperty(e,t,r)};ad.defineProperty.sham&&(sd.sham=!0);var cd=r(rd.exports),ud=TypeError,dd=function(e){if(e>9007199254740991)throw ud("Maximum allowed index exceeded");return e},ld=Cr,hd=a,pd=ro,vd=te,fd=Ye,_d=Hr,md=dd,gd=ei,yd=wo,Sd=Us,bd=_e,Ed=pt("isConcatSpreadable"),kd=bd>=51||!hd((function(){var e=[];return e[Ed]=!1,e.concat()[0]!==e})),Td=Sd("concat"),Id=function(e){if(!vd(e))return!1;var t=e[Ed];return void 0!==t?!!t:pd(e)};ld({target:"Array",proto:!0,arity:1,forced:!kd||!Td},{concat:function(e){var t,r,n,i,o,a=fd(this),s=yd(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(Id(o=-1===t?a:arguments[t]))for(i=_d(o),md(c+i),r=0;r<i;r++,c++)r in o&&gd(s,c,o[r]);else md(c+1),gd(s,c++,o);return s.length=c,s}}),Ti("asyncIterator"),Ti("hasInstance"),Ti("isConcatSpreadable"),Ti("iterator"),Ti("match"),Ti("matchAll"),Ti("replace"),Ti("search"),Ti("species"),Ti("split");var Rd=Ci;Ti("toPrimitive"),Rd();var Ad=se,wd=Vi;Ti("toStringTag"),wd(Ad("Symbol"),"Symbol"),Ti("unscopables"),Vi(o.JSON,"JSON",!0);var Cd=re.Symbol;Ti("asyncDispose"),Ti("dispose"),Ti("matcher"),Ti("metadataKey"),Ti("observable"),Ti("metadata"),Ti("patternMatch"),Ti("replaceAll");var xd=r(Cd),Od=T,Pd=Mr,Md=Sn,Dd=Y,Nd=Od("".charAt),Ld=Od("".charCodeAt),Ud=Od("".slice),Vd=function(e){return function(t,r){var n,i,o=Md(Dd(t)),a=Pd(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Ld(o,a))<55296||n>56319||a+1===s||(i=Ld(o,a+1))<56320||i>57343?e?Nd(o,a):n:e?Ud(o,a,a+2):i-56320+(n-55296<<10)+65536}},Fd={codeAt:Vd(!1),charAt:Vd(!0)},Bd=Fd.charAt,jd=Sn,Hd=eo,Gd=su,zd=cu,Kd="String Iterator",Xd=Hd.set,Wd=Hd.getterFor(Kd);Gd(String,"String",(function(e){Xd(this,{type:Kd,string:jd(e),index:0})}),(function(){var e,t=Wd(this),r=t.string,n=t.index;return n>=r.length?zd(void 0,!0):(e=Bd(r,n),t.index+=e.length,zd(e,!1))}));var qd=r(fi.f("iterator"));function Yd(e){return(Yd="function"==typeof xd&&"symbol"==typeof qd?function(e){return typeof e}:function(e){return e&&"function"==typeof xd&&e.constructor===xd&&e!==xd.prototype?"symbol":typeof e})(e)}var Jd=r(fi.f("toPrimitive"));function Qd(e){var t=function(e,t){if("object"!==Yd(e)||null===e)return e;var r=e[Jd];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==Yd(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Yd(t)?t:String(t)}function Zd(e,t,r){return(t=Qd(t))in e?cd(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function $d(e,t){var r=cn(e);if(Ms){var n=Ms(e);t&&(n=Ks(n).call(n,(function(t){return ic(e,t).enumerable}))),r.push.apply(r,n)}return r}function el(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?Uu(r=$d(Object(i),!0)).call(r,(function(t){Zd(e,t,i[t])})):qu?td(e,qu(i)):Uu(n=$d(Object(i))).call(n,(function(t){cd(e,t,ic(i,t))}))}return e}var tl=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}(tl||{}),rl=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}(rl||{}),nl=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}(nl||{}),il=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(il||{}),ol=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(ol||{}),al=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(al||{}),sl=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(sl||{}),cl=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(cl||{}),ul=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}(ul||{}),dl=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(dl||{}),ll=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(ll||{}),hl=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}(hl||{}),pl=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}(pl||{}),vl=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(vl||{}),fl=function(e){return e[e.NORMAL=0]="NORMAL",e[e.DISCONNECT=1]="DISCONNECT",e[e.RESET=2]="RESET",e}(fl||{}),_l=function(e){return e[e.MICROPHONE=0]="MICROPHONE",e[e.AUDIOMIXING=1]="AUDIOMIXING",e}(_l||{}),ml=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(ml||{}),gl=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(gl||{}),yl=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}(yl||{}),Sl=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(Sl||{}),bl=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}(bl||{}),El=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(El||{}),kl=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}(kl||{}),Tl=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(Tl||{}),Il=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}(Il||{}),Rl=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}(Rl||{}),Al=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}(Al||{}),wl=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(wl||{}),Cl=function(e){return e.H264="H264",e.H265="H265",e}(Cl||{}),xl=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(xl||{}),Ol=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(Ol||{}),Pl=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}(Pl||{}),Ml=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}(Ml||{}),Dl=Object.freeze({__proto__:null,AAC_PROFILE:wl,AudioProfileType:Rl,AudioReportMode:_l,AudioSourceType:rl,ChannelProfile:il,ConnectionState:pl,FallbackOrRecoverReason:Tl,ForwardStreamError:Ml,ForwardStreamState:Pl,LocalMainReportMode:fl,LogChannel:ml,MediaType:ll,MirrorMode:cl,MirrorType:vl,NetworkQuality:kl,PublicInterpolationMode:Sl,PublicStreamType:yl,PublishState:sl,RTCAutoPlayPolicy:Al,RemoteUserPriority:El,RoomProfileType:Il,SUBTITLE_MODE:xl,StreamIndex:dl,StreamRemoveReason:hl,SubscribeFallbackOption:bl,SubscribeMode:ol,SubscribeState:al,SubtitleEventType:Ol,TRANSCODING_VIDEO_CODEC:Cl,USER_ONLINE_STATUS:gl,UserOfflineReason:nl,VideoRenderMode:ul,VideoSourceType:tl}),Nl=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}(Nl||{}),Ll=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(Ll||{}),Ul=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}(Ul||{}),Vl=Object.freeze({__proto__:null,AudioMixingDualMonoMode:Nl,AudioMixingState:Ul,AudioMixingType:Ll}),Fl=function(e){return e.onTrackEnded="onTrackEnded",e.onTrackMute="onTrackMute",e.onTrackUnmute="onTrackUnmute",e.onPlayerEvent="onPlayerEvent",e.onAutoplayFailed="onAutoplayFailed",e.onUserJoined="onUserJoined",e.onUserLeave="onUserLeave",e.onConnectionStateChanged="onConnectionStateChanged",e.onUserPublishStream="onUserPublishStream",e.onUserUnpublishStream="onUserUnpublishStream",e.onUserPublishScreen="onUserPublishScreen",e.onUserUnpublishScreen="onUserUnpublishScreen",e.onRoomMessageReceived="onRoomMessageReceived",e.onRoomBinaryMessageReceived="onRoomBinaryMessageReceived",e.onUserMessageReceived="onUserMessageReceived",e.onUserBinaryMessageReceived="onUserBinaryMessageReceived",e.onVideoFirstFrameRendered="onVideoFirstFrameRendered",e.onVideoFirstFrameDecoded="onVideoFirstFrameDecoded",e.onRemoteVideoFirstFrame="onRemoteVideoFirstFrame",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onRemoteAudioFirstFrame="onRemoteAudioFirstFrame",e.onFirstPublicStreamVideoFrameRendered="onFirstPublicStreamVideoFrameRendered",e.onFirstPublicStreamVideoFrameDecoded="onFirstPublicStreamVideoFrameDecoded",e.onFirstPublicStreamAudioFrameDecoded="onFirstPublicStreamAudioFrameDecoded",e.onVideoDeviceStateChanged="onVideoDeviceStateChanged",e.onAudioDeviceStateChanged="onAudioDeviceStateChanged",e.onRemoteStreamStats="onRemoteStreamStats",e.onPublicStreamStats="onPublicStreamStats",e.onLocalStreamStats="onLocalStreamStats",e.onAudioVolumeIndication="onAudioVolumeIndication",e.onLocalAudioPropertiesReport="onLocalAudioPropertiesReport",e.onRemoteAudioPropertiesReport="onRemoteAudioPropertiesReport",e.onActiveSpeaker="onActiveSpeaker",e.onAudioPlaybackDeviceChanged="onAudioPlaybackDeviceChanged",e.onUserStartVideoCapture="onUserStartVideoCapture",e.onUserStopVideoCapture="onUserStopVideoCapture",e.onUserStartAudioCapture="onUserStartAudioCapture",e.onUserStopAudioCapture="onUserStopAudioCapture",e.onAutoPublishResult="onAutoPublishResult",e.onAutoSubscribeResult="onAutoSubscribeResult",e.onLiveTranscodingResult="onLiveTranscodingResult",e.onStreamMixingEvent="onStreamMixingEvent",e.onAudioPlaybackDeviceTestVolume="onAudioPlaybackDeviceTestVolume",e.onSEIMessageReceived="onSEIMessageReceived",e.onError="onError",e.onAudioMixingStateChanged="onAudioMixingStateChanged",e.onUserMessageReceivedOutsideRoom="onUserMessageReceivedOutsideRoom",e.onUserBinaryMessageReceivedOutsideRoom="onUserBinaryMessageReceivedOutsideRoom",e.onTokenWillExpire="onTokenWillExpire",e.onCloudProxyConnected="onCloudProxyConnected",e.onPushPublicStreamResult="onPushPublicStreamResult",e.onPublicStreamSEIMessageReceived="onPublicStreamSEIMessageReceived",e.onNetworkQuality="onNetworkQuality",e.onSimulcastSubscribeFallback="onSimulcastSubscribeFallback",e.onRemoteVideoSizeChanged="onRemoteVideoSizeChanged",e.onVideoStreamBanned="onVideoStreamBanned",e.onAudioStreamBanned="onAudioStreamBanned",e.onLocalVideoSizeChanged="onLocalVideoSizeChanged",e.onSubtitleStateChanged="onSubtitleStateChanged",e.onSubtitleMessageReceived="onSubtitleMessageReceived",e.onServerParamsSetResult="onServerParamsSetResult",e.onLocalStreamTrackChangedByExtension="onLocalStreamTrackChangedByExtension",e.onVendorConnectionStateChanged="onVendorConnectionStateChanged",e.onForwardStreamError="onForwardStreamError",e.onRejoinWithTcp="onRejoinWithTcp",e.onIceConnectWithTcp="onIceConnectWithTcp",e.onPublishRetry="onPublishRetry",e.onSubscribeRetry="onSubscribeRetry",e}(Fl||{});function Bl(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),cd(e,Qd(n.key),n)}}function jl(e,t,r){return t&&Bl(e.prototype,t),r&&Bl(e,r),cd(e,"prototype",{writable:!1}),e}function Hl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Cr({target:"Object",stat:!0,sham:!x},{create:Xn});var Gl=re.Object,zl=r((function(e,t){return Gl.create(e,t)})),Kl=Ye,Xl=Sc,Wl=hc;Cr({target:"Object",stat:!0,forced:a((function(){Xl(1)})),sham:!Wl},{getPrototypeOf:function(e){return Xl(Kl(e))}});var ql=r(re.Object.getPrototypeOf);Cr({target:"Object",stat:!0},{setPrototypeOf:zc});var Yl=r(re.Object.setPrototypeOf),Jl=Ze,Ql=Gu,Zl=C,$l=Zt,eh=Error,th=T("".replace),rh=String(eh("zxcasd").stack),nh=/\n\s*at [^:]*:[^\n]*/,ih=nh.test(rh),oh=te,ah=mr,sh=oc,ch=pt("iterator"),uh=Array.prototype,dh=function(e){return void 0!==e&&(sh.Array===e||uh[ch]===e)},lh=mn,hh=De,ph=X,vh=oc,fh=pt("iterator"),_h=function(e){if(!ph(e))return hh(e,fh)||hh(e,"@@iterator")||vh[lh(e)]},mh=M,gh=Oe,yh=nr,Sh=Ae,bh=_h,Eh=TypeError,kh=function(e,t){var r=arguments.length<2?bh(e):t;if(gh(r))return yh(mh(r,e));throw Eh(Sh(e)+" is not iterable")},Th=M,Ih=nr,Rh=De,Ah=function(e,t,r){var n,i;Ih(e);try{if(!(n=Rh(e,"return"))){if("throw"===t)throw r;return r}n=Th(n,e)}catch(o){i=!0,n=o}if("throw"===t)throw r;if(i)throw n;return Ih(n),r},wh=Qt,Ch=M,xh=nr,Oh=Ae,Ph=dh,Mh=Hr,Dh=ce,Nh=kh,Lh=_h,Uh=Ah,Vh=TypeError,Fh=function(e,t){this.stopped=e,this.result=t},Bh=Fh.prototype,jh=function(e,t,r){var n,i,o,a,s,c,u,d=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),v=!(!r||!r.INTERRUPTED),f=wh(t,d),_=function(e){return n&&Uh(n,"normal",e),new Fh(!0,e)},m=function(e){return l?(xh(e),v?f(e[0],e[1],_):f(e[0],e[1])):v?f(e,_):f(e)};if(h)n=e.iterator;else if(p)n=e;else{if(!(i=Lh(e)))throw Vh(Oh(e)+" is not iterable");if(Ph(i)){for(o=0,a=Mh(e);a>o;o++)if((s=m(e[o]))&&Dh(Bh,s))return s;return new Fh(!1)}n=Nh(e,i)}for(c=h?e.next:n.next;!(u=Ch(c,n)).done;){try{s=m(u.value)}catch(g){Uh(n,"throw",g)}if("object"==typeof s&&s&&Dh(Bh,s))return s}return new Fh(!1)},Hh=Sn,Gh=B,zh=!a((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Gh(1,7)),7!==e.stack)})),Kh=Cr,Xh=ce,Wh=Sc,qh=zc,Yh=function(e,t,r){for(var n=Ql(t),i=$l.f,o=Zl.f,a=0;a<n.length;a++){var s=n[a];Jl(e,s)||r&&Jl(r,s)||i(e,s,o(t,s))}},Jh=Xn,Qh=mr,Zh=B,$h=function(e,t){if(ih&&"string"==typeof e&&!eh.prepareStackTrace)for(;t--;)e=th(e,nh,"");return e},ep=function(e,t){oh(t)&&"cause"in t&&ah(e,"cause",t.cause)},tp=jh,rp=function(e,t){return void 0===e?arguments.length<2?"":t:Hh(e)},np=zh,ip=pt("toStringTag"),op=Error,ap=[].push,sp=function(e,t){var r,n=arguments.length>2?arguments[2]:void 0,i=Xh(cp,this);qh?r=qh(op(),i?Wh(this):cp):(r=i?this:Jh(cp),Qh(r,ip,"Error")),void 0!==t&&Qh(r,"message",rp(t)),np&&Qh(r,"stack",$h(r.stack,1)),ep(r,n);var o=[];return tp(e,ap,{that:o}),Qh(r,"errors",o),r};qh?qh(sp,op):Yh(sp,op,{name:!0});var cp=sp.prototype=Jh(op.prototype,{constructor:Zh(1,sp),message:Zh(1,""),name:Zh(1,"AggregateError")});Kh({global:!0,constructor:!0,arity:2},{AggregateError:sp});var up,dp,lp,hp,pp="process"==b(o.process),vp=se,fp=Zt,_p=x,mp=pt("species"),gp=function(e){var t=vp(e),r=fp.f;_p&&t&&!t[mp]&&r(t,mp,{configurable:!0,get:function(){return this}})},yp=ce,Sp=TypeError,bp=function(e,t){if(yp(t,e))return e;throw Sp("Incorrect invocation")},Ep=bo,kp=Ae,Tp=TypeError,Ip=function(e){if(Ep(e))return e;throw Tp(kp(e)+" is not a constructor")},Rp=nr,Ap=Ip,wp=X,Cp=pt("species"),xp=function(e,t){var r,n=Rp(e).constructor;return void 0===n||wp(r=Rp(n)[Cp])?t:Ap(r)},Op=TypeError,Pp=function(e,t){if(e<t)throw Op("Not enough arguments");return e},Mp=/(?:ipad|iphone|ipod).*applewebkit/i.test(ue),Dp=o,Np=h,Lp=Qt,Up=w,Vp=Ze,Fp=a,Bp=Cn,jp=os,Hp=At,Gp=Pp,zp=Mp,Kp=pp,Xp=Dp.setImmediate,Wp=Dp.clearImmediate,qp=Dp.process,Yp=Dp.Dispatch,Jp=Dp.Function,Qp=Dp.MessageChannel,Zp=Dp.String,$p=0,ev={},tv="onreadystatechange";try{up=Dp.location}catch(BY){}var rv=function(e){if(Vp(ev,e)){var t=ev[e];delete ev[e],t()}},nv=function(e){return function(){rv(e)}},iv=function(e){rv(e.data)},ov=function(e){Dp.postMessage(Zp(e),up.protocol+"//"+up.host)};Xp&&Wp||(Xp=function(e){Gp(arguments.length,1);var t=Up(e)?e:Jp(e),r=jp(arguments,1);return ev[++$p]=function(){Np(t,void 0,r)},dp($p),$p},Wp=function(e){delete ev[e]},Kp?dp=function(e){qp.nextTick(nv(e))}:Yp&&Yp.now?dp=function(e){Yp.now(nv(e))}:Qp&&!zp?(hp=(lp=new Qp).port2,lp.port1.onmessage=iv,dp=Lp(hp.postMessage,hp)):Dp.addEventListener&&Up(Dp.postMessage)&&!Dp.importScripts&&up&&"file:"!==up.protocol&&!Fp(ov)?(dp=ov,Dp.addEventListener("message",iv,!1)):dp=tv in Hp("script")?function(e){Bp.appendChild(Hp("script"))[tv]=function(){Bp.removeChild(this),rv(e)}}:function(e){setTimeout(nv(e),0)});var av,sv,cv,uv,dv,lv,hv,pv,vv={set:Xp,clear:Wp},fv=o,_v=/ipad|iphone|ipod/i.test(ue)&&void 0!==fv.Pebble,mv=/web0s(?!.*chrome)/i.test(ue),gv=o,yv=Qt,Sv=C.f,bv=vv.set,Ev=Mp,kv=_v,Tv=mv,Iv=pp,Rv=gv.MutationObserver||gv.WebKitMutationObserver,Av=gv.document,wv=gv.process,Cv=gv.Promise,xv=Sv(gv,"queueMicrotask"),Ov=xv&&xv.value;Ov||(av=function(){var e,t;for(Iv&&(e=wv.domain)&&e.exit();sv;){t=sv.fn,sv=sv.next;try{t()}catch(BY){throw sv?uv():cv=void 0,BY}}cv=void 0,e&&e.enter()},Ev||Iv||Tv||!Rv||!Av?!kv&&Cv&&Cv.resolve?((hv=Cv.resolve(void 0)).constructor=Cv,pv=yv(hv.then,hv),uv=function(){pv(av)}):Iv?uv=function(){wv.nextTick(av)}:(bv=yv(bv,gv),uv=function(){bv(av)}):(dv=!0,lv=Av.createTextNode(""),new Rv(av).observe(lv,{characterData:!0}),uv=function(){lv.data=dv=!dv}));var Pv=Ov||function(e){var t={fn:e,next:void 0};cv&&(cv.next=t),sv||(sv=t,uv()),cv=t},Mv=o,Dv=function(e){try{return{error:!1,value:e()}}catch(BY){return{error:!0,value:BY}}},Nv=function(){this.head=null,this.tail=null};Nv.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var Lv=Nv,Uv=o.Promise,Vv="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Fv=!Vv&&!pp&&"object"==typeof window&&"object"==typeof document,Bv=o,jv=Uv,Hv=w,Gv=Wt,zv=ao,Kv=pt,Xv=Fv,Wv=Vv,qv=_e,Yv=jv&&jv.prototype,Jv=Kv("species"),Qv=!1,Zv=Hv(Bv.PromiseRejectionEvent),$v={CONSTRUCTOR:Gv("Promise",(function(){var e=zv(jv),t=e!==String(jv);if(!t&&66===qv)return!0;if(!Yv.catch||!Yv.finally)return!0;if(!qv||qv<51||!/native code/.test(e)){var r=new jv((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[Jv]=n,!(Qv=r.then((function(){}))instanceof n))return!0}return!t&&(Xv||Wv)&&!Zv})),REJECTION_EVENT:Zv,SUBCLASSING:Qv},ef={},tf=Oe,rf=TypeError,nf=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw rf("Bad Promise constructor");t=e,r=n})),this.resolve=tf(t),this.reject=tf(r)};ef.f=function(e){return new nf(e)};var of,af,sf=Cr,cf=pp,uf=o,df=M,lf=vi,hf=Vi,pf=gp,vf=Oe,ff=w,_f=te,mf=bp,gf=xp,yf=vv.set,Sf=Pv,bf=function(e,t){var r=Mv.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},Ef=Dv,kf=Lv,Tf=eo,If=Uv,Rf=$v,Af=ef,wf="Promise",Cf=Rf.CONSTRUCTOR,xf=Rf.REJECTION_EVENT,Of=Tf.getterFor(wf),Pf=Tf.set,Mf=If&&If.prototype,Df=If,Nf=Mf,Lf=uf.TypeError,Uf=uf.document,Vf=uf.process,Ff=Af.f,Bf=Ff,jf=!!(Uf&&Uf.createEvent&&uf.dispatchEvent),Hf="unhandledrejection",Gf=function(e){var t;return!(!_f(e)||!ff(t=e.then))&&t},zf=function(e,t){var r,n,i,o=t.value,a=1==t.state,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&Yf(t),t.rejection=1),!0===s?r=o:(d&&d.enter(),r=s(o),d&&(d.exit(),i=!0)),r===e.promise?u(Lf("Promise-chain cycle")):(n=Gf(r))?df(n,r,c,u):c(r)):u(o)}catch(BY){d&&!i&&d.exit(),u(BY)}},Kf=function(e,t){e.notified||(e.notified=!0,Sf((function(){for(var r,n=e.reactions;r=n.get();)zf(r,e);e.notified=!1,t&&!e.rejection&&Wf(e)})))},Xf=function(e,t,r){var n,i;jf?((n=Uf.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),uf.dispatchEvent(n)):n={promise:t,reason:r},!xf&&(i=uf["on"+e])?i(n):e===Hf&&bf("Unhandled promise rejection",r)},Wf=function(e){df(yf,uf,(function(){var t,r=e.facade,n=e.value;if(qf(e)&&(t=Ef((function(){cf?Vf.emit("unhandledRejection",n,r):Xf(Hf,r,n)})),e.rejection=cf||qf(e)?2:1,t.error))throw t.value}))},qf=function(e){return 1!==e.rejection&&!e.parent},Yf=function(e){df(yf,uf,(function(){var t=e.facade;cf?Vf.emit("rejectionHandled",t):Xf("rejectionhandled",t,e.value)}))},Jf=function(e,t,r){return function(n){e(t,n,r)}},Qf=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,Kf(e,!0))},Zf=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw Lf("Promise can't be resolved itself");var n=Gf(t);n?Sf((function(){var r={done:!1};try{df(n,t,Jf(Zf,r,e),Jf(Qf,r,e))}catch(BY){Qf(r,BY,e)}})):(e.value=t,e.state=1,Kf(e,!1))}catch(BY){Qf({done:!1},BY,e)}}};Cf&&(Nf=(Df=function(e){mf(this,Nf),vf(e),df(of,this);var t=Of(this);try{e(Jf(Zf,t),Jf(Qf,t))}catch(BY){Qf(t,BY)}}).prototype,(of=function(e){Pf(this,{type:wf,done:!1,notified:!1,parent:!1,reactions:new kf,rejection:!1,state:0,value:void 0})}).prototype=lf(Nf,"then",(function(e,t){var r=Of(this),n=Ff(gf(this,Df));return r.parent=!0,n.ok=!ff(e)||e,n.fail=ff(t)&&t,n.domain=cf?Vf.domain:void 0,0==r.state?r.reactions.add(n):Sf((function(){zf(n,r)})),n.promise})),af=function(){var e=new of,t=Of(e);this.promise=e,this.resolve=Jf(Zf,t),this.reject=Jf(Qf,t)},Af.f=Ff=function(e){return e===Df||undefined===e?new af(e):Bf(e)}),sf({global:!0,constructor:!0,wrap:!0,forced:Cf},{Promise:Df}),hf(Df,wf,!1,!0),pf(wf);var $f=pt("iterator"),e_=!1;try{var t_=0,r_={next:function(){return{done:!!t_++}},return:function(){e_=!0}};r_[$f]=function(){return this},Array.from(r_,(function(){throw 2}))}catch(BY){}var n_=function(e,t){if(!t&&!e_)return!1;var r=!1;try{var n={};n[$f]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(BY){}return r},i_=Uv,o_=$v.CONSTRUCTOR||!n_((function(e){i_.all(e).then(void 0,(function(){}))})),a_=M,s_=Oe,c_=ef,u_=Dv,d_=jh;Cr({target:"Promise",stat:!0,forced:o_},{all:function(e){var t=this,r=c_.f(t),n=r.resolve,i=r.reject,o=u_((function(){var r=s_(t.resolve),o=[],a=0,s=1;d_(e,(function(e){var c=a++,u=!1;s++,a_(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 l_=Cr,h_=$v.CONSTRUCTOR;Uv&&Uv.prototype,l_({target:"Promise",proto:!0,forced:h_,real:!0},{catch:function(e){return this.then(void 0,e)}});var p_=M,v_=Oe,f_=ef,__=Dv,m_=jh;Cr({target:"Promise",stat:!0,forced:o_},{race:function(e){var t=this,r=f_.f(t),n=r.reject,i=__((function(){var i=v_(t.resolve);m_(e,(function(e){p_(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var g_=M,y_=ef;Cr({target:"Promise",stat:!0,forced:$v.CONSTRUCTOR},{reject:function(e){var t=y_.f(this);return g_(t.reject,void 0,e),t.promise}});var S_=nr,b_=te,E_=ef,k_=function(e,t){if(S_(e),b_(t)&&t.constructor===e)return t;var r=E_.f(e);return(0,r.resolve)(t),r.promise},T_=Cr,I_=Uv,R_=$v.CONSTRUCTOR,A_=k_,w_=se("Promise"),C_=!R_;T_({target:"Promise",stat:!0,forced:true},{resolve:function(e){return A_(C_&&this===w_?I_:this,e)}});var x_=M,O_=Oe,P_=ef,M_=Dv,D_=jh;Cr({target:"Promise",stat:!0},{allSettled:function(e){var t=this,r=P_.f(t),n=r.resolve,i=r.reject,o=M_((function(){var r=O_(t.resolve),i=[],o=0,a=1;D_(e,(function(e){var s=o++,c=!1;a++,x_(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 N_=M,L_=Oe,U_=se,V_=ef,F_=Dv,B_=jh,j_="No one promise resolved";Cr({target:"Promise",stat:!0},{any:function(e){var t=this,r=U_("AggregateError"),n=V_.f(t),i=n.resolve,o=n.reject,a=F_((function(){var n=L_(t.resolve),a=[],s=0,c=1,u=!1;B_(e,(function(e){var d=s++,l=!1;c++,N_(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,j_)))}))})),--c||o(new r(a,j_))}));return a.error&&o(a.value),n.promise}});var H_=Cr,G_=Uv,z_=a,K_=se,X_=w,W_=xp,q_=k_,Y_=G_&&G_.prototype;H_({target:"Promise",proto:!0,real:!0,forced:!!G_&&z_((function(){Y_.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=W_(this,K_("Promise")),r=X_(e);return this.then(r?function(r){return q_(t,e()).then((function(){return r}))}:e,r?function(r){return q_(t,e()).then((function(){throw r}))}:e)}});var J_=re.Promise,Q_=ef,Z_=Dv;Cr({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=Q_.f(this),r=Z_(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var $_=r(J_),em=Cr,tm=ro,rm=T([].reverse),nm=[1,2];em({target:"Array",proto:!0,forced:String(nm)===String(nm.reverse())},{reverse:function(){return tm(this)&&(this.length=this.length),rm(this)}});var im=Bs("Array").reverse,om=ce,am=im,sm=Array.prototype,cm=r((function(e){var t=e.reverse;return e===sm||om(sm,e)&&t===sm.reverse?am:t})),um=Cr,dm=ro,lm=bo,hm=te,pm=Ur,vm=Hr,fm=Z,_m=ei,mm=pt,gm=os,ym=Us("slice"),Sm=mm("species"),bm=Array,Em=Math.max;um({target:"Array",proto:!0,forced:!ym},{slice:function(e,t){var r,n,i,o=fm(this),a=vm(o),s=pm(e,a),c=pm(void 0===t?a:t,a);if(dm(o)&&(r=o.constructor,(lm(r)&&(r===bm||dm(r.prototype))||hm(r)&&null===(r=r[Sm]))&&(r=void 0),r===bm||void 0===r))return gm(o,s,c);for(n=new(void 0===r?bm:r)(Em(c-s,0)),i=0;s<c;s++,i++)s in o&&_m(n,i,o[s]);return n.length=i,n}});var km=Bs("Array").slice,Tm=ce,Im=km,Rm=Array.prototype,Am=r((function(e){var t=e.slice;return e===Rm||Tm(Rm,e)&&t===Rm.slice?Im:t}));function wm(){wm=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=cd||function(e,t,r){e[t]=r.value},i="function"==typeof xd?xd:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,r){return cd(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(A){c=function(e,t,r){return e[t]=r}}function u(e,t,r,i){var o=t&&t.prototype instanceof h?t:h,a=zl(o.prototype),s=new T(i||[]);return n(a,"_invoke",{value:S(e,r,s)}),a}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(A){return{type:"throw",arg:A}}}e.wrap=u;var l={};function h(){}function p(){}function v(){}var f={};c(f,o,(function(){return this}));var _=ql&&ql(ql(I([])));_&&_!==t&&r.call(_,o)&&(f=_);var m=v.prototype=h.prototype=zl(f);function g(e){var t;Uu(t=["next","throw","return"]).call(t,(function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){function i(n,o,a,s){var c=d(e[n],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Yd(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return i("throw",e,a,s)}))}s(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function S(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=b(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=d(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function b(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),l;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,l;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],Uu(e).call(e,E,this),this.reset(!0)}function I(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:R}}function R(){return{value:void 0,done:!0}}return p.prototype=v,n(m,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:p,configurable:!0}),p.displayName=c(v,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Yl?Yl(e,v):(e.__proto__=v,c(e,s,"GeneratorFunction")),e.prototype=zl(m),e},e.awrap=function(e){return{__await:e}},g(y.prototype),c(y.prototype,a,(function(){return this})),e.AsyncIterator=y,e.async=function(t,r,n,i,o){void 0===o&&(o=$_);var a=new y(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),c(m,s,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return cm(r).call(r),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,T.prototype={constructor:T,reset:function(e){var t;if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,Uu(t=this.tryEntries).call(t,k),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+Am(n).call(n,1))&&(this[n]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;k(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function Cm(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(BY){return void r(BY)}s.done?t(c):$_.resolve(c).then(n,i)}function xm(e){return function(){var t=this,r=arguments;return new $_((function(n,i){var o=e.apply(t,r);function a(e){Cm(o,n,i,a,s,"next",e)}function s(e){Cm(o,n,i,a,s,"throw",e)}a(void 0)}))}}var Om=Bs("Array").concat,Pm=ce,Mm=Om,Dm=Array.prototype,Nm=r((function(e){var t=e.concat;return e===Dm||Pm(Dm,e)&&t===Dm.concat?Mm:t})),Lm=re,Um=h;Lm.JSON||(Lm.JSON={stringify:JSON.stringify});var Vm=function(e,t,r){return Um(Lm.JSON.stringify,null,arguments)},Fm=r(Vm),Bm=Lo.map;Cr({target:"Array",proto:!0,forced:!Us("map")},{map:function(e){return Bm(this,e,arguments.length>1?arguments[1]:void 0)}});var jm=Bs("Array").map,Hm=ce,Gm=jm,zm=Array.prototype,Km=r((function(e){var t=e.map;return e===zm||Hm(zm,e)&&t===zm.map?Gm:t})),Xm="\t\n\v\f\r                 \u2028\u2029\ufeff",Wm=Y,qm=Sn,Ym=Xm,Jm=T("".replace),Qm="["+Ym+"]",Zm=RegExp("^"+Qm+Qm+"*"),$m=RegExp(Qm+Qm+"*$"),eg=function(e){return function(t){var r=qm(Wm(t));return 1&e&&(r=Jm(r,Zm,"")),2&e&&(r=Jm(r,$m,"")),r}},tg={start:eg(1),end:eg(2),trim:eg(3)},rg=o,ng=a,ig=T,og=Sn,ag=tg.trim,sg=Xm,cg=rg.parseInt,ug=rg.Symbol,dg=ug&&ug.iterator,lg=/^[+-]?0x/i,hg=ig(lg.exec),pg=8!==cg(sg+"08")||22!==cg(sg+"0x16")||dg&&!ng((function(){cg(Object(dg))}))?function(e,t){var r=ag(og(e));return cg(r,t>>>0||(hg(lg,r)?16:10))}:cg;Cr({global:!0,forced:parseInt!=pg},{parseInt:pg});var vg=r(re.parseInt),fg={exports:{}},_g=a((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),mg=a,gg=te,yg=b,Sg=_g,bg=Object.isExtensible,Eg=mg((function(){bg(1)}))||Sg?function(e){return!!gg(e)&&((!Sg||"ArrayBuffer"!=yg(e))&&(!bg||bg(e)))}:bg,kg=!a((function(){return Object.isExtensible(Object.preventExtensions({}))})),Tg=Cr,Ig=T,Rg=qr,Ag=te,wg=Ze,Cg=Zt.f,xg=Wn,Og=Jn,Pg=Eg,Mg=kg,Dg=!1,Ng=nt("meta"),Lg=0,Ug=function(e){Cg(e,Ng,{value:{objectID:"O"+Lg++,weakData:{}}})},Vg=fg.exports={enable:function(){Vg.enable=function(){},Dg=!0;var e=xg.f,t=Ig([].splice),r={};r[Ng]=1,e(r).length&&(xg.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===Ng){t(n,i,1);break}return n},Tg({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Og.f}))},fastKey:function(e,t){if(!Ag(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!wg(e,Ng)){if(!Pg(e))return"F";if(!t)return"E";Ug(e)}return e[Ng].objectID},getWeakData:function(e,t){if(!wg(e,Ng)){if(!Pg(e))return!0;if(!t)return!1;Ug(e)}return e[Ng].weakData},onFreeze:function(e){return Mg&&Dg&&Pg(e)&&!wg(e,Ng)&&Ug(e),e}};Rg[Ng]=!0;var Fg=fg.exports,Bg=Cr,jg=o,Hg=Fg,Gg=a,zg=mr,Kg=jh,Xg=bp,Wg=w,qg=te,Yg=Vi,Jg=Zt.f,Qg=Lo.forEach,Zg=x,$g=eo.set,ey=eo.getterFor,ty=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=jg[e],c=s&&s.prototype,u={};if(Zg&&Wg(s)&&(o||c.forEach&&!Gg((function(){(new s).entries().next()})))){var d=(n=t((function(t,r){$g(Xg(t,d),{type:e,collection:new s}),null!=r&&Kg(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,l=ey(e);Qg(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in c)||o&&"clear"==e||zg(d,e,(function(r,n){var i=l(this).collection;if(!t&&o&&!qg(r))return"get"==e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||Jg(d,"size",{configurable:!0,get:function(){return l(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Hg.enable();return Yg(n,e,!1,!0),u[e]=n,Bg({global:!0,forced:!0},u),o||r.setStrong(n,e,i),n},ry=vi,ny=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:ry(e,n,t[n],r);return e},iy=Zt.f,oy=Xn,ay=ny,sy=Qt,cy=bp,uy=X,dy=jh,ly=su,hy=cu,py=gp,vy=x,fy=Fg.fastKey,_y=eo.set,my=eo.getterFor,gy={getConstructor:function(e,t,r,n){var i=e((function(e,i){cy(e,o),_y(e,{type:t,index:oy(null),first:void 0,last:void 0,size:0}),vy||(e.size=0),uy(i)||dy(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=my(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=fy(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),vy?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=fy(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return ay(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,vy?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),vy?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=sy(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)}}),ay(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)}}),vy&&iy(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=my(t),o=my(n);ly(e,t,(function(e,t){_y(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)?hy("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,hy(void 0,!0))}),r?"entries":"values",!r,!0),py(t)}};ty("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),gy);var yy=re.Map,Sy=Qt,by=M,Ey=Oe,ky=Ip,Ty=X,Iy=jh,Ry=[].push,Ay=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return ky(this),(t=void 0!==a)&&Ey(a),Ty(e)?new this:(r=[],t?(n=0,i=Sy(a,o>2?arguments[2]:void 0),Iy(e,(function(e){by(Ry,r,i(e,n++))}))):Iy(e,Ry,{that:r}),new this(r))};Cr({target:"Map",stat:!0,forced:!0},{from:Ay});var wy=os,Cy=function(){return new this(wy(arguments))};Cr({target:"Map",stat:!0,forced:!0},{of:Cy});var xy=M,Oy=Oe,Py=nr,My=function(){for(var e,t=Py(this),r=Oy(t.delete),n=!0,i=0,o=arguments.length;i<o;i++)e=xy(r,t,arguments[i]),n=n&&e;return!!n};Cr({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:My});var Dy=M,Ny=Oe,Ly=nr;Cr({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,t){var r,n,i=Ly(this),o=Ny(i.get),a=Ny(i.has),s=Ny(i.set);return Dy(a,i,e)?(r=Dy(o,i,e),"update"in t&&(r=t.update(r,e,i),Dy(s,i,e,r)),r):(n=t.insert(e,i),Dy(s,i,e,n),n)}});var Uy=kh,Vy=nr,Fy=Qt,By=Uy,jy=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=Vy(this),r=By(t),n=Fy(e,arguments.length>1?arguments[1]:void 0);return!jy(r,(function(e,r,i){if(!n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var Hy=se,Gy=Qt,zy=M,Ky=Oe,Xy=nr,Wy=xp,qy=Uy,Yy=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=Xy(this),r=qy(t),n=Gy(e,arguments.length>1?arguments[1]:void 0),i=new(Wy(t,Hy("Map"))),o=Ky(i.set);return Yy(r,(function(e,r){n(r,e,t)&&zy(o,i,e,r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var Jy=nr,Qy=Qt,Zy=Uy,$y=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=Jy(this),r=Zy(t),n=Qy(e,arguments.length>1?arguments[1]:void 0);return $y(r,(function(e,r,i){if(n(r,e,t))return i(r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var eS=nr,tS=Qt,rS=Uy,nS=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=eS(this),r=rS(t),n=tS(e,arguments.length>1?arguments[1]:void 0);return nS(r,(function(e,r,i){if(n(r,e,t))return i(e)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var iS=Cr,oS=M,aS=Oe,sS=kh,cS=jh,uS=T([].push);iS({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){aS(t);var r=sS(e),n=new this,i=aS(n.has),o=aS(n.get),a=aS(n.set);return cS(r,(function(e){var r=t(e);oS(i,n,r)?uS(oS(o,n,r),e):oS(a,n,r,[e])}),{IS_ITERATOR:!0}),n}});var dS=nr,lS=Uy,hS=function(e,t){return e===t||e!=e&&t!=t},pS=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return pS(lS(dS(this)),(function(t,r,n){if(hS(r,e))return n()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var vS=M,fS=jh,_S=Oe;Cr({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new this;_S(t);var n=_S(r.set);return fS(e,(function(e){vS(n,r,t(e),e)})),r}});var mS=nr,gS=Uy,yS=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){return yS(gS(mS(this)),(function(t,r,n){if(r===e)return n(t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var SS=se,bS=Qt,ES=M,kS=Oe,TS=nr,IS=xp,RS=Uy,AS=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=TS(this),r=RS(t),n=bS(e,arguments.length>1?arguments[1]:void 0),i=new(IS(t,SS("Map"))),o=kS(i.set);return AS(r,(function(e,r){ES(o,i,n(r,e,t),r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var wS=se,CS=Qt,xS=M,OS=Oe,PS=nr,MS=xp,DS=Uy,NS=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=PS(this),r=DS(t),n=CS(e,arguments.length>1?arguments[1]:void 0),i=new(MS(t,wS("Map"))),o=OS(i.set);return NS(r,(function(e,r){xS(o,i,e,n(r,e,t))}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var LS=Oe,US=nr,VS=jh;Cr({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=US(this),r=LS(t.set),n=arguments.length,i=0;i<n;)VS(arguments[i++],r,{that:t,AS_ENTRIES:!0});return t}});var FS=nr,BS=Oe,jS=Uy,HS=jh,GS=TypeError;Cr({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=FS(this),r=jS(t),n=arguments.length<2,i=n?void 0:arguments[1];if(BS(e),HS(r,(function(r,o){n?(n=!1,i=o):i=e(i,o,r,t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),n)throw GS("Reduce of empty map with no initial value");return i}});var zS=nr,KS=Qt,XS=Uy,WS=jh;Cr({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=zS(this),r=XS(t),n=KS(e,arguments.length>1?arguments[1]:void 0);return WS(r,(function(e,r,i){if(n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var qS=M,YS=nr,JS=Oe,QS=TypeError;Cr({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=YS(this),n=JS(r.get),i=JS(r.has),o=JS(r.set),a=arguments.length;JS(t);var s=qS(i,r,e);if(!s&&a<3)throw QS("Updating absent value");var c=s?qS(n,r,e):JS(a>2?arguments[2]:void 0)(e,r);return qS(o,r,e,t(c,e,r)),r}});var ZS=M,$S=Oe,eb=w,tb=nr,rb=TypeError,nb=function(e,t){var r,n=tb(this),i=$S(n.get),o=$S(n.has),a=$S(n.set),s=arguments.length>2?arguments[2]:void 0;if(!eb(t)&&!eb(s))throw rb("At least one callback required");return ZS(o,n,e)?(r=ZS(i,n,e),eb(t)&&(r=t(r),ZS(a,n,e,r))):eb(s)&&(r=s(),ZS(a,n,e,r)),r};Cr({target:"Map",proto:!0,real:!0,forced:!0},{upsert:nb}),Cr({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:nb});var ib=r(yy),ob=Oe,ab=Ye,sb=K,cb=Hr,ub=TypeError,db=function(e){return function(t,r,n,i){ob(r);var o=ab(t),a=sb(o),s=cb(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 ub("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}},lb={left:db(!1),right:db(!0)}.left,hb=_e,pb=pp;Cr({target:"Array",proto:!0,forced:!Au("reduce")||!pb&&hb>79&&hb<83},{reduce:function(e){var t=arguments.length;return lb(this,e,t,t>1?arguments[1]:void 0)}});var vb=Bs("Array").reduce,fb=ce,_b=vb,mb=Array.prototype,gb=r((function(e){var t=e.reduce;return e===mb||fb(mb,e)&&t===mb.reduce?_b:t})),yb=x,Sb=T,bb=M,Eb=a,kb=on,Tb=hi,Ib=D,Rb=Ye,Ab=K,wb=Object.assign,Cb=Object.defineProperty,xb=Sb([].concat),Ob=!wb||Eb((function(){if(yb&&1!==wb({b:1},wb(Cb({},"a",{enumerable:!0,get:function(){Cb(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=wb({},e)[r]||kb(wb({},t)).join("")!=n}))?function(e,t){for(var r=Rb(e),n=arguments.length,i=1,o=Tb.f,a=Ib.f;n>i;)for(var s,c=Ab(arguments[i++]),u=o?xb(kb(c),o(c)):kb(c),d=u.length,l=0;d>l;)s=u[l++],yb&&!bb(a,c,s)||(r[s]=c[s]);return r}:wb,Pb=Ob;Cr({target:"Object",stat:!0,arity:2,forced:Object.assign!==Pb},{assign:Pb});var Mb=r(re.Object.assign),Db=te,Nb=b,Lb=pt("match"),Ub=function(e){var t;return Db(e)&&(void 0!==(t=e[Lb])?!!t:"RegExp"==Nb(e))},Vb=TypeError,Fb=function(e){if(Ub(e))throw Vb("The method doesn't accept regular expressions");return e},Bb=pt("match"),jb=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Bb]=!1,"/./"[e](t)}catch(n){}}return!1},Hb=Cr,Gb=T;C.f;var zb=Br,Kb=Sn,Xb=Fb,Wb=Y,qb=jb,Yb=Gb("".endsWith),Jb=Gb("".slice),Qb=Math.min;Hb({target:"String",proto:!0,forced:!qb("endsWith")},{endsWith:function(e){var t=Kb(Wb(this));Xb(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:Qb(zb(r),n),o=Kb(e);return Yb?Yb(t,o,i):Jb(t,i-o.length,i)===o}});var Zb=Bs("String").endsWith,$b=ce,eE=Zb,tE=String.prototype,rE=r((function(e){var t=e.endsWith;return"string"==typeof e||e===tE||$b(tE,e)&&t===tE.endsWith?eE:t})),nE=!0,iE=!0;function oE(e,t,r){var n=e.match(t);return n&&n.length>=r&&vg(n[r],10)}function aE(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 ib),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===cn(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},cd(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 sE(e){return"boolean"!=typeof e?new Error("Argument type: "+Yd(e)+". Please use a boolean."):(nE=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function cE(e){return"boolean"!=typeof e?new Error("Argument type: "+Yd(e)+". Please use a boolean."):(iE=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function uE(){if("object"===("undefined"==typeof window?"undefined":Yd(window))){if(nE)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function dE(e,t){iE&&console.warn(e+" is deprecated, please use "+t+" instead.")}function lE(e){return"[object Object]"===Object.prototype.toString.call(e)}function hE(e){var t;return lE(e)?gb(t=cn(e)).call(t,(function(t,r){var n=lE(e[r]),i=n?hE(e[r]):e[r],o=n&&!cn(i).length;return void 0===i||o?t:Mb(t,Zd({},r,i))}),{}):e}function pE(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),cn(t).forEach((function(n){rE(n).call(n,"Id")?pE(e,e.get(t[n]),r):rE(n).call(n,"Ids")&&t[n].forEach((function(t){pE(e,e.get(t),r)}))})))}function vE(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new ib;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&&pE(e,r,i)}))})),i}var fE=Cr,_E=Lo.find,mE="find",gE=!0;mE in[]&&Array(1)[mE]((function(){gE=!1})),fE({target:"Array",proto:!0,forced:gE},{find:function(e){return _E(this,e,arguments.length>1?arguments[1]:void 0)}});var yE=Bs("Array").find,SE=ce,bE=yE,EE=Array.prototype,kE=r((function(e){var t=e.find;return e===EE||SE(EE,e)&&t===EE.find?bE:t})),TE=Cr,IE=Wr.indexOf,RE=Au,AE=T([].indexOf),wE=!!AE&&1/AE([1],1,-0)<0,CE=RE("indexOf");TE({target:"Array",proto:!0,forced:wE||!CE},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return wE?AE(this,e,t)||0:IE(this,e,t)}});var xE=Bs("Array").indexOf,OE=ce,PE=xE,ME=Array.prototype,DE=r((function(e){var t=e.indexOf;return e===ME||OE(ME,e)&&t===ME.indexOf?PE:t})),NE=x,LE=ro,UE=TypeError,VE=Object.getOwnPropertyDescriptor,FE=NE&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(BY){return BY instanceof TypeError}}(),BE=Ae,jE=TypeError,HE=function(e,t){if(!delete e[t])throw jE("Cannot delete property "+BE(t)+" of "+BE(e))},GE=Cr,zE=Ye,KE=Ur,XE=Mr,WE=Hr,qE=FE?function(e,t){if(LE(e)&&!VE(e,"length").writable)throw UE("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},YE=dd,JE=wo,QE=ei,ZE=HE,$E=Us("splice"),ek=Math.max,tk=Math.min;GE({target:"Array",proto:!0,forced:!$E},{splice:function(e,t){var r,n,i,o,a,s,c=zE(this),u=WE(c),d=KE(e,u),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=u-d):(r=l-2,n=tk(ek(XE(t),0),u-d)),YE(u+r-n),i=JE(c,n),o=0;o<n;o++)(a=d+o)in c&&QE(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]:ZE(c,s);for(o=u;o>u-n+r;o--)ZE(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]:ZE(c,s);for(o=0;o<r;o++)c[o+d]=arguments[o+2];return qE(c,u-n+r),i}});var rk=Bs("Array").splice,nk=ce,ik=rk,ok=Array.prototype,ak=r((function(e){var t=e.splice;return e===ok||nk(ok,e)&&t===ok.splice?ik:t})),sk=Wr.includes;Cr({target:"Array",proto:!0,forced:a((function(){return!Array(1).includes()}))},{includes:function(e){return sk(this,e,arguments.length>1?arguments[1]:void 0)}});var ck=Bs("Array").includes,uk=Cr,dk=Fb,lk=Y,hk=Sn,pk=jb,vk=T("".indexOf);uk({target:"String",proto:!0,forced:!pk("includes")},{includes:function(e){return!!~vk(hk(lk(this)),hk(dk(e)),arguments.length>1?arguments[1]:void 0)}});var fk=Bs("String").includes,_k=ce,mk=ck,gk=fk,yk=Array.prototype,Sk=String.prototype,bk=r((function(e){var t=e.includes;return e===yk||_k(yk,e)&&t===yk.includes?mk:"string"==typeof e||e===Sk||_k(Sk,e)&&t===Sk.includes?gk:t})),Ek=uE;function kk(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==Yd(e)||e.mandatory||e.optional)return e;var t,r={};(cn(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===Yd(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()+Am(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=Nm(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(Fm(e)))&&"object"===Yd(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(Fm(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===Yd(e.video)){var a=e.video.facingMode;a=a&&("object"===Yd(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=Ks(t).call(t,(function(e){return"videoinput"===e.kind}));var r=kE(t).call(t,(function(e){return s.some((function(t){var r;return bk(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&bk(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),Ek("chrome: "+Fm(e)),i(e)}));e.video=n(e.video)}return Ek("chrome: "+Fm(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 $_.reject(o(e))}))}))}}}}function Tk(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function Ik(e){if("object"===Yd(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){cd(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=kE(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=kE(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 aE(e,"track",(function(e){return e.transceiver||cd(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function Rk(e){if("object"===Yd(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||[],Am(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=DE(t=this._senders).call(t,e);-1!==i&&ak(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=kE(r=t._senders).call(r,(function(t){return t.track===e}));o&&ak(n=t._senders).call(n,DE(i=t._senders).call(i,o),1)}))}}else if("object"===Yd(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},cd(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 Ak(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=Am(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 ib(Km(t=cn(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 $_((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function wk(e){if("object"===Yd(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 vE(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}),aE(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 vE(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?$_.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():$_.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function Ck(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Km(e=cn(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===DE(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(kE(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=Ks(t=this.getSenders()).call(t,(function(e){return-1===DE(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Nm(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&&cn(this._shimmedLocalStreams).forEach((function(r){var n,i,o=DE(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&ak(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function xk(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Ck(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},Km(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(kE(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=Am([]).call(arguments,1);if(1!==s.length||!kE(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(kE(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),$_.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 kE(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Zd({},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,cn(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=ic(e.RTCPeerConnection.prototype,"localDescription");cd(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||{},cn(this._streams).forEach((function(n){var i;kE(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 cn(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 Ok(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=Zd({},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 Pk(e,t){aE(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 Mk=Object.freeze({__proto__:null,fixNegotiationNeeded:Pk,shimAddTrackRemoveTrack:xk,shimAddTrackRemoveTrackWithNative:Ck,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:Rk,shimGetStats:Ak,shimGetUserMedia:kk,shimMediaStream:Tk,shimOnTrack:Ik,shimPeerConnection:Ok,shimSenderReceiverGetStats:wk});Cr({target:"Array",stat:!0},{isArray:ro});var Dk=r(re.Array.isArray);function Nk(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Lk=r(_h),Uk=nr,Vk=Ah,Fk=Qt,Bk=M,jk=Ye,Hk=function(e,t,r,n){try{return n?t(Uk(r)[0],r[1]):t(r)}catch(BY){Vk(e,"throw",BY)}},Gk=dh,zk=bo,Kk=Hr,Xk=ei,Wk=kh,qk=_h,Yk=Array,Jk=function(e){var t=jk(e),r=zk(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=Fk(i,n>2?arguments[2]:void 0));var a,s,c,u,d,l,h=qk(t),p=0;if(!h||this===Yk&&Gk(h))for(a=Kk(t),s=r?new this(a):Yk(a);a>p;p++)l=o?i(t[p],p):t[p],Xk(s,p,l);else for(d=(u=Wk(t,h)).next,s=r?new this:[];!(c=Bk(d,u)).done;p++)l=o?Hk(u,i,[c.value,p],!0):c.value,Xk(s,p,l);return s.length=p,s},Qk=Jk;Cr({target:"Array",stat:!0,forced:!n_((function(e){Array.from(e)}))},{from:Qk});var Zk=r(re.Array.from);function $k(e,t){var r;if(e){if("string"==typeof e)return Nk(e,t);var n=Am(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Zk(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Nk(e,t):void 0}}function eT(e){return function(e){if(Dk(e))return Nk(e)}(e)||function(e){if(void 0!==xd&&null!=Lk(e)||null!=e["@@iterator"])return Zk(e)}(e)||$k(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 tT=o,rT=a,nT=Sn,iT=tg.trim,oT=Xm,aT=T("".charAt),sT=tT.parseFloat,cT=tT.Symbol,uT=cT&&cT.iterator,dT=1/sT(oT+"-0")!=-1/0||uT&&!rT((function(){sT(Object(uT))}))?function(e){var t=iT(nT(e)),r=sT(t);return 0===r&&"-"==aT(t,0)?-0:r}:sT;Cr({global:!0,forced:parseFloat!=dT},{parseFloat:dT});var lT=r(re.parseFloat);function hT(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){dE("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"===Yd(e)&&"object"===Yd(e.audio)&&(e=JSON.parse(Fm(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"===Yd(e)&&(e=JSON.parse(Fm(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function pT(e){"object"===Yd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&cd(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function vT(e,t){if("object"===Yd(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=Zd({},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=Am(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,Mb({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function fT(e){if("object"===Yd(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):$_.resolve(new ib)}}}function _T(e){if("object"===Yd(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}),aE(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function mT(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;dE("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&bk(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function gT(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function yT(e){if("object"===Yd(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=eT(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&&!(lT(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(lT(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===cn(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 ST(e){if("object"===Yd(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=Nm(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function bT(e){if("object"===Yd(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?$_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function ET(e){if("object"===Yd(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?$_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var kT=Object.freeze({__proto__:null,shimAddTransceiver:yT,shimCreateAnswer:ET,shimCreateOffer:bT,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,$_.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})},shimGetParameters:ST,shimGetUserMedia:hT,shimOnTrack:pT,shimPeerConnection:vT,shimRTCDataChannel:gT,shimReceiverGetStats:_T,shimRemoveStream:mT,shimSenderGetStats:fT});function TT(e){if("object"===Yd(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=[]),bk(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?bk(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=DE(t=this._localStreams).call(t,e);if(-1!==i){ak(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){bk(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function IT(e){if("object"===Yd(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){cd(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=[]),!bk(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=[]),!(DE(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 RT(e){if("object"===Yd(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),$_.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),$_.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),$_.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),$_.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),$_.resolve()):n},t.addIceCandidate=s}}function AT(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(wT(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function wT(e){return e&&void 0!==e.video?Mb({},e,{video:hE(e.video)}):e}function CT(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")?(dE("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(Fm(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&&cd(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function xT(e){"object"===Yd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&cd(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function OT(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=kE(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=kE(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 PT(e){"object"!==Yd(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var MT=Object.freeze({__proto__:null,shimAudioContext:PT,shimCallbacksAPI:RT,shimConstraints:wT,shimCreateOfferLegacy:OT,shimGetUserMedia:AT,shimLocalStreamsAPI:TT,shimRTCIceServerUrls:CT,shimRemoteStreamsAPI:IT,shimTrackEventTransceiver:xT}),DT=lc.PROPER,NT=a,LT=Xm,UT=tg.trim;Cr({target:"String",proto:!0,forced:function(e){return NT((function(){return!!LT[e]()||"​…᠎"!=="​…᠎"[e]()||DT&&LT[e].name!==e}))}("trim")},{trim:function(){return UT(this)}});var VT,FT,BT=Bs("String").trim,jT=ce,HT=BT,GT=String.prototype,zT=r((function(e){var t=e.trim;return"string"==typeof e||e===GT||jT(GT,e)&&t===GT.trim?HT:t})),KT={exports:{}};VT=KT,(FT={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=FT.generateIdentifier(),FT.splitLines=function(e){var t;return Km(t=zT(e).call(e).split("\n")).call(t,(function(e){return zT(e).call(e)}))},FT.splitSections=function(e){var t=e.split("\nm=");return Km(t).call(t,(function(e,t){var r;return zT(r=t>0?"m="+e:e).call(r)+"\r\n"}))},FT.getDescription=function(e){var t=FT.splitSections(e);return t&&t[0]},FT.getMediaSections=function(e){var t=FT.splitSections(e);return t.shift(),t},FT.matchPrefix=function(e,t){var r;return Ks(r=FT.splitLines(e)).call(r,(function(e){return 0===DE(e).call(e,t)}))},FT.parseCandidate=function(e){for(var t,r={foundation:(t=0===DE(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:vg(t[3],10),ip:t[4],address:t[4],port:vg(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=vg(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},FT.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(" ")},FT.parseIceOptions=function(e){return e.substr(14).split(" ")},FT.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:vg(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=vg(t[1],10),r.channels=3===t.length?vg(t[2],10):1,r.numChannels=r.channels,r},FT.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"},FT.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:vg(r[0],10),direction:DE(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},FT.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},FT.parseFmtp=function(e){for(var t,r={},n=e.substr(DE(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=zT(o=n[i]).call(o).split("="),r[zT(a=t[0]).call(a)]=t[1]}return r},FT.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&cn(e.parameters).length){var n=[];cn(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},FT.parseRtcpFb=function(e){var t=e.substr(DE(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},FT.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},FT.parseSsrcMedia=function(e){var t=DE(e).call(e," "),r={ssrc:vg(e.substr(7,t-7),10)},n=DE(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},FT.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:Km(t).call(t,(function(e){return vg(e,10)}))}},FT.getMid=function(e){var t=FT.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},FT.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},FT.getDtlsParameters=function(e,t){var r=FT.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:Km(r).call(r,FT.parseFingerprint)}},FT.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},FT.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:vg(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:Am(t).call(t,3)}},FT.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===Yd(e.keyParams)?FT.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},FT.parseCryptoKeyParams=function(e){if(0!==DE(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}},FT.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},FT.getCryptoParameters=function(e,t){var r=FT.matchPrefix(e+t,"a=crypto:");return Km(r).call(r,FT.parseCryptoLine)},FT.getIceParameters=function(e,t){var r=FT.matchPrefix(e+t,"a=ice-ufrag:")[0],n=FT.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},FT.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},FT.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=FT.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=FT.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=FT.parseRtpMap(o),c=FT.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=c.length?FT.parseFmtp(c[0]):{},s.rtcpFeedback=Km(a=FT.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,FT.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return FT.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(FT.parseExtmap(e))})),t},FT.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=Km(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+=FT.writeRtpMap(e),n+=FT.writeFmtp(e),n+=FT.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+=FT.writeExtmap(e)})),n},FT.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],c=FT.parseRtpParameters(e),u=-1!==DE(t=c.fecMechanisms).call(t,"RED"),d=-1!==DE(r=c.fecMechanisms).call(r,"ULPFEC"),l=Ks(n=Km(i=FT.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return FT.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=l.length>0&&l[0].ssrc,p=Km(o=FT.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return Km(t).call(t,(function(e){return vg(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:vg(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),u&&((t=JSON.parse(Fm(t))).fec={ssrc:h,mechanism:d?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var v,f,_=FT.matchPrefix(e,"b=");return _.length&&(_=0===DE(v=_[0]).call(v,"b=TIAS:")?vg(_[0].substr(7),10):0===DE(f=_[0]).call(f,"b=AS:")?1e3*vg(_[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=_}))),s},FT.parseRtcpParameters=function(e){var t,r,n={},i=Ks(t=Km(r=FT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return FT.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=FT.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=FT.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},FT.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},FT.parseMsid=function(e){var t,r,n,i=FT.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=Ks(t=Km(r=FT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return FT.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},FT.parseSctpDescription=function(e){var t,r=FT.parseMLine(e),n=FT.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=vg(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=FT.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:vg(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=FT.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:vg(a[0],10),protocol:a[1],maxMessageSize:t}}},FT.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("")},FT.generateSessionId=function(){return Math.random().toString().substr(2,21)},FT.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||FT.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},FT.getDirection=function(e,t){for(var r=FT.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?FT.getDirection(t):"sendrecv"},FT.getKind=function(e){return FT.splitLines(e)[0].split(" ")[0].substr(2)},FT.isRejected=function(e){return"0"===e.split(" ",2)[1]},FT.parseMLine=function(e){var t=FT.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:vg(t[1],10),protocol:t[2],fmt:Am(t).call(t,3).join(" ")}},FT.parseOLine=function(e){var t=FT.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:vg(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},FT.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=FT.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},VT.exports=FT;var XT=KT.exports,WT=r(XT),qT=e({__proto__:null,default:WT},[XT]);function YT(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===Yd(e)&&e.candidate&&0===DE(r=e.candidate).call(r,"a=")&&((e=JSON.parse(Fm(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=WT.parseCandidate(e.candidate),o=Mb(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,aE(e,"icecandidate",(function(t){return t.candidate&&cd(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function JT(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||aE(e,"icecandidate",(function(e){if(e.candidate){var t=WT.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function QT(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||cd(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&&cd(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=WT.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=WT.parseMLine(e);return r&&"application"===r.kind&&-1!==DE(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=vg(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=WT.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=vg(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={};cd(c,"maxMessageSize",{get:function(){return i}}),this._sctp=c}return r.apply(this,arguments)}}}function ZT(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},aE(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 $T(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;cd(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),cd(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 eI(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!==DE(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=Ks(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==zT(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 tI(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?$_.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),$_.resolve())})}}function rI(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"!==Yd(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 nI=Object.freeze({__proto__:null,removeExtmapAllowMixed:eI,shimAddIceCandidateNullOrEmpty:tI,shimConnectionState:$T,shimMaxMessageSize:QT,shimParameterlessSetLocalDescription:rI,shimRTCIceCandidate:YT,shimRTCIceCandidateRelayProtocol:JT,shimSendThrowTypeError:ZT});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=uE,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=oE(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=oE(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=oE(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),i={browserDetails:n,commonShim:nI,extractVersion:oE,disableLog:sE,disableWarnings:cE,sdp:qT};switch(n.browser){case"chrome":if(!Mk||!Ok||!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=Mk,tI(e,n),rI(e),kk(e,n),Tk(e),Ok(e,n),Ik(e),xk(e,n),Rk(e),Ak(e),wk(e),Pk(e,n),YT(e),JT(e),$T(e),QT(e,n),ZT(e),eI(e,n);break;case"firefox":if(!kT||!vT||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),i;r("adapter.js shimming firefox."),i.browserShim=kT,tI(e,n),rI(e),hT(e,n),vT(e,n),pT(e),mT(e),fT(e),_T(e),gT(e),yT(e),ST(e),bT(e),ET(e),YT(e),$T(e),QT(e,n),ZT(e);break;case"safari":if(!MT||!t.shimSafari)return r("Safari shim is not included in this adapter release."),i;r("adapter.js shimming safari."),i.browserShim=MT,tI(e,n),rI(e),CT(e),OT(e),RT(e),TT(e),IT(e),xT(e),AT(e),PT(e),YT(e),JT(e),QT(e,n),ZT(e),eI(e,n);break;default:r("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var iI=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=iI.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 oI(e,t){var r=void 0!==xd&&Lk(e)||e["@@iterator"];if(!r){if(Dk(e)||(r=$k(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 aI(e,t){return function(e){if(Dk(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==xd&&Lk(e)||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(d){u=!0,i=d}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||$k(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function sI(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var cI=Ze,uI=function(e){return void 0!==e&&(cI(e,"value")||cI(e,"writable"))},dI=M,lI=te,hI=nr,pI=uI,vI=C,fI=Sc;Cr({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return hI(t)===o?t[r]:(n=vI.f(t,r))?pI(n)?n.value:void 0===n.get?void 0:dI(n.get,o):lI(i=fI(t))?e(i,r,o):void 0}});var _I=r(re.Reflect.get),mI=T,gI=Oe,yI=te,SI=Ze,bI=os,EI=s,kI=Function,TI=mI([].concat),II=mI([].join),RI={},AI=EI?kI.bind:function(e){var t=gI(this),r=t.prototype,n=bI(arguments,1),i=function(){var r=TI(n,bI(arguments));return this instanceof i?function(e,t,r){if(!SI(RI,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";RI[t]=kI("C,a","return new C("+II(n,",")+")")}return RI[t](e,r)}(t,r.length,r):t.apply(e,r)};return yI(r)&&(i.prototype=r),i},wI=AI;Cr({target:"Function",proto:!0,forced:Function.bind!==wI},{bind:wI});var CI=Bs("Function").bind,xI=ce,OI=CI,PI=Function.prototype,MI=r((function(e){var t=e.bind;return e===PI||xI(PI,e)&&t===PI.bind?OI:t}));function DI(e){var t;return(DI=Yl?MI(t=ql).call(t):function(e){return e.__proto__||ql(e)})(e)}function NI(){var e;"undefined"!=typeof Reflect&&_I?NI=MI(e=_I).call(e):NI=function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=DI(e)););return e}(e,t);if(n){var i=ic(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return NI.apply(this,arguments)}function LI(e,t){var r;return(LI=Yl?MI(r=Yl).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function UI(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=zl(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),cd(e,"prototype",{writable:!1}),t&&LI(e,t)}var VI=Cr,FI=h,BI=AI,jI=Ip,HI=nr,GI=te,zI=Xn,KI=a,XI=se("Reflect","construct"),WI=Object.prototype,qI=[].push,YI=KI((function(){function e(){}return!(XI((function(){}),[],e)instanceof e)})),JI=!KI((function(){XI((function(){}))})),QI=YI||JI;VI({target:"Reflect",stat:!0,forced:QI,sham:QI},{construct:function(e,t){jI(e),HI(t);var r=arguments.length<3?e:jI(arguments[2]);if(JI&&!YI)return XI(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 FI(qI,n,t),new(FI(BI,e,n))}var i=r.prototype,o=zI(GI(i)?i:WI),a=FI(e,o,t);return GI(a)?a:o}});var ZI=r(re.Reflect.construct);function $I(){if("undefined"==typeof Reflect||!ZI)return!1;if(ZI.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(ZI(Boolean,[],(function(){}))),!0}catch(e){return!1}}function eR(e){var t=$I();return function(){var r,n=DI(e);if(t){var i=DI(this).constructor;r=ZI(n,arguments,i)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===Yd(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return sI(e)}(this,r)}}var tR=Bs("Array").values,rR=mn,nR=Ze,iR=ce,oR=tR,aR=Array.prototype,sR={DOMTokenList:!0,NodeList:!0},cR=r((function(e){var t=e.values;return e===aR||iR(aR,e)&&t===aR.values||nR(sR,rR(e))?oR:t})),uR=ai,dR=Math.floor,lR=function(e,t){var r=e.length,n=dR(r/2);return r<8?hR(e,t):pR(e,lR(uR(e,0,n),t),lR(uR(e,n),t),t)},hR=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},pR=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},vR=lR,fR=ue.match(/firefox\/(\d+)/i),_R=!!fR&&+fR[1],mR=/MSIE|Trident/.test(ue),gR=ue.match(/AppleWebKit\/(\d+)\./),yR=!!gR&&+gR[1],SR=Cr,bR=T,ER=Oe,kR=Ye,TR=Hr,IR=HE,RR=Sn,AR=a,wR=vR,CR=Au,xR=_R,OR=mR,PR=_e,MR=yR,DR=[],NR=bR(DR.sort),LR=bR(DR.push),UR=AR((function(){DR.sort(void 0)})),VR=AR((function(){DR.sort(null)})),FR=CR("sort"),BR=!AR((function(){if(PR)return PR<70;if(!(xR&&xR>3)){if(OR)return!0;if(MR)return MR<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++)DR.push({k:t+n,v:r})}for(DR.sort((function(e,t){return t.v-e.v})),n=0;n<DR.length;n++)t=DR[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));SR({target:"Array",proto:!0,forced:UR||!VR||!FR||!BR},{sort:function(e){void 0!==e&&ER(e);var t=kR(this);if(BR)return void 0===e?NR(t):NR(t,e);var r,n,i=[],o=TR(t);for(n=0;n<o;n++)n in t&&LR(i,t[n]);for(wR(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:RR(t)>RR(r)?1:-1}}(e)),r=TR(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)IR(t,n++);return t}});var jR=Bs("Array").sort,HR=ce,GR=jR,zR=Array.prototype,KR=r((function(e){var t=e.sort;return e===zR||HR(zR,e)&&t===zR.sort?GR:t})),XR=Cr,WR=Lo.findIndex,qR="findIndex",YR=!0;qR in[]&&Array(1)[qR]((function(){YR=!1})),XR({target:"Array",proto:!0,forced:YR},{findIndex:function(e){return WR(this,e,arguments.length>1?arguments[1]:void 0)}});var JR=Bs("Array").findIndex,QR=ce,ZR=JR,$R=Array.prototype,eA=r((function(e){var t=e.findIndex;return e===$R||QR($R,e)&&t===$R.findIndex?ZR:t})),tA=Cr,rA=T;C.f;var nA=Br,iA=Sn,oA=Fb,aA=Y,sA=jb,cA=rA("".startsWith),uA=rA("".slice),dA=Math.min;tA({target:"String",proto:!0,forced:!sA("startsWith")},{startsWith:function(e){var t=iA(aA(this));oA(e);var r=nA(dA(arguments.length>1?arguments[1]:void 0,t.length)),n=iA(e);return cA?cA(t,n,r):uA(t,r,r+n.length)===n}});var lA=Bs("String").startsWith,hA=ce,pA=lA,vA=String.prototype,fA=r((function(e){var t=e.startsWith;return"string"==typeof e||e===vA||hA(vA,e)&&t===vA.startsWith?pA:t})),_A=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_EXCEED_QPS="USER_MESSAGE_EXCEED_QPS",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e.SUBTITLE_ALREADY_ON="SUBTITLE_ALREADY_ON",e.SUBTITLE_NOT_TURNED_ON="SUBTITLE_NOT_TURNED_ON",e.SUBTITLE_ERR_POSTPROCESS="SUBTITLE_ERR_POSTPROCESS",e.SUBTITLE_ERR_CONNECTION_ERROR="SUBTITLE_ERR_CONNECTION_ERROR",e.SUBTITLE_ERR_PROCESS_ERROR="SUBTITLE_ERR_PROCESS_ERROR",e.SUBTITLE_ERR_UNKNOWN="SUBTITLE_ERR_UNKNOWN",e.UNEXPECTED_INVOKE_FORWARD_STREAM="UNEXPECTED_INVOKE_FORWARD_STREAM",e.ROOM_FORBIDDEN="ROOM_FORBIDDEN",e.USER_FORBIDDEN="USER_FORBIDDEN",e}(_A||{}),mA=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}(mA||{});function gA(e,t,r){var n;$I()?gA=MI(n=ZI).call(n):gA=function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(MI(Function).apply(e,n));return r&&LI(i,r.prototype),i};return gA.apply(null,arguments)}function yA(e){var t="function"==typeof ib?new ib:void 0;return yA=function(e){if(null===e||(r=e,-1===DE(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 gA(e,arguments,DI(this).constructor)}return i.prototype=zl(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),LI(i,e)},yA(e)}var SA=function(e){UI(r,e);var t=eR(r);function r(e,n,i){var o;return Hl(this,r),Zd(sI(o=t.call(this,n)),"code",void 0),Zd(sI(o),"message",void 0),Zd(sI(o),"error",void 0),o.code=e,o.message=n,o.error=i,Yl(sI(o),r.prototype),o}return jl(r,[{key:"toString",value:function(){var e;return Nm(e="SDKError: ".concat(this.code," ")).call(e,this.message)}}]),r}(yA(Error)),bA=x,EA=T,kA=on,TA=Z,IA=EA(D.f),RA=EA([].push),AA=function(e){return function(t){for(var r,n=TA(t),i=kA(n),o=i.length,a=0,s=[];o>a;)r=i[a++],bA&&!IA(n,r)||RA(s,e?[r,n[r]]:n[r]);return s}},wA={entries:AA(!0),values:AA(!1)}.entries;Cr({target:"Object",stat:!0},{entries:function(e){return wA(e)}});var CA=r(re.Object.entries),xA=Mr,OA=Sn,PA=Y,MA=RangeError,DA=T,NA=Br,LA=Sn,UA=function(e){var t=OA(PA(this)),r="",n=xA(e);if(n<0||n==1/0)throw MA("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},VA=Y,FA=DA(UA),BA=DA("".slice),jA=Math.ceil,HA=function(e){return function(t,r,n){var i,o,a=LA(VA(t)),s=NA(r),c=a.length,u=void 0===n?" ":LA(n);return s<=c||""==u?a:((o=FA(u,jA((i=s-c)/u.length))).length>i&&(o=BA(o,0,i)),e?a+o:o+a)}},GA={start:HA(!1),end:HA(!0)},zA=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(ue),KA=GA.end;Cr({target:"String",proto:!0,forced:zA},{padEnd:function(e){return KA(this,e,arguments.length>1?arguments[1]:void 0)}});var XA=Bs("String").padEnd,WA=ce,qA=XA,YA=String.prototype,JA=r((function(e){var t=e.padEnd;return"string"==typeof e||e===YA||WA(YA,e)&&t===YA.padEnd?qA:t})),QA=pg;Cr({target:"Number",stat:!0,forced:Number.parseInt!=QA},{parseInt:QA});var ZA=r(re.Number.parseInt),$A=Math.log,ew=Math.LOG10E;Cr({target:"Math",stat:!0},{log10:Math.log10||function(e){return $A(e)*ew}});var tw,rw=r(re.Math.log10),nw=Bs("Array").keys,iw=mn,ow=Ze,aw=ce,sw=nw,cw=Array.prototype,uw={DOMTokenList:!0,NodeList:!0},dw=r((function(e){var t=e.keys;return e===cw||aw(cw,e)&&t===cw.keys||ow(uw,iw(e))?sw:t})),lw=new Uint8Array(16);function hw(){if(!tw&&!(tw="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 tw(lw)}var pw=/^(?:[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 vw=[],fw=0;fw<256;++fw)vw.push((fw+256).toString(16).substr(1));function _w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(vw[e[t+0]]+vw[e[t+1]]+vw[e[t+2]]+vw[e[t+3]]+"-"+vw[e[t+4]]+vw[e[t+5]]+"-"+vw[e[t+6]]+vw[e[t+7]]+"-"+vw[e[t+8]]+vw[e[t+9]]+"-"+vw[e[t+10]]+vw[e[t+11]]+vw[e[t+12]]+vw[e[t+13]]+vw[e[t+14]]+vw[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&pw.test(e)}(r))throw TypeError("Stringified UUID is invalid");return r}function mw(e,t,r){var n=(e=e||{}).random||(e.rng||hw)();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 _w(n)}var gw=function(){return"undefined"==typeof window},yw=function(){return mw()},Sw=function(e){return"number"==typeof e},bw=function(e){var t;return bk(t=Function.prototype.toString.call(e)).call(t,"[native code]")};function Ew(e){return null==e?"undefined | null":"string"==typeof e?e:Fm({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function kw(e){return null==e?"undefined | null":"string"==typeof e?e:Fm({id:e.id,active:e.active})}function Tw(e){return null==e?"undefined | null":"string"==typeof e?e:Fm({track:Ew(e.track)})}function Iw(e){return null==e?"undefined | null":"string"==typeof e?e:Fm({track:Ew(e.track)})}function Rw(e){return null==e?"undefined | null":"string"==typeof e?e:Fm({currentDirection:e.currentDirection,direction:e.direction,mid:e.mid,stopped:e.stopped,receiver:Iw(e.receiver),sender:Tw(e.sender)})}var Aw="@byted/ve-rtc",ww="@byted/ve-rtc-cache-size",Cw=function(){function e(){Hl(this,e),Zd(this,"storeKey",void 0),Zd(this,"logLevel",void 0),Zd(this,"LogfileSize",void 0),Zd(this,"db",void 0),Zd(this,"logId",void 0),Zd(this,"cacheLog",void 0),Zd(this,"cachedSize",void 0),Zd(this,"preCacheTime",void 0),Zd(this,"timer",void 0),Zd(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 jl(e,[{key:"_createStore",value:function(){var e=this;if(!gw()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(Aw);try{localStorage.removeItem(ww)}catch(BY){}},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(ww);if(t)this.cachedSize=Number(t);else cR(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(BY){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(ww,"".concat(this.cachedSize))}catch(BY){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(Aw,e).objectStore(Aw)}},{key:"set",value:function(e){var t=this;return new $_((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Nm(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=Nm(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Nm(s=Nm(c="".concat(l?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(Nm(u="".concat(l)).call(u,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Nm(d="".concat(t.cacheLog)).call(d,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(v){var p;if(!e)return n(v);t.cacheLog+=Nm(p="\n\n".concat(t.logId,": ")).call(p,e),t.logId++,n(v)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Nm(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new $_((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 $_((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 dw(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 $_((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 $_((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}(),xw=new Cw,Ow=GA.start;Cr({target:"String",proto:!0,forced:zA},{padStart:function(e){return Ow(this,e,arguments.length>1?arguments[1]:void 0)}});var Pw=Bs("String").padStart,Mw=ce,Dw=Pw,Nw=String.prototype,Lw=r((function(e){var t=e.padStart;return"string"==typeof e||e===Nw||Mw(Nw,e)&&t===Nw.padStart?Dw:t})),Uw=function(){function e(){Hl(this,e),Zd(this,"_all",{})}return jl(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||ak(r).call(r,DE(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||Am(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,Nm(t=[e]).call(t,n))}catch(BY){console.error(BY)}}},{key:"destroy",value:function(){this._all={}}}]),e}(),Vw=["UPLOAD_CONSOLE_LENGTH_CUT","UPLOAD_REPORT_LIMIT"];var Fw=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Nm(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 jl(r,[{key:"setParameter",value:function(e,t){if(function(e){return bk(Vw).call(Vw,e)}(e))try{var r=Number(t);if(Number.isNaN(r))return;this.config[e]=r}catch(i){var n;return void console.warn(Nm(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 cn(this.config)}}]),r}(Uw),Bw=new Fw,jw=ro,Hw=Hr,Gw=dd,zw=Qt,Kw=function(e,t,r,n,i,o,a,s){for(var c,u,d=i,l=0,h=!!a&&zw(a,s);l<n;)l in r&&(c=h?h(r[l],l,t):r[l],o>0&&jw(c)?(u=Hw(c),d=Kw(e,t,c,u,d,o-1)-1):(Gw(d+1),e[d]=c),d++),l++;return d},Xw=Kw,Ww=Ye,qw=Hr,Yw=Mr,Jw=wo;Cr({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Ww(this),r=qw(t),n=Jw(t,0);return n.length=Xw(n,t,t,r,0,void 0===e?1:Yw(e)),n}});var Qw=Bs("Array").flat,Zw=ce,$w=Qw,eC=Array.prototype,tC=r((function(e){var t=e.flat;return e===eC||Zw(eC,e)&&t===eC.flat?$w:t})),rC={};!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=Am(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==Yd(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 Nm([]).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)}(rC);var nC={},iC={},oC={},aC=rC,sC=0,cC=1;function uC(e){for(var t=e.length;--t>=0;)e[t]=0}var dC=0,lC=29,hC=256,pC=hC+1+lC,vC=30,fC=19,_C=2*pC+1,mC=15,gC=16,yC=7,SC=256,bC=16,EC=17,kC=18,TC=[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],IC=[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],RC=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],AC=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],wC=new Array(2*(pC+2));uC(wC);var CC=new Array(2*vC);uC(CC);var xC=new Array(512);uC(xC);var OC=new Array(256);uC(OC);var PC=new Array(lC);uC(PC);var MC,DC,NC,LC=new Array(vC);function UC(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 VC(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function FC(e){return e<256?xC[e]:xC[256+(e>>>7)]}function BC(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function jC(e,t,r){e.bi_valid>gC-r?(e.bi_buf|=t<<e.bi_valid&65535,BC(e,e.bi_buf),e.bi_buf=t>>gC-e.bi_valid,e.bi_valid+=r-gC):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function HC(e,t,r){jC(e,r[2*t],r[2*t+1])}function GC(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function zC(e,t,r){var n,i,o=new Array(mC+1),a=0;for(n=1;n<=mC;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]=GC(o[s]++,s))}}function KC(e){var t;for(t=0;t<pC;t++)e.dyn_ltree[2*t]=0;for(t=0;t<vC;t++)e.dyn_dtree[2*t]=0;for(t=0;t<fC;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*SC]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function XC(e){e.bi_valid>8?BC(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 WC(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 qC(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&WC(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!WC(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function YC(e,t,r){var n,i,o,a,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?HC(e,i,t):(HC(e,(o=OC[i])+hC+1,t),0!==(a=TC[o])&&jC(e,i-=PC[o],a),HC(e,o=FC(--n),r),0!==(a=IC[o])&&jC(e,n-=LC[o],a))}while(s<e.last_lit);HC(e,SC,t)}function JC(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=_C,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--)qC(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],qC(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++,qC(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,a,s,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,v=t.stat_desc.max_length,f=0;for(o=0;o<=mC;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<_C;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>v&&(o=v,f++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),s=c[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(d[2*n+1]+a)));if(0!==f){do{for(o=v-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[v]--,f-=2}while(f>0);for(o=v;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}}(e,t),zC(o,u,e.bl_count)}function QC(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*bC]++):s<=10?e.bl_tree[2*EC]++:e.bl_tree[2*kC]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function ZC(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{HC(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(HC(e,i,e.bl_tree),s--),HC(e,bC,e.bl_tree),jC(e,s-3,2)):s<=10?(HC(e,EC,e.bl_tree),jC(e,s-3,3)):(HC(e,kC,e.bl_tree),jC(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}uC(LC);var $C=!1;function ex(e,t,r,n){jC(e,(dC<<1)+(n?1:0),3),function(e,t,r,n){XC(e),n&&(BC(e,r),BC(e,~r)),aC.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}oC._tr_init=function(e){$C||(!function(){var e,t,r,n,i,o=new Array(mC+1);for(r=0,n=0;n<lC-1;n++)for(PC[n]=r,e=0;e<1<<TC[n];e++)OC[r++]=n;for(OC[r-1]=n,i=0,n=0;n<16;n++)for(LC[n]=i,e=0;e<1<<IC[n];e++)xC[i++]=n;for(i>>=7;n<vC;n++)for(LC[n]=i<<7,e=0;e<1<<IC[n]-7;e++)xC[256+i++]=n;for(t=0;t<=mC;t++)o[t]=0;for(e=0;e<=143;)wC[2*e+1]=8,e++,o[8]++;for(;e<=255;)wC[2*e+1]=9,e++,o[9]++;for(;e<=279;)wC[2*e+1]=7,e++,o[7]++;for(;e<=287;)wC[2*e+1]=8,e++,o[8]++;for(zC(wC,pC+1,o),e=0;e<vC;e++)CC[2*e+1]=5,CC[2*e]=GC(e,5);MC=new UC(wC,TC,hC+1,pC,mC),DC=new UC(CC,IC,0,vC,mC),NC=new UC(new Array(0),RC,0,fC,yC)}(),$C=!0),e.l_desc=new VC(e.dyn_ltree,MC),e.d_desc=new VC(e.dyn_dtree,DC),e.bl_desc=new VC(e.bl_tree,NC),e.bi_buf=0,e.bi_valid=0,KC(e)},oC._tr_stored_block=ex,oC._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 sC;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return cC;for(t=32;t<hC;t++)if(0!==e.dyn_ltree[2*t])return cC;return sC}(e)),JC(e,e.l_desc),JC(e,e.d_desc),a=function(e){var t;for(QC(e,e.dyn_ltree,e.l_desc.max_code),QC(e,e.dyn_dtree,e.d_desc.max_code),JC(e,e.bl_desc),t=fC-1;t>=3&&0===e.bl_tree[2*AC[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?ex(e,t,r,n):4===e.strategy||o===i?(jC(e,2+(n?1:0),3),YC(e,wC,CC)):(jC(e,4+(n?1:0),3),function(e,t,r,n){var i;for(jC(e,t-257,5),jC(e,r-1,5),jC(e,n-4,4),i=0;i<n;i++)jC(e,e.bl_tree[2*AC[i]+1],3);ZC(e,e.dyn_ltree,t-1),ZC(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),YC(e,e.dyn_ltree,e.dyn_dtree)),KC(e),n&&XC(e)},oC._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*(OC[r]+hC+1)]++,e.dyn_dtree[2*FC(t)]++),e.last_lit===e.lit_bufsize-1},oC._tr_align=function(e){jC(e,2,3),HC(e,SC,wC),function(e){16===e.bi_valid?(BC(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 tx=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 rx=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 nx,ix=function(e,t,r,n){var i=rx,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},ox={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"},ax=rC,sx=oC,cx=tx,ux=ix,dx=ox,lx=0,hx=4,px=0,vx=-2,fx=-1,_x=4,mx=2,gx=8,yx=9,Sx=286,bx=30,Ex=19,kx=2*Sx+1,Tx=15,Ix=3,Rx=258,Ax=Rx+Ix+1,wx=42,Cx=103,xx=113,Ox=666,Px=1,Mx=2,Dx=3,Nx=4;function Lx(e,t){return e.msg=dx[t],t}function Ux(e){return(e<<1)-(e>4?9:0)}function Vx(e){for(var t=e.length;--t>=0;)e[t]=0}function Fx(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(ax.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 Bx(e,t){sx._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Fx(e.strm)}function jx(e,t){e.pending_buf[e.pending++]=t}function Hx(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function Gx(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-Ax?e.strstart-(e.w_size-Ax):0,u=e.window,d=e.w_mask,l=e.prev,h=e.strstart+Rx,p=u[o+a-1],v=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===v&&u[r+a-1]===p&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<h);if(n=Rx-(h-o),o=h-Rx,n>a){if(e.match_start=t,a=n,n>=s)break;p=u[o+a-1],v=u[o+a]}}}while((t=l[t&d])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function zx(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-Ax)){ax.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,ax.arraySet(s,a.input,a.next_in,d,c),1===a.state.wrap?a.adler=cx(a.adler,s,d,c):2===a.state.wrap&&(a.adler=ux(a.adler,s,d,c)),a.next_in+=d,a.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=Ix)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+Ix-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<Ix)););}while(e.lookahead<Ax&&0!==e.strm.avail_in)}function Kx(e,t){for(var r,n;;){if(e.lookahead<Ax){if(zx(e),e.lookahead<Ax&&t===lx)return Px;if(0===e.lookahead)break}if(r=0,e.lookahead>=Ix&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ix-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-Ax&&(e.match_length=Gx(e,r)),e.match_length>=Ix)if(n=sx._tr_tally(e,e.strstart-e.match_start,e.match_length-Ix),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Ix){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ix-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=sx._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(Bx(e,!1),0===e.strm.avail_out))return Px}return e.insert=e.strstart<Ix-1?e.strstart:Ix-1,t===hx?(Bx(e,!0),0===e.strm.avail_out?Dx:Nx):e.last_lit&&(Bx(e,!1),0===e.strm.avail_out)?Px:Mx}function Xx(e,t){for(var r,n,i;;){if(e.lookahead<Ax){if(zx(e),e.lookahead<Ax&&t===lx)return Px;if(0===e.lookahead)break}if(r=0,e.lookahead>=Ix&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ix-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=Ix-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-Ax&&(e.match_length=Gx(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===Ix&&e.strstart-e.match_start>4096)&&(e.match_length=Ix-1)),e.prev_length>=Ix&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-Ix,n=sx._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Ix),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+Ix-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=Ix-1,e.strstart++,n&&(Bx(e,!1),0===e.strm.avail_out))return Px}else if(e.match_available){if((n=sx._tr_tally(e,0,e.window[e.strstart-1]))&&Bx(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return Px}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=sx._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Ix-1?e.strstart:Ix-1,t===hx?(Bx(e,!0),0===e.strm.avail_out?Dx:Nx):e.last_lit&&(Bx(e,!1),0===e.strm.avail_out)?Px:Mx}function Wx(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 qx(){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=gx,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 ax.Buf16(2*kx),this.dyn_dtree=new ax.Buf16(2*(2*bx+1)),this.bl_tree=new ax.Buf16(2*(2*Ex+1)),Vx(this.dyn_ltree),Vx(this.dyn_dtree),Vx(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new ax.Buf16(Tx+1),this.heap=new ax.Buf16(2*Sx+1),Vx(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new ax.Buf16(2*Sx+1),Vx(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 Yx(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=mx,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?wx:xx,e.adler=2===t.wrap?0:1,t.last_flush=lx,sx._tr_init(t),px):Lx(e,vx)}function Jx(e){var t,r=Yx(e);return r===px&&((t=e.state).window_size=2*t.w_size,Vx(t.head),t.max_lazy_match=nx[t.level].max_lazy,t.good_match=nx[t.level].good_length,t.nice_match=nx[t.level].nice_length,t.max_chain_length=nx[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=Ix-1,t.match_available=0,t.ins_h=0),r}function Qx(e,t,r,n,i,o){if(!e)return vx;var a=1;if(t===fx&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>yx||r!==gx||n<8||n>15||t<0||t>9||o<0||o>_x)return Lx(e,vx);8===n&&(n=9);var s=new qx;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+Ix-1)/Ix),s.window=new ax.Buf8(2*s.w_size),s.head=new ax.Buf16(s.hash_size),s.prev=new ax.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new ax.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,Jx(e)}nx=[new Wx(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(zx(e),0===e.lookahead&&t===lx)return Px;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,Bx(e,!1),0===e.strm.avail_out))return Px;if(e.strstart-e.block_start>=e.w_size-Ax&&(Bx(e,!1),0===e.strm.avail_out))return Px}return e.insert=0,t===hx?(Bx(e,!0),0===e.strm.avail_out?Dx:Nx):(e.strstart>e.block_start&&(Bx(e,!1),e.strm.avail_out),Px)})),new Wx(4,4,8,4,Kx),new Wx(4,5,16,8,Kx),new Wx(4,6,32,32,Kx),new Wx(4,4,16,16,Xx),new Wx(8,16,32,32,Xx),new Wx(8,16,128,128,Xx),new Wx(8,32,128,256,Xx),new Wx(32,128,258,1024,Xx),new Wx(32,258,258,4096,Xx)],iC.deflateInit=function(e,t){return Qx(e,t,gx,15,8,0)},iC.deflateInit2=Qx,iC.deflateReset=Jx,iC.deflateResetKeep=Yx,iC.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?vx:(e.state.gzhead=t,px):vx},iC.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?Lx(e,vx):vx;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===Ox&&t!==hx)return Lx(e,0===e.avail_out?-5:vx);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===wx)if(2===n.wrap)e.adler=0,jx(n,31),jx(n,139),jx(n,8),n.gzhead?(jx(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)),jx(n,255&n.gzhead.time),jx(n,n.gzhead.time>>8&255),jx(n,n.gzhead.time>>16&255),jx(n,n.gzhead.time>>24&255),jx(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),jx(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(jx(n,255&n.gzhead.extra.length),jx(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=ux(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(jx(n,0),jx(n,0),jx(n,0),jx(n,0),jx(n,0),jx(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),jx(n,3),n.status=xx);else{var a=gx+(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=xx,Hx(n,a),0!==n.strstart&&(Hx(n,e.adler>>>16),Hx(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=ux(e.adler,n.pending_buf,n.pending-i,i)),Fx(e),i=n.pending,n.pending!==n.pending_buf_size));)jx(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=ux(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=ux(e.adler,n.pending_buf,n.pending-i,i)),Fx(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,jx(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=ux(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=ux(e.adler,n.pending_buf,n.pending-i,i)),Fx(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,jx(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=ux(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=Cx)}else n.status=Cx;if(n.status===Cx&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&Fx(e),n.pending+2<=n.pending_buf_size&&(jx(n,255&e.adler),jx(n,e.adler>>8&255),e.adler=0,n.status=xx)):n.status=xx),0!==n.pending){if(Fx(e),0===e.avail_out)return n.last_flush=-1,px}else if(0===e.avail_in&&Ux(t)<=Ux(r)&&t!==hx)return Lx(e,-5);if(n.status===Ox&&0!==e.avail_in)return Lx(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==lx&&n.status!==Ox){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(zx(e),0===e.lookahead)){if(t===lx)return Px;break}if(e.match_length=0,r=sx._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Bx(e,!1),0===e.strm.avail_out))return Px}return e.insert=0,t===hx?(Bx(e,!0),0===e.strm.avail_out?Dx:Nx):e.last_lit&&(Bx(e,!1),0===e.strm.avail_out)?Px:Mx}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=Rx){if(zx(e),e.lookahead<=Rx&&t===lx)return Px;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=Ix&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+Rx;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=Rx-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Ix?(r=sx._tr_tally(e,1,e.match_length-Ix),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=sx._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Bx(e,!1),0===e.strm.avail_out))return Px}return e.insert=0,t===hx?(Bx(e,!0),0===e.strm.avail_out?Dx:Nx):e.last_lit&&(Bx(e,!1),0===e.strm.avail_out)?Px:Mx}(n,t):nx[n.level].func(n,t);if(s!==Dx&&s!==Nx||(n.status=Ox),s===Px||s===Dx)return 0===e.avail_out&&(n.last_flush=-1),px;if(s===Mx&&(1===t?sx._tr_align(n):5!==t&&(sx._tr_stored_block(n,0,0,!1),3===t&&(Vx(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Fx(e),0===e.avail_out))return n.last_flush=-1,px}return t!==hx?px:n.wrap<=0?1:(2===n.wrap?(jx(n,255&e.adler),jx(n,e.adler>>8&255),jx(n,e.adler>>16&255),jx(n,e.adler>>24&255),jx(n,255&e.total_in),jx(n,e.total_in>>8&255),jx(n,e.total_in>>16&255),jx(n,e.total_in>>24&255)):(Hx(n,e.adler>>>16),Hx(n,65535&e.adler)),Fx(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?px:1)},iC.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==wx&&69!==t&&73!==t&&91!==t&&t!==Cx&&t!==xx&&t!==Ox?Lx(e,vx):(e.state=null,t===xx?Lx(e,-3):px):vx},iC.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,d=t.length;if(!e||!e.state)return vx;if(2===(o=(r=e.state).wrap)||1===o&&r.status!==wx||r.lookahead)return vx;for(1===o&&(e.adler=cx(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(Vx(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new ax.Buf8(r.w_size),ax.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,zx(r);r.lookahead>=Ix;){n=r.strstart,i=r.lookahead-(Ix-1);do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+Ix-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=Ix-1,zx(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=Ix-1,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,px},iC.deflateInfo="pako deflate (from Nodeca project)";var Zx={},$x=rC,eO=!0,tO=!0;try{String.fromCharCode.apply(null,[0])}catch(jY){eO=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(jY){tO=!1}for(var rO=new $x.Buf8(256),nO=0;nO<256;nO++)rO[nO]=nO>=252?6:nO>=248?5:nO>=240?4:nO>=224?3:nO>=192?2:1;function iO(e,t){if(t<65534&&(e.subarray&&tO||!e.subarray&&eO))return String.fromCharCode.apply(null,$x.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}rO[254]=rO[254]=1,Zx.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 $x.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},Zx.buf2binstring=function(e){return iO(e,e.length)},Zx.binstring2buf=function(e){for(var t=new $x.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},Zx.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=rO[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 iO(s,n)},Zx.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+rO[e[r]]>t?r:t};var oO=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},aO=iC,sO=rC,cO=Zx,uO=ox,dO=oO,lO=Object.prototype.toString,hO=0,pO=-1,vO=0,fO=8;function _O(e){if(!(this instanceof _O))return new _O(e);this.options=sO.assign({level:pO,method:fO,chunkSize:16384,windowBits:15,memLevel:8,strategy:vO,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 dO,this.strm.avail_out=0;var r=aO.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==hO)throw new Error(uO[r]);if(t.header&&aO.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?cO.string2buf(t.dictionary):"[object ArrayBuffer]"===lO.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=aO.deflateSetDictionary(this.strm,n))!==hO)throw new Error(uO[r]);this._dict_set=!0}}function mO(e,t){var r=new _O(t);if(r.push(e,!0),r.err)throw r.msg||uO[r.err];return r.result}_O.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=cO.string2buf(e):"[object ArrayBuffer]"===lO.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 sO.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=aO.deflate(i,n))&&r!==hO)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(cO.buf2binstring(sO.shrinkBuf(i.output,i.next_out))):this.onData(sO.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=aO.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===hO):2!==n||(this.onEnd(hO),i.avail_out=0,!0)},_O.prototype.onData=function(e){this.chunks.push(e)},_O.prototype.onEnd=function(e){e===hO&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=sO.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},nC.Deflate=_O,nC.deflate=mO,nC.deflateRaw=function(e,t){return(t=t||{}).raw=!0,mO(e,t)},nC.gzip=function(e,t){return(t=t||{}).gzip=!0,mO(e,t)};var gO={},yO=nr,SO=M,bO=Ze,EO=ce,kO=function(){var e=yO(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},TO=RegExp.prototype,IO=ce,RO=function(e){var t=e.flags;return void 0!==t||"flags"in TO||bO(e,"flags")||!EO(TO,e)?t:SO(kO,e)},AO=RegExp.prototype,wO=r((function(e){return e===AO||IO(AO,e)?RO(e):e.flags})),CO={},xO=rC,OO=15,PO=[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],MO=[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],DO=[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],NO=[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],LO=rC,UO=tx,VO=ix,FO=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,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,v=r.bits,f=r.lencode,_=r.distcode,m=(1<<r.lenbits)-1,g=(1<<r.distbits)-1;e:do{v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),y=f[p&m];t:for(;;){if(p>>>=S=y>>>24,v-=S,0===(S=y>>>16&255))R[o++]=65535&y;else{if(!(16&S)){if(0==(64&S)){y=f[(65535&y)+(p&(1<<S)-1)];continue t}if(32&S){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=65535&y,(S&=15)&&(v<S&&(p+=I[n++]<<v,v+=8),b+=p&(1<<S)-1,p>>>=S,v-=S),v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),y=_[p&g];r:for(;;){if(p>>>=S=y>>>24,v-=S,!(16&(S=y>>>16&255))){if(0==(64&S)){y=_[(65535&y)+(p&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(E=65535&y,v<(S&=15)&&(p+=I[n++]<<v,(v+=8)<S&&(p+=I[n++]<<v,v+=8)),(E+=p&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(p>>>=S,v-=S,E>(S=o-a)){if((S=E-S)>d&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(k=0,T=h,0===l){if(k+=u-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}else if(l<S){if(k+=u+l-S,(S-=l)<b){b-=S;do{R[o++]=h[k++]}while(--S);if(k=0,l<b){b-=S=l;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}}else if(k+=l-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}for(;b>2;)R[o++]=T[k++],R[o++]=T[k++],R[o++]=T[k++],b-=3;b&&(R[o++]=T[k++],b>1&&(R[o++]=T[k++]))}else{k=o-E;do{R[o++]=R[k++],R[o++]=R[k++],R[o++]=R[k++],b-=3}while(b>2);b&&(R[o++]=R[k++],b>1&&(R[o++]=R[k++]))}break}}break}}while(n<i&&o<s);n-=b=v>>3,p&=(1<<(v-=b<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<s?s-o+257:257-(o-s),r.hold=p,r.bits=v},BO=function(e,t,r,n,i,o,a,s){var c,u,d,l,h,p,v,f,_,m=s.bits,g=0,y=0,S=0,b=0,E=0,k=0,T=0,I=0,R=0,A=0,w=null,C=0,x=new xO.Buf16(16),O=new xO.Buf16(16),P=null,M=0;for(g=0;g<=OO;g++)x[g]=0;for(y=0;y<n;y++)x[t[r+y]]++;for(E=m,b=OO;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<=OO;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<OO;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=PO,C-=257,P=MO,M-=257,p=256):(w=DO,P=NO,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(;;){v=g-T,a[y]<p?(f=0,_=a[y]):a[y]>p?(f=P[M+a[y]],_=w[C+a[y]]):(f=96,_=0),c=1<<g-T,S=u=1<<k;do{i[h+(A>>T)+(u-=c)]=v<<24|f<<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&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},jO=1,HO=2,GO=0,zO=-2,KO=1,XO=12,WO=30,qO=852,YO=592;function JO(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function QO(){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 LO.Buf16(320),this.work=new LO.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function ZO(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=KO,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new LO.Buf32(qO),t.distcode=t.distdyn=new LO.Buf32(YO),t.sane=1,t.back=-1,GO):zO}function $O(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,ZO(e)):zO}function eP(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)?zO:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,$O(e))):zO}function tP(e,t){var r,n;return e?(n=new QO,e.state=n,n.window=null,(r=eP(e,t))!==GO&&(e.state=null),r):zO}var rP,nP,iP=!0;function oP(e){if(iP){var t;for(rP=new LO.Buf32(512),nP=new LO.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(BO(jO,e.lens,0,288,rP,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;BO(HO,e.lens,0,32,nP,0,e.work,{bits:5}),iP=!1}e.lencode=rP,e.lenbits=9,e.distcode=nP,e.distbits=5}function aP(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 LO.Buf8(o.wsize)),n>=o.wsize?(LO.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),LO.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(LO.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}CO.inflateReset=$O,CO.inflateReset2=eP,CO.inflateResetKeep=ZO,CO.inflateInit=function(e){return tP(e,15)},CO.inflateInit2=tP,CO.inflate=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R=0,A=new LO.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 zO;(r=e.state).mode===XO&&(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=GO;e:for(;;)switch(r.mode){case KO: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=VO(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=WO;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=WO;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=WO;break}r.dmax=1<<E,e.adler=r.check=1,r.mode=512&u?10:XO,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&wO(r))){e.msg="unknown compression method",r.mode=WO;break}if(57344&wO(r)){e.msg="unknown header flags set",r.mode=WO;break}r.head&&(r.head.text=u>>8&1),512&wO(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=VO(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&wO(r)&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=VO(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&wO(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=VO(r.check,A,2,0)),u=0,d=0,r.mode=5;case 5:if(1024&wO(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&wO(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=VO(r.check,A,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&wO(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)),LO.arraySet(r.head.extra,n,o,p,E)),512&wO(r)&&(r.check=VO(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&wO(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&wO(r)&&(r.check=VO(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&wO(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&wO(r)&&(r.check=VO(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&wO(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=WO;break}u=0,d=0}r.head&&(r.head.hcrc=wO(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=XO;break;case 10:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}e.adler=r.check=JO(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=XO;case XO: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(oP(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=WO}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=WO;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;LO.arraySet(i,n,o,p,a),s-=p,o+=p,c-=p,a+=p,r.length-=p;break}r.mode=XO;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=WO;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=BO(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid code lengths set",r.mode=WO;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)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(g<16)u>>>=_,d-=_,r.lens[r.have++]=g;else{if(16===g){for(I=_+2;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u>>>=_,d-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=WO;break}E=r.lens[r.have-1],p=3+(3&u),u>>>=2,d-=2}else if(17===g){for(I=_+3;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,E=0,p=3+(7&(u>>>=_)),u>>>=3,d-=3}else{for(I=_+7;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,E=0,p=11+(127&(u>>>=_)),u>>>=7,d-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=WO;break}for(;p--;)r.lens[r.have++]=E}}if(r.mode===WO)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=WO;break}if(r.lenbits=9,T={bits:r.lenbits},k=BO(jO,r.lens,0,r.nlen,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid literal/lengths set",r.mode=WO;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},k=BO(HO,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,T),r.distbits=T.bits,k){e.msg="invalid distances set",r.mode=WO;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,FO(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===XO&&(r.back=-1);break}for(r.back=0;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=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)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=y,d-=y,r.back+=y}if(u>>>=_,d-=_,r.back+=_,r.length=g,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=XO;break}if(64&m){e.msg="invalid literal/length code",r.mode=WO;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,!((_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=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)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=y,d-=y,r.back+=y}if(u>>>=_,d-=_,r.back+=_,64&m){e.msg="invalid distance code",r.mode=WO;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=WO;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=WO;break}p>r.wnext?(p-=r.wnext,v=r.wsize-p):v=r.wnext-p,p>r.length&&(p=r.length),f=r.window}else f=i,v=a-r.offset,p=r.length;p>c&&(p=c),c-=p,r.length-=p;do{i[a++]=f[v++]}while(--p);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===s)break e;s--,u|=n[o++]<<d,d+=8}if(h-=c,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=wO(r)?VO(r.check,i,h,a-h):UO(r.check,i,h,a-h)),h=c,(wO(r)?u:JO(u))!==r.check){e.msg="incorrect data check",r.mode=WO;break}u=0,d=0}r.mode=28;case 28:if(r.wrap&&wO(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=WO;break}u=0,d=0}r.mode=29;case 29:k=1;break e;case WO:k=-3;break e;case 31:return-4;default:return zO}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<WO&&(r.mode<27||4!==t))&&aP(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=wO(r)?VO(r.check,i,h,e.next_out-h):UO(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===XO?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&k===GO&&(k=-5),k},CO.inflateEnd=function(e){if(!e||!e.state)return zO;var t=e.state;return t.window&&(t.window=null),e.state=null,GO},CO.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?zO:(r.head=t,t.done=!1,GO):zO},CO.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?zO:11===r.mode&&UO(1,t,n,0)!==r.check?-3:aP(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,GO):zO},CO.inflateInfo="pako inflate (from Nodeca project)";var sP={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 cP=CO,uP=rC,dP=Zx,lP=sP,hP=ox,pP=oO,vP=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},fP=Object.prototype.toString;function _P(e){if(!(this instanceof _P))return new _P(e);this.options=uP.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 pP,this.strm.avail_out=0;var r=cP.inflateInit2(this.strm,t.windowBits);if(r!==lP.Z_OK)throw new Error(hP[r]);if(this.header=new vP,cP.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=dP.string2buf(t.dictionary):"[object ArrayBuffer]"===fP.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=cP.inflateSetDictionary(this.strm,t.dictionary))!==lP.Z_OK))throw new Error(hP[r])}function mP(e,t){var r=new _P(t);if(r.push(e,!0),r.err)throw r.msg||hP[r.err];return r.result}_P.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?lP.Z_FINISH:lP.Z_NO_FLUSH,"string"==typeof e?s.input=dP.binstring2buf(e):"[object ArrayBuffer]"===fP.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 uP.Buf8(c),s.next_out=0,s.avail_out=c),(r=cP.inflate(s,lP.Z_NO_FLUSH))===lP.Z_NEED_DICT&&u&&(r=cP.inflateSetDictionary(this.strm,u)),r===lP.Z_BUF_ERROR&&!0===d&&(r=lP.Z_OK,d=!1),r!==lP.Z_STREAM_END&&r!==lP.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==lP.Z_STREAM_END&&(0!==s.avail_in||n!==lP.Z_FINISH&&n!==lP.Z_SYNC_FLUSH)||("string"===this.options.to?(i=dP.utf8border(s.output,s.next_out),o=s.next_out-i,a=dP.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&uP.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(uP.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!==lP.Z_STREAM_END);return r===lP.Z_STREAM_END&&(n=lP.Z_FINISH),n===lP.Z_FINISH?(r=cP.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===lP.Z_OK):n!==lP.Z_SYNC_FLUSH||(this.onEnd(lP.Z_OK),s.avail_out=0,!0)},_P.prototype.onData=function(e){this.chunks.push(e)},_P.prototype.onEnd=function(e){e===lP.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=uP.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},gO.Inflate=_P,gO.inflate=mP,gO.inflateRaw=function(e,t){return(t=t||{}).raw=!0,mP(e,t)},gO.ungzip=mP;var gP={};(0,rC.assign)(gP,nC,gO,sP);var yP,SP,bP,EP=r(gP),kP=1,TP=function(){function e(t){Hl(this,e),Zd(this,"lockingPromise",$_.resolve()),Zd(this,"locks",0),Zd(this,"name",""),Zd(this,"lockId",void 0),this.lockId=kP++,t&&(this.name=t)}return jl(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t=this;this.locks+=1;var r=new $_((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}(),IP="BytePlusRTC",RP=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},AP=function(){function e(t){Hl(this,e),Zd(this,"storeName",void 0),Zd(this,"pendingList",[]),this.storeName=t,!gw()&&RP()&&this._checkAndCreateStore(t)}var t,r,n,i,o,a,s;return jl(e,[{key:"_checkAndCreateStore",value:(s=xm(wm().mark((function t(r,n){var i,o,a=this;return wm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e._promiseLock.lock();case 2:if(i=t.sent,!RP.databases){t.next=6;break}return t.next=6,new $_((function(e){var t=function(){return RP.databases().finally(e)};o=setInterval(t,100),t()})).finally((function(){return clearInterval(o)}));case 6:return t.abrupt("return",new $_((function(t){e.db&&(e.db.close(),delete e.db);var o=n?RP().open(IP,n):RP().open(IP);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=xm(wm().mark((function e(t){var r,n,i,o;return wm().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=xm(wm().mark((function t(r){var n,i=this;return wm().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 $_((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=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{n=Fm(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=xm(wm().mark((function e(t){var r,n;return wm().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=xm(wm().mark((function e(t,r){var n;return wm().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 $_((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=xm(wm().mark((function e(t){var r;return wm().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 $_((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=xm(wm().mark((function e(t){var r;return wm().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 $_((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}();Zd(AP,"db",void 0),Zd(AP,"state","init"),Zd(AP,"_promiseLock",new TP("iDB"));var wP={product_line:"rtc",report_version:"5",os:"web",user_agent:gw()?"":null===(yP=navigator)||void 0===yP?void 0:yP.userAgent,platform:"web",product:"webrtc",app_state:"active"},CP="LogReportor",xP="undefined"!=typeof window&&(bk(SP=window.location.search).call(SP,"_rtc_debug_")||(null===(bP=window.localStorage)||void 0===bP?void 0:bP.getItem("_rtc_debug_"))),OP=function(){function e(t){Hl(this,e),Zd(this,"_buffer",void 0),this._buffer=new AP(t)}var t,r;return jl(e,[{key:"set",value:(r=xm(wm().mark((function e(t,r){return wm().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=xm(wm().mark((function e(t){var r,n;return wm().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}(),PP=function(){function e(){var t=this;Hl(this,e),Zd(this,"reportCommon",wP),Zd(this,"reportIds",new ib),Zd(this,"dataBuffer",[]),Zd(this,"reportorList",[]),Zd(this,"dbBuffer",void 0),Zd(this,"posting",!1),Zd(this,"sucSendTimer",void 0),Zd(this,"preSucTime",0),Zd(this,"errSendTimer",void 0),Zd(this,"errSendDelay",100),Zd(this,"_logServerUrl",void 0),Zd(this,"_retryCount",0),Zd(this,"_reportLimit",5e5),Zd(this,"_disableTimeout",!1),gw()||(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"})})),xP&&(window.__rtc_debug_reportor__=this)),Bw.on("UPLOAD_REPORT_LIMIT",(function(e){t.setReportLimit(e)})),Bw.on("ENABLE_REPORT_IDB_BUFFER",(function(e){e&&t.enableIndexedDBBuffer()})),setTimeout((function(){t.reportorList.push(cM)}))}var t;return jl(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.reportCommon=Mb(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&&(KP("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){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.send(e):(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 OP("ReportorDBBuffer"),this.dbBuffer.get(CP).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){e.forEach((function(e){t.push(e)}))}))})))}},{key:"backup",value:function(){var e=this;try{var t;null===(t=this.dbBuffer)||void 0===t||t.set(eT(this.dataBuffer),CP),this.reportorList.forEach((function(t){var r;null===(r=e.dbBuffer)||void 0===r||r.set(eT(t.get()),t.name)}))}catch(r){KP("Error when save log into IDB",-1,r)}}},{key:"unshift",value:function(e){var t;this.dataBuffer=Nm(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+=Fm(e[n]).length)>t)return n;return e.length}(this.dataBuffer,this._reportLimit);0===r&&this.dataBuffer.length>0&&(this._reportLimit=Fm(this.dataBuffer[0]).length+10,r=1,KP("update report limit to ".concat(this._reportLimit),0,null));var n=ak(e=this.dataBuffer).call(e,0,r),i=Fm(n).length,o=[n],a=this._reportLimit-i;return this.reportorList.forEach((function(e){var r=ak(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),!gw()&&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=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.backup(),i=gb(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=xP,s={data:t||tC(o).call(o),header:el(el({},this.reportCommon),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},c={method:"POST",body:a?Fm(s):EP.gzip(Fm(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;KP(Nm(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 MP,DP=new PP,NP=function(){function e(t){Hl(this,e),Zd(this,"modifyIds",{}),this.id=t}return jl(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=el(el(el({event_key:e,rtc_timestamp:Date.now()},this.modifyIds),t),{},{common_extra_info:Fm(i),report_id:DP.getReportId(this.modifyIds.engine_session_id)});!gw()&&window.__onRTCReport&&(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.modifyIds.engine_session_id,o,DP.getCommonStats()));DP.push(o)}},{key:"reportLog",value:function(e){var t=el(el({event_key:"rtc_invoke_status",sdk_api_name:"console_log",rtc_timestamp:Date.now()},this.modifyIds),{},{message:e});cM.push(t)}},{key:"set",value:function(e){this.modifyIds=Mb(this.modifyIds,e)}},{key:"destroy",value:function(){}}]),e}();setTimeout((function(){MP=new fM("MessageReportor",1)}),0);var LP=function(){function e(t){Hl(this,e),Zd(this,"_preTime",Date.now()),Zd(this,"_one2oneNum",0),Zd(this,"_one2manyNum",0),Zd(this,"_one2oneMsgCache",new ib),Zd(this,"_one2manyMsgCache",new ib),Zd(this,"roomId",""),Zd(this,"userId",""),Zd(this,"rtsSessionId",""),this.id=t}return jl(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,el({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,el(el({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,el({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,el(el({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(MP.info("reportP2PMsg",r.type,Fm(r)),null===(t=qP(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(MP.info("reportOne2ManyMsg",r.type,Fm(r)),null===(t=qP(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)||"",MP.info("reportMsgRecv",t.type,Fm(t)),null===(n=qP(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}();Zd(LP,"config",void 0);var UP=new ib,VP={_cache:UP,setConfig:function(e){MP.info("setConfig","get config: ".concat(Fm(e))),LP.config=e},setRtsSessionId:function(e,t){var r=UP.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=UP.get(e)||new LP(e);return UP.set(e,t),t},destroyRTSMsgReportor:function(e){var t=UP.get(e);t&&(t.destroy(),UP.delete(e))},setRoomId:function(e,t){var r=UP.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=UP.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=UP.get(e);if(null!=r&&r.needReport("one2one")){var n,i=Nm(n="".concat(t.from)).call(n,t.id),o=t.to?"one2one":"one2server";t.enable_report=!0,t.report_msg_id=t.id,r.cacheP2PMsg({rts_session_id:r.rtsSessionId,msg_id:i,node_role:"src_sdk",from:t.from,to:t.to||"server",type:o,rts_room_id:t.room,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""})}return t},updateP2PMsgReq:function(e,t,r){var n,i;t.enable_report&&Sw(t.report_msg_id)&&(null===(n=UP.get(e))||void 0===n||n.updateP2PMsg(Nm(i="".concat(t.from)).call(i,t.report_msg_id),{send_ts:Date.now(),msg_size:r}))},updateP2PMsgAck:function(e,t,r){if(t.enable_report&&Sw(t.report_msg_id)){var n,i,o=UP.get(e);null==o||o.updateP2PMsg(Nm(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(Nm(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n,i=UP.get(e);null!=i&&i.needReport("one2many")&&(r.enable_report=!0,r.report_msg_id=t,i.cacheCustomMsg({rts_session_id:i.rtsSessionId,msg_id:Nm(n="".concat(r.clientId)).call(n,t),node_role:"src_sdk",from:r.clientId,to:i.roomId,type:"one2many",rts_room_id:i.roomId,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""}));return r},reportP2PMsgRecv:function(e,t,r){if(t.enable_report&&Sw(t.report_msg_id)){var n,i=UP.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Nm(n="".concat(t.from)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:o,rts_room_id:t.room,from:t.from,to:t.to||t.room,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:t.to?"":i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},updateOne2ManyMsgAck:function(e,t,r){if(t.enable_report&&Sw(t.report_msg_id)){var n,i,o=UP.get(e);if(o)null==o||o.updateOne2ManyMsg(Nm(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(Nm(i="".concat(t.clientId)).call(i,t.report_msg_id))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&Sw(t.report_msg_id)){var n,i=UP.get(e);if(i)i.updateOne2ManyMsg(Nm(n="".concat(t.clientId)).call(n,t.report_msg_id),{send_ts:Date.now(),msg_size:r})}},reportOne2ManyMsgRecv:function(e,t,r){if(t.enable_report&&Sw(t.report_msg_id)){var n,i=UP.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Nm(n="".concat(t.clientId)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:"one2many",rts_room_id:t.roomId,from:t.clientId,to:t.roomId,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}}},FP=function(){function e(t){Hl(this,e),Zd(this,"_timer",void 0),Zd(this,"userMessage",{}),Zd(this,"roomMessage",{}),this.id=t,this._setTimer()}return jl(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(cn(this.userMessage).length||cn(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e,t,r,n=this;null===(e=qP(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:Km(t=cn(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:Km(r=cn(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[Nm(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Nm(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[Nm(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Nm(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Nm(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Nm(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)&&(bk(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[Nm(o="".concat(t,"-")).call(o,e)];a&&(a.dc_send_ack++,a.dc_cost_time+=r,a.dc_cost_s2s+=n||0,a.dc_cost_peer_s2e+=i,a.dc_cost_e2s+=r-(n||0)-i,r<=100?(a.dc_send_ack_100++,a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=200?(a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=400?(a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=1e3&&a.dc_send_ack_1s++,r<a.dc_least_time&&(a.dc_least_time=r),r>a.dc_most_time&&(a.dc_most_time=r))}},{key:"sendRoomMessage",value:function(e,t){this.roomMessage[e]||(this.roomMessage[e]={dc_room_id:e,dc_send_total:0,dc_send_ack:0,dc_cost_time:0,dc_least_time:Number(1/0),dc_most_time:0,dc_send_fail:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_send_binary:0}),this.roomMessage[e].dc_send_total++,t&&this.roomMessage[e].dc_send_binary++}},{key:"sendRoomFail",value:function(e){var t=this.roomMessage[e];t&&t.dc_send_fail++}},{key:"sendRoomAck",value:function(e,t){var r=this.roomMessage[e];r&&(r.dc_send_ack++,r.dc_cost_time+=t,t<r.dc_least_time&&(r.dc_least_time=t),t>r.dc_most_time&&(r.dc_most_time=t),t<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=1e3&&r.dc_send_ack_1s++)}},{key:"sendP2PMessage",value:function(e,t){this._sendUserMessage(e,"p2p",t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,"p2p")}},{key:"sendP2PFail",value:function(e,t){this._sendUserFail(e,"p2p",t)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p",t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,"p2p_outside_room",t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,"p2p_outside_room")}},{key:"sendP2POutRoomFail",value:function(e,t){this._sendUserFail(e,"p2p_outside_room",t)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p_outside_room",t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("","p2server",e)}},{key:"sendP2serverFail",value:function(e){this._sendUserFail("","p2server",e)}},{key:"sendP2serveAck",value:function(e,t,r){this._sendUserAck("","p2server",e,t,r)}},{key:"countP2PMessage",value:function(e,t,r,n,i){this.sendP2PMessage(t,r),e?this.sendP2PAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2PFail(t,i)}},{key:"countRoomMessage",value:function(e,t,r,n){this.sendRoomMessage(t,r),e?this.sendRoomAck(t,Date.now()-n):this.sendRoomFail(t)}},{key:"countUserMessageOutsideRoom",value:function(e,t,r,n,i){this.sendP2POutRoomMessage(t,r),e?this.sendP2POutRoomAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2POutRoomFail(t,i)}},{key:"countServerMessage",value:function(e,t,r,n){this.sendP2serverMessage(t),e?(n=n||{},this.sendP2serveAck(Date.now()-r,n.s2s_time||0,n.s2e_time||0)):this.sendP2serverFail(n)}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),BP=function(e){DP.setCommonStats(e)},jP=function(e){DP.setUrl(e)},HP=new NP("global"),GP=function(e,t,r){HP.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},zP=function(e,t,r){HP.report("rtc_sdk_callback",{sdk_callback_name:e,error_code:t,message:r})},KP=function(e,t,r){HP.report("rtc_error",{message:e,error_code:t},r)},XP=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;HP.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)};var WP=new ib,qP=function(e){return WP.get(e)},YP=function(e,t){var r=new NP(e);return r.set(el(el({},t),{},{engine_session_id:yw()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),WP.set(e,r),r};function JP(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r,n){if("function"==typeof n.value){var i=n.value;n.value=function(){for(var e,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];var s,c,u=this.engineId||this.id,d={};(t.forEach((function(e,t){d[e]=o[t]})),"joinRoom"===r)&&(null===(s=qP(u))||void 0===s||s.set({room_id:o[1],user_id:null===(c=o[2])||void 0===c?void 0:c.userId}));null===(e=qP(u))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:Fm(tM(o)),error_code:0},d);var l=i.apply(this,o);return"function"==typeof(null==l?void 0:l.then)?l.then((function(e){return ZP(u,r,[e||{}]),e})).catch((function(e){throw ZP(u,r,e.message,e.code),e})):(ZP(u,r,[l||{}]),l)}}}}var QP,ZP=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:Fm(Array.isArray(r)?tM(r):r)};i&&(o.room_id=i),null===(n=qP(e))||void 0===n||n.report("rtc_sdk_callback",o)},$P=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=qP(e))||void 0===n||n.report("rtc_invoke_status",{sdk_api_name:t,message:r,error_code:i,stream_id:o,elapse:0},a)},eM=10;function tM(e){return Km(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>eM){var c,u,d,l,h=new DataView(o),p=Km(c=Zk({length:eM/2})).call(c,(function(e,t){return h.getUint8(t)})),v=Km(u=Km(d=Zk({length:eM/2})).call(d,(function(e,t){return a-1-t})).reverse()).call(u,(function(e){return h.getUint8(e)}));s=Nm(l=[]).call(l,eT(p),["..."],eT(v))}else s=Zk(new Uint8Array(o));return Nm(n=Nm(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return Km(t).call(t,e);if(bk(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var f={};for(var _ in t)f[_]=e(t[_]);return f}return t}))}var rM="undefined"!=typeof window&&bk(QP=window.location.search).call(QP,"_rtc_upload_console_"),nM=function(){function e(){var t=this;Hl(this,e),Zd(this,"name","ConsoleReportor"),Zd(this,"_uuid","".concat(Math.floor(899*Math.random())+100)),Zd(this,"_consoleReportId",0),Zd(this,"_engineReportIdMap",new ib),Zd(this,"_enabled","NULL"),Zd(this,"_consoleCutLength",Bw.getParameter("UPLOAD_CONSOLE_LENGTH_CUT")),Zd(this,"buffer",[]),rM&&setTimeout((function(){t.switchOn()}),0),Bw.on("UPLOAD_CONSOLE_ON",(function(e){e?t.switchOn():t.turnOff()})),Bw.on("UPLOAD_CONSOLE_LENGTH_CUT",(function(e){t._consoleCutLength=e}))}return jl(e,[{key:"enabled",get:function(){return"OFF"!==this._enabled}},{key:"switchOn",value:function(){"NULL"===this._enabled&&(console.log("[LoggerReportor.constructor] console upload switch ON"),this._enabled="ON")}},{key:"turnOff",value:function(){"NULL"===this._enabled&&(console.log("[LoggerReportor.constructor] console upload switch OFF"),this._enabled="OFF",this.buffer=[])}},{key:"getEngineConsoleId",value:function(e){var t,r=null!==(t=this._engineReportIdMap.get(e))&&void 0!==t?t:0;return this._engineReportIdMap.set(e,r+1),r}},{key:"report",value:function(e,t,r,n,i,o,a,s,c){var u,d,l,h,p,v,f,_,m,g,y,S=this;if("OFF"!==this._enabled){var b,E=qP(t),k=this._consoleReportId++,T=this.getEngineConsoleId(t),I=iM(c,this._consoleCutLength),R=eT(c),A="".concat(s).replace(/%o|%s/gi,(function(){return iM([R.shift()],S._consoleCutLength)})),w=Nm(u=Nm(d=Nm(l=Nm(h=Nm(p=Nm(v=Nm(f=Nm(_=Nm(m=Nm(g=Nm(y="[".concat(this._uuid,"-")).call(y,k,"][")).call(g,t,"-")).call(m,T,"]-")).call(_,r,"-")).call(f,e,"[")).call(v,n,"]")).call(p,i,"[")).call(h,o,".")).call(l,a,"] ")).call(d,A," ")).call(u,I);E?E.reportLog(w):(b=w,HP.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=Fm(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:ak(t=this.buffer).call(t,0,n),payloadSize:i}}},{key:"unshift",value:function(e){this.buffer=Nm(e).call(e,this.buffer)}},{key:"get",value:function(){return this.buffer}},{key:"isEmpty",value:function(){return"OFF"===this._enabled||0===this.buffer.length}}]),e}();function iM(e,t){return Km(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 Ew(e);if(e instanceof MediaStream)return kw(e);if(e instanceof RTCRtpSender)return Tw(e);if(e instanceof RTCRtpReceiver)return Iw(e);if(e instanceof RTCRtpTransceiver)return Rw(e);r=Fm(e)}catch(n){r=e.toString()}return r&&r.length>=t&&(r=Am(r).call(r,0,t)),r})).join(", ")}var oM,aM,sM,cM=new nM,uM="[VERTC]",dM="#0050b3",lM=(Zd(oM={},"DEBUG","rgba(0, 0, 0, 0)"),Zd(oM," INFO","rgba(93, 173, 226, 0)"),Zd(oM," WARN","rgba(255, 119, 0, 0.3)"),Zd(oM,"ERROR","rgba(255, 0, 0, 0.3)"),Zd(oM," SUCC","rgba(0, 119, 0, 0.3)"),oM),hM="undefined"!=typeof window&&(bk(aM=window.location.search).call(aM,"_rtc_debug_")||(null===(sM=window.localStorage)||void 0===sM?void 0:sM.getItem("_rtc_debug_"))),pM=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"global";Hl(this,e),Zd(this,"indent",void 0),Zd(this,"module",void 0),Zd(this,"_engineId",void 0),this.module=t,this.indent=r,this._engineId=n}return jl(e,[{key:"_print",value:function(e,t){for(var r,n,i,o,a,s,c,u,d=arguments.length,l=new Array(d>2?d-2:0),h=2;h<d;h++)l[h-2]=arguments[h];var p=l.shift();try{var v,f,_,m,g=Nm(v=[]).call(v,l),y="".concat(p).replace(/%o/gi,(function(){var e=g.shift();return Fm(e)}));xw.set(Nm(f=Nm(_=Nm(m="".concat(uM,"[").concat(this.module,".")).call(m,t,"] ")).call(_,y," ")).call(f,Km(g).call(g,(function(e){return Fm(e)})).join(", ")))}catch(BY){}for(var S="",b=0;b<this.indent;b++)S+=" ";var E=vM();cM.report(uM,this._engineId,E,e,S,this.module,t,p,l),hM&&(r=console).log.apply(r,Nm(n=[Nm(i=Nm(o=Nm(a=Nm(s=Nm(c=Nm(u="%c".concat(E,"-")).call(u,uM,"%c[")).call(c,e,"]%c")).call(s,S,"[")).call(a,this.module,".")).call(o,t,"] ")).call(i,p),"color:".concat(dM,";"),"background-color:".concat(lM[e],";"),"color:".concat(dM,";")]).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,Nm(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,Nm(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,Nm(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,Nm(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,Nm(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,Nm(t=[" SUCC",e]).call(t,n))}}]),e}(),vM=function(){var e,t,r=new Date;return Nm(e="".concat(r.toTimeString().split(" ")[0],":")).call(e,Lw(t=r.getMilliseconds().toString()).call(t,3,"0"))},fM=pM,_M=function(e){var t,r=qP(e.engineId),n={keys:dw(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId,deviceId:e.deviceId,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0},i=Km(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:Fm(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=Km(i).call(i,function(){var e=xm(wm().mark((function e(t,r){var i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:Fm(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 $_((function(e){(function(e){return new $_((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:Fm(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})}))}))},mM={exports:{}},gM=o;Cr({global:!0,forced:gM.globalThis!==gM},{globalThis:gM});var yM=r(o);var SM,bM={exports:{}},EM=new Proxy({},{get(e,t){throw new Error(`Module "" has been externalized for browser compatibility. Cannot access ".${t}" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.`)}}),kM=n(Object.freeze({__proto__:null,default:EM}));function TM(){return SM||(SM=1,function(e,r){var n;e.exports=(n=n||function(e,r){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),void 0!==yM&&yM.crypto&&(n=yM.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==t&&t.crypto&&(n=t.crypto),!n)try{n=kM}catch(_){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(_){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(_){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),a={},s=a.lib={},c=s.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=s.WordArray=c.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=t!=r?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var s=0;s<i;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e,t=c.clone.call(this);return t.words=Am(e=this.words).call(e,0),t},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new u.init(t,e)}}),d=a.enc={},l=d.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=vg(e.substr(n,2),16)<<24-n%8*4;return new u.init(r,t/2)}},h=d.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new u.init(r,t)}},p=d.Utf8={stringify:function(e){try{return decodeURIComponent(escape(h.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return h.parse(unescape(encodeURIComponent(e)))}},v=s.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){var t;"string"==typeof e&&(e=p.parse(e)),Nm(t=this._data).call(t,e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,s=o/(4*a),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,d=e.min(4*c,o);if(c){for(var l=0;l<c;l+=a)this._doProcessBlock(i,l);r=ak(i).call(i,0,c),n.sigBytes-=d}return new u.init(r,d)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=v.extend({cfg:c.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){v.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new f.HMAC.init(e,r).finalize(t)}}});var f=a.algo={};return a}(Math),n)}(bM)),bM.exports}!function(e,t){var r;e.exports=(r=TM(),function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init,n=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};n.prototype=e}}(),r.lib.WordArray)}(mM);var IM,RM=r(mM.exports),AM={exports:{}},wM={exports:{}};function CM(){return IM||(IM=1,function(e,t){var r;e.exports=(r=TM(),function(){var e=r,t=e.lib.WordArray;function n(e,r,n){for(var i=[],o=0,a=0;a<r;a++)if(a%4){var s=n[e.charCodeAt(a-1)]<<a%4*2|n[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=s<<24-o%4*8,o++}return t.create(i,o)}e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)i.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<r.length;o++)i[r.charCodeAt(o)]=o}var a=r.charAt(64);if(a){var s=DE(e).call(e,a);-1!==s&&(t=s)}return n(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),r.enc.Base64)}(wM)),wM.exports}var xM,OM={exports:{}};function PM(){return xM||(xM=1,function(e,t){var r;e.exports=(r=TM(),function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,a=t.algo,s=[];!function(){for(var t=0;t<64;t++)s[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,a=e[t+0],c=e[t+1],p=e[t+2],v=e[t+3],f=e[t+4],_=e[t+5],m=e[t+6],g=e[t+7],y=e[t+8],S=e[t+9],b=e[t+10],E=e[t+11],k=e[t+12],T=e[t+13],I=e[t+14],R=e[t+15],A=o[0],w=o[1],C=o[2],x=o[3];A=u(A,w,C,x,a,7,s[0]),x=u(x,A,w,C,c,12,s[1]),C=u(C,x,A,w,p,17,s[2]),w=u(w,C,x,A,v,22,s[3]),A=u(A,w,C,x,f,7,s[4]),x=u(x,A,w,C,_,12,s[5]),C=u(C,x,A,w,m,17,s[6]),w=u(w,C,x,A,g,22,s[7]),A=u(A,w,C,x,y,7,s[8]),x=u(x,A,w,C,S,12,s[9]),C=u(C,x,A,w,b,17,s[10]),w=u(w,C,x,A,E,22,s[11]),A=u(A,w,C,x,k,7,s[12]),x=u(x,A,w,C,T,12,s[13]),C=u(C,x,A,w,I,17,s[14]),A=d(A,w=u(w,C,x,A,R,22,s[15]),C,x,c,5,s[16]),x=d(x,A,w,C,m,9,s[17]),C=d(C,x,A,w,E,14,s[18]),w=d(w,C,x,A,a,20,s[19]),A=d(A,w,C,x,_,5,s[20]),x=d(x,A,w,C,b,9,s[21]),C=d(C,x,A,w,R,14,s[22]),w=d(w,C,x,A,f,20,s[23]),A=d(A,w,C,x,S,5,s[24]),x=d(x,A,w,C,I,9,s[25]),C=d(C,x,A,w,v,14,s[26]),w=d(w,C,x,A,y,20,s[27]),A=d(A,w,C,x,T,5,s[28]),x=d(x,A,w,C,p,9,s[29]),C=d(C,x,A,w,g,14,s[30]),A=l(A,w=d(w,C,x,A,k,20,s[31]),C,x,_,4,s[32]),x=l(x,A,w,C,y,11,s[33]),C=l(C,x,A,w,E,16,s[34]),w=l(w,C,x,A,I,23,s[35]),A=l(A,w,C,x,c,4,s[36]),x=l(x,A,w,C,f,11,s[37]),C=l(C,x,A,w,g,16,s[38]),w=l(w,C,x,A,b,23,s[39]),A=l(A,w,C,x,T,4,s[40]),x=l(x,A,w,C,a,11,s[41]),C=l(C,x,A,w,v,16,s[42]),w=l(w,C,x,A,m,23,s[43]),A=l(A,w,C,x,S,4,s[44]),x=l(x,A,w,C,k,11,s[45]),C=l(C,x,A,w,R,16,s[46]),A=h(A,w=l(w,C,x,A,p,23,s[47]),C,x,a,6,s[48]),x=h(x,A,w,C,g,10,s[49]),C=h(C,x,A,w,I,15,s[50]),w=h(w,C,x,A,_,21,s[51]),A=h(A,w,C,x,k,6,s[52]),x=h(x,A,w,C,v,10,s[53]),C=h(C,x,A,w,b,15,s[54]),w=h(w,C,x,A,c,21,s[55]),A=h(A,w,C,x,y,6,s[56]),x=h(x,A,w,C,R,10,s[57]),C=h(C,x,A,w,m,15,s[58]),w=h(w,C,x,A,T,21,s[59]),A=h(A,w,C,x,f,6,s[60]),x=h(x,A,w,C,E,10,s[61]),C=h(C,x,A,w,p,15,s[62]),w=h(w,C,x,A,S,21,s[63]),o[0]=o[0]+A|0,o[1]=o[1]+w|0,o[2]=o[2]+C|0,o[3]=o[3]+x|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,c=s.words,u=0;u<4;u++){var d=c[u];c[u]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+i+a;return(s<<o|s>>>32-o)+t}function d(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+i+a;return(s<<o|s>>>32-o)+t}function l(e,t,r,n,i,o,a){var s=e+(t^r^n)+i+a;return(s<<o|s>>>32-o)+t}function h(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+i+a;return(s<<o|s>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),r.MD5)}(OM)),OM.exports}var MM,DM={exports:{}},NM={exports:{}};function LM(){return MM||(MM=1,function(e,t){var r,n,i,o,a,s,c,u;e.exports=(u=TM(),n=(r=u).lib,i=n.WordArray,o=n.Hasher,a=r.algo,s=[],c=a.SHA1=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)s[u]=0|e[t+u];else{var d=s[u-3]^s[u-8]^s[u-14]^s[u-16];s[u]=d<<1|d>>>31}var l=(n<<5|n>>>27)+c+s[u];l+=u<20?1518500249+(i&o|~i&a):u<40?1859775393+(i^o^a):u<60?(i&o|i&a|o&a)-1894007588:(i^o^a)-899497514,c=a,a=o,o=i<<30|i>>>2,i=n,n=l}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=o._createHelper(c),r.HmacSHA1=o._createHmacHelper(c),u.SHA1)}(NM)),NM.exports}var UM,VM,FM={exports:{}};function BM(){return UM||(UM=1,function(e,t){var r,n,i,o;e.exports=(r=TM(),i=(n=r).lib.Base,o=n.enc.Utf8,void(n.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=o.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),a=this._iKey=t.clone(),s=i.words,c=a.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;i.sigBytes=a.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t,r=this._hasher,n=r.finalize(e);return r.reset(),r.finalize(Nm(t=this._oKey.clone()).call(t,n))}})))}(FM)),FM.exports}function jM(){return VM||(VM=1,function(e,t){var r,n,i,o,a,s,c,u;e.exports=(u=TM(),LM(),BM(),n=(r=u).lib,i=n.Base,o=n.WordArray,a=r.algo,s=a.MD5,c=a.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=o.create(),s=a.words,c=n.keySize,u=n.iterations;s.length<c;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var d=1;d<u;d++)r=i.finalize(r),i.reset();Nm(a).call(a,r)}return a.sigBytes=4*c,a}}),r.EvpKDF=function(e,t,r){return c.create(r).compute(e,t)},u.EvpKDF)}(DM)),DM.exports}var HM,GM={exports:{}};function zM(){return HM||(HM=1,function(e,t){var r;e.exports=(r=TM(),jM(),void(r.lib.Cipher||function(e){var t=r,n=t.lib,i=n.Base,o=n.WordArray,a=n.BufferedBlockAlgorithm,s=t.enc;s.Utf8;var c=s.Base64,u=t.algo.EvpKDF,d=n.Cipher=a.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?y:m}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()});n.StreamCipher=d.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var l=t.mode={},h=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),p=l.CBC=function(){var t=h.extend();function r(t,r,n){var i,o=this._iv;o?(i=o,this._iv=e):i=this._prevBlock;for(var a=0;a<n;a++)t[r+a]^=i[a]}return t.Encryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize;r.call(this,e,t,i),n.encryptBlock(e,t),this._prevBlock=Am(e).call(e,t,t+i)}}),t.Decryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,o=Am(e).call(e,t,t+i);n.decryptBlock(e,t),r.call(this,e,t,i),this._prevBlock=o}}),t}(),v=(t.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var c=o.create(a,n);Nm(e).call(e,c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};n.BlockCipher=d.extend({cfg:d.cfg.extend({mode:p,padding:v}),reset:function(){var e;d.reset.call(this);var t=this.cfg,r=t.iv,n=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=n.createEncryptor:(e=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(n,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var f=n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),_=(t.format={}).OpenSSL={stringify:function(e){var t,r,n=e.ciphertext,i=e.salt;return(i?Nm(t=Nm(r=o.create([1398893684,1701076831])).call(r,i)).call(t,n):n).toString(c)},parse:function(e){var t,r=c.parse(e),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(t=o.create(Am(n).call(n,2,4)),ak(n).call(n,0,4),r.sigBytes-=16),f.create({ciphertext:r,salt:t})}},m=n.SerializableCipher=i.extend({cfg:i.extend({format:_}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),a=i.cfg;return f.create({ciphertext:o,key:r,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),g=(t.kdf={}).OpenSSL={execute:function(e,t,r,n,i){var a;if(n||(n=o.random(8)),i)s=u.create({keySize:t+r,hasher:i}).compute(e,n);else var s=u.create({keySize:t+r}).compute(e,n);var c=o.create(Am(a=s.words).call(a,t),4*r);return s.sigBytes=4*t,f.create({key:s,iv:c,salt:n})}},y=n.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:g}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize,n.salt,n.hasher);n.iv=i.iv;var o=m.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt,n.hasher);return n.iv=i.iv,m.decrypt.call(this,e,t,i.key,n)}})}()))}(GM)),GM.exports}!function(e,t){var r;e.exports=(r=TM(),CM(),PM(),jM(),zM(),function(){var e=r,t=e.lib.BlockCipher,n=e.algo,i=[],o=[],a=[],s=[],c=[],u=[],d=[],l=[],h=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var v=n^n<<1^n<<2^n<<3^n<<4;v=v>>>8^255&v^99,i[r]=v,o[v]=r;var f=e[r],_=e[f],m=e[_],g=257*e[v]^16843008*v;a[r]=g<<24|g>>>8,s[r]=g<<16|g>>>16,c[r]=g<<8|g>>>24,u[r]=g,g=16843009*m^65537*_^257*f^16843008*r,d[v]=g<<24|g>>>8,l[v]=g<<16|g>>>16,h[v]=g<<8|g>>>24,p[v]=g,r?(r=f^e[e[e[m^f]]],n^=e[e[n]]):r=n=1}}();var v=[0,1,2,4,8,16,32,64,128,27,54],f=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a<n;a++)a<r?o[a]=t[a]:(u=o[a-1],a%r?r>6&&a%r==4&&(u=i[u>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u]):(u=i[(u=u<<8|u>>>24)>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u],u^=v[a/r|0]<<24),o[a]=o[a-r]^u);for(var s=this._invKeySchedule=[],c=0;c<n;c++){if(a=n-c,c%4)var u=o[a];else u=o[a-4];s[c]=c<4||a<=4?u:d[i[u>>>24]]^l[i[u>>>16&255]]^h[i[u>>>8&255]]^p[i[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,c,u,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,d,l,h,p,o),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,a,s){for(var c=this._nRounds,u=e[t]^r[0],d=e[t+1]^r[1],l=e[t+2]^r[2],h=e[t+3]^r[3],p=4,v=1;v<c;v++){var f=n[u>>>24]^i[d>>>16&255]^o[l>>>8&255]^a[255&h]^r[p++],_=n[d>>>24]^i[l>>>16&255]^o[h>>>8&255]^a[255&u]^r[p++],m=n[l>>>24]^i[h>>>16&255]^o[u>>>8&255]^a[255&d]^r[p++],g=n[h>>>24]^i[u>>>16&255]^o[d>>>8&255]^a[255&l]^r[p++];u=f,d=_,l=m,h=g}f=(s[u>>>24]<<24|s[d>>>16&255]<<16|s[l>>>8&255]<<8|s[255&h])^r[p++],_=(s[d>>>24]<<24|s[l>>>16&255]<<16|s[h>>>8&255]<<8|s[255&u])^r[p++],m=(s[l>>>24]<<24|s[h>>>16&255]<<16|s[u>>>8&255]<<8|s[255&d])^r[p++],g=(s[h>>>24]<<24|s[u>>>16&255]<<16|s[d>>>8&255]<<8|s[255&l])^r[p++],e[t]=f,e[t+1]=_,e[t+2]=m,e[t+3]=g},keySize:8});e.AES=t._createHelper(f)}(),r.AES)}(AM);var KM=AM.exports,XM={exports:{}};!function(e,t){e.exports=TM().enc.Hex}(XM);var WM=r(XM.exports),qM={exports:{}};!function(e,t){var r,n,i;e.exports=(i=TM(),zM(),i.mode.CTR=(r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,o=this._counter;i&&(o=this._counter=Am(i).call(i,0),this._iv=void 0);var a=Am(o).call(o,0);r.encryptBlock(a,0),o[n-1]=o[n-1]+1|0;for(var s=0;s<n;s++)e[t+s]^=a[s]}}),r.Decryptor=n,r),i.mode.CTR)}(qM);var YM=r(qM.exports),JM={exports:{}};!function(e,t){var r;e.exports=(r=TM(),zM(),r.pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)}(JM);var QM=r(JM.exports),ZM=new TextDecoder,$M=new TextEncoder,eD=function(){return mw()},tD=function(){return Date.now()};function rD(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 nD=function(){function e(){Hl(this,e)}var t,r;return jl(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(Ks(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=CA(t);n<i.length;n++){var o=aI(i[n],2),a=o[0],s=o[1];null!==s&&"object"===Yd(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return ZM.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 $M.encode(e).buffer}},{key:"ab2b64str",value:(r=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new $_((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=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,".concat(t)).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function iD(){for(var e,t,r=Number(JA(e=Am(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=JA(r).call(r,28,"1").split(""),i=[];n.length;)i.push(ak(n).call(n,0,7));return Km(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return ZA(r+e.join(""),2)}))}var oD=function(){return Math.floor(65535*Math.random())};function aD(e){return"string"==typeof e&&DE(e).call(e,"__web__rtc__rtt__")>-1}var sD,cD,uD,dD,lD,hD,pD,vD,fD=function(){var e=xm(wm().mark((function e(){var t,r,n,i=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]&&i[0],(r=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"})).createDataChannel("default"),r.addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),t&&(r.addTransceiver("audio",{direction:"sendonly"}),r.addTransceiver("video",{direction:"sendonly"})),e.next=8,r.createOffer();case 8:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),_D=function(e){return new $_((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 mD(e){return Number(Math.max(-127,10*rw(Math.pow(e/255,2))).toFixed(2))}function gD(e){return(e&ll.AUDIO)===ll.AUDIO}function yD(e){return(e&ll.VIDEO)===ll.VIDEO}function SD(e){var t={};return cn(e).forEach((function(r){"object"===Yd(e[r])?t[r]=SD(e[r]):fA(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 ED(e){return void 0===e}function kD(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Nm(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 TD(e){console.warn("[RTC WebSDK]: ".concat(e))}function ID(e){return"number"==typeof e?e:"number"==typeof(null==e?void 0:e.exact)?e.exact:"number"==typeof(null==e?void 0:e.ideal)?e.ideal:"number"==typeof(null==e?void 0:e.max)?e.max:"number"==typeof(null==e?void 0:e.min)?e.min:1}function RD(e){for(var t=atob(e),r=t.length,n=new Uint8Array(r),i=0;i<r;i++)n[i]=t.charCodeAt(i);return n}function AD(e){for(var t="",r=e.byteLength,n=0;n<r;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function wD(e,t,r){var n=CD(e),i=CD(t),o=CD(r);return function(e){for(var t=e.toString(WM),r=new Uint8Array(t.length/2),n=0;n<t.length;n+=2)r[n/2]=vg(t.substr(n,2),16);return r}(KM.encrypt(n,i,{iv:o,mode:YM,padding:QM}).ciphertext)}function CD(e){for(var t=[],r=0;r<e.length;r+=4)t.push(e[r]<<24|(e[r+1]||0)<<16|(e[r+2]||0)<<8|(e[r+3]||0));return RM.create(t,e.length)}var xD=function(){return"undefined"==typeof window},OD=xD()?"":window.navigator.userAgent;function PD(){var e="none";return xD()||(null!==OD.match("Firefox")?e="mozilla":null!==OD.match("Chrome")?(e="chrome-stable",null!==OD.match("Electron")&&(e="electron")):(null!==OD.match("Safari")||null!==OD.match("AppleWebKit"))&&(e="safari")),e}var MD,DD="mozilla"===PD(),ND="safari"===PD(),LD="chrome-stable"===PD(),UD=!xD()&&/CriOS/i.test(OD),VD=!xD()&&/Edg\//i.test(OD),FD=!xD()&&/EdgA/i.test(OD),BD=!xD()&&/EdgiOS/i.test(OD),jD=VD||FD||BD,HD=!xD()&&/DingTalk/i.test(navigator.userAgent),GD=!xD()&&(!!/(iPad)/i.exec(OD)||/Macintosh/i.test(OD)&&"ontouchend"in document),zD=!xD()&&/Macintosh/i.test(OD),KD=!xD()&&/MicroMessenger/i.test(OD),XD=!xD()&&bk(sD=OD.toLowerCase()).call(sD,"mobile"),WD=!xD()&&!!/(iPhone|iPad|iPod)/i.exec(OD),qD=!xD()&&/Android/i.test(OD),YD=!xD()&&/Windows/i.test(OD),JD=0,QD="0",ZD=!xD()&&(null===(cD=OD.match(/version\/(\d+)/i))||void 0===cD?void 0:cD[1]);ND&&ZD&&(JD=Number(ZD),QD=null===(MD=navigator.userAgent.match(/version\/(\d+\.\d+)/i))||void 0===MD?void 0:MD[1]);var $D=!xD()&&(null===(uD=OD.match(/Firefox\/(\d+)/i))||void 0===uD?void 0:uD[1]);DD&&$D&&(JD=Number($D));var eN=JD,tN=JD,rN=QD,nN=null!==(dD=!xD()&&(null===(lD=OD.match(/ ([\d_]+) like Mac OS X/i))||void 0===lD||null===(hD=lD[1])||void 0===hD?void 0:Km(pD=hD.split("_")).call(pD,(function(e){return vg(e)}))))&&void 0!==dD?dD:[],iN=0,oN=!xD()&&(null===(vD=OD.match(/Chrome\/(\d+)/i))||void 0===vD?void 0:vD[1]);oN&&(iN=Number(oN));var aN=iN,sN="BytePlus",cN="RTC_DEVICE_ID",uN="RTC_ACCESS_URLS",dN="ENGINE_WEB_CONFIG",lN="SERVER_CONFIG",hN=function(){function e(){Hl(this,e)}return jl(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,Fm(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}(),pN=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Nm(e=[this]).call(e,o))),"_accessVersion","v2"),n}return jl(r,[{key:"getDeviceId",value:function(){if(xD())return"";var e=this.get(cN);return e&&!/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e)||(e=function(e){for(var t="",r=0;r<e;r++)t+=Math.floor(10*Math.random());return t}(30)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return BP({device_id:e}),this.set(cN,e),e}},{key:"getAccessKey",value:function(e){var t,r;return Nm(t=Nm(r="".concat("RTC_ACCESS_NODE","_").concat(e,"-")).call(r,sN,"-")).call(t,this._accessVersion)}},{key:"getAccessNode",value:function(e){return this.get(this.getAccessKey(e))}},{key:"setAccessNode",value:function(e,t,r){return this.set(this.getAccessKey(e),t,1e3*r)}},{key:"deleteAccessNode",value:function(e,t){var r=this.getAccessNode(e),n=this.getTtl(this.getAccessKey(e));Array.isArray(r)&&r.length>0&&((r=Ks(r).call(r,(function(e){return e.mediaID!==t.mediaID&&e.msgKey!==t.msgKey}))).length>0?this.setAccessNode(e,r,n||0):this.clearAccessNode(e))}},{key:"clearAccessNode",value:function(e){this.delete(this.getAccessKey(e))}},{key:"getAccessUrls",value:function(){return this.get("".concat(uN,"-").concat(sN))}},{key:"setAccessUrls",value:function(e){var t=Km(e).call(e,(function(e){var t,r=e.host,n=e.path;return Nm(t="https://".concat(r)).call(t,n)}));return this.set("".concat(uN,"-").concat(sN),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(uN,"-").concat(sN))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Nm(r=Nm(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(dN);return(null==a||null===(i=kE(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=Nm(n=Nm(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(dN)||[];return(a=Ks(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(dN,Am(a).call(a,-5))}}},{key:"getServerConfig",value:function(e){var t,r="".concat(e),n=this.get(lN);return(null==n||null===(t=kE(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(lN)||[];return(n=Ks(n).call(n,(function(e){return e.key!==r}))).push({key:r,config:t}),this.set(lN,Am(n).call(n,-5))}}}]),r}(hN),vN=new pN,fN=new fM("JoinRoomConfig",0),_N=function(){function e(t){var r;Hl(this,e),Zd(this,"_useTcpAfterJoinTimeout",e.DEFAULT_CONF.useTcpAfterJoinTimeout),Zd(this,"_joinWithTcpOnly",e.DEFAULT_CONF.joinWithTcpOnly),Zd(this,"_joinWithTcpOnlyDelay",e.DEFAULT_CONF.joinWithTcpOnlyDelay),Zd(this,"_blackBrowserRegexList",[]),this._engineId=t,DE(r=location.search).call(r,"__rtc_tcp_only__")>-1&&(this._joinWithTcpOnly=!0,this._joinWithTcpOnlyDelay=0),this._report()}return jl(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 kE(e=this._blackBrowserRegexList).call(e,(function(e){return new RegExp(e).test(navigator.userAgent)}))}},{key:"setServerConfig",value:function(e){var t,r,n,i,o,a,s=!1;"boolean"==typeof(null==e||null===(t=e.use_tcp_after_join_timeout)||void 0===t?void 0:t.enable)&&(this._useTcpAfterJoinTimeout=null===(i=e.use_tcp_after_join_timeout)||void 0===i?void 0:i.enable,s=!0);"boolean"==typeof(null==e||null===(r=e.join_with_tcp_only)||void 0===r?void 0:r.enable)&&(this._joinWithTcpOnly=null===(o=e.join_with_tcp_only)||void 0===o?void 0:o.enable,s=!0);"number"==typeof(null==e||null===(n=e.join_with_tcp_only)||void 0===n?void 0:n.delay_ms)&&(this._joinWithTcpOnlyDelay=null===(a=e.join_with_tcp_only)||void 0===a?void 0:a.delay_ms,s=!0);e&&Array.isArray(e.black_browser_regex_list)&&(this._blackBrowserRegexList=e.black_browser_regex_list,s=!0),s&&this._report()}},{key:"toString",value:function(){return Fm({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(){fN.print("_report",this.toString()),$P(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}();Zd(_N,"DEFAULT_CONF",{useTcpAfterJoinTimeout:!0,joinWithTcpOnly:!1,joinWithTcpOnlyDelay:5e3});var mN="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function gN(){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 yN="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",SN="rtc.rtcplus.com".split(","),bN={VERSION:"4.56.18",ICE_CONFIG_REQUEST_URLS_INTERNAL:Km(mN).call(mN,gN),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:yN,CONFIG_REQUEST_DOMAINS:SN,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",FORCE_ENABLED_REPORT_CALLBACKS:[],SKIP_WEB_AUDIO_IN_TRACK:!1,AUDIO_STALL:!0,VIDEO_STALL:!0,STATS_SCALLBACK_SUPPORT:!0,JOIN_ROOM_CONFIG:_N.DEFAULT_CONF,SIGNAL_COMPRESSION:!0,SIGNAL_CROP_JOINROOM:!0,IOS_SAFARI_ORIENTATION:!1,ENABLE_FALLBACK_HANDLER:!1,ENABLE_STANDARD_HANDLER:!1,PC_KILLSWITCH:{}};function EN(e,t){var r;if(GP("setParameter",0,Nm(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("JOIN_ROOM_CONFIG"===e)return _N.setDefaulConf(t);if("ICE_CONFIG_REQUEST_URLS"!==e)if("PLATFORM"!==e||"string"!=typeof t)if("PRODUCT"!==e||"string"!=typeof t)if("FORCE_ENABLED_REPORT_CALLBACKS"!==e){if("LOG_SERVER_URL"===e){var n=t===ml.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===ml.domestic?yN:"string"==typeof t?t:void 0;n&&(bN.LOG_SERVER_URL=n,jP(n))}else if("OVERSEA"===e)return BP({extra_is_oversea:t?"1":"0"}),void(bN.OVERSEA=t);if("CONFIG_REQUEST_DOMAINS"===e&&Array.isArray(t)&&t.length>0)bN.CONFIG_REQUEST_DOMAINS=t;else{"DEVICE_ID"===e&&vN.setDeviceId(t);var i=Bw.getKeys();bk(i).call(i,e)?Bw.setParameter(e,t):bN[e]=t}}else{var o="string"==typeof t?[t]:t;bN.FORCE_ENABLED_REPORT_CALLBACKS=o}else BP({product:t});else BP({platform:t});else{var a="string"==typeof t?[t]:t;bN.ICE_CONFIG_REQUEST_URLS=Km(a).call(a,gN)}}}function kN(e){return"DEVICE_ID"===e?vN.getDeviceId():bN[e]}function TN(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)||Sl.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:Km(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 IN=[];function RN(e){IN=e}var AN={width:640,height:480,frameRate:15,maxKbps:600},wN={width:1920,height:1080,frameRate:15,maxKbps:3e3};function CN(e,t){if("boolean"!=typeof e)throw new SA(_A.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function xN(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 SA(_A.INVALID_PARAMS,Nm(r=Nm(n="Invalid ".concat(t,": the value range is [")).call(n,i,", ")).call(r,o,"]. integer only"))}function ON(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 SA(_A.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 SA(_A.INVALID_PARAMS,Nm(r=Nm(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function PN(e,t,r){var n;if(!bk(r).call(r,e))throw new SA(_A.INVALID_PARAMS,Nm(n="Invalid ".concat(t,": The value can only be set as ")).call(n,Fm(r)))}function MN(e){if(!(e instanceof MediaStreamTrack))throw new SA(_A.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function DN(e,t){if(UN(e))throw new SA(_A.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function NN(e,t){if(!(e instanceof ArrayBuffer))throw new SA(_A.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function LN(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=cn(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(o){}}function UN(e){return null==e}function VN(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new SA(_A.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function FN(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new SA(_A.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function BN(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new SA(_A.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function jN(e){DN(e,"userInfo"),FN(e.userId),UN(e.extraInfo)||ON(e.extraInfo,"userInfo.extraInfo",1,200)}function HN(e){DN(e,"roomConfig"),CN(e.isAutoPublish,"roomConfig.isAutoPublish"),CN(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),CN(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),UN(e.roomProfileType)||PN(e.roomProfileType,"roomConfig",[Il.communication,Il.chat,Il.chatRoom,Il.coHost,Il.meeting,Il.classRoom])}function GN(e){DN(e,"videoPlayerOption")}function zN(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 SA(_A.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:nD.str2ab(Fm(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new SA(_A.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function KN(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new SA(_A.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function XN(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 SA(_A.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function WN(e){var t,r=oI(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;xN(null==n?void 0:n.maxKbps,"maxKbps"),XN(null==n?void 0:n.width,"width"),XN(null==n?void 0:n.height,"height"),XN(null==n?void 0:n.frameRate,"frameRate")}}catch(i){r.e(i)}finally{r.f()}}function qN(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 xN(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var YN={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?Am(n).call(n,1):n);return Ms?Nm(i).call(i,Ms(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}(YN);var JN=YN.exports,QN=r(JN),ZN=new fM("VERTC",0),$N=function(e){UI(r,e);var t=eR(r);function r(){return Hl(this,r),t.apply(this,arguments)}return jl(r,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var n,i,o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return(n=NI(DI(r.prototype),"emit",this)).call.apply(n,Nm(i=[this,e]).call(i,a))}catch(BY){return ZN.error("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,BY),console.error(BY),Boolean(t)}}}]),r}(JN.EventEmitter),eL=M,tL=nr,rL=te,nL=uI,iL=Zt,oL=C,aL=Sc,sL=B;Cr({target:"Reflect",stat:!0,forced:a((function(){var e=function(){},t=iL.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=oL.f(tL(t),r);if(!c){if(rL(o=aL(t)))return e(o,r,n,s);c=sL(0)}if(nL(c)){if(!1===c.writable||!rL(s))return!1;if(i=oL.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,iL.f(s,r,i)}else iL.f(s,r,sL(0,n))}else{if(void 0===(a=c.set))return!1;eL(a,s,n)}return!0}});var cL=r(re.Reflect.set),uL=r(fi.f("asyncIterator"));function dL(e){var t,r,n,i=2;for(void 0!==xd&&(r=uL,n=qd);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new lL(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function lL(e){function t(e){if(Object(e)!==e)return $_.reject(new TypeError(e+" is not an object."));var t=e.done;return $_.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(lL=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?$_.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?$_.reject(e):t(r.apply(this.s,arguments))}},new lL(e)}var hL=[{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}];ty("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),gy);var pL=re.Set;Cr({target:"Set",stat:!0,forced:!0},{from:Ay}),Cr({target:"Set",stat:!0,forced:!0},{of:Cy});var vL=M,fL=Oe,_L=nr,mL=function(){for(var e=_L(this),t=fL(e.add),r=0,n=arguments.length;r<n;r++)vL(t,e,arguments[r]);return e};Cr({target:"Set",proto:!0,real:!0,forced:!0},{addAll:mL}),Cr({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:My});var gL=kh,yL=nr,SL=Qt,bL=gL,EL=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=yL(this),r=bL(t),n=SL(e,arguments.length>1?arguments[1]:void 0);return!EL(r,(function(e,r){if(!n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var kL=se,TL=M,IL=Oe,RL=nr,AL=xp,wL=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){var t=RL(this),r=new(AL(t,kL("Set")))(t),n=IL(r.delete);return wL(e,(function(e){TL(n,r,e)})),r}});var CL=se,xL=M,OL=Oe,PL=nr,ML=Qt,DL=xp,NL=gL,LL=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=PL(this),r=NL(t),n=ML(e,arguments.length>1?arguments[1]:void 0),i=new(DL(t,CL("Set"))),o=OL(i.add);return LL(r,(function(e){n(e,e,t)&&xL(o,i,e)}),{IS_ITERATOR:!0}),i}});var UL=nr,VL=Qt,FL=gL,BL=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=UL(this),r=FL(t),n=VL(e,arguments.length>1?arguments[1]:void 0);return BL(r,(function(e,r){if(n(e,e,t))return r(e)}),{IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var jL=se,HL=M,GL=Oe,zL=nr,KL=xp,XL=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){var t=zL(this),r=new(KL(t,jL("Set"))),n=GL(t.has),i=GL(r.add);return XL(e,(function(e){HL(n,t,e)&&HL(i,r,e)})),r}});var WL=M,qL=Oe,YL=nr,JL=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){var t=YL(this),r=qL(t.has);return!JL(e,(function(e,n){if(!0===WL(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var QL=se,ZL=M,$L=Oe,eU=w,tU=nr,rU=kh,nU=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){var t=rU(this),r=tU(e),n=r.has;return eU(n)||(r=new(QL("Set"))(e),n=$L(r.has)),!nU(t,(function(e,t){if(!1===ZL(n,r,e))return t()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var iU=M,oU=Oe,aU=nr,sU=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){var t=aU(this),r=oU(t.has);return!sU(e,(function(e,n){if(!1===iU(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var cU=Cr,uU=nr,dU=Sn,lU=gL,hU=jh,pU=T([].join),vU=[].push;cU({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=uU(this),r=lU(t),n=void 0===e?",":dU(e),i=[];return hU(r,vU,{that:i,IS_ITERATOR:!0}),pU(i,n)}});var fU=se,_U=Qt,mU=M,gU=Oe,yU=nr,SU=xp,bU=gL,EU=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=yU(this),r=bU(t),n=_U(e,arguments.length>1?arguments[1]:void 0),i=new(SU(t,fU("Set"))),o=gU(i.add);return EU(r,(function(e){mU(o,i,n(e,e,t))}),{IS_ITERATOR:!0}),i}});var kU=Oe,TU=nr,IU=gL,RU=jh,AU=TypeError;Cr({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=TU(this),r=IU(t),n=arguments.length<2,i=n?void 0:arguments[1];if(kU(e),RU(r,(function(r){n?(n=!1,i=r):i=e(i,r,r,t)}),{IS_ITERATOR:!0}),n)throw AU("Reduce of empty set with no initial value");return i}});var wU=nr,CU=Qt,xU=gL,OU=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=wU(this),r=xU(t),n=CU(e,arguments.length>1?arguments[1]:void 0);return OU(r,(function(e,r){if(n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var PU=se,MU=M,DU=Oe,NU=nr,LU=xp,UU=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){var t=NU(this),r=new(LU(t,PU("Set")))(t),n=DU(r.delete),i=DU(r.add);return UU(e,(function(e){MU(n,r,e)||MU(i,r,e)})),r}});var VU=se,FU=Oe,BU=nr,jU=xp,HU=jh;Cr({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){var t=BU(this),r=new(jU(t,VU("Set")))(t);return HU(e,FU(r.add),{that:r}),r}});var GU=r(pL),zU=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!xD()&&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,$U();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,ZU();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)}}(),KU=function(){var e=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.next=3,$U();case 3:if(e.t0=e.sent,!e.t0){e.next=8;break}return e.next=7,ZU();case 7:e.t0=e.sent;case 8:if(!e.t0){e.next=10;break}t.push("H264");case 10:return e.next=12,tV();case 12:if(e.t1=e.sent,!e.t1){e.next=17;break}return e.next=16,eV();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)}}(),XU=function(){var e=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,KU();case 2:return t=e.sent,e.abrupt("return",Km(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),WU={};function qU(e){var t,r=!1,n=oI(e.split("\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value;if(bk(i).call(i,"level-asymmetry-allowed=1")&&bk(i).call(i,"packetization-mode=1")&&bk(i).call(i,"profile-level-id=42e0")){r=!0;break}}}catch(u){n.e(u)}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 YU=function(){var e=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("video",{direction:t}),e.next=4,r.createOffer();case 4:return n=e.sent,r.close(),e.abrupt("return",n.sdp.toLowerCase());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),JU=function(){var e=xm(wm().mark((function e(){var t,r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,YU("sendonly");case 2:if(r=e.sent,!bk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,YU("sendonly");case 6:r=e.sent;case 7:return WU.h264encode=qU(r),WU.vp8encode=DE(r).call(r,"vp8")>-1,e.abrupt("return",WU);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),QU=function(){var e=xm(wm().mark((function e(){var t,r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,YU("recvonly");case 2:if(r=e.sent,!bk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,YU("recvonly");case 6:r=e.sent;case 7:return WU.h264decode=qU(r),WU.vp8decode=DE(r).call(r,"vp8")>-1,e.abrupt("return",WU);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ZU=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==WU.h264encode){e.next=9;break}return e.prev=1,e.next=4,JU();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",WU.h264encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),$U=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==WU.h264decode){e.next=9;break}return e.prev=1,e.next=4,QU();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",WU.h264decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),eV=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==WU.vp8encode){e.next=9;break}return e.prev=1,e.next=4,JU();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",WU.vp8encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),tV=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==WU.vp8decode){e.next=9;break}return e.prev=1,e.next=4,QU();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",WU.vp8decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),rV=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},nV=function(){return zD?LD&&aN>=70||DD&&tN>=80||ND&&eN>=14:YD?LD&&aN>=70||DD&&tN>=80:WD?nN[0]>=14:!!qD&&(LD&&aN>=86)},iV=LD&&aN<=114,oV=!DD||tN>=96,aV=!(ND&&eN<=14),sV=qD&&LD||WD&&(17===nN[0]||16===nN[0]),cV=new ib,uV=!0,dV=function(){var e=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new $_((function(e){var r={all:[],getTrackStats:function(){return[]}},n=kN("STATS_SCALLBACK_SUPPORT");if(uV&&LD&&void 0===window.InstallTrigger&&iV&&n)try{var i,o,a,s;null===(i=t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!bk(vV).call(vV,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(el(el({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return Ks(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(){uV=!1,e(r)}))}catch(c){uV=!1,e(r)}else e(r)})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),lV=function(){var e=xm(wm().mark((function e(t){var r,n,i,o,a,s,c;return wm().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 ib,n.forEach((function(e){var t=o.get(e.type)||new ib;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(pV.codec))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=o.get(pV.transport))||void 0===n||n.forEach((function(e){e.id===d&&(s=e,t.add(e))})),null===(i=o.get(pV.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(a=o.get(pV.mediaPlayout))||void 0===a||a.forEach((function(e){e.id===h&&t.add(e)})),s){var p,v,f=s,_=f.localCertificateId,m=f.remoteCertificateId,g=f.selectedCandidatePairId;null===(p=o.get(pV.certificate))||void 0===p||p.forEach((function(e){(e.id===_||e.id===m)&&t.add(e)})),null===(v=o.get(pV.candidatePair))||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(pV.localCandidate))||void 0===y||y.forEach((function(e){e.id===E&&t.add(e)})),null===(S=o.get(pV.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===k&&t.add(e)}))}}))},o.get(pV.mediaSource)?null===(s=o.get(pV.mediaSource))||void 0===s||s.forEach((function(e){var t,r=new GU;r.add(e);var n=[];null===(t=o.get(pV.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=o.get(pV.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=Zk(r)})):o.get(pV.track)&&(null===(c=o.get(pV.track))||void 0===c||c.forEach((function(e){var t,r=new GU;r.add(e);var n=[];null===(t=o.get(pV.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.trackId===e.id&&(r.add(t),n.push(t),null===(i=o.get(pV.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=Zk(r)}))),null===(r=o.get(pV.inboundRtp))||void 0===r||r.forEach((function(e){var t,r=new GU;r.add(e),null===(t=o.get(pV.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),a([e],r);var n,s=e.trackIdentifier;s||(null===(n=o.get(pV.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(s=t.trackIdentifier)})));i[s]=Zk(r)})),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),hV=function(){var e=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!DD&&!ND){e.next=10;break}return o=[],e.next=7,t.getStats(r);case 7:return e.sent.forEach((function(e){o.push(e)})),e.abrupt("return",o);case 10:return(!(a=cV.get(t))||Date.now()-a.timestamp>150)&&(a={timestamp:Date.now(),statsPromise:lV(t),extraStatsPromise:dV(t)},cV.set(t,a)),e.next=14,a.statsPromise;case 14:if(s=e.sent,c=(i?s[i]:s.all)||[],n){e.next=21;break}return e.next=19,a.extraStatsPromise;case 19:u=e.sent,c=Nm(c).call(c,(i?u.getTrackStats(i):u.all)||[]);case 21:return e.abrupt("return",c);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),pV=function(e){return e.codec="codec",e.inboundRtp="inbound-rtp",e.outboundRtp="outbound-rtp",e.remoteInboundRtp="remote-inbound-rtp",e.remoteOutboundRtp="remote-outbound-rtp",e.mediaSource="media-source",e.csrc="csrc",e.peerConnection="peer-connection",e.dataChannel="data-channel",e.stream="stream",e.track="track",e.transceiver="transceiver",e.sender="sender",e.receiver="receiver",e.transport="transport",e.sctpTransport="sctp-transport",e.candidatePair="candidate-pair",e.localCandidate="local-candidate",e.remoteCandidate="remote-candidate",e.certificate="certificate",e.iceServer="ice-server",e.mediaPlayout="media-playout",e}(pV||{}),vV=["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"],fV={},_V={},mV={exports:{}},gV=mV.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"]}]};cn(gV).forEach((function(e){gV[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}));var yV=mV.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=yV,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t,o={},a=[],s=o;return Ks(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=Am(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 gb(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return Km(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=Km(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 Km(t=e.split(" ")).call(t,(function(e){var t;return gb(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return Km(r=e.split(";")).call(r,(function(e){var r;return Km(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}}))}))}}(_V);var SV=yV,bV=/%[sdv%]/g,EV=function(e){var t=1,r=arguments,n=r.length;return e.replace(bV,(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""}}))},kV=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 EV.apply(null,n)},TV=["v","o","s","i","u","e","p","c","b","t","r","z","a"],IV=["i","c","b","a"],RV=_V,AV=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||TV,n=t.innerOrder||IV,i=[];return r.forEach((function(t){SV[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(kV(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(kV(t,r,e))}))}))})),e.media.forEach((function(e){i.push(kV("m",SV.m[0],e)),n.forEach((function(t){SV[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(kV(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(kV(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};fV.write=AV,fV.parse=RV.parse,fV.parseParams=RV.parseParams,fV.parseFmtpConfig=RV.parseFmtpConfig,fV.parsePayloads=RV.parsePayloads,fV.parseRemoteCandidates=RV.parseRemoteCandidates,fV.parseImageAttributes=RV.parseImageAttributes,fV.parseSimulcastStreamList=RV.parseSimulcastStreamList;var wV=Ye,CV=Ur,xV=Hr,OV=function(e){for(var t=wV(this),r=xV(t),n=arguments.length,i=CV(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:CV(o,r);a>i;)t[i++]=e;return t};Cr({target:"Array",proto:!0},{fill:OV});var PV=Bs("Array").fill,MV=ce,DV=PV,NV=Array.prototype,LV=r((function(e){var t=e.fill;return e===NV||MV(NV,e)&&t===NV.fill?DV:t})),UV=new fM("FirefoxHandler",3),VV=Math.pow(2,32),FV="kp34Za0H+aVf862l";function BV(e){return e>VV-18?(UV.warn("generateAllSsrc","reset start id",e),BV(e=e-VV+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var jV=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:Nm(n=Nm(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Nm(o="".concat(e,"-")).call(o,t)}]},HV=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=gb(s).call(s,(function(t,r){return Nm(t).call(t,jV(e,"video",r,c))}),[]),h=[{semantics:"FID",ssrcs:Nm(r="".concat(i," ")).call(r,o)}];u&&h.push({semantics:"FEC-FR",ssrcs:Nm(d="".concat(i," ")).call(d,a)});return{ssrcs:l,ssrcGroups:h}};function GV(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 zV=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=el(el({},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,fV.write(i)};function KV(e){return XV.apply(this,arguments)}function XV(){return(XV=xm(wm().mark((function e(t){var r,n,i,o,a;return wm().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,qV(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=WV(n,a),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function WV(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(el(el({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(el(el({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var qV=function(){var e=xm(wm().mark((function e(t){var r,n,i,o,a,s,c;return wm().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,nD.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=rD(Uint8Array,n,i,o,a),e.next=15,nD.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)}}(),YV=function(e){return e[e.kICEConfigTypeSrtpDtlsType=0]="kICEConfigTypeSrtpDtlsType",e[e.kICEConfigTypeRenominationType=1]="kICEConfigTypeRenominationType",e[e.kICEConfigTypeTcpType=2]="kICEConfigTypeTcpType",e[e.kICEConfigTypeMultiSendType=3]="kICEConfigTypeMultiSendType",e[e.kICEConfigTypeKcpType=4]="kICEConfigTypeKcpType",e[e.kICEConfigTypeSrtpSdesType=5]="kICEConfigTypeSrtpSdesType",e}(YV||{});function JV(e){var t,r=e.random,n=e.serverUfrag,i=e.serverPwd,o=e.clientPwd,a=e.options,s=(new TextEncoder).encode("WPRE");r||(r=new Uint8Array(4),crypto.getRandomValues(r));var c=RD(n);c.byteLength;var u=wD(RD(o),RD(i).subarray(0,16),RD(n).subarray(0,16));u.byteLength;var d=new Uint8Array(gb(t=cn(a)).call(t,(function(e,t){var r=Number(t);return e.push(r),e.push(a[r]?1:0),e}),[]));d.byteLength;var l,h=rD(Uint8Array,s,r,[c.byteLength],c,[u.byteLength],u,d);h.byteLength%3!=0&&(h=rD(Uint8Array,h,LV(l=new Uint8Array(3-h.byteLength%3)).call(l,255)));return[AD(h),AD(rD(Uint8Array,r,c.subarray(0,20)))]}var QV=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=oI(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(bk(o=c.config).call(o,"level-asymmetry-allowed=1")&&bk(a=c.config).call(a,"packetization-mode=1")&&bk(s=c.config).call(s,"profile-level-id=42e0")){r=c.payload;break}}}catch(v){i.e(v)}finally{i.f()}for(var u=0;u<e.rtp.length;u++){var d=e.rtp[u];if("H264"===t){if(d.payload===r){var l;e.rtp.unshift(ak(l=e.rtp).call(l,u,1)[0]);break}}else if(d.codec===t){var h;e.rtp.unshift(ak(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(" ")}},ZV=function(e){var t,r=fV.parse(e);return r.media=Km(t=r.media).call(t,(function(e){return"audio"===e.type?eF(e,r):$V(e,["H264","VP8"],r)})),fV.write(r)},$V=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(fA(r).call(r,"apt=")){var n=Am(r).call(r,4);u[t]=n}else bk(r).call(r,"42e0")&&bk(r).call(r,"packetization-mode=1")&&(l=t)})),Array.isArray(e.rtp))&&(e.rtp=Ks(n=e.rtp).call(n,(function(e){var r,n=e.codec,i=e.payload;switch(n){case"H264":return r=!1,Km(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":return d[i]=i,!0;default:return r=!1,Km(t).call(t,(function(e){e===n&&(d[i]=i,h.push(i),r=!0)})),r}})));Array.isArray(e.fmtp)&&(e.fmtp=Ks(i=e.fmtp).call(i,(function(e){return d[e.payload]})));Array.isArray(e.rtcpFb)?e.rtcpFb=Ks(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"})})),tF(e,r),Array.isArray(e.ext))&&(e.ext=Ks(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=Ks(s=e.payloads.split(" ")).call(s,(function(e){return d[e]})).join(" "));return e},eF=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{rrtr:!1},i={};Array.isArray(e.rtp)&&(e.rtp=Ks(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&&cn(i).forEach((function(t){var r;null===(r=e.rtcpFb)||void 0===r||r.push({payload:Number(t),type:"rrtr"})})),tF(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},tF=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)},rF=function(e){UI(n,e);var t,r=eR(n);function n(e,t){var i;return Hl(this,n),Zd(sI(i=r.call(this)),"_peerConnection",void 0),Zd(sI(i),"_dataChannel",void 0),Zd(sI(i),"_context",void 0),Zd(sI(i),"peerConnectionMode",0),Zd(sI(i),"id",void 0),Zd(sI(i),"_monitor",void 0),Zd(sI(i),"logger",void 0),Zd(sI(i),"_nextSsrc",Math.floor(Math.random()*VV+1e4)),Zd(sI(i),"_aSendonlyAnswerTpl",void 0),Zd(sI(i),"_vSendonlyAnswerTpl",void 0),Zd(sI(i),"_enableSubFlexfec",!1),Zd(sI(i),"audioTrack4ff",void 0),Zd(sI(i),"setLocalDescription",void 0),Zd(sI(i),"setRemoteDescription",void 0),i.peer=t,i.id=e.id,i._monitor=qP(i.id),i.logger=new fM("BasicHandler",3,e.id),i._peerConnection=t.getOriginRTCPeerConnection(),i._dataChannel=t.getOriginRTCDataChannel(),i.setLocalDescription=t.setLocalDescription.bind(t),i.setRemoteDescription=t.setRemoteDescription.bind(t),i._context=e,i.peer.on("ontrack",(function(e){i.emit("ontrack",e)})),i}return jl(n,[{key:"destroy",value:function(){this.logger.info("destroy",this.peerConnectionId||""),NI(DI(n.prototype),"removeAllListeners",this).call(this)}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"getConnectionState",value:function(){return this._peerConnection.connectionState}},{key:"_simulcast",value:function(e,t,r,n,i){var o,a,s,c=[];1===e.videoEncodeConfig.length?(c=function(e,t){var r=[];if(t<=1)return r;var n=Math.min(e.width,e.height)/90;return r.push({scaleResolutionDownBy:n,width:Math.floor(e.width/n),height:Math.floor(e.height/n),maxkbps:100,frameRate:10}),t<=2||r.unshift({scaleResolutionDownBy:2,width:Math.floor(e.width/2),height:Math.floor(e.height/2),maxkbps:Math.floor(e.maxKbps/2),frameRate:e.frameRate>=30?Math.floor(e.frameRate/2):e.frameRate}),r}(t,i),this.logger.info("simulcast() ","simulcastLayers: %o",c)):(c=Km(o=Am(a=Am(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){var r=ID(e.width),n=t.width/r;return{width:r,height:Math.floor(t.height/n),scaleResolutionDownBy:n,frameRate:ID(e.frameRate)||15,maxkbps:e.maxKbps||600}})),this.logger.info("simulcast() ","simulcastLayers2: %o",c));var u=[!0];c.forEach((function(e,t){var i,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:e.scaleResolutionDownBy,rid:"".concat(t+1),maxFramerate:e.frameRate};null===(i=r.sendEncodings)||void 0===i||i.unshift(o),n.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)}),u.push(!0)})),this._context&&(this._context.activeSimStreams=u)}},{key:"internalPublish",value:function(e){var t=e.stream,r=e.videoTrack,n=e.audioTrack,i=e.enableSimulcast,o=e.pubAudio,a=e.pubVideo,s={direction:"sendonly",streams:[t]},c={direction:"sendonly",streams:[t]},u=[],d=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var l=null==r?void 0:r.getTrack(),h=el({},AN);if(l){var p=null==l?void 0:l.getSettings();h={width:Math.floor(p.width),height:Math.floor(p.height),frameRate:Math.floor(p.frameRate)}}"number"!=typeof h.frameRate&&(h.frameRate=30);var v=null==e?void 0:e.videoEncodeConfig[0],f={maxBitrate:1e3*v.maxKbps,rid:"0"};if(e.prevBitrate=v.maxKbps,c.sendEncodings=[f],u.push({width:h.width,height:h.height,framerate:h.frameRate,maxkbps:v.maxKbps,rid:"0"}),!DD&&i){var _,m,g=function(e){for(var t=0,r=e.width*e.height,n=0;n<hL.length;n++)if(r>=hL[n].totalPixels){t=n;break}if(0===t)return hL[t].maxLayers;var i=hL[t-1].totalPixels;return(i-r)/(i-hL[t].totalPixels)<.1?hL[t-1].maxLayers:hL[t].maxLayers}(h);if(this.logger.info("simulcast() ","maxLayers: %o",g),g>1)this._simulcast(e,el(el({},h),{},{maxKbps:v.maxKbps}),c,u,g),null!==(_=this._context)&&void 0!==_&&null!==(m=_.serverConfig)&&void 0!==m&&m.simulcastOnDemand&&(d=Km(u).call(u,(function(e,t){return el(el({},e),{},{video_index:t,sub_index:t})})))}}this.logger.info("publish videoTransceiverInit videoDescriptions","",c,u);var y=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==Ll.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(y=null==n?void 0:n.mixedAudioTrack),y=o&&y?y:"audio";var S=null==r?void 0:r.getTrack("preprocessing");S=a&&S?S:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",Fm({aTrack:Ew(y),vTrack:Ew(S),audioTransceiverInit:s,videoTransceiverInit:c}))}catch(BY){}return{semantics:"unified-plan",videoDescriptions:u,subVideoDescriptions:d,audioTransceiverInit:{track:y,init:s},videoTransceiverInit:{track:S,init:c}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;this.logger.info("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.getTrack(),a=e.videoTransceiver;if(o&&e.pubVideo&&a){var s=null===(r=e.videoEncodeConfig)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.maxKbps;if(s){if(s===e.prevBitrate)return void 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:Km(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",Fm(c.encodings))}catch(BY){}}}else this.logger.warn("updateMaxBitrate()","no pub")}},{key:"getStats",value:function(e,t){return hV(this._peerConnection,e,t)}},{key:"setCurrentDescription",value:(t=xm(wm().mark((function e(){return wm().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;fV.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:kE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:kE(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&&bk(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))}))}},{key:"pc",get:function(){return this._peerConnection}},{key:"peerConnectionId",get:function(){return this.peer.getConnectionId()||""}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n,i=r.codec,o=r.payload;if(bk(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=kE(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=Nm(s=[]).call(s,eT(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,el(el({},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}(JN.EventEmitter),nF=function(e){UI(p,e);var t,r,n,i,o,a,s,c,u,d,l,h=eR(p);function p(){var e,t,r;return Hl(this,p),Zd(sI(r=h.call(this)),"inited",!1),Zd(sI(r),"deviceMap",{audioinput:new ib,audiooutput:new ib,videoinput:new ib}),Zd(sI(r),"checkDeviceChangeTimer",null),Zd(sI(r),"isSupportedPermissionsQuery",!1),Zd(sI(r),"isGrantedMicrophonePermission",!1),Zd(sI(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!xD()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(sI(r)),!xD()&&r.refreshDevices(),r}return jl(p,[{key:"refreshDevices",value:(l=xm(wm().mark((function e(){var t,r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices){e.next=2;break}return e.abrupt("return");case 2:if(t=void 0,!DD){e.next=12;break}return e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:!0});case 7:t=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:return e.next=14,navigator.mediaDevices.enumerateDevices();case 14:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),r.forEach((function(e){var t;e.deviceId&&(null===(t=n.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))})),this.inited||this.initListener(),this.inited=!0;case 19:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return l.apply(this,arguments)})},{key:"initListener",value:(d=xm(wm().mark((function e(){var t,r,n,i,o=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.ondevicechange)&&"function"==typeof(null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)?navigator.mediaDevices.addEventListener("devicechange",(function(){o._handleDeviceChange(),setTimeout((function(){o._handleDeviceChange()}),300)})):this.checkDeviceChangeTimer=window.setInterval((function(){o._handleDeviceChange()}),3e3),!this.isSupportedPermissionsQuery){e.next=22;break}return e.prev=2,e.next=5,navigator.permissions.query({name:"microphone"});case 5:n=e.sent,this.isGrantedMicrophonePermission="granted"===n.state,n.addEventListener("change",(function(){o.isGrantedMicrophonePermission="granted"===n.state})),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.prev=12,e.next=15,navigator.permissions.query({name:"camera"});case 15:i=e.sent,this.isGrantedCameraPermission="granted"===i.state,i.addEventListener("change",(function(){o.isGrantedCameraPermission="granted"===i.state})),e.next=22;break;case 20:e.prev=20,e.t1=e.catch(12);case 22:case"end":return e.stop()}}),e,this,[[2,10],[12,20]])}))),function(){return d.apply(this,arguments)})},{key:"_handleDeviceChange",value:(u=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=void 0,!DD){e.next=5;break}return e.next=4,navigator.mediaDevices.getUserMedia({audio:!0});case 4:o=e.sent;case 5:return e.next=7,navigator.mediaDevices.enumerateDevices();case 7:a=e.sent,a=Ks(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=Zk(Nm(t=[]).call(t,eT(cR(r=this.deviceMap.audioinput).call(r)),eT(cR(n=this.deviceMap.videoinput).call(n)),eT(cR(i=this.deviceMap.audiooutput).call(i)))),(XD||GD)&&!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||(bk(t=e.kind).call(t,"video")?c.emit(Fl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):bk(r=e.kind).call(r,"audio")&&c.emit(Fl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;kE(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),bk(t=e.kind).call(t,"video")?c.emit(Fl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):bk(r=e.kind).call(r,"audio")&&c.emit(Fl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 14:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getUserMedia",value:(c=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia(t);case 2:return r=e.sent,null!=t&&t.audio&&(this.isGrantedMicrophonePermission=!0),null!=t&&t.video&&(this.isGrantedCameraPermission=!0),this.refreshDevices(),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(s=xm(wm().mark((function e(){var t,r;return wm().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=Ks(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=Ks(r).call(r,(function(e){return"videoinput"===e.kind&&e.label&&e.deviceId})).length>0,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"getPermissions",value:(a=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l=arguments;return wm().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:return e.next=72,this.refreshDevices();case 72:return e.abrupt("return",a);case 73:case"end":return e.stop()}}),e,this,[[31,38]])}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=xm(wm().mark((function e(){var t,r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions();case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Zk(Nm(t=[]).call(t,eT(cR(r=this.deviceMap.audioinput).call(r)),eT(cR(n=this.deviceMap.videoinput).call(n)),eT(cR(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=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Zk(cR(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=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({video:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Zk(cR(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=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",Zk(cR(t=this.deviceMap.audiooutput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getDeviceById",value:(t=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateDevices();case 2:return r=e.sent,e.abrupt("return",kE(r).call(r,(function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),p}($N),iF=new nF;!xD()&&(window.__rtc_dd__=iF);var oF=new fM("InternalEventBus",1),aF=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}(aF||{}),sF=function(e){UI(r,e);var t=eR(r);function r(){return Hl(this,r),t.apply(this,arguments)}return jl(r,[{key:"emit",value:function(e){var t,n;oF.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=NI(DI(r.prototype),"emit",this)).call.apply(t,Nm(n=[this,e]).call(n,o))}}]),r}(JN.EventEmitter),cF=new sF,uF=new fM("AudioContext",1),dF=function(){function e(){var t=this;Hl(this,e),Zd(this,"_audioContextInstance",void 0),Zd(this,"_previousState",""),Zd(this,"_currentState",""),Zd(this,"_contextStuckAt",0);var r=0;xD()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,uF.info("currentTime resume"),XP("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,uF.warn("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),XP("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return jl(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;uF.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(),(WD||GD)&&("running"===e._previousState&&"interrupted"===e._currentState&&cF.emit(aF.ON_IOS_INTERRUPTION_START),"interrupted"===e._previousState&&"running"===e._currentState&&cF.emit(aF.ON_IOS_INTERRUPTION_END))}}return this._audioContextInstance}}]),e}(),lF=function(){function e(t){Hl(this,e),Zd(this,"_ctx",void 0),Zd(this,"_analyserNode",void 0),Zd(this,"_audioSource",void 0),Zd(this,"currentTrackId",void 0),this.currentTrackId=t.id;var r=hF.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 jl(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=xm(wm().mark((function e(){var t;return wm().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}(),hF=new dF,pF=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}(pF||{}),vF=function(){function e(t){Hl(this,e),Zd(this,"_plugins",new ib),this.id=t}var t;return jl(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(eA(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 kE(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=xm(wm().mark((function e(t){var r,n,i,o,a;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.getTrack(),i=oI(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}(),fF=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(fF||{}),_F=new fM("VERTC",0),mF=function(e){UI(r,e);var t=eR(r);function r(e,n){var i;return Hl(this,r),Zd(sI(i=t.call(this)),"sourceType",1),Zd(sI(i),"mediaType",void 0),Zd(sI(i),"_trackId",void 0),Zd(sI(i),"_ac",void 0),Zd(sI(i),"_sourceNode",void 0),Zd(sI(i),"_gainNode",void 0),Zd(sI(i),"_destNode",void 0),Zd(sI(i),"_channelCount",void 0),i._trackId=e,i.mediaType=n,"audio"===n&&nV()&&!kN("SKIP_WEB_AUDIO_IN_TRACK")&&(i._ac=hF.getAudioContextInstance(),i._gainNode=i._ac.createGain(),i._destNode=i._ac.createMediaStreamDestination(),i._gainNode.connect(i._destNode)),i}return jl(r,[{key:"getId",value:function(){return this._trackId}},{key:"setVolume",value:function(e){this._gainNode&&(this._gainNode.gain.value=e/100)}},{key:"getVolume",value:function(){return this._gainNode?Math.round(100*this._gainNode.gain.value):-1}},{key:"channelCount",get:function(){var e;return null!==(e=this._channelCount)&&void 0!==e?e:0}},{key:"connectAudioTrack",value:function(e){var t;if(this._channelCount=e.getSettings().channelCount,!nV()||kN("SKIP_WEB_AUDIO_IN_TRACK"))return e;this._sourceNode&&(this._sourceNode.mediaStream.getTracks().forEach((function(e){e.stop()})),delete this._sourceNode);var r,n=new MediaStream;(n.addTrack(e),this._sourceNode=null===(t=this._ac)||void 0===t?void 0:t.createMediaStreamSource(n),this._gainNode)&&(null===(r=this._sourceNode)||void 0===r||r.connect(this._gainNode));return this._destNode.stream.getTracks()[0]}},{key:"destroy",value:function(){var e,t,r,n;(null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),13!==eN)&&(null===(n=this._destNode)||void 0===n||n.stream.getTracks().forEach((function(e){e.stop()})));null===(t=this._sourceNode)||void 0===t||t.disconnect(),null===(r=this._gainNode)||void 0===r||r.disconnect(),delete this._sourceNode,delete this._gainNode,delete this._destNode}}]),r}($N),gF=function(e){UI(n,e);var t,r=eR(n);function n(e,t,i){var o;return Hl(this,n),Zd(sI(o=r.call(this,t,i)),"_mediaTrack",void 0),Zd(sI(o),"_preProcessingTrack",void 0),Zd(sI(o),"_originTrack",void 0),Zd(sI(o),"captureSessionId",""),Zd(sI(o),"handleTrackEnded",(function(){o.emit("track-ended",sI(o)),o.close()})),Zd(sI(o),"handleMute",(function(){o.emit("track-mute",sI(o))})),Zd(sI(o),"handleUnmute",(function(){o.emit("track-unmute",sI(o))})),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o._initListeners(),o}return jl(n,[{key:"getTrack",value:function(){return"origin"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"origin")?this._mediaTrack:this._preProcessingTrack||this._mediaTrack}},{key:"setTrack",value:function(e,t){this._mediaTrack="audio"===this.mediaType?this.connectAudioTrack(e):e,this._originTrack=e,t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._preProcessingTrack=void 0,e.prev=1,e.next=4,t.getPreProcessingTrack(this);case 4:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e){return t.apply(this,arguments)})},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){var e;return this._mediaTrack.onended=null,this._mediaTrack.onmute=null,this._mediaTrack.onunmute=null,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(),"audio"===this.mediaType?this.destroy():this._mediaTrack.stop()}},{key:"_initListeners",value:function(){this._originTrack instanceof MediaStreamTrack&&(this._originTrack.addEventListener("ended",this.handleTrackEnded),this._originTrack.addEventListener("mute",this.handleMute),this._originTrack.addEventListener("unmute",this.handleUnmute))}}]),n}(mF),yF=function(e){UI(r,e);var t=eR(r);function r(e,n,i){var o;return Hl(this,r),Zd(sI(o=t.call(this,n,i)),"_mediaTrack",void 0),Zd(sI(o),"_originTrack",void 0),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o}return jl(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){return this.destroy()}}]),r}(mF),SF=function(e){UI(n,e);var t,r=eR(n);function n(e,t){var i;return Hl(this,n),Zd(sI(i=r.call(this,e,t,"video")),"resolution",void 0),Zd(sI(i),"dummy",!1),i.resolution={width:0,height:0},i}return jl(n,[{key:"updateVideoCaptureConfig",value:(t=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return _F.info("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=el({},t)).contentHint,DD&&this.streamIndex===dl.STREAM_INDEX_MAIN&&(r.frameRate={ideal:30,max:30}),e.next=8,this.getTrack().applyConstraints(r);case 8:((n=this.getTrack().getSettings()).width&&n.width!==this.resolution.width||n.height&&n.height!==this.resolution.height)&&(this.resolution={width:n.width,height:n.height},this.emit("resolution-change",this.resolution));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){var t;this._mediaTrack&&"contentHint"in this._mediaTrack&&bk(t=["text","motion","detail"]).call(t,e)&&(this._mediaTrack.contentHint=e)}}]),n}(gF),bF=function(e){UI(n,e);var t,r=eR(n);function n(e,t){var i;return Hl(this,n),Zd(sI(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),Zd(sI(i),"mixedAudioTrack",void 0),Zd(sI(i),"mixType",Ll.PLAYOUT_AND_PUBLISH),Zd(sI(i),"_audioFetchMap",new ib),i}return jl(n,[{key:"getAudioLevel",value:function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_l.MICROPHONE,n=r===_l.AUDIOMIXING&&this.mixType!==Ll.PLAYOUT&&null!==(e=this.mixedAudioTrack)&&void 0!==e?e:this.getTrack("preprocessing"),i=this._audioFetchMap.get(r);i&&i.currentTrackId===n.id||(null===(t=i)||void 0===t||t.destroy(),i=new lF(n),this._audioFetchMap.set(r,i));return i.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=xm(wm().mark((function e(){return wm().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 _F.info("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,this.getOrgTrack().applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){this._audioFetchMap.forEach((function(e){return e.destroy()})),this._audioFetchMap.clear(),NI(DI(n.prototype),"close",this).call(this)}}]),n}(gF),EF=function(e){UI(r,e);var t=eR(r);function r(e,n){return Hl(this,r),t.call(this,e,n,"video")}return jl(r)}(yF),kF=function(e){UI(r,e);var t=eR(r);function r(e,n){var i;return Hl(this,r),Zd(sI(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return jl(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new lF(this.getOrgTrack())),this._audioLevelFetcher.getAudioLevel()}},{key:"close",value:function(){var e;null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),NI(DI(r.prototype),"close",this).call(this)}}]),r}(yF),TF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Nm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_MAIN),n}return jl(r)}(bF),IF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Nm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_MAIN),n}return jl(r)}(SF),RF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Nm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_MAIN),Zd(sI(n),"sourceType",0),n}return jl(r)}(SF),AF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Nm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_MAIN),Zd(sI(n),"sourceType",0),n}return jl(r)}(bF),wF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Nm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_SCREEN),n}return jl(r)}(SF),CF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Nm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_SCREEN),n}return jl(r)}(bF),xF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Nm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_SCREEN),Zd(sI(n),"sourceType",0),n}return jl(r)}(SF),OF=function(e){UI(r,e);var t=eR(r);function r(){var e,n;Hl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Zd(sI(n=t.call.apply(t,Nm(e=[this]).call(e,o))),"streamIndex",dl.STREAM_INDEX_SCREEN),Zd(sI(n),"sourceType",0),n}return jl(r)}(bF);function PF(e,t){return MF.apply(this,arguments)}function MF(){return(MF=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new IF(t,eD())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function DF(e,t){return NF.apply(this,arguments)}function NF(){return(NF=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new wF(t,eD())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function LF(e,t){return UF.apply(this,arguments)}function UF(){return(UF=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return wm().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=qP(r.id),s=eD(),e.prev=3,_F.info("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o,capture_session_id:s}),u=tD(),DD&&(t.frameRate={ideal:30,max:30}),e.next=10,iF.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:tD()-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 SA(_A.GET_VIDEO_TRACK_FAILED,Nm(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 IF(l,eD())).captureSessionId=s,e.next=23,h.generatePreProcessingTrack(r);case 23:return e.abrupt("return",h);case 24:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function VF(e,t){return FF.apply(this,arguments)}function FF(){return(FF=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _F.info("createMicrophoneAudioTrack","constraints:",t),o=(null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=qP(r.id),s=eD(),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=tD(),(d=r.getPluginByName(pF.PRE_PROCESSING,"RTCAIAnsExtension"))&&(d.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=11,iF.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:tD()-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 SA(_A.GET_AUDIO_TRACK_FAILED,Nm(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 TF(h,eD())).captureSessionId=s,e.next=24,p.generatePreProcessingTrack(r);case 24:return e.abrupt("return",p);case 25:case"end":return e.stop()}}),e,null,[[4,15]])})))).apply(this,arguments)}function BF(e,t,r){return jF.apply(this,arguments)}function jF(){return(jF=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _F.print("createCameraAndMicrophoneTrack","audioConstraints:",t,"videoConstraints:",r),a=qP(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=eD(),l=eD(),eD(),eD(),e.prev=8,null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:u,capture_session_id:d}),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_begin",media_device_id:c,event_session_id:l}),v=tD(),DD&&(r.frameRate={ideal:30,max:30}),(f=n.getPluginByName(pF.PRE_PROCESSING,"RTCAIAnsExtension"))&&(f.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=17,iF.getUserMedia({audio:t,video:r});case 17:s=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:u,media_device_name:(null===(h=s.getVideoTracks()[0])||void 0===h?void 0:h.label)||"",reason:"success",elapse:tD()-v,capture_session_id:d}),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_result",media_device_id:c,media_device_name:(null===(p=s.getAudioTracks()[0])||void 0===p?void 0:p.label)||"",reason:"success",elapse:tD()-v,event_session_id:l}),e.next=27;break;case 22:throw e.prev=22,e.t0=e.catch(8),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:u,error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:d}),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_end",media_device_id:c,error_code:e.t0.code,reason:e.t0.name+e.t0.message,event_session_id:l}),new SA(_A.GET_VIDEO_TRACK_FAILED,Nm(_="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(_,e.t0.message||"unknown message","."),e.t0);case 27:return m=s.getVideoTracks()[0],(g=new IF(m,eD())).captureSessionId=d,e.next=32,g.generatePreProcessingTrack(n);case 32:return y=s.getAudioTracks()[0],(S=new TF(y,eD())).captureSessionId=l,e.next=37,S.generatePreProcessingTrack(n);case 37:return e.abrupt("return",{videoTrack:g,audioTrack:S});case 38:case"end":return e.stop()}}),e,null,[[8,22]])})))).apply(this,arguments)}function HF(){return GF.apply(this,arguments)}function GF(){return GF=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=f.length>0&&void 0!==f[0]&&f[0],r=f.length>1?f[1]:void 0,n=f.length>2?f[2]:void 0,_F.info("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=qP(r.id),a=eD(),e.prev=6,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen",capture_session_id:a}),d=tD(),e.next=11,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!ND||"16.1"!==rN))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!0,autoGainControl:!1}});case 11:i=e.sent,null==o||o.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",media_device_name:Nm(s="".concat((null===(c=i.getVideoTracks()[0])||void 0===c?void 0:c.label)||"",", ")).call(s,(null===(u=i.getAudioTracks()[0])||void 0===u?void 0:u.label)||""),reason:"success",elapse:tD()-d,capture_session_id:a}),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(6),null==o||o.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:"screen",error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:a}),new SA(_A.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 19:return l=i.getVideoTracks()[0],(h=new wF(l,eD())).captureSessionId=a,e.next=24,h.generatePreProcessingTrack(r);case 24:if(!(p=i.getAudioTracks()[0])){e.next=30;break}return v=new CF(p,eD()),e.next=29,v.generatePreProcessingTrack(r);case 29:return e.abrupt("return",[h,v]);case 30:return e.abrupt("return",[h,void 0]);case 31:case"end":return e.stop()}}),e,null,[[6,15]])}))),GF.apply(this,arguments)}function zF(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:eD();return new kF(e,t)}function KF(e,t){return XF.apply(this,arguments)}function XF(){return(XF=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new RF(t,eD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function WF(e,t){return qF.apply(this,arguments)}function qF(){return(qF=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new AF(t,eD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function YF(e,t){return JF.apply(this,arguments)}function JF(){return(JF=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new xF(t,eD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function QF(e,t){return ZF.apply(this,arguments)}function ZF(){return(ZF=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new OF(t,eD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var $F=bF,eB=kF,tB=function(e){return e[e.NONE=0]="NONE",e}(tB||{}),rB={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)?rB.getAnnexbNals(e):rB.getAvccNals(e)},getAnnexbNals:function(e){for(var t=[],r=rB.getHeaderPositionAnnexB(e),n=r.pos,i=n;n<e.length-4;){var o,a,s=new Uint8Array(Am(o=e.buffer).call(o,n,n+r.headerLength));r.pos===e.position&&e.skip(r.headerLength),i=(r=rB.getHeaderPositionAnnexB(e)).pos;var c={header:s,body:new Uint8Array(Am(a=e.buffer).call(a,n+s.byteLength,i)),type:-1};rB.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(Am(n=e.buffer).call(n,e.position,e.position+4));e.skip(4);var a=new Uint8Array(Am(i=e.buffer).call(i,e.position,e.position+r));e.skip(r);var s={header:o,body:a,type:-1};rB.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}}},nB=function(){function e(t){Hl(this,e),Zd(this,"_position",0),Zd(this,"_dataview",void 0),this._dataview=new DataView(t)}return jl(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}(),iB=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(iB||{}),oB=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),aB=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]);function sB(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function cB(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 uB=function(){function e(){Hl(this,e)}return jl(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?oB:aB,s=sB(e.byteLength+a.byteLength),c=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]&&t.push(3),t.push(e[r]);return new Uint8Array(t)}(e);return new Uint8Array(Nm(t=[]).call(t,eT(n),eT(i),eT(o),eT(s),eT(a),eT(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=Am(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=aI(cB(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=aB.byteLength&&i>=aB.byteLength&&Am(t).call(t,r,r+aB.byteLength).toString()===aB.toString()?(r+=aB.byteLength,o=1):t.byteLength>=aB.byteLength&&i>=aB.byteLength&&Am(t).call(t,r,r+oB.byteLength).toString()===oB.toString()&&(r+=oB.byteLength,o=0),{type:o,payload:Am(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new ib,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=aI(cB(e.payload,r),2),i=n[0];r=n[1];var o,a=aI(cB(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,Am(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=oI(e);try{for(n.s();!(t=n.n()).done;){var i=aI(t.value,2),o=i[0],a=i[1],s=sB(o),c=sB(a.byteLength);r.push(s,c,a)}}catch(l){n.e(l)}finally{n.f()}var u=gb(r).call(r,(function(e,t){return e+t.byteLength}),0),d=new Uint8Array(u);return gb(r).call(r,(function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),dB=function(){function e(t){Hl(this,e),Zd(this,"player",void 0),Zd(this,"_timer",void 0),Zd(this,"handler",void 0),Zd(this,"_monitor",void 0),Zd(this,"logger",void 0),Zd(this,"_destroyed",!1),this._context=t,this._monitor=qP(t.id),this.logger=new fM("Stats",3,t.id)}return jl(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,$P(this._context.id,"del_media_statistics_timer",Nm(t="reason: ".concat(e,", stack: ")).call(t,(new Error).stack),0,this._stream.streamId||""))}},{key:"filterIllegal",value:function(e){var t={};return cn(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"),$P(this._context.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.stopReport("destroy"),this._destroyed=!0}}]),e}(),lB=function(e){UI(i,e);var t,r,n=eR(i);function i(e,t){var r;return Hl(this,i),(r=n.call(this,e))._stream=t,r}return jl(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.getTrack("preprocessing"),u=null===(n=s.videoTrack)||void 0===n?void 0:n.getTrack("preprocessing");this.getAudioStats(c,a,null===(i=s.audioTrack)||void 0===i?void 0:i.getAudioLevel()),this.getVideoStats(u,a);var d=function(){var e=xm(wm().mark((function e(){var t,r,n,i,c,u,d;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=s.audioTrack)||void 0===t?void 0:t.getTrack("preprocessing"),c=null===(r=s.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,o.getAudioStats(i,a,null===(n=s.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return u=e.sent,e.next=7,o.getVideoStats(c,a);case 7:return d=e.sent,e.abrupt("return",{audioStats:u,videoStats:d,isScreen:s.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),l=function(){var t=xm(wm().mark((function t(){var r;return wm().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=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,g;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s={},c={timestamp:Date.now()},u=this._stream,d=u.streamId,l=u.audioMid,h=u.isScreen,p=u.pubAttributes,v=u.pubAudio,f=u.audioTrack,_={media_type:"audio",is_screen:!!h,direction:"up",stream_id:d,vid:l,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:p.localaudio?"capture_state_on":"capture_state_off",mute_state:v?"mute_state_off":"mute_state_on"},f&&(_.playback_volume=f.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",s);case 7:return e.next=9,this.handler.getStats(t);case 9:if((m=e.sent).length){e.next=12;break}return e.abrupt("return",s);case 12:if(m.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,o=e.clockRate,a=e.roundTripTime,u=e.channels,d=e.audioLevel;e.googRtt;var l=e.mimeType,h=e.availableIncomingBitrate,p=e.availableOutgoingBitrate,v=e.bytesReceived,f=e.nominated,m=e.id,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,M=e.nackCount,D=e.retransmittedBytesSent,N=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(c.packetsSent=r,c.bytesSent=i,_.bytes=i,_.packetsSent=r,_.nackCount=M,_.ssrc=U,_.retransmitted_bytes_sent=D,_.retransmitted_packets_sent=N,c.retransmittedBytesSent=D,c.retransmittedPacketsSent=N):"remote-inbound-rtp"===t?(c.packetsLost=n,_.packetsLost=n,_.net_jitter=1e3*R,s.rtt=1e3*a,_.rtt=s.rtt,s._fractionLost=j||0):"codec"===t?(s.recordSampleRate=o,s.numChannels=u,_.codecName=l):"media-source"===t&&void 0!==d?(_.audio_level=d?-10*rw(Math.pow(d,2)):d,_.volume=255*d,_.total_audio_energy=V,_.totalInputDuration=F):"ssrc"===t&&"audio"===B?_.send_level=L:"candidate-pair"===t?(_.ice_available_incoming_bitrate=h,_.ice_available_outgoing_bitrate=p,_.ice_bytes_received=v,_.ice_bytes_sent=i,_.ice_nominated=Number(f),_.ice_pair_id=m,_.ice_pair_rtt=g,_.ice_pair_state=y,_.ice_pair_writable=S,_.recv_ping_requests=b,_.recv_ping_responses=E,_.sent_ping_requests_before_first_response=k,_.sent_ping_requests_total=k+(T||0),_.sent_ping_responses=I):"local-candidate"===t?(_.local_candidate_type=A,_.local_ip=w||C,_.local_network_type=x,_.local_port=O,_.protocol=P):"remote-candidate"===t&&(_.remote_candidate_type=A,_.remote_ip=w||C,_.remote_port=O);var H=kN("STATS_SCALLBACK_SUPPORT");iV&&H||"media-source"===t&&(_.send_level=d)})),void 0===_.volume&&void 0!==n&&(_.volume=n,_.audio_level=n?-10*rw(Math.pow(n/255,2)):n),(g=r.audio).timestamp){e.next=18;break}return r.audio=c,e.abrupt("return",this.filterIllegal(s));case 18:return void 0!==c.packetsLost&&(s.audioLossRate=(c.packetsLost-g.packetsLost)/(c.packetsSent-g.packetsSent),s.audioLossRate=Number.isNaN(s.audioLossRate)?0:s.audioLossRate,_.fraction_lost=s.audioLossRate),s.statsInterval=c.timestamp-g.timestamp,_.stats_interval=s.statsInterval,s.sendKBitrate=(c.bytesSent-g.bytesSent||0)/s.statsInterval*8,_.mediaBitratebps=Math.round(1e3*s.sendKBitrate),_.bandwidth=Math.round(_.mediaBitratebps/1024),void 0!==c.retransmittedBytesSent&&(_.retransmitBitratebps=(c.retransmittedBytesSent-g.retransmittedBytesSent||0)/s.statsInterval),r.audio=c,_.vendor_mode=(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,_.pc_session_id=null===(o=this.handler)||void 0===o?void 0:o.peerConnectionId,null===(a=this._monitor)||void 0===a||a.report("rtc_media_statistics",_),s._retransmittedRate=(c.retransmittedPacketsSent-g.retransmittedPacketsSent)/(c.packetsSent-g.packetsSent),void 0===s.audioLossRate&&(s.audioLossRate=s._retransmittedRate,_.fraction_lost=s.audioLossRate),s._fractionLost=Math.max(s._fractionLost,s.audioLossRate),e.abrupt("return",this.filterIllegal(s));case 33:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},i={timestamp:Date.now(),simulcast:{}},o=this._stream,a=o.streamId,s=o.videoMid,c=o.isScreen,u=o.pubAttributes,d=o.enableSimulcast,l=o.pubVideo,e.t0=el,e.t1={media_type:"video",is_screen:!!c,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:u.localvideo?"capture_state_on":"capture_state_off",mute_state:l?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,h=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",n);case 11:return h.cap_frame_width=t.getSettings().width,h.cap_frame_height=t.getSettings().height,h.frameRateSent=t.getSettings().frameRate,n.isScreen=c,e.next=17,this.handler.getStats(t);case 17:if((p=e.sent).length){e.next=20;break}return e.abrupt("return",n);case 20:if(v=0,p.forEach((function(e){var t=e.type,o=e.framesEncoded,a=e.packetsLost,s=e.bytesSent,c=e.framesSent,u=e.retransmittedBytesSent,l=e.totalPacketSendDelay,p=e.totalEncodeTime,f=e.firCount,_=e.targetBitrate,m=e.roundTripTime,g=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,M=e.id,D=e.currentRoundTripTime,N=e.state,L=e.writable,U=e.candidateType,V=e.ip,F=e.address,B=e.networkType,j=e.port,H=e.nackCount,G=e.pliCount,z=e.protocol,K=e.qpSum,X=e.requestsReceived,W=e.responsesReceived,q=e.googRetransmitBitrate,Y=e.requestsSent,J=e.consentRequestsSent,Q=e.responsesSent,Z=e.ssrc,$=e.googTargetEncBitrate,ee=e.googTransmitBitrate,te=e.retransmittedPacketsSent,re=e.encoderImplementation,ne=e.jitter,ie=e.rid,oe=e.fractionLost,ae=e.googAdaptationChanges,se=e.qualityLimitationReason,ce=e.qualityLimitationDurations,ue=e.googFirsReceived,de=e.googFrameRateSent,le=e.keyFramesEncoded,he=e.scalabilityMode,pe=e.framesPerSecond,ve=e.frames;"outbound-rtp"===t?(d&&(ie?i.simulcast[ie]=e:i.simulcast[v]=e,v++),i.framesEncoded=o||i.framesEncoded||0,h.key_frames_encoded=le||0,i.bytesSent=s||i.bytesSent||0,i.framesSent=c||i.framesSent,h.bytes=s||h.bytes||0,i.packetsSent=b||i.packetsSent||0,h.packetsSent=b||h.packetsSent||0,h.nackCount=H||h.nackCount||0,h.pli_count=G||h.pli_count||0,h.qp_sum=K||h.qp_sum||0,h.ssrc=Z||h.ssrc||0,h.retransmitted_packets_sent=te,i.retransmittedPacketsSent=te,i.retransmittedBytesSent=u,h.encoder_implementation=re,h.qualityLimitationReason=se,h.qualityLimitationDurations=ce,h.scalabilityMode=he,void 0!==y&&((!n.encodedFrameWidth||y>n.encodedFrameWidth)&&(n.encodedFrameWidth=y),(!n.encodedFrameHeight||S>n.encodedFrameHeight)&&(n.encodedFrameHeight=S),h.frame_size_height=S,h.frame_size_width=y)):"track"===t?(n.encodedFrameWidth=y,n.encodedFrameHeight=S,h.frame_size_height=S,h.frame_size_width=y):"remote-inbound-rtp"===t?(i.packetsLost=a,n.rtt=1e3*m,h.rtt=n.rtt,h.jitter=1e3*ne,h.packetsLost=a,n._fractionLost=oe||0):"codec"===t?(n.codecType=g,h.codecName=g):"candidate-pair"===t?(h.ice_available_incoming_bitrate=C,h.ice_available_outgoing_bitrate=x,h.ice_bytes_received=O,h.ice_bytes_sent=s,h.ice_nominated=Number(P),h.ice_pair_id=M,h.ice_pair_rtt=D,h.ice_pair_state=N,h.ice_pair_writable=L,h.recv_ping_requests=X,h.recv_ping_responses=W,h.sent_ping_requests_before_first_response=Y,h.sent_ping_requests_total=Y+J,h.sent_ping_responses=Q):"local-candidate"===t?(h.local_candidate_type=U,h.local_ip=V||F,h.local_network_type=B,h.local_port=j,h.protocol=z):"remote-candidate"===t?(h.remote_candidate_type=U,h.remote_ip=V||F,h.remote_port=j):"VideoBwe"===t?(h.encBitratebps=E,h.available_receive_bandwidth=k,h.available_send_bandwidth=T,h.bucket_delay=R,h.retransmitBitratebps=q,h.targetEncBitratebps=$,h.transmit_bitrate=ee,n._sendBandWidth=Number(T)):"ssrc"===t&&(h.avg_encode_ms=I,h.encodeUsage=A,h.frame_rate_input=w,h.orignal_input_Framerate=Number(w),h.ddaptationChanges=ae,h.firsReceived=ue,h.frameRateSent=de);var fe=kN("STATS_SCALLBACK_SUPPORT");if(!iV||!fe){var _e=r.video,me=i.timestamp-_e.timestamp;if("outbound-rtp"===t){var ge=s-_e.bytesSent,ye=u-_e.retransmittedBytesSent;h.encBitratebps=Math.round(8e3*(ge-ye)/me),h.bucket_delay=l/b,h.retransmitBitratebps=Math.round(8e3*ye/me),h.targetEncBitratebps=_,h.transmit_bitrate=Math.round(1e3*(s-_e.bytesSent)*8/me),h.avg_encode_ms=1e3*p/o,h.firsReceived=f+G}else"candidate-pair"===t?(h.available_send_bandwidth=x,n._sendBandWidth=x):"media-source"===t&&(h.frame_rate_input=pe,h.orignal_input_Framerate=Number(pe),h.frame_input=ve)}})),(f=r.video).timestamp){e.next=26;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 26:return n.statsInterval=i.timestamp-f.timestamp,h.stats_interval=n.statsInterval,_=cn(i.simulcast),d?(h.sim_enc_width=[],h.sim_enc_height=[],h.sim_enc_bps=[],h.sim_enc_framerate=[],h.sim_enc_key_frames=[],h.sim_rids=[],h.sim_enc_bandwidth=[],h.sim_sent_framerate=[],h.sim_fraction_lost=[],h.sim_keyencoded=[],h.active_sim_streams=(null===(m=this._context)||void 0===m?void 0:m.activeSimStreams)||[],h.sim_retransmittedRate=[],b=!1,KR(_).call(_,(function(e,t){return Number(e)-Number(t)})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,p=t.qualityLimitationDurations,v=t.qualityLimitationResolutionChanges,_=t.retransmittedPacketsSent,m=t.pliCount,g=t.keyFramesEncoded;void 0!==l&&(h.sim_qualityLimitationReason||(h.sim_qualityLimitationReason=[],h.sim_qualityLimitationDurations=[],h.sim_qualityLimitationResolutionChanges=[]),h.sim_qualityLimitationReason.push(l),h.sim_qualityLimitationDurations.push(p),h.sim_qualityLimitationResolutionChanges.push(v));var y=f.simulcast[e];if(h.sim_enc_width.push(r||0),h.sim_enc_height.push(o||0),h.sim_enc_key_frames.push(g||0),y){var S=(a-y.bytesSent||0)/n.statsInterval;h.sim_enc_bps.push(Math.round(8e3*S)),h.sim_enc_bandwidth.push(Math.round(8e3*S/1024));var E=1e3*(s-y.framesEncoded)/n.statsInterval;h.sim_enc_framerate.push(Math.round(E)),h.sim_rids.push(e);var k=void 0!==c?c-y.framesSent:s-y.framesEncoded,T=1e3*k/n.statsInterval;h.sim_sent_framerate.push(Math.round(T));var I=(u-y.packetsLost)/(d-y.packetsSent);n._retransmittedRate=(_-y.retransmittedPacketsSent)/(d-y.packetsSent),I=Number.isNaN(I)?0:I,h.sim_fraction_lost.push(I),h.sim_keyencoded.push(m-y.pliCount>0),h.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!b&&(n.sentKBitrate=8*S,n.encoderOutputFrameRate=E,n.encodedFrameCount=k,n.sentFrameRate=T,n.videoLossRate=I,b=!0)}})),h.vendor_mode=(null===(g=this._stream)||void 0===g?void 0:g.vendorCode)||0,h.pc_session_id=null===(y=this.handler)||void 0===y?void 0:y.peerConnectionId,null===(S=this._monitor)||void 0===S||S.report("rtc_media_statistics",h)):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-f.framesSent:i.framesEncoded-f.framesEncoded,n.sentKBitrate=(i.bytesSent-f.bytesSent||0)/n.statsInterval*8,h.bitrate=Math.round(1e3*n.sentKBitrate),h.bandwidth=Math.round(h.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-f.framesEncoded)/n.statsInterval,h.frame_rate_encoded=Math.round(n.encoderOutputFrameRate),n.sentFrameRate=1e3*n.encodedFrameCount/n.statsInterval,h.frame_rate_sent=Math.round(n.sentFrameRate),n.videoLossRate=(i.packetsLost-f.packetsLost)/(i.packetsSent-f.packetsSent),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,h.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-f.retransmittedPacketsSent)/(i.packetsSent-f.packetsSent),h.vendor_mode=(null===(E=this._stream)||void 0===E?void 0:E.vendorCode)||0,h.pc_session_id=null===(k=this.handler)||void 0===k?void 0:k.peerConnectionId,null===(T=this._monitor)||void 0===T||T.report("rtc_media_statistics",h)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 33:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(dB),hB=function(e){UI(o,e);var t,r,n,i=eR(o);function o(e,t){var r;return Hl(this,o),Zd(sI(r=i.call(this,e)),"isPaused",void 0),Zd(sI(r),"pauseStart",void 0),Zd(sI(r),"pauseDuration",void 0),Zd(sI(r),"_audioStallCount",void 0),Zd(sI(r),"_setAudioStallCount",void 0),Zd(sI(r),"_audioStallTimer",void 0),Zd(sI(r),"_audioStallInterval",void 0),Zd(sI(r),"_audioStallRatio",void 0),Zd(sI(r),"_videoInWaiting",void 0),r._stream=t,r._videoInWaiting=!1,r.pauseDuration=0,r}return jl(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=xm(wm().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,p,v,f,_,m,g,y=this;return wm().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),this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,s={audio:{},video:{}},this._destroyed=!1,c=this._stream,u=null===(n=c.audioTrack)||void 0===n?void 0:n.getOrgTrack(),d=null===(i=c.videoTrack)||void 0===i?void 0:i.getTrack(),this.getRemoteVideoStats(d,s),e.next=14,this.getRemoteAudioStats(u,s,null===(a=this._stream.audioTrack)||void 0===a?void 0:a.getAudioLevel());case 14:this._stopAudioStallTimer(),l=0,h=0,v=[],f=0,_=tD(),this._setAudioStallCount=function(){if(bN.AUDIO_STALL&&y._audioStallInterval>0&&void 0!==s.audio.concealedSamples){var e=s.audio.concealedSamples,t=s.audio.totalSamplesReceived;_=tD();var r={isStall:!1,counted:!1,diff:0},n=.5*y._audioStallInterval;y._audioStallCount=xm(wm().mark((function i(){var o,a,s,u,d,p,m,g,S,b,E,k,T,I,R,A,w,C,x,O;return wm().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=c.hasAudio,s=c.subAudio,u=c.virtual,d=c.virtualOccupy,!c.removeTrack){i.next=4;break}return clearTimeout(y._audioStallTimer),i.abrupt("return");case 4:if(a&&s){i.next=10;break}return r.isStall=!1,r.counted=!1,v.push({reason:Nm(p="hasAudio: ".concat(a,", subAudio: ")).call(p,s)}),_=tD(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 10:if(!u||d){i.next=16;break}return r.isStall=!1,r.counted=!1,v.push({reason:Nm(m="virtual: ".concat(u,", virtualOccupy: ")).call(m,d)}),_=tD(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 16:return g=null===(o=c.audioTrack)||void 0===o?void 0:o.getOrgTrack(),S=Date.now(),i.next=20,y.handler.getStats(g,!0);case 20:if(b=i.sent,E=Date.now(),k=tD(),!((T=k-_)<n)){i.next=27;break}return v.push({diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:Nm(I="diff(".concat(T,") < minInterval(")).call(I,n,")")}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 27:if(R=b.length,A=kE(b).call(b,(function(e){return"inbound-rtp"===e.type}))){i.next=32;break}return v.push({diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:R?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 32:return w=A.concealedSamples,C=A.totalSamplesReceived,O=C-t,(x=w-e)>=0&&O>=0&&x>=y._audioStallRatio*O?(v.push({concealed:x,received:O,diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,is_stall:!0}),r.isStall?(r.counted?h+=T:(h=h+r.diff+T,l++),r.counted=!0):T>=200?(h+=T,l++,r.counted=!0):(r.counted=!1,r.diff=T),r.isStall=!0):(v.push({concealed:x,received:O,diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E}),r.isStall=!1,r.counted=!1),e=w,t=C,_=k,f++,i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 41:case"end":return i.stop()}}),i)}))),p=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!y._audioStallCount&&y._setAudioStallCount&&y._setAudioStallCount(),!y._audioStallCount){e.next=6;break}return e.next=4,y._audioStallCount();case 4:y._audioStallTimer&&clearTimeout(y._audioStallTimer),y._audioStallTimer=setTimeout(p,y._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y._audioStallTimer&&clearTimeout(y._audioStallTimer),y._audioStallTimer=setTimeout(p,y._audioStallInterval)}},this._setAudioStallCount(),m=function(){var e=xm(wm().mark((function e(){var t,r,n,i,o,a,u;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=c.audioTrack)||void 0===t?void 0:t.getOrgTrack(),o=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,y.getRemoteAudioStats(i,s,null===(n=y._stream.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return a=e.sent,l=0,h=0,v=[],f=0,e.next=11,y.getRemoteVideoStats(o,s);case 11:return u=e.sent,e.abrupt("return",{audioStats:a,videoStats:u,isScreen:c.isScreen,userId:c.userId,streamId:c.streamId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),g=function(){var e=xm(wm().mark((function e(){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m();case 2:r=e.sent,t(r),p&&(_=tD(),y._audioStallTimer&&clearTimeout(y._audioStallTimer),y._audioStallTimer=setTimeout(p,y._audioStallInterval)),y._timer&&clearTimeout(y._timer),y._destroyed||(y._timer=setTimeout(g,2e3));case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(g,2e3);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_stopAudioStallTimer",value:function(){clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){this.logger.info("unsubscribe","invoke"),NI(DI(o.prototype),"stopReport",this).call(this,"unsubscribe"),this._stopAudioStallTimer(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d={},l={},h=this._stream,p=h.streamId,v=h.userId,f=h.isScreen,_=h.audioMid,m=h.subMediaType,g=h._attributes,y=h.virtual,S=h.audioTrack,b={media_type:"audio",is_screen:!!f,direction:"down",stream_id:p,stream_user_id:v,vid:_,audio_mux:y,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:gD(m)?"mute_state_off":"mute_state_on",remote_user_capture_state:g.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:g.localaudio&&g.audiostream?"mute_state_off":"mute_state_on"},S&&(b.playback_volume=S.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",d);case 7:return e.next=9,this.handler.getStats(t);case 9:if((E=e.sent).length){e.next=12;break}return e.abrupt("return",d);case 12:if(E.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,o=e.bytesReceived,a=e.jitterBufferDelay,s=e.jitterBufferEmittedCount,c=e.clockRate,u=e.channels,h=e.totalSamplesReceived,v=e.concealedSamples,f=e.silentConcealedSamples,_=e.concealmentEvents,m=e.totalRoundTripTime,g=e.packetsDiscarded,y=e.state,S=e.currentRoundTripTime,E=e.audioLevel,k=e.totalAudioEnergy,T=e.totalSamplesDuration,I=e.mimeType,R=e.googDecodingNormal,A=e.googDecodingMuted,w=e.availableIncomingBitrate,C=e.availableOutgoingBitrate,O=e.bytesSent,P=e.nominated,M=e.id,D=e.writable,N=e.jitter,L=e.candidateType,U=e.ip,V=e.address,F=e.networkType,B=e.port,j=e.protocol,H=e.audioOutputLevel,G=e.requestsReceived,z=e.responsesReceived,K=e.requestsSent,X=e.consentRequestsSent,W=e.responsesSent,q=e.ssrc;e.kind;var Y=e.nackCount,J=e.lastPacketReceivedTimestamp,Q=e.concealmentevents,Z=e.fecPacketsReceived;if("inbound-rtp"===t)l.packetsLost=r,l.packetsReceived=i,b.packetsLost=r,b.packetsReceived=i,b.packetsDiscarded=g,b.nackCount=Y,b.lastPacketReceivedTimestamp=J,b.concealmentevents=Q,l.bytesReceived=o,void 0!==a&&(d.jitterBufferDelay=a/s*1e3,b.average_jitter_buffer_delay_ms=d.jitterBufferDelay),void 0!==h&&(l.totalSamplesReceived=h,d.concealedSamples=v,l.concealedSamples=v,l.silentConcealedSamples=f,b.concealedSamples=v,d.concealmentEvents=_,b.totalSamplesReceived=h),void 0!==Z&&(b.fec_packets_received=Z,l.fecPacketsReceived=Z),b.jitter=1e3*N,b.ssrc=q,void 0!==E&&0!==E?(b.audio_level=E?-10*rw(Math.pow(E,2)):E,b.volume=255*E):(b.volume=null!=n?n:255*E,b.audio_level=n?-10*rw(Math.pow(n/255,2)):n),void 0!==k&&(b.total_audio_energy=k),void 0!==T&&(b.totalAudioDuration=T);else if("codec"===t)d.recordSampleRate=c,u&&(d.numChannels=u),b.codecName=I;else if("candidate-pair"===t){var $,ee,te;b.ice_available_incoming_bitrate=w,b.ice_available_outgoing_bitrate=C,b.ice_bytes_received=o,b.ice_bytes_sent=O,b.ice_nominated=Number(P),b.ice_pair_id=M,b.ice_pair_rtt=S,b.rtt=1e3*S,b.rtt&&null!==($=x._context)&&void 0!==$&&null!==(ee=$.streamRTT)&&void 0!==ee&&null!==(te=ee[p])&&void 0!==te&&te.audio&&(b.total_rtt_ms=Math.round(b.rtt+x._context.streamRTT[p].audio)),b.ice_pair_state=y,b.ice_pair_writable=D,b.recv_ping_requests=G,b.recv_ping_responses=z,b.sent_ping_requests_before_first_response=K,b.sent_ping_requests_total=K+(X||0),b.sent_ping_responses=W,"succeeded"===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*rw(Math.pow(n/255,2)):n):(b.audio_level=E?-10*rw(Math.pow(E,2)):E,b.volume=255*E),b.total_audio_energy=k,b.totalAudioDuration=T):"ssrc"===t?(b.decodingNormal=R,b.recvAudioLevel=H,b.decodingMuted=A):"local-candidate"===t?(b.local_candidate_type=L,b.local_ip=U||V,b.local_network_type=F,b.local_port=B,b.protocol=j):"remote-candidate"===t&&(b.remote_candidate_type=L,b.remote_ip=U||V,b.remote_port=B)})),(k=r.audio).timestamp){e.next=18;break}return l.timestamp=Date.now(),r.audio=l,e.abrupt("return",this.filterIllegal(d));case 18:if(T={},void 0!==l.concealedSamples&&(b.interval_concealed_samples=l.concealedSamples-k.concealedSamples,b.interval_samples_received=l.totalSamplesReceived-k.totalSamplesReceived,b.interval_silent_concealed_samples=l.silentConcealedSamples-k.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==k.concealedSamples)){e.next=38;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=36;break}return e.next=26,this._audioStallCount();case 26:I=e.sent,R=I.stall_count,A=I.stall_duration,w=I.stall_list,C=I.stats_count,T.stall_list=w,T.stats_count=C,b.concealedSamples===b.interval_concealed_samples&&b.totalSamplesReceived===b.interval_samples_received?(b.stall_count=0,b.stall_duration=0):(b.stall_count=R,b.stall_duration=A),d.stallCount=b.stall_count,d.stallDuration=b.stall_duration;case 36:e.next=42;break;case 38:b.stall_count=0,b.stall_duration=0,d.stallCount=b.stall_count,d.stallDuration=b.stall_duration;case 42:return l.timestamp=Date.now(),d.audioLossRate=(l.packetsLost-k.packetsLost)/(l.packetsReceived-k.packetsReceived+(l.packetsLost-k.packetsLost)),d.audioLossRate=Number.isNaN(d.audioLossRate)?0:d.audioLossRate,b.fraction_lost=d.audioLossRate,d.statsInterval=l.timestamp-k.timestamp,b.stats_interval=d.statsInterval,d.receivedKBitrate=(l.bytesReceived-k.bytesReceived||0)/d.statsInterval*8,b.bandwidth=Math.round(1e3*d.receivedKBitrate/1024),void 0!==l.concealedSamples&&(d.receivedSampleRate=1e3*b.interval_samples_received/d.statsInterval),void 0!==l.fecPacketsReceived&&(b.fecBitratebps=(l.fecPacketsReceived-k.fecPacketsReceived||0)/d.statsInterval),b.average_jitter_buffer_delay_ms&&b.total_rtt_ms&&(d.e2eDelay=b.average_jitter_buffer_delay_ms+b.total_rtt_ms),null!==(i=this._context)&&void 0!==i&&null!==(o=i.streamRTT)&&void 0!==o&&null!==(a=o[p])&&void 0!==a&&a.audio&&(d.totalRtt=(b.rtt?b.rtt:0)+this._context.streamRTT[p].audio),r.audio=l,b.vendor_mode=(null===(s=this._stream)||void 0===s?void 0:s.vendorCode)||0,b.pc_session_id=null===(c=this.handler)||void 0===c?void 0:c.peerConnectionId,null===(u=this._monitor)||void 0===u||u.report("rtc_media_statistics",b,T),e.abrupt("return",this.filterIllegal(d));case 59:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u={},d={timestamp:Date.now()},l=this._stream,h=l.streamId,p=l.userId,v=l.isScreen,f=l.subMediaType,_=l._attributes,e.t0=el,e.t1={media_type:"video",is_screen:!!v,direction:"down",stream_id:h,stream_user_id:p,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:yD(f)?"mute_state_off":"mute_state_on",remote_user_capture_state:_.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:_.localvideo&&_.videostream?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,m=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",u);case 11:return u.isScreen=v,e.next=14,this.handler.getStats(t);case 14:if((g=e.sent).length){e.next=17;break}return e.abrupt("return",u);case 17:if(g.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,i=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,s=e.framesDecoded,c=e.jitterBufferDelay,l=e.jitterBufferEmittedCount,p=e.mimeType,v=e.firCount,f=e.availableIncomingBitrate,_=e.availableOutgoingBitrate,g=e.bytesSent,y=e.nominated,S=e.id,E=e.currentRoundTripTime,k=e.state,T=e.writable,I=e.candidateType,R=e.ip,A=e.address,w=e.networkType,C=e.port,x=e.nackCount,O=e.pliCount,P=e.protocol,M=e.requestsReceived,D=e.responsesReceived,N=e.requestsSent,L=e.consentRequestsSent,U=e.responsesSent,V=e.ssrc,F=e.jitter,B=e.framesReceived,j=e.keyFramesDecoded,H=e.totalDecodeTime,G=e.decoderImplementation,z=e.lastPacketReceivedTimestamp,K=e.framesDropped;if("inbound-rtp"===t)d.packetsLost=i,m.packetsLost=i,d.packetsReceived=o,m.packetsReceived=o,d.bytesReceived=a,m.bytes=a,d.framesDecoded=s,d.totalDecodeTime=H,void 0!==c&&(d.jitterBufferDelay=c/l*1e3,m.average_jitter_buffer_delay_ms=d.jitterBufferDelay),m.fir_count=v,m.nackCount=x,d.nackCount=x,m.pli_count=O,m.ssrc=V,m.framesDropped=K,m.jitter=1e3*F,m.framesReceived=B,d.framesReceived=B,m.framesDecoded=s,m.key_frames_decoded=j,m.decoder_name=G,m.last_packet_received_timestamp=z,void 0!==n&&(u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r);else if("track"===t&&void 0!==n)u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r,void 0!==B&&(m.framesReceived=B,d.framesReceived=B);else if("codec"===t)m.codecName=p;else if("candidate-pair"===t){var X,W,q;m.ice_available_incoming_bitrate=f,m.ice_available_outgoing_bitrate=_,m.ice_bytes_received=a,m.ice_bytes_sent=g,m.ice_nominated=Number(y),m.ice_pair_id=S,m.ice_pair_rtt=E,m.rtt=1e3*E,m.rtt&&null!==(X=b._context)&&void 0!==X&&null!==(W=X.streamRTT)&&void 0!==W&&null!==(q=W[h])&&void 0!==q&&q.video&&(m.total_rtt_ms=Math.round(m.rtt+b._context.streamRTT[h].video)),u.rtt=m.rtt,m.ice_pair_state=k,m.ice_pair_writable=T,m.recv_ping_requests=M,m.recv_ping_responses=D,m.sent_ping_requests_before_first_response=N,m.sent_ping_requests_total=N+(L||0),m.sent_ping_responses=U}else"local-candidate"===t?(m.local_candidate_type=I,m.local_ip=R||A,m.local_network_type=w,m.local_port=C,m.protocol=P):"remote-candidate"===t&&(m.remote_candidate_type=I,m.remote_ip=R||A,m.remote_port=C)})),(y=r.video).timestamp){e.next=22;break}return r.video=d,e.abrupt("return",this.filterIllegal(u));case 22:return u.videoLossRate=(d.packetsLost-y.packetsLost)/(d.packetsReceived-y.packetsReceived+(d.packetsLost-y.packetsLost)),y.totalDecodeTime&&y.framesDecoded&&d.framesDecoded!==y.framesDecoded&&(m.decode_elapse_per_frame=Number(((d.totalDecodeTime-y.totalDecodeTime)/(d.framesDecoded-y.framesDecoded)*1e3).toFixed(2))),u._retransmittedRate=(d.nackCount-y.nackCount)/(d.packetsReceived-y.packetsReceived+(d.packetsLost-y.packetsLost)),u.videoLossRate=Number.isNaN(u.videoLossRate)?0:u.videoLossRate,m.fraction_lost=u.videoLossRate,u.statsInterval=d.timestamp-y.timestamp,m.stats_interval=u.statsInterval,u.receivedKBitrate=(d.bytesReceived-y.bytesReceived||0)/u.statsInterval*8,m.bitrate=Math.round(1e3*u.receivedKBitrate),m.bandwidth=Math.round(m.bitrate/1024),u.decoderOutputFrameRate=1e3*(d.framesDecoded-y.framesDecoded)/u.statsInterval,u.receivedFrameRate=1e3*(d.framesReceived-y.framesReceived)/u.statsInterval,m.frame_rate_decoded=Math.round(u.decoderOutputFrameRate),m.frame_rate_received=Math.round(u.receivedFrameRate),m.average_jitter_buffer_delay_ms&&m.total_rtt_ms&&(u.e2eDelay=m.average_jitter_buffer_delay_ms+m.total_rtt_ms),null!==(n=this._context)&&void 0!==n&&null!==(i=n.streamRTT)&&void 0!==i&&null!==(o=i[h])&&void 0!==o&&o.video&&(u.totalRtt=(m.rtt?m.rtt:0)+this._context.streamRTT[h].video),r.video=d,this.processStall(this._stream,m,u,v),this.isPaused?(S=d.timestamp-(this.pauseStart||0),m.pause_duration=this.pauseDuration+(S>500?S:0),this.pauseStart=d.timestamp):m.pause_duration=this.pauseDuration,m.pause_duration=Math.min(m.stall_duration||m.stuck_length||0,m.pause_duration),this.pauseDuration=0,m.vendor_mode=(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,m.pc_session_id=null===(s=this.handler)||void 0===s?void 0:s.peerConnectionId,null===(c=this._monitor)||void 0===c||c.report("rtc_media_statistics",m),e.abrupt("return",this.filterIllegal(u));case 47:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"processStall",value:function(e,t,r,n){var i=0,o=0,a=0;if(e.recordedVideoFrames&&this.player&&this.player.played){e.recordedVideoFrames.forEach((function(e){e.isStall&&(i+=e.stallCount,o+=e.stallDuration),a=e.playTime})),e.recordedVideoFrames.length||(o=2e3,i=this._videoInWaiting?0:1,this._videoInWaiting=!0);var s=e.recordedVideoFrames.pop();s&&(s.isStall?this._videoInWaiting=!0:this._videoInWaiting=!1),e.recordedVideoFrames=[]}t.stall_count=i,n?(t.stuck_length=Math.min(o,t.stats_interval),t.stall_duration=void 0):(t.stall_duration=Math.min(o,t.stats_interval),t.stuck_length=void 0),t.play_time=a,r.stallCount=i,r.stallDuration=o}},{key:"destroy",value:function(){NI(DI(o.prototype),"destroy",this).call(this),NI(DI(o.prototype),"stopReport",this).call(this,"destroy"),this._stopAudioStallTimer(),this._videoInWaiting=!1}}],[{key:"audioStallConfig",set:function(e){o.audioStallInterval=((null==e?void 0:e.audio_stall_interval)||200)/2,o.audioStallRatio=null==e?void 0:e.audio_stall_ratio}}]),o}(dB);Zd(hB,"audioStallInterval",void 0),Zd(hB,"audioStallRatio",void 0);var pB,vB,fB=function(e){UI(r,e);var t=eR(r);function r(e){var n;return Hl(this,r),Zd(sI(n=t.call(this)),"videoDom",void 0),Zd(sI(n),"audioMid",void 0),Zd(sI(n),"videoMid",void 0),Zd(sI(n),"videoTransceiver",void 0),Zd(sI(n),"audioTransceiver",void 0),Zd(sI(n),"vendorHandler",void 0),Zd(sI(n),"vendorCode",0),Zd(sI(n),"engineId",void 0),Zd(sI(n),"logger",void 0),Zd(sI(n),"__seiHelper",uB),n._ctx=e,n.engineId=e.id,n.logger=new fM("Stream",0,e.id),n}return jl(r,[{key:"requestVideoFrameCallback",value:function(){var e=this;return new $_((function(t){var r,n=null===(r=e.videoDom)||void 0===r?void 0:r.requestVideoFrameCallback;if("function"==typeof n){var i=function(e,r){var n={};cn(r).forEach((function(e){var t=e.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return Nm(t="".concat(e[0],"_")).call(t,e[1].toLowerCase())}));n["video_".concat(t)]=r[e]})),clearInterval(o),t(n)};n.call(e.videoDom,i);var o=setTimeout((function(){var r;null===(r=e.videoDom)||void 0===r||r.cancelVideoFrameCallback(i),t({})}),500)}else t({})}))}},{key:"stopReport",value:function(e){this.statsReport.stopReport(e)}},{key:"destroy",value:function(){var e,t;delete this.audioMid,delete this.videoMid,this.statsReport.destroy(),null===(e=this.observer)||void 0===e||e.reset(),delete this.videoTransceiver,delete this.audioTransceiver,null===(t=this.vendorHandler)||void 0===t||t.destroy(),this.vendorCode=0,delete this.vendorHandler}}]),r}($N),_B=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(_B||{}),mB=function(e){UI(r,e);var t=eR(r);function r(e){var n;return Hl(this,r),Zd(sI(n=t.call(this,e)),"id",void 0),Zd(sI(n),"isScreen",!1),Zd(sI(n),"stream",void 0),Zd(sI(n),"streamId",void 0),Zd(sI(n),"seiList",[]),Zd(sI(n),"videoTrack",void 0),Zd(sI(n),"audioTrack",void 0),Zd(sI(n),"videoEncodeConfig",[AN]),Zd(sI(n),"subVideoDescriptions",[]),Zd(sI(n),"enableSimulcast",!1),Zd(sI(n),"observer",void 0),Zd(sI(n),"statsReport",void 0),Zd(sI(n),"prevBitrate",0),Zd(sI(n),"pubAudio",!1),Zd(sI(n),"pubVideo",!1),Zd(sI(n),"pubAttributes",void 0),Zd(sI(n),"pcSessionId",void 0),n.stream=new MediaStream,n.id=yw(),n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},n.statsReport=new lB(e,sI(n)),n}return jl(r,[{key:"audioHasCapture",get:function(){return this.pubAttributes.localaudio}},{key:"audioHasPublish",get:function(){return this.pubAttributes.audiostream}},{key:"videoHasCapture",get:function(){return this.pubAttributes.localvideo}},{key:"videoHasPublish",get:function(){return this.pubAttributes.videostream}},{key:"hasPublished",get:function(){return!!this.audioMid&&!!this.videoMid}},{key:"isEmptyStream",get:function(){return!this.audioTrack&&!this.videoTrack}},{key:"initStreamId",get:function(){return this.stream.id}},{key:"startReport",value:function(e,t){this.statsReport.setLocalStreamStatsEvtInterval(e,t)}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add&&rV()){var r=t.createEncodedStreams(),n=r.readable,i=r.writable,o=new TransformStream({transform:function(t,r){var n=e.seiList[0];if(n){var i,o=uB.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)ak(i=e.seiList).call(i,0,1);n.repeatCount--,a.set(new Uint8Array(t.data)),a.set(o,t.data.byteLength),t.data=a.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else this.logger.warn("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender)if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add){var e=this.audioTransceiver.sender.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else this.logger.warn("initAudioEncodedTransform","legacy EncodedTransform is not supported");else this.logger.warn("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){$P(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),NI(DI(r.prototype),"destroy",this).call(this),this.prevBitrate=0,this.subVideoDescriptions=[]}},{key:"switchTrackEnableState",value:function(e,t){var r,n;"audio"===e?n=this.audioTrack:"video"===e&&(n=this.videoTrack);var i=null===(r=n)||void 0===r?void 0:r.getTrack();return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}},{key:"resetStream",value:function(){this.stream=new MediaStream}}]),r}(fB),gB=function(e){UI(r,e);var t=eR(r);function r(e,n,i,o,a,s){var c;return Hl(this,r),Zd(sI(c=t.call(this,e)),"streamId",void 0),Zd(sI(c),"userId",void 0),Zd(sI(c),"isScreen",void 0),Zd(sI(c),"isPublic",void 0),Zd(sI(c),"hasVideo",void 0),Zd(sI(c),"hasAudio",void 0),Zd(sI(c),"_attributes",void 0),Zd(sI(c),"streamState",void 0),Zd(sI(c),"removeTrack",!1),Zd(sI(c),"observer",void 0),Zd(sI(c),"statsReport",void 0),Zd(sI(c),"subVideo",void 0),Zd(sI(c),"subAudio",void 0),Zd(sI(c),"subMediaType",void 0),Zd(sI(c),"subLayer",void 0),Zd(sI(c),"_sequenceId",void 0),Zd(sI(c),"stream",void 0),Zd(sI(c),"videoTrack",void 0),Zd(sI(c),"audioTrack",void 0),Zd(sI(c),"recordedVideoFrames",void 0),Zd(sI(c),"stillExist",void 0),Zd(sI(c),"originalMediaType",void 0),Zd(sI(c),"priority",void 0),Zd(sI(c),"originalStreamIndex",0),Zd(sI(c),"virtual",void 0),Zd(sI(c),"pcSessionId",void 0),Zd(sI(c),"_virtualOccupy",void 0),c.virtual=!1,c._virtualOccupy=!1,c.userId=n,c.isScreen=o,c.isPublic=a,c.streamId=i,c.hasAudio=s.audiostream&&s.localaudio,c.hasVideo=s.videostream&&s.localvideo,c._attributes=s,c.vendorCode=(null==s?void 0:s.vendorCode)||0,c.subVideo=!1,c.subAudio=!1,c._sequenceId=0,c.subMediaType=tB.NONE,c.subLayer={spatialLayer:0,spatialSubLayer:-1},c.streamState=0,c.statsReport=new hB(e,sI(c)),c.enableVendorMode&&(c.pcSessionId=yw()),c}return jl(r,[{key:"vendor",get:function(){return this._attributes.vendorCode}},{key:"audioHasCapture",get:function(){return this._attributes.localaudio}},{key:"audioHasPublish",get:function(){return this._attributes.audiostream}},{key:"videoHasCapture",get:function(){return this._attributes.localvideo}},{key:"videoHasPublish",get:function(){return this._attributes.videostream}},{key:"sequenceId",get:function(){return this._sequenceId||-1},set:function(e){"number"==typeof e&&(this._sequenceId=e)}},{key:"enableVendorMode",get:function(){return"number"==typeof this.attributes.vendorCode&&0!==this.attributes.vendorCode}},{key:"hasSubscribed",get:function(){return 2===this.streamState}},{key:"attributes",get:function(){return this._attributes},set:function(e){this.hasVideo=e.localvideo&&e.videostream,this.hasAudio=e.localaudio&&e.audiostream,this._attributes=e,this.vendorCode=e.vendorCode||0}},{key:"virtualOccupy",get:function(){return this._virtualOccupy},set:function(e){var t;if(this._virtualOccupy&&!e)null===(t=this.observer)||void 0===t||t.setPushTrack(!1);else if(!this._virtualOccupy&&e){var r;null===(r=this.observer)||void 0===r||r.setPushTrack(!0)}this._virtualOccupy=e}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver)if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){rB.getNalunits(new nB(t.data)).forEach((function(t){if(t.sei){var r=uB.decodeSeiBody(t.body);r&&r.type!==iB.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else this.logger.warn("initAudioEncodedTransform","legacy EncodedTransform is not supported");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)if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add){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("legacy EncodedTransform is not supported");else this.logger.warn("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n;try{var i;$P(this.engineId,"Stream.ontrack",Fm({uid:this.userId,streamId:this.streamId,streams:gb(i=e.streams).call(i,(function(e,t){return e+kw(t)}),""),transceiver:Rw(e.transceiver),track:Ew(e.track)}),0,this.streamId||"")}catch(BY){}if(this.enableVendorMode||null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&bk(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:"clean",value:function(){var e,t;this.logger.info("clean",Nm(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),$P(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),NI(DI(r.prototype),"destroy",this).call(this),this.subAudio=!1,this.subVideo=!1,this.sequenceId=0,this.videoTrack=void 0,null===(t=this.audioTrack)||void 0===t||t.close(),this.audioTrack=void 0,this.stream=void 0,this.recordedVideoFrames=void 0,delete this.priority}},{key:"destroy",value:function(){this.clean(),this.attributes={audiostream:!1,localaudio:!1,localvideo:!1,videostream:!1,extvideo:!1,extaudio:!1,videoDescriptions:[]}}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{key:"_setStream",value:function(e){var t=this;this.stream=e,e.onaddtrack=function(e){"video"===e.track.kind?t._setVideoTrack(e.track):"audio"===e.track.kind&&t._setAudioTrack(e.track)}}},{key:"_setAudioTrack",value:function(e){var t,r;(null===(t=this.audioTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.audioTrack=zF(e),this.emit("ontrack",this.audioTrack))}},{key:"_setVideoTrack",value:function(e){var t,r;(null===(t=this.videoTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.videoTrack=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:eD();return new EF(e,t)}(e),this.emit("ontrack",this.videoTrack))}}]),r}(fB),yB=new fM("queue",4),SB=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(SB||{}),bB=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(bB||{}),EB=(Zd(pB={},"publish","unpublish"),Zd(pB,"subscribe","unsubscribe"),Zd(pB,"pushtrack","removetrack"),pB),kB=(Zd(vB={},"publish",0),Zd(vB,"subscribe",0),Zd(vB,"pushtrack",0),Zd(vB,"unpublish",1),Zd(vB,"unsubscribe",1),Zd(vB,"removetrack",1),vB),TB=function(e){UI(r,e);var t=eR(r);function r(){var e;return Hl(this,r),Zd(sI(e=t.call(this)),"_queue",void 0),e._queue=[],e}return jl(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t,r=this._queue.length,n="";return this._queue=Ks(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==EB[t.action]||(n=t.streamId,yB.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;LD&&aN>=86&&aN<=92&&(t=Math.min(this._queue.length,5));for(var r=kB[this._queue[0].action],n=1;n<t;n++){var i;if(kB[this._queue[n].action]!==r)return{sdpStrategy:r,items:ak(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:ak(e=this._queue).call(e,0,t)}}}]),r}(QN),IB="object"==typeof global&&global&&global.Object===Object&&global,RB="object"==typeof self&&self&&self.Object===Object&&self,AB=IB||RB||Function("return this")(),wB=AB.Symbol,CB=Object.prototype,xB=CB.hasOwnProperty,OB=CB.toString,PB=wB?wB.toStringTag:void 0;var MB=Object.prototype.toString;var DB="[object Null]",NB="[object Undefined]",LB=wB?wB.toStringTag:void 0;function UB(e){return null==e?void 0===e?NB:DB:LB&&LB in Object(e)?function(e){var t=xB.call(e,PB),r=e[PB];try{e[PB]=void 0;var n=!0}catch(o){}var i=OB.call(e);return n&&(t?e[PB]=r:delete e[PB]),i}(e):function(e){return MB.call(e)}(e)}function VB(e){return null!=e&&"object"==typeof e}var FB=Array.isArray;function BB(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function jB(e){return e}var HB="[object AsyncFunction]",GB="[object Function]",zB="[object GeneratorFunction]",KB="[object Proxy]";function XB(e){if(!BB(e))return!1;var t=UB(e);return t==GB||t==zB||t==HB||t==KB}var WB,qB=AB["__core-js_shared__"],YB=(WB=/[^.]+$/.exec(qB&&qB.keys&&qB.keys.IE_PROTO||""))?"Symbol(src)_1."+WB:"";var JB=Function.prototype.toString;function QB(e){if(null!=e){try{return JB.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var ZB=/^\[object .+?Constructor\]$/,$B=Function.prototype,ej=Object.prototype,tj=$B.toString,rj=ej.hasOwnProperty,nj=RegExp("^"+tj.call(rj).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ij(e){return!(!BB(e)||(t=e,YB&&YB in t))&&(XB(e)?nj:ZB).test(QB(e));var t}function oj(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return ij(r)?r:void 0}var aj=oj(AB,"WeakMap"),sj=Object.create,cj=function(){function e(){}return function(t){if(!BB(t))return{};if(sj)return sj(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();var uj=Date.now;var dj,lj,hj,pj=function(){try{var e=oj(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),vj=pj,fj=vj?function(e,t){return vj(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:jB,_j=(dj=fj,lj=0,hj=0,function(){var e=uj(),t=16-(e-hj);if(hj=e,t>0){if(++lj>=800)return arguments[0]}else lj=0;return dj.apply(void 0,arguments)}),mj=_j;var gj=9007199254740991,yj=/^(?:0|[1-9]\d*)$/;function Sj(e,t){var r=typeof e;return!!(t=null==t?gj:t)&&("number"==r||"symbol"!=r&&yj.test(e))&&e>-1&&e%1==0&&e<t}function bj(e,t,r){"__proto__"==t&&vj?vj(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function Ej(e,t){return e===t||e!=e&&t!=t}var kj=Object.prototype.hasOwnProperty;function Tj(e,t,r){var n=e[t];kj.call(e,t)&&Ej(n,r)&&(void 0!==r||t in e)||bj(e,t,r)}function Ij(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?bj(r,s,c):Tj(r,s,c)}return r}var Rj=Math.max;function Aj(e,t){return mj(function(e,t,r){return t=Rj(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=Rj(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,jB),e+"")}var wj=9007199254740991;function Cj(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=wj}function xj(e){return null!=e&&Cj(e.length)&&!XB(e)}var Oj=Object.prototype;function Pj(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Oj)}function Mj(e){return VB(e)&&"[object Arguments]"==UB(e)}var Dj=Object.prototype,Nj=Dj.hasOwnProperty,Lj=Dj.propertyIsEnumerable,Uj=Mj(function(){return arguments}())?Mj:function(e){return VB(e)&&Nj.call(e,"callee")&&!Lj.call(e,"callee")},Vj=Uj;var Fj="object"==typeof exports&&exports&&!exports.nodeType&&exports,Bj=Fj&&"object"==typeof module&&module&&!module.nodeType&&module,jj=Bj&&Bj.exports===Fj?AB.Buffer:void 0,Hj=(jj?jj.isBuffer:void 0)||function(){return!1},Gj={};function zj(e){return function(t){return e(t)}}Gj["[object Float32Array]"]=Gj["[object Float64Array]"]=Gj["[object Int8Array]"]=Gj["[object Int16Array]"]=Gj["[object Int32Array]"]=Gj["[object Uint8Array]"]=Gj["[object Uint8ClampedArray]"]=Gj["[object Uint16Array]"]=Gj["[object Uint32Array]"]=!0,Gj["[object Arguments]"]=Gj["[object Array]"]=Gj["[object ArrayBuffer]"]=Gj["[object Boolean]"]=Gj["[object DataView]"]=Gj["[object Date]"]=Gj["[object Error]"]=Gj["[object Function]"]=Gj["[object Map]"]=Gj["[object Number]"]=Gj["[object Object]"]=Gj["[object RegExp]"]=Gj["[object Set]"]=Gj["[object String]"]=Gj["[object WeakMap]"]=!1;var Kj="object"==typeof exports&&exports&&!exports.nodeType&&exports,Xj=Kj&&"object"==typeof module&&module&&!module.nodeType&&module,Wj=Xj&&Xj.exports===Kj&&IB.process,qj=function(){try{var e=Xj&&Xj.require&&Xj.require("util").types;return e||Wj&&Wj.binding&&Wj.binding("util")}catch(t){}}(),Yj=qj&&qj.isTypedArray,Jj=Yj?zj(Yj):function(e){return VB(e)&&Cj(e.length)&&!!Gj[UB(e)]},Qj=Object.prototype.hasOwnProperty;function Zj(e,t){var r=FB(e),n=!r&&Vj(e),i=!r&&!n&&Hj(e),o=!r&&!n&&!i&&Jj(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&&!Qj.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Sj(u,c))||s.push(u);return s}function $j(e,t){return function(r){return e(t(r))}}var eH=$j(Object.keys,Object),tH=Object.prototype.hasOwnProperty;function rH(e){return xj(e)?Zj(e):function(e){if(!Pj(e))return eH(e);var t=[];for(var r in Object(e))tH.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var nH=Object.prototype.hasOwnProperty;function iH(e){if(!BB(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=Pj(e),r=[];for(var n in e)("constructor"!=n||!t&&nH.call(e,n))&&r.push(n);return r}function oH(e){return xj(e)?Zj(e,!0):iH(e)}var aH,sH=(aH=function(e,t){Ij(t,oH(t),e)},Aj((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=aH.length>3&&"function"==typeof i?(n--,i):void 0,o&&function(e,t,r){if(!BB(r))return!1;var n=typeof t;return!!("number"==n?xj(r)&&Sj(t,r.length):"string"==n&&t in r)&&Ej(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&&aH(e,a,r,i)}return e}))),cH=oj(Object,"create");var uH=Object.prototype.hasOwnProperty;var dH=Object.prototype.hasOwnProperty;function lH(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 hH(e,t){for(var r=e.length;r--;)if(Ej(e[r][0],t))return r;return-1}lH.prototype.clear=function(){this.__data__=cH?cH(null):{},this.size=0},lH.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},lH.prototype.get=function(e){var t=this.__data__;if(cH){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return uH.call(t,e)?t[e]:void 0},lH.prototype.has=function(e){var t=this.__data__;return cH?void 0!==t[e]:dH.call(t,e)},lH.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=cH&&void 0===t?"__lodash_hash_undefined__":t,this};var pH=Array.prototype.splice;function vH(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])}}vH.prototype.clear=function(){this.__data__=[],this.size=0},vH.prototype.delete=function(e){var t=this.__data__,r=hH(t,e);return!(r<0)&&(r==t.length-1?t.pop():pH.call(t,r,1),--this.size,!0)},vH.prototype.get=function(e){var t=this.__data__,r=hH(t,e);return r<0?void 0:t[r][1]},vH.prototype.has=function(e){return hH(this.__data__,e)>-1},vH.prototype.set=function(e,t){var r=this.__data__,n=hH(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var fH=oj(AB,"Map");function _H(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 mH(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 gH(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}mH.prototype.clear=function(){this.size=0,this.__data__={hash:new lH,map:new(fH||vH),string:new lH}},mH.prototype.delete=function(e){var t=_H(this,e).delete(e);return this.size-=t?1:0,t},mH.prototype.get=function(e){return _H(this,e).get(e)},mH.prototype.has=function(e){return _H(this,e).has(e)},mH.prototype.set=function(e,t){var r=_H(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};var yH=$j(Object.getPrototypeOf,Object);function SH(e){var t=this.__data__=new vH(e);this.size=t.size}SH.prototype.clear=function(){this.__data__=new vH,this.size=0},SH.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},SH.prototype.get=function(e){return this.__data__.get(e)},SH.prototype.has=function(e){return this.__data__.has(e)},SH.prototype.set=function(e,t){var r=this.__data__;if(r instanceof vH){var n=r.__data__;if(!fH||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new mH(n)}return r.set(e,t),this.size=r.size,this};var bH="object"==typeof exports&&exports&&!exports.nodeType&&exports,EH=bH&&"object"==typeof module&&module&&!module.nodeType&&module,kH=EH&&EH.exports===bH?AB.Buffer:void 0,TH=kH?kH.allocUnsafe:void 0;function IH(){return[]}var RH=Object.prototype.propertyIsEnumerable,AH=Object.getOwnPropertySymbols,wH=AH?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}(AH(e),(function(t){return RH.call(e,t)})))}:IH;var CH=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)gH(t,wH(e)),e=yH(e);return t}:IH;function xH(e,t,r){var n=t(e);return FB(e)?n:gH(n,r(e))}function OH(e){return xH(e,rH,wH)}function PH(e){return xH(e,oH,CH)}var MH=oj(AB,"DataView"),DH=oj(AB,"Promise"),NH=oj(AB,"Set"),LH="[object Map]",UH="[object Promise]",VH="[object Set]",FH="[object WeakMap]",BH="[object DataView]",jH=QB(MH),HH=QB(fH),GH=QB(DH),zH=QB(NH),KH=QB(aj),XH=UB;(MH&&XH(new MH(new ArrayBuffer(1)))!=BH||fH&&XH(new fH)!=LH||DH&&XH(DH.resolve())!=UH||NH&&XH(new NH)!=VH||aj&&XH(new aj)!=FH)&&(XH=function(e){var t=UB(e),r="[object Object]"==t?e.constructor:void 0,n=r?QB(r):"";if(n)switch(n){case jH:return BH;case HH:return LH;case GH:return UH;case zH:return VH;case KH:return FH}return t});var WH=XH,qH=Object.prototype.hasOwnProperty;var YH=AB.Uint8Array;function JH(e){var t=new e.constructor(e.byteLength);return new YH(t).set(new YH(e)),t}var QH=/\w*$/;var ZH=wB?wB.prototype:void 0,$H=ZH?ZH.valueOf:void 0;var eG="[object Boolean]",tG="[object Date]",rG="[object Map]",nG="[object Number]",iG="[object RegExp]",oG="[object Set]",aG="[object String]",sG="[object Symbol]",cG="[object ArrayBuffer]",uG="[object DataView]",dG="[object Float32Array]",lG="[object Float64Array]",hG="[object Int8Array]",pG="[object Int16Array]",vG="[object Int32Array]",fG="[object Uint8Array]",_G="[object Uint8ClampedArray]",mG="[object Uint16Array]",gG="[object Uint32Array]";function yG(e,t,r){var n,i,o,a=e.constructor;switch(t){case cG:return JH(e);case eG:case tG:return new a(+e);case uG:return function(e,t){var r=t?JH(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case dG:case lG:case hG:case pG:case vG:case fG:case _G:case mG:case gG:return function(e,t){var r=t?JH(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,r);case rG:return new a;case nG:case aG:return new a(e);case iG:return(o=new(i=e).constructor(i.source,QH.exec(i))).lastIndex=i.lastIndex,o;case oG:return new a;case sG:return n=e,$H?Object($H.call(n)):{}}}var SG=qj&&qj.isMap,bG=SG?zj(SG):function(e){return VB(e)&&"[object Map]"==WH(e)};var EG=qj&&qj.isSet,kG=EG?zj(EG):function(e){return VB(e)&&"[object Set]"==WH(e)},TG=1,IG=2,RG=4,AG="[object Arguments]",wG="[object Function]",CG="[object GeneratorFunction]",xG="[object Object]",OG={};function PG(e,t,r,n,i,o){var a,s=t&TG,c=t&IG,u=t&RG;if(r&&(a=i?r(e,n,i,o):r(e)),void 0!==a)return a;if(!BB(e))return e;var d=FB(e);if(d){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&qH.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=WH(e),h=l==wG||l==CG;if(Hj(e))return function(e,t){if(t)return e.slice();var r=e.length,n=TH?TH(r):new e.constructor(r);return e.copy(n),n}(e,s);if(l==xG||l==AG||h&&!i){if(a=c||h?{}:function(e){return"function"!=typeof e.constructor||Pj(e)?{}:cj(yH(e))}(e),!s)return c?function(e,t){return Ij(e,CH(e),t)}(e,function(e,t){return e&&Ij(t,oH(t),e)}(a,e)):function(e,t){return Ij(e,wH(e),t)}(e,function(e,t){return e&&Ij(t,rH(t),e)}(a,e))}else{if(!OG[l])return i?e:{};a=yG(e,l,s)}}o||(o=new SH);var p=o.get(e);if(p)return p;o.set(e,a),kG(e)?e.forEach((function(n){a.add(PG(n,t,r,n,e,o))})):bG(e)&&e.forEach((function(n,i){a.set(i,PG(n,t,r,i,e,o))}));var v=d?void 0:(u?c?PH:OH:c?oH:rH)(e);return function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););}(v||e,(function(n,i){v&&(n=e[i=n]),Tj(a,i,PG(n,t,r,i,e,o))})),a}OG[AG]=OG["[object Array]"]=OG["[object ArrayBuffer]"]=OG["[object DataView]"]=OG["[object Boolean]"]=OG["[object Date]"]=OG["[object Float32Array]"]=OG["[object Float64Array]"]=OG["[object Int8Array]"]=OG["[object Int16Array]"]=OG["[object Int32Array]"]=OG["[object Map]"]=OG["[object Number]"]=OG[xG]=OG["[object RegExp]"]=OG["[object Set]"]=OG["[object String]"]=OG["[object Symbol]"]=OG["[object Uint8Array]"]=OG["[object Uint8ClampedArray]"]=OG["[object Uint16Array]"]=OG["[object Uint32Array]"]=!0,OG["[object Error]"]=OG[wG]=OG["[object WeakMap]"]=!1;function MG(e){return PG(e,5)}function DG(e,t){return function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}(t,(function(t){return e[t]}))}function NG(e){return null==e?[]:DG(e,rH(e))}var LG=rV(),UG=function(e){UI(u,e);var t,r,n,i,o,a,s,c=eR(u);function u(e,t){var r;return Hl(this,u),Zd(sI(r=c.call(this,e,t)),"name","chrome"),Zd(sI(r),"_queueBusy",!1),Zd(sI(r),"_sdpQueue",void 0),Zd(sI(r),"_aSendonlyOfferTpl",void 0),Zd(sI(r),"_vSendonlyOfferTpl",void 0),Zd(sI(r),"_aRecvonlyOfferTpl",void 0),Zd(sI(r),"_vRecvonlyOfferTpl",void 0),Zd(sI(r),"_mid",10),Zd(sI(r),"_inactiveMlineIndex",[]),Zd(sI(r),"_mlinesCache",{}),Zd(sI(r),"setDescription",void 0),r.logger=new fM("ChromeHandler",3,e.id),r.setDescription=t.setDescription.bind(t),r._sdpQueue=new TB,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(r.logger.info("dequeue start"),r.dequeue())})),r}return jl(u,[{key:"destroy",value:function(){NI(DI(u.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(s=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,M,D,N,L,U,V,F,B;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d=t.stream,l=t.enableSimulcast,h=NI(DI(u.prototype),"internalPublish",this).call(this,t),p=h.videoDescriptions,v=h.subVideoDescriptions,f=h.audioTransceiverInit,_=h.videoTransceiverInit,m=BV(this._nextSsrc),this._nextSsrc=m.next,g="".concat(this._mid++),y="".concat(this._mid++),S=el(el(el({},this._aSendonlyOfferTpl),this.peer._offerIce),{},{mid:g,msid:Nm(r="".concat(d.id," ")).call(r,d.id,"-audio"),ssrcs:jV(d.id,"audio",m.audio,FV)}),b=el(el(el({},this._vSendonlyOfferTpl),this.peer._offerIce),{},{mid:y,msid:Nm(n="".concat(d.id," ")).call(n,d.id,"-video")}),l?(this.logger.info("subVideoDesc","desc: %o ",v),delete b.ssrcGroups,delete b.ssrcs,E=[],b.rids=Km(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=HV(d.id,m,{cname:FV}),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=eA(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(C=ak(w=S.rtp).call(w,A,1),x=aI(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&&QV(b,null===(M=this._context)||void 0===M||null===(D=M.serverConfig)||void 0===D?void 0:D.videoCodec),Array.isArray(b.ext)&&(kN("IOS_SAFARI_ORIENTATION")||!ND&&!WD||(b.ext=Ks(L=b.ext).call(L,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&bk(t).call(t,"video-orientation"))}))),b.ext=Ks(N=b.ext).call(N,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&bk(t).call(t,"framemarking"))}))),(U=null==S?void 0:kE(c=S.rtp).call(c,(function(e){return"opus"===e.codec})))&&S.fmtp&&(B=kE(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||ND||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:zV(this.peer._offerSession,S,b),audioMid:g,videoMid:y,type:"incroffer",semantics:"unified-plan",videoDescriptions:p,subVideoDescriptions:v,audioTransceiverInit:f,videoTransceiverInit:_,peerConnectionMode:this.peerConnectionMode});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"subscribe",value:(a=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,M,D,N,L,U;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("subscribe"),a="incroffer",s="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return c=e.sent,e.next=9,this.createAVMlineOfferTpl(c);case 9:return u="",d="",l=!1,h=!1,p=void 0,v=void 0,this._mlinesCache[t.streamId]=[p,v],t.virtual?(u="".concat(this._mid++),l=!0):r.multiChatMode?(u="".concat(this._mid++),d="".concat(this._mid++),h=!0):(l=!0,h=!0,u="".concat(this._mid++),d="".concat(this._mid++)),u&&(p=el(el({},MG(this._aRecvonlyOfferTpl)),{},{mid:u})),l&&(this._mlinesCache[t.streamId][0]=p,f={track:"audio",init:{direction:"recvonly"}}),d&&(v=el(el({},MG(this._vRecvonlyOfferTpl)),{},{mid:d})),h&&(this._mlinesCache[t.streamId][1]=v,_={track:"video",init:{direction:"recvonly"}}),m=zV(this.peer._offerSession,p,v),g=void 0,y=void 0,t.enableVendorMode||r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl||(g=BV(this._nextSsrc),this._nextSsrc=g.next,A=el(el(el({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Nm(S=Nm(b="".concat(t.streamId)).call(b,null!==(E=this._context)&&void 0!==E&&E.avSync?"":"-audio"," ")).call(S,t.streamId,"-audio"),ssrcs:jV(t.streamId,"audio",g.audio)}),w=el(el(el({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:d,msid:Nm(k=Nm(T="".concat(t.streamId)).call(T,null!==(I=this._context)&&void 0!==I&&I.avSync?"":"-video"," ")).call(k,t.streamId,"-video")},HV(t.streamId,g,{flexfec:this._enableSubFlexfec})),y={sdp:fV.write(el(el({},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:kE(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:kE(O=x.fmtp).call(O,(function(e){return e.payload===C.payload})))&&this._context&&(P.config+=";stereo=1;sprop-stereo=1"),t.isPublic&&aN>=86&&null!=(L=null===(M=v)||void 0===M?void 0:Ks(D=M.rtp).call(D,(function(e){return"H264"===e.codec})))&&L.length&&null!==(N=v)&&void 0!==N&&N.fmtp&&(null===(U=v)||void 0===U||U.fmtp.forEach((function(e){kE(L).call(L,(function(t){return t.payload===e.payload}))&&(e.config+=";sps-pps-idr-in-keyframe=1")}))),e.abrupt("return",{partialSdp:m,audioMid:u,videoMid:d,type:a,semantics:s,audioTransceiverInit:f,videoTransceiverInit:_,allSsrc:g,peerConnectionMode:this.peerConnectionMode,signalingAck:y});case 29:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handleAck",value:(o=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("handleAck()","item: %o",t),e.abrupt("return",this._sdpQueue.enqueue(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"dequeue",value:(i=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m=this;return wm().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!==SB.ADD){e.next=16;break}return e.delegateYield(wm().mark((function e(){var t,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=el({},m.peer._answerIce)).candidates,c=!1,u=!1,e.prev=4,l=dL(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 gB;if(i.onSuccess&&s.push(i.onSuccess),i.onFail&&r.push(i.onFail),p&&(null==l?void 0:l.sequenceId)<h.sequenceId)return"break";var v,f={},_={},g=fV.parse(l.sdp);Array.isArray(g.media)&&KR(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=el(el({},r),t)).type?(f=r).mid=e:(_=r).mid=n}));var y,S=h.streamId;if(c===bB.publish&&(S=null===(y=h.stream)||void 0===y?void 0:y.id),!m._mlinesCache[S])return"break";var b=aI(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",Fm({audioStreamTrack:Ew(u.track)}));var T=m._inactiveMlineIndex.shift();T||(T=m.peer._offerMlines.length),m.peer._offerMlines[T]=el({},E),m.peer._answerMlines[T]=f,LG&&h.initAudioEncodedTransform()}if(d&&k){var I,R;h.videoTransceiver=m._peerConnection.addTransceiver(d.track,d.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",Fm({videoStreamTrack:Ew(d.track)}));var A,w,C=m._inactiveMlineIndex.shift();C||(C=m.peer._offerMlines.length),m.peer._offerMlines[C]=el({},k),c===bB.publish&&null!==(I=m._context)&&void 0!==I&&null!==(R=I.serverConfig)&&void 0!==R&&R.videoCodec&&QV(_,null===(A=m._context)||void 0===A||null===(w=A.serverConfig)||void 0===w?void 0:w.videoCodec),m.peer._answerMlines[C]=_,LG&&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:_={},n.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;_[t]=t,n!==bB.removetrack&&(_[r]=r),_[t]=t})),this.peer._offerMlines=Km(p=this.peer._offerMlines).call(p,(function(e,t){return _[e.mid]&&(e=GV(e),m._inactiveMlineIndex.push(t)),e})),KR(v=this._inactiveMlineIndex).call(v,(function(e,t){return e-t})),this.peer._answerMlines=Km(f=this.peer._answerMlines).call(f,(function(e){return _[e.mid]&&(e=GV(e)),e}));case 21:return e.prev=21,e.next=24,this.peer.getOriginRTCPeerConnection().createOffer();case 24:return e.next=26,this.setDescription(o.length?{streamId:o.join(","),streamUserId:a.join(",")}:void 0);case 26:e.next=34;break;case 28:if(e.prev=28,e.t1=e.catch(21),"have-local-offer"!==this._peerConnection.signalingState){e.next=33;break}return e.next=33,this._peerConnection.setLocalDescription({type:"rollback"});case 33:throw e.t1;case 34:try{s.forEach((function(e){return e()}))}catch(BY){}this.logger.info("dequeue","loop"),e.next=42;break;case 38:e.prev=38,e.t2=e.catch(7),this.logger.error("dequeue","unknown error: %o",e.t2),r.forEach((function(t){return t(e.t2)}));case 42:return e.prev=42,this.dequeue(),e.finish(42);case 45:case"end":return e.stop()}}),e,this,[[7,38,42,45],[21,28]])}))),function(){return i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=xm(wm().mark((function e(){var t,r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._genOfferSdp();case 2:return r=e.sent,this.createAVMlineOfferTpl(r),n=fV.parse(r),i=[],n.media=Ks(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=Ks(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),i.push("".concat(e.mid)),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:fV.write(n),semantics:"unified-plan",type:"incroffer"});case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"rollback",value:(r=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.msid,delete this._mlinesCache[r];case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;fV.parse(e).media.forEach((function(e){if(e.icePwd=t.peer._offerIce.icePwd,e.iceUfrag=t.peer._offerIce.iceUfrag,"audio"===e.type)if("sendonly"===e.direction)t._aSendonlyOfferTpl=e;else{var r;if(Array.isArray(e.ext))e.ext=Ks(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=Ks(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}}))}},{key:"_genOfferSdp",value:(t=xm(wm().mark((function e(){var t,r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fD(!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 SA(_A.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return t.apply(this,arguments)})}]),u}(rF),VG=function(e){UI(d,e);var t,r,n,i,o,a,s,c,u=eR(d);function d(e,t){var r;return Hl(this,d),Zd(sI(r=u.call(this,e,t)),"name","firefox"),Zd(sI(r),"_aRecvonlyOfferTpl",void 0),r.logger=new fM("FirefoxHandler",3,e.id),r}return jl(d,[{key:"publish",value:(c=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,f,_,m=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=NI(DI(d.prototype),"internalPublish",this).call(this,t),o=i.videoDescriptions,a=i.subVideoDescriptions,s=i.audioTransceiverInit,c=i.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(s.track,s.init),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),u=tD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=7,this._peerConnection.createOffer();case 7:return l=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:tD()-u}),(h=fV.parse(l.sdp)).media=null===(r=h.media)||void 0===r?void 0:Km(r).call(r,(function(e){return el(el({},e),m.peer._offerIce)})),e.next=13,this.setLocalDescription(fV.write(h));case 13:return p=t.audioTransceiver.mid,v=t.videoTransceiver.mid,f=null,_=null,h.media=null===(n=h.media)||void 0===n?void 0:Km(n).call(n,(function(e){if("".concat(e.mid)===p){var t,r,n=null===(t=f=e)||void 0===t?void 0:kE(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&f.fmtp){var i,o,a=kE(i=f.fmtp).call(i,(function(e){return e.payload===n.payload}));a&&null!==(o=m._context)&&void 0!==o&&o.audioProfileManager&&(a.config=m._context.audioProfileManager.getOpusConfigStr(a.config))}}else if("".concat(e.mid)===v){var s,c,u,d;null!==(s=m._context)&&void 0!==s&&null!==(c=s.serverConfig)&&void 0!==c&&c.videoCodec&&QV(e,null===(u=m._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec),_=e}return e})),this.addBitrateLimit(_,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(fV.write(h));case 21:return e.abrupt("return",{partialSdp:zV(h,f,_,!1),audioMid:p,videoMid:v,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:c,peerConnectionMode:this.peerConnectionMode});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R,A,w=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("subscribe()"),c="",u="",d=!1,l=!1,h=void 0,p=void 0,t.virtual?d=!0:(r.multiChatMode||(d=!0),l=!0),d&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),l&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),v=tD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return f=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:tD()-v}),(_=fV.parse(f.sdp)).media=null===(n=_.media)||void 0===n?void 0:Km(n).call(n,(function(e){return el(el({},e),w.peer._offerIce)})),Km(i=_.media).call(i,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Ks(t).call(t,(function(e){var t;return-1===DE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Ks(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=21,this.setLocalDescription(fV.write(_),{streamId:t.streamId||"",streamUserId:t.userId});case 21: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&&(p=e)})),c&&h||(c="audio_".concat(u),h=el(el({},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=BV(this._nextSsrc),this._nextSsrc=m.next,R=el(el(el({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:c,msid:Nm(y=Nm(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:jV(t.streamId,"audio",m.audio)}),A=el(el(el({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Nm(E=Nm(k="".concat(t.streamId)).call(k,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},HV(t.streamId,m,{flexfec:this._enableSubFlexfec})),g={sdp:fV.write(el(el({},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:zV(_,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 31:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=xm(wm().mark((function e(t){var r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==bB.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==bB.unpublish&&i!==bB.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=fV.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=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=fV.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=el(el({},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 mB&&tN<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=Ks(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=Ks(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=Ks(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=Ks(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=fV.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=Km(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,Km(a=c.media).call(a,(function(e){var t,r,n;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Ks(t).call(t,(function(e){var t;return-1===DE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Ks(r).call(r,(function(e){return"goog-remb"!==e.type})),tN>=138&&(e.ext=null===(n=e.ext)||void 0===n?void 0:Ks(n).call(n,(function(e){var t;return!bk(t=e.uri).call(t,"sdes:mid")}))))})),e.next=11,this.setRemoteDescription(fV.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=xm(wm().mark((function e(){var t,r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=fV.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Ks(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:fV.write(i),semantics:"unified-plan",type:"incroffer"});case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=xm(wm().mark((function e(t){var r,n,i;return wm().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=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f=this;return wm().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=fV.parse(null==l?void 0:l.sdp)).media=Km(i=h.media).call(i,(function(e){return u[e.mid]&&(e=GV(e)),"inactive"!==e.direction&&d.push(e.mid),el(el({},e),f.peer._offerIce)})),p=fV.parse(null===(o=this._peerConnection.remoteDescription)||void 0===o?void 0:o.sdp),v={},p.media.forEach((function(e){void 0!==e.mid&&(v[e.mid]=e)})),p.media=Km(a=h.media).call(a,(function(e){return"inactive"===e.direction?e:v[e.mid]})),h.groups&&p.groups&&(h.groups[0].mids=d.join(" "),p.groups[0].mids=d.join(" ")),e.next=19,this.setLocalDescription(fV.write(h));case 19:return e.next=21,this.setRemoteDescription(fV.write(p));case 21:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=xm(wm().mark((function e(){return wm().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;fV.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(rF),FG=function(e){UI(d,e);var t,r,n,i,o,a,s,c,u=eR(d);function d(e,t){var r;return Hl(this,d),Zd(sI(r=u.call(this,e,t)),"name","fallback"),Zd(sI(r),"_aRecvonlyOfferTpl",void 0),r.logger=new fM("FallbackHandler",3,e.id),r.logger.warn("ctor","using fallback handler"),r._report("rtc_error",{message:"using fallback handler",error_code:-1}),r}return jl(d,[{key:"publish",value:(c=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,f,_;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=NI(DI(d.prototype),"internalPublish",this).call(this,t),i=n.videoDescriptions,o=n.subVideoDescriptions,a=n.audioTransceiverInit,s=n.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(a.track,a.init),Array.isArray(s.init.sendEncodings)&&1===s.init.sendEncodings.length&&(s.init.sendEncodings=Km(c=s.init.sendEncodings).call(c,(function(e){return delete e.rid,e}))),t.videoTransceiver=this._peerConnection.addTransceiver(s.track,s.init),u=tD(),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 l=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:tD()-u}),h=fV.parse(l.sdp),e.next=13,this.setLocalDescription(l.sdp);case 13:return p=t.audioTransceiver.mid,v=t.videoTransceiver.mid,f=null,_=null,h.media=null===(r=h.media)||void 0===r?void 0:Km(r).call(r,(function(e){return"".concat(e.mid)===p?f=e:"".concat(e.mid)===v&&(_=e),e})),rV()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:zV(h,f,_),audioMid:p,videoMid:v,type:"incroffer",semantics:"unified-plan",videoDescriptions:i,subVideoDescriptions:o,audioTransceiverInit:a,videoTransceiverInit:s,peerConnectionMode:this.peerConnectionMode});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("subscribe()"),a="",s="",c=!1,u=!1,d=void 0,l=void 0,t.virtual?c=!0:(r.multiChatMode||(c=!0),u=!0),c&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),u&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),h=tD(),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:tD()-h}),v=fV.parse(p.sdp),e.next=19,this.setLocalDescription(p.sdp,{streamId:t.streamId||"",streamUserId:t.userId});case 19:return a=null===(n=t.audioTransceiver)||void 0===n?void 0:n.mid,s=null===(i=t.videoTransceiver)||void 0===i?void 0:i.mid,null===(o=v.media)||void 0===o||o.forEach((function(e){"".concat(e.mid)===a?d=e:"".concat(e.mid)===s&&(l=e)})),a&&d||(a="audio_".concat(s),d=el(el({},this._aRecvonlyOfferTpl),{},{mid:a})),t.audioMid=a,t.videoMid=s,f=void 0,_=void 0,!r.multiChatMode&&!t.virtual&&this._aSendonlyAnswerTpl&&this._aSendonlyAnswerTpl&&(f=BV(this._nextSsrc),this._nextSsrc=f.next,T=el(el(el({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:a,msid:Nm(m=Nm(g="".concat(t.streamId)).call(g,null!==(y=this._context)&&void 0!==y&&y.avSync?"":"-audio"," ")).call(m,t.streamId,"-audio"),ssrcs:jV(t.streamId,"audio",f.audio)}),I=el(el(el({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:s,msid:Nm(S=Nm(b="".concat(t.streamId)).call(b,null!==(E=this._context)&&void 0!==E&&E.avSync?"":"-video"," ")).call(S,t.streamId,"-video")},HV(t.streamId,f,{flexfec:this._enableSubFlexfec})),_={sdp:fV.write(el(el({},this.peer._answerSession),{},{media:[T,I]})),sequenceId:t.sequenceId?++t.sequenceId:0},null===(k=f)||void 0===k||delete k.next),rV()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:zV(v,d,l,!1),audioMid:a,videoMid:s,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:f,peerConnectionMode:this.peerConnectionMode,signalingAck:_});case 30:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=xm(wm().mark((function e(t){var r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==bB.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==bB.unpublish&&i!==bB.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=fV.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=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=fV.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){"audio"===(e=el(el({},e),l.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e)})),u=fV.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=Km(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,Km(a=c.media).call(a,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Ks(t).call(t,(function(e){var t;return-1===DE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Ks(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(fV.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=xm(wm().mark((function e(){var t,r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=fV.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Ks(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:fV.write(i),semantics:"unified-plan",type:"incroffer"});case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=xm(wm().mark((function e(t){var r,n,i;return wm().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=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f=this;return wm().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=fV.parse(null==l?void 0:l.sdp)).media=Km(i=h.media).call(i,(function(e){return u[e.mid]&&(e=GV(e)),"inactive"!==e.direction&&d.push(e.mid),el(el({},e),f.peer._offerIce)})),p=fV.parse(null===(o=this._peerConnection.remoteDescription)||void 0===o?void 0:o.sdp),v={},p.media.forEach((function(e){void 0!==e.mid&&(v[e.mid]=e)})),p.media=Km(a=h.media).call(a,(function(e){return"inactive"===e.direction?e:v[e.mid]})),h.groups&&p.groups&&(h.groups[0].mids=d.join(" "),p.groups[0].mids=d.join(" ")),e.next=19,this.setLocalDescription(null==l?void 0:l.sdp);case 19:return e.next=21,this.setRemoteDescription(fV.write(p));case 21:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=xm(wm().mark((function e(){return wm().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;fV.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(rF);function BG(e,t){var r=(new Error).stack;KP("[DCHECK FAILED] ".concat(t),-1,{stack:r})}var jG=cd,HG=ic,GG=function(e,t,r,n){for(var i,o=n>1?void 0:n?HG(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&&jG(t,r,o),o},zG=function(){function e(t){Hl(this,e),Zd(this,"_queue",[]),Zd(this,"_runningTask",[]),Zd(this,"executor",void 0),Zd(this,"busy",!1),this.executor=t}var t;return jl(e,[{key:"add",value:function(e){var t=qG(),r=t.promise,n=t.resolve,i=t.reject;return this._queue.push({item:e,resolve:n,reject:i}),this.busy||this._emit(),r}},{key:"destroy",value:function(){var e;Nm(e=[]).call(e,eT(this._queue),eT(this._runningTask)).forEach((function(e){(0,e.reject)(new SA(_A.OPERATION_CANCEL,"queue close"))})),this.busy=!1,this._queue=[]}},{key:"_emit",value:(t=xm(wm().mark((function e(){var t,r,n,i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._queue,this._runningTask=t,this._queue=[],0!==t.length){e.next=6;break}return this.busy=!1,e.abrupt("return");case 6:return r=Km(t).call(t,(function(e){return e.item})),n=Km(t).call(t,(function(e){return e.resolve})),i=Km(t).call(t,(function(e){return e.reject})),e.prev=9,this.busy=!0,e.next=13,this.executor(r);case 13:o=e.sent,n.forEach((function(e){return e(o)})),e.next=20;break;case 17:e.prev=17,e.t0=e.catch(9),i.forEach((function(t){return t(e.t0)}));case 20:return this._runningTask=[],setTimeout((function(){a._emit()})),e.abrupt("return");case 23:case"end":return e.stop()}}),e,this,[[9,17]])}))),function(){return t.apply(this,arguments)})}]),e}(),KG=function(e){UI(h,e);var t,r,n,i,o,a,s,c,u,d,l=eR(h);function h(e,t){var r;return Hl(this,h),Zd(sI(r=l.call(this,e,t)),"name","standard"),Zd(sI(r),"_applyQueue",new zG(r.apply.bind(sI(r)))),Zd(sI(r),"_createQueue",new zG(r.create.bind(sI(r)))),Zd(sI(r),"_pqueue",new WG),Zd(sI(r),"_midMap",new ib),Zd(sI(r),"_aRecvonlyOfferTpl",void 0),r.logger=new fM("StandardHandler",3,e.id),r.logger.warn("ctor","using standard handler"),r}return jl(h,[{key:"publish",value:(d=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,p,v,f,_;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("publish()","streamId: ".concat(t.streamId)),n=NI(DI(h.prototype),"internalPublish",this).call(this,t),i=n.videoDescriptions,o=n.subVideoDescriptions,a=n.audioTransceiverInit,s=n.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(a.track,el(el({},a.init),{},{direction:"sendonly"})),Array.isArray(s.init.sendEncodings)&&1===s.init.sendEncodings.length&&(s.init.sendEncodings=Km(c=s.init.sendEncodings).call(c,(function(e){return delete e.rid,e}))),t.videoTransceiver=this._peerConnection.addTransceiver(s.track,el(el({},s.init),{},{direction:"sendonly"})),u=tD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=9,this._createQueue.add();case 9:return d=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:tD()-u}),l=t.audioTransceiver.mid,p=t.videoTransceiver.mid,BG(0,"Transceiver not return MID after setLocalDescription"),t.audioMid=l,t.videoMid=p,v=null,f=null,(_=fV.parse(d)).media=null===(r=_.media)||void 0===r?void 0:Km(r).call(r,(function(e){return"".concat(e.mid)===l?v=e:"".concat(e.mid)===p&&(f=e),e})),rV()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:zV(_,v,f),audioMid:l,videoMid:p,type:"incroffer",semantics:"unified-plan",videoDescriptions:i,subVideoDescriptions:o,audioTransceiverInit:a,videoTransceiverInit:s,peerConnectionMode:this.peerConnectionMode});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"subscribe",value:(u=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R,A;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("subscribe()","streamId: ".concat(t.streamId)),c=!1,u=!1,d=void 0,l=void 0,t.virtual?c=!0:(r.multiChatMode||(c=!0),u=!0),c&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),u&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),h=tD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=12,this._createQueue.add();case 12:return p=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:tD()-h}),v=null!==(n=null===(i=t.audioTransceiver)||void 0===i?void 0:i.mid)&&void 0!==n?n:void 0,f=null!==(o=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid)&&void 0!==o?o:void 0,_=fV.parse(p),null===(s=_.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===v?d=e:"".concat(e.mid)===f&&(l=e)})),v&&d||(v="audio_".concat(f),d=el(el({},this._aRecvonlyOfferTpl),{},{mid:v})),t.audioMid=v,t.videoMid=f,m=void 0,g=void 0,!r.multiChatMode&&!t.virtual&&this._aSendonlyAnswerTpl&&this._aSendonlyAnswerTpl&&(m=this._generateAllSsrc(),R=el(el(el({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:v,msid:Nm(y=Nm(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:jV(t.streamId,"audio",m.audio)}),A=el(el(el({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:f,msid:Nm(E=Nm(k="".concat(t.streamId)).call(k,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},HV(t.streamId,m,{flexfec:this._enableSubFlexfec})),g={sdp:fV.write(el(el({},this.peer._answerSession),{},{media:[R,A]})),sequenceId:t.sequenceId?++t.sequenceId:0},null===(I=m)||void 0===I||delete I.next),rV()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:zV(_,d,l,!1),audioMid:v,videoMid:f||"",type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:m,peerConnectionMode:this.peerConnectionMode,signalingAck:g});case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"handleAck",value:(c=xm(wm().mark((function e(t){var r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==bB.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==bB.unpublish&&i!==bB.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=fV.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 c.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(s=xm(wm().mark((function e(t,r){var n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){"audio"===(e=el(el({},e),n.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,n._midMap.set(r.audioMid,e)):n._midMap.set(e.mid,e)),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,n._midMap.set(r.videoMid,e)):n._midMap.set(e.mid,e))})),r instanceof mB?this.handlePublishAction({stream:r}):this.handleSubscribeAction({stream:r}),e.next=7,this._applyQueue.add();case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handlePublishAction",value:function(e){var t,r,n,i,o,a,s,c,u=e.stream,d=u.audioMid?this._midMap.get(u.audioMid):void 0,l=u.videoMid?this._midMap.get(u.videoMid):void 0;null!==(t=this._context)&&void 0!==t&&t.pcKillSwitch.sld_rtcpfb_rrtr_add&&aV&&(XG.addRRTR(d),XG.addRRTR(l));var h,p=null!==(r=this._context)&&void 0!==r&&null!==(n=r.serverConfig)&&void 0!==n&&n.audioRed?"RED":"OPUS";("OPUS"!==p&&d&&function(e,t){if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){for(var r=0;r<e.rtp.length;r++)if(e.rtp[r].codec.toUpperCase()===t.toUpperCase()){var n;e.rtp.unshift(ak(n=e.rtp).call(n,r,1)[0]);break}var i=[];e.rtp.forEach((function(e){return i.push(e.payload)})),e.payloads=i.join(" ")}}(d,p),null!==(i=this._context)&&void 0!==i&&i.pcKillSwitch.sld_fmtp_opus_add)&&XG.decorateOpusConfig(d,null===(h=this._context)||void 0===h?void 0:h.audioProfileManager);DD&&tN<=87&&XG.removeRtxInMLine(l);var v=null===(o=this._context)||void 0===o||null===(a=o.serverConfig)||void 0===a?void 0:a.videoCodec;v&&l&&QV(l,v),null!==(s=this._context)&&void 0!==s&&s.pcKillSwitch.sld_ext_sdesmid_remove&&DD&&tN>=138&&XG.removeExtSdesMid(l),null!==(c=this._context)&&void 0!==c&&c.pcKillSwitch.sld_fmtp_bitrate_add&&(u.enableSimulcast||ND||!l||this.addBitrateLimit(l,u.videoEncodeConfig[0].maxKbps)),DD&&XG.selectCC(l,oV?"tcc":"remb"),u.audioMid&&d&&this._midMap.set(u.audioMid,d),u.videoMid&&l&&this._midMap.set(u.videoMid,l)}},{key:"handleSubscribeAction",value:function(e){var t,r,n,i=e.stream,o=i.audioMid?this._midMap.get(i.audioMid):void 0,a=i.videoMid?this._midMap.get(i.videoMid):void 0;DD||(XG.removeRtpStreamId(o),XG.removeRtpStreamId(a)),null!==(t=this._context)&&void 0!==t&&t.pcKillSwitch.sld_rtcpfb_rrtr_add&&aV&&(XG.addRRTR(o),XG.addRRTR(a)),null!==(r=this._context)&&void 0!==r&&r.pcKillSwitch.sld_fmtp_opus_add&&XG.decorateOpusConfig(o,this._context.audioProfileManager),kN("IOS_SAFARI_ORIENTATION")||!ND&&!WD||XG.removeExtVideoOrientation(a),null!==(n=this._context)&&void 0!==n&&n.pcKillSwitch.sld_fmtp_sps_add&&i.isPublic&&LD&&aN>=86&&XG.decorateSpsPpsIdrInKeyframe(a),i.audioMid&&o&&this._midMap.set(i.audioMid,o),i.videoMid&&a&&this._midMap.set(i.videoMid,a)}},{key:"getDefaultSdp",value:(a=xm(wm().mark((function e(){var t,r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=fV.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Ks(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),aV&&i.media.forEach((function(e){"audio"!==e.type&&"video"!==e.type||e.rtp.forEach((function(t){var r;e.rtcpFb||(e.rtcpFb=[]),kE(r=e.rtcpFb).call(r,(function(e){return e.payload===t.payload&&"rrtr"===e.type}))||e.rtcpFb.push({payload:t.payload,type:"rrtr"})}))})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:fV.write(i),semantics:"unified-plan",type:"incroffer"});case 14:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"rollback",value:(o=xm(wm().mark((function e(t){var r,n,i;return wm().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 o.apply(this,arguments)})},{key:"close",value:(i=xm(wm().mark((function e(t,r,n){var i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("close()"),i=t.audioMid||r,o=t.videoMid||n,t.audioTransceiver&&i)try{t.audioTransceiver.stop(),delete t.audioTransceiver}catch(c){}if(t.videoTransceiver&&o)try{t.videoTransceiver.stop(),delete t.videoTransceiver}catch(u){}return a=i?this._midMap.get(i):void 0,s=o?this._midMap.get(o):void 0,a&&GV(a),s&&GV(s),i&&a&&this._midMap.set(i,a),o&&s&&this._midMap.set(o,s),e.next=13,this._applyQueue.add();case 13:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return i.apply(this,arguments)})},{key:"setCurrentDescription",value:(n=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._applyQueue.add();case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;fV.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}},{key:"_generateAllSsrc",value:function(){var e=BV(this._nextSsrc);return this._nextSsrc=e.next,e}},{key:"create",value:(r=xm(wm().mark((function e(){var t,r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("RTCPeerConnection create"),e.next=3,this._peerConnection.createOffer();case 3:return t=e.sent,r=t.sdp,BG(0,"RTCPeerConnection not return SDP"),e.next=8,this.peer.setLocalDescription(r);case 8:return e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"apply",value:(t=xm(wm().mark((function e(){var t,r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("RTCPeerConnection apply"),e.next=3,this._peerConnection.createOffer();case 3:return t=e.sent,r=t.sdp,BG(0,"RTCPeerConnection not return SDP"),n=fV.parse(r),r=this.generateOffer(n,r),i=this.generateAnswer(n),e.next=11,this.setLocalDescription(r);case 11:return e.next=13,this.setRemoteDescription(i);case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"generateOffer",value:function(e,t){var r,n,i,o=this,a=!1;"v1"===this.peer.getIceVersion()&&DD&&(e.media=Km(n=e.media).call(n,(function(e){return el(el({},e),o.peer._offerIce)})),a=!0);null!==(r=this._context)&&void 0!==r&&r.pcKillSwitch.sld_rtcpfb_rrtr_add&&(e.media=Km(i=e.media).call(i,(function(e){return XG.addRRTR(e),e})),a=!0);return a?fV.write(e):t}},{key:"generateAnswer",value:function(e){var t=this,r=[];return e.media.forEach((function(e){if("application"===e.type){BG(e.mid,"should always have mid in mline");var n=t._midMap.get(e.mid);return n||(n=t.generateDCAnswer(e),t._midMap.set(e.mid,n)),void r.push(el({},n))}var i="".concat(e.mid);BG(0,"No MID in offer m-line: ".concat(e));var o=t._midMap.get(i);o||(t.logger.info("generateInactiveAnswerMLine","mid: %o, mLine: %o",e.mid,e),o=t.generateInactiveAnswerMLine(e)),r.push(o)})),this.peer.createAnswerSdp(r,e.groups)}},{key:"generateInactiveAnswerMLine",value:function(e){return el(el(el({},e),this.peer._answerIce),{},{direction:"inactive"})}},{key:"generateDCAnswer",value:function(e){var t=el(el(el({},e),this.peer._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}});return DD&&(delete t.bundleOnly,t.port=9),t}},{key:"destroy",value:function(){NI(DI(h.prototype),"destroy",this).call(this),this._pqueue.destroy(),this._applyQueue.destroy(),this._createQueue.destroy()}}]),h}(rF);GG([function(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var r,i,o,a,s,c=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=this.logger).info("SDP Lock","pending task %o",t),e.next=4,this._pqueue.enqueue(0);case 4:for(i=e.sent,r.info("SDP Lock","running task %o",t),e.prev=6,o=c.length,a=new Array(o),s=0;s<o;s++)a[s]=c[s];return e.next=10,null==n?void 0:n.apply(this,a);case 10:return e.abrupt("return",e.sent);case 11:return e.prev=11,r.info("SDP Lock","unlocking by task %o",t),i(),e.finish(11);case 15:case"end":return e.stop()}}),e,this,[[6,,11,15]])}))),r}],KG.prototype,"create",1),GG([function(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var r,i,o,a,s,c=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=this.logger).info("SDP Lock","pending task %o",t),e.next=4,this._pqueue.enqueue(1);case 4:for(i=e.sent,r.info("SDP Lock","running task %o",t),e.prev=6,o=c.length,a=new Array(o),s=0;s<o;s++)a[s]=c[s];return e.next=10,null==n?void 0:n.apply(this,a);case 10:return e.abrupt("return",e.sent);case 11:return e.prev=11,r.info("SDP Lock","unlocking by task %o",t),i(),e.finish(11);case 15:case"end":return e.stop()}}),e,this,[[6,,11,15]])}))),r}],KG.prototype,"apply",1);var XG={decorateOpusConfig:function(e,t){var r;if(e){var n=null==e?void 0:kE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&e.fmtp){var i,o=kE(i=e.fmtp).call(i,(function(e){return e.payload===n.payload}));o&&t&&(o.config=t.getOpusConfigStr(o.config))}}},removeRtxInMLine:function(e){var t,r,n,i;if(e){var o=[];e.rtp=Ks(t=e.rtp).call(t,(function(e){return"rtx"===e.codec&&o.push(e.payload),"rtx"!==e.codec})),e.fmtp=Ks(r=e.fmtp).call(r,(function(e){return bk(o).call(o,e.payload)})),e.payloads=null===(n=e.payloads)||void 0===n?void 0:Ks(i=n.split(" ")).call(i,(function(e){return!bk(o).call(o,vg(e))})).join(" ")}},removeExtSdesMid:function(e){var t;e&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Ks(t).call(t,(function(e){var t;return!bk(t=e.uri).call(t,"sdes:mid")})))},selectCC:function(e,t){var r,n;if(e)if("tcc"===t)e.ext=null===(r=e.ext)||void 0===r?void 0:Ks(r).call(r,(function(e){var t;return-1===DE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:Ks(n).call(n,(function(e){return"goog-remb"!==e.type}));else if("remb"===t){var i,o;e.rtcpFb=null===(i=e.rtcpFb)||void 0===i?void 0:Ks(i).call(i,(function(e){return"transport-cc"!==e.type})),e.ext=null===(o=e.ext)||void 0===o?void 0:Ks(o).call(o,(function(e){var t;return-1===DE(t=e.uri).call(t,"transport")}))}},addRRTR:function(e){e&&e.rtp.forEach((function(t){var r;e.rtcpFb||(e.rtcpFb=[]),kE(r=e.rtcpFb).call(r,(function(e){return e.payload===t.payload&&"rrtr"===e.type}))||e.rtcpFb.push({payload:t.payload,type:"rrtr"})}))},removeRtpStreamId:function(e){var t;e&&(Array.isArray(e.ext)&&(e.ext=Ks(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))))},decorateSpsPpsIdrInKeyframe:function(e){var t;if(e){var r=Ks(t=e.rtp).call(t,(function(e){return"H264"===e.codec}));r.length&&e.fmtp&&e.fmtp.forEach((function(e){kE(r).call(r,(function(t){return t.payload===e.payload}))&&(e.config+=";sps-pps-idr-in-keyframe=1")}))}},removeExtVideoOrientation:function(e){var t;e&&(Array.isArray(e.ext)&&(e.ext=Ks(t=e.ext).call(t,(function(e){var t;return!bk(t=e.uri).call(t,"video-orientation")}))))},removeExtFramemarking:function(e){var t;e&&(Array.isArray(e.ext)&&(e.ext=Ks(t=e.ext).call(t,(function(e){var t;return!bk(t=e.uri).call(t,"framemarking")}))))}},WG=function(){function e(){Hl(this,e),Zd(this,"queue",[]),Zd(this,"processing",!1)}var t;return jl(e,[{key:"enqueue",value:(t=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u=this,d=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=d.length>0&&void 0!==d[0]?d[0]:0,n=qG(),i=n.promise,o=n.resolve,a={priority:r,resolve:o},-1===(s=eA(t=this.queue).call(t,(function(e){return e.priority>r})))?this.queue.push(a):ak(c=this.queue).call(c,s,0,a),this.tryProcess(),e.next=8,i;case 8:return this.processing=!0,e.abrupt("return",(function(){u.processing=!1,u.tryProcess()}));case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this.queue.forEach((function(e){(0,e.resolve)()})),this.queue=[],this.processing=!1}},{key:"tryProcess",value:function(){if(!this.processing){var e=this.queue.shift();e&&e.resolve()}}}]),e}();function qG(){var e=void 0,t=void 0,r=new $_((function(r,n){e=r,t=n}));if(!e||!t)throw Error("Broken Implement of Promise");return{promise:r,resolve:e,reject:t}}var YG,JG,QG=function(e,t){return e.enableFallbackHandler?new FG(e,t):e.enableStandardHandler?new KG(e,t):DD?new VG(e,t):new UG(e,t)},ZG=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}(ZG||{}),$G=function(e){return e.PushLimitWarn="PushLimitWarn",e}($G||{}),ez=function(e){return e.ON_ADD_STREAM="onAddStream",e.ON_ADD_STREAM_LIST="onAddStreamList",e.ON_REMOVE_STREAM="onRemoveStream",e.ON_REMOVE_STREAM_LIST="onRemoveStreamList",e.USER_DISCONNECTION="userDisconnection",e.USER_DISCONNECTION_LIST="userDisconnectionList",e.USER_CONNECTION="userConnection",e.USER_CONNECTION_LIST="userConnectionList",e.ON_UPDATE_STREAM_ATTRIBUTES="onUpdateStreamAttributes",e.ON_UPDATE_ROOM_ATTRIBUTES="onUpdateRoomAttributes",e.ON_UPDATE_USER_ATTRIBUTES="onUpdateUserAttributes",e.ON_PUSH_TRACK="onPushTrack",e.ON_REMOVE_TRACK="onRemoveTrack",e.ON_CUSTOM_MESSAGE="onCustomMessage",e.NODE_CHANGE="nodeChange",e.USER_MESSAGE_RECEIVED="userMessageReceived",e.USER_BINARY_MESSAGE_RECEIVED="userBinaryMessageReceived",e.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM="userMessageReceivedOutsideRoom",e.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM="userBinaryMessageReceivedOutsideRoom",e.POST_PROCESSING_MESSAGE="postProcessingMessage",e.ON_USER_TOKEN_WILL_EXPIRE="onUserTokenWillExpire",e.STREAM_CONTROL_MESSAGE="streamControlMessage",e.ON_SPEAKER_CHANGE="onSpeakerChange",e.ON_STREAM_FAILED="streamFailed",e.ON_NOTIFY_RECONNECT="notifyReconnect",e.ON_FORWARD_DST_ROOM_USER_KICK="onForwardDstRoomUserKick",e}(ez||{}),tz=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(tz||{}),rz=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ON_VENDOR_CONNECTION_STATE_CHANGE="onVendorConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(rz||{}),nz=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(nz||{}),iz=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(iz||{}),oz=new fM("Locker",2),az=1,sz=function(){function e(t){var r;Hl(this,e),Zd(this,"lockingPromise",$_.resolve()),Zd(this,"locks",0),Zd(this,"name",""),Zd(this,"lockId",void 0),this.lockId=az++,t&&(this.name=t),oz.info(Nm(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return jl(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,oz.info(Nm(e=Nm(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new $_((function(e){r=function(){var t,r;n.locks-=1,oz.info(Nm(t=Nm(r="[lock-".concat(n.name,"-")).call(r,n.lockId,"] unlocked, current queue ")).call(t,n.locks,".")),e()}})),o=this.lockingPromise.then((function(){return r}));return this.lockingPromise=this.lockingPromise.then((function(){return i})),o}}]),e}(),cz=function(e){return e.RESUBSCRIBE="resubscribe",e.STREAM_FAILED="stream_failed",e.SUBSCRIBE_PUSH_TRACK="subscribe_push_track",e.REMOVE_PUSH_TRACK="remove_push_track",e.VIDEO_FIRST_FRAME="video_first_frame",e.ON_USER_PUBLISH_STATE_CHANGE="on_user_publish_state_change",e.ON_USER_START_AUDIO_CAPTURE="on_user_start_audio_capture",e.ON_USER_STOP_AUDIO_CAPTURE="on_user_stop_audio_capture",e.ON_USER_START_VIDEO_CAPTURE="on_user_start_video_capture",e.ON_USER_STOP_VIDEO_CAPTURE="on_user_stop_video_capture",e.ON_SEI_MESSAGED_RECEIVED="on_sei_messaged_received",e.ON_PUBLISH_RESULT="on_publish_result",e.ON_UPDATE_TOKEN_SUCCESS="on_update_token_success",e.ON_REMOTE_STREAM_STATS="ON_REMOTE_STREAM_STATS",e.ON_LOCAL_STREAM_STATS="ON_LOCAL_STREAM_STATS",e.ON_USER_LEAVE="on_user_leave",e.ON_ROOM_ERROR="on_room_error",e.ON_NETWORK_QUALITY="on_network_quality",e.ON_SIMULCAST_SUBSCRIBE_FALLBACK="on_simulcast_subscribe_fallback",e.ON_REMOTE_VIDEO_SIZE_CHANGED="on_remote_video_size_changed",e.RECONNECT_FAILED="reconnect_failed",e.ON_SUBTITLE_STATE_CHANGED="ON_SUBTITLE_STATE_CHANGED",e.ON_SUBTITLE_MESSAGE_RECEIVED="ON_SUBTITLE_MESSAGE_RECEIVED",e.ON_VIDEO_STREAM_BANNED="ON_VIDEO_STREAM_BANNED",e.ON_AUDIO_STREAM_BANNED="ON_AUDIO_STREAM_BANNED",e.ON_FORWARD_STREAM_ERROR="ON_FORWARD_STREAM_ERROR",e.ON_REJOIN_WITH_TCP="ON_REJOIN_WITH_TCP",e.ON_ICE_CONNECT_WITH_TCP="ON_ICE_CONNECT_WITH_TCP",e.PUB_RETRY="PUB_RETRY",e.SUB_RETRY="SUB_RETRY",e}(cz||{}),uz=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}(uz||{}),dz=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(dz||{}),lz=(Zd(YG={},Il.communication,[0]),Zd(YG,Il.chat,[0]),Zd(YG,Il.chatRoom,[1,"IES_chatroom"]),Zd(YG,Il.coHost,[1,"IES_PK"]),Zd(YG,Il.meeting,[16]),Zd(YG,Il.classRoom,[0]),YG),hz=rV(),pz=function(e){UI(s,e);var t,r,n,i,o,a=eR(s);function s(e,t){var r;return Hl(this,s),Zd(sI(r=a.call(this,e,t)),"_peerConnectionId",eD()),Zd(sI(r),"peerConnectionMode",1),Zd(sI(r),"name","vendor"),Zd(sI(r),"direction","up"),Zd(sI(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 jl(s,[{key:"publish",value:(o=xm(wm().mark((function e(t){var r,n,i,o,a,c,u,d,l,h,p=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.enableSimulcast=!1,this.stream=t,r=NI(DI(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),hz&&(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=tD(),d=fV.parse(c.sdp),Array.isArray(d.media)&&(d.media=Km(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&&QV(e,null===(i=p._context)||void 0===i||null===(o=i.serverConfig)||void 0===o?void 0:o.videoCodec),(ND||WD)&&Array.isArray(e.ext)&&(e.ext=Ks(a=e.ext).call(a,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&bk(t).call(t,"video-orientation"))}))),ND||p.addBitrateLimit(e,t.videoEncodeConfig[0].maxKbps);else if("audio"===e.type){var s,c=null==e?void 0:kE(s=e.rtp).call(s,(function(e){return"opus"===e.codec}));if(c&&e.fmtp){var u,d,l=kE(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:fV.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:tD()-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:tD()-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=xm(wm().mark((function e(t){var r,n,i,o,a,s=this;return wm().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"}),hz&&(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=tD(),i=fV.parse(r.sdp),Array.isArray(i.media)&&(i.media=Km(o=i.media).call(o,(function(e){if("audio"===e.type){var t,r=null==e?void 0:kE(t=e.rtp).call(t,(function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n,i=null==e?void 0:kE(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:fV.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:tD()-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:tD()-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=xm(wm().mark((function e(t){var r,n,i,o,a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.action!==bB.publish&&t.action!==bB.subscribe){e.next=16;break}return n=new RTCSessionDescription({sdp:null===(r=t.signalingAck)||void 0===r?void 0:r.sdp,type:"answer"}),i=tD(),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:tD()-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:tD()-i},{type:"offer"}),e.t0;case 13:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=17;break;case 16:t.action!==bB.unpublish&&t.action!==bB.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(),NI(DI(s.prototype),"destroy",this).call(this)}},{key:"getDefaultSdp",value:(r=xm(wm().mark((function e(){return wm().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=xm(wm().mark((function e(){return wm().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}(rF),vz=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}(vz||{}),fz={start_interval:100,multiplier:2,max_interval:3e4},_z=function(){function e(){Hl(this,e),Zd(this,"_times",0),Zd(this,"_config",fz),Zd(this,"initTs",tD())}return jl(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}(),mz=function(){function e(t){Hl(this,e),Zd(this,"_reconnectTimer",void 0),Zd(this,"_abortControllers",[]),Zd(this,"_monitor",void 0),Zd(this,"logger",void 0),Zd(this,"_groupConfigId",eD()),Zd(this,"_retryLimiter",new _z),Zd(this,"_timer",void 0),this._ctx=t,this._monitor=qP(t.id),this.logger=new fM("ICERequest",4,t.id)}var t,r,n,i,o;return jl(e,[{key:"getICENode",value:(o=xm(wm().mark((function e(t){var r;return wm().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 SA(_A.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 $_((function(n,i){t._getAccessNode(e).then((function(e){t._retryLimiter.reset(),n(e)})).catch((function(o){if(Array.isArray(o)&&o.length>0){if(eA(o).call(o,(function(e){return 400<=e.code&&e.code<500}))>-1)return t._retryLimiter.reset(),i(new Error("HTTP request failed(4xx)"));if(o.every((function(e){var t;return 201===e.code||201===(null===(t=e.error)||void 0===t?void 0:t.code)}))&&r++,3===r)return t._retryLimiter.reset(),i(new Error("HTTP request failed(201)"))}var a=t._retryLimiter.getRetryDelay();t.logger.warn("_getAccessWithRetry()","_getAccessWithRetry error, will retry after ".concat(a,"ms"),o),t._reconnectTimer=self.setTimeout((function(){t._getAccessWithRetry(e,r).then(n).catch(i)}),a)}))}))}},{key:"_getAccessNode",value:(i=xm(wm().mark((function e(t){var r=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new $_((function(e,n){var i=vN.getAccessNode(r._ctx.appId);i?(r.logger.info("getAccessNode","use cache node."),e(Array.isArray(i)?i:[i]),r._timer=window.setTimeout((function(){r._getAccessNodeFromServer(t),r._reportRtcInvokeStatus("es.R.node.cache",i),delete r._timer}),0)):r._getAccessNodeFromServer(t).then(e).catch(n)})));case 1:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"_getAccessNodeFromServer",value:(n=xm(wm().mark((function e(t){var r,n,i,o=this;return wm().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&&vN.setAccessNode(o._ctx.appId,t,e.ttl||11200),e.dispatchDomains&&!o._ctx.useCloudProxy&&vN.setAccessUrls(e.dispatchDomains),t})).catch((function(e){if(i)return o._reportRtcInvokeStatus("es.R.req.fallback",""),vN.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=vN.getAccessUrls()||[],t=!0;return this._reportRtcInvokeStatus("es.R.req.cache.urls",e),0===e.length&&(e=bN.ICE_CONFIG_REQUEST_URLS,t=!1,this._reportRtcInvokeStatus("es.R.req.external.urls",e)),0===e.length&&(e=bN.ICE_CONFIG_REQUEST_URLS_INTERNAL,t=!1,this._reportRtcInvokeStatus("es.R.req.internal.urls",e)),{urls:e,needFallback:t}}},{key:"getICEConfigFromServer",value:(r=xm(wm().mark((function e(t,r){var n,i,o,a,s=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={appID:this._ctx.appId,deviceID:vN.getDeviceId(),os:"web",sdkVersion:bN.VERSION,isOversea:bN.OVERSEA,expectedAddr:kN("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC,accessParams:Fm({requireICEUfragV2:!0}),userAgent:navigator.userAgent},r&&(n.feedbackInfo=r,"ICE_FAILED"!==(null===(i=r[0])||void 0===i||null===(o=i.feedbackReason)||void 0===o?void 0:o.type)&&delete n.expectedAddr),a=Km(t).call(t,(function(e){return s._httpRequest(e,n)})),e.abrupt("return",_D(a));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_httpRequest",value:(t=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=eD(),r.connectSessionID=i,o=Date.now(),null===(n=this._monitor)||void 0===n||n.report("rtc_get_access",{error_code:0,message:Fm(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:Fm(r),signal:a.signal});case 10:s=e.sent,e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),bw(fetch)||null===(d=this._monitor)||void 0===d||d.report("rtc_error",{error_code:vz.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=Ks(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:Fm(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:Fm(e.t1)}),e.t1;case 33:case"end":return e.stop()}}),e,this,[[6,29],[7,13]])}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._abortControllers.forEach((function(e){return e.abort()})),this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer),this._timer&&(window.clearTimeout(this._timer),delete this._timer)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r;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}(),gz=rV(),yz={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"},Sz=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}(Sz||{}),bz=0,Ez=function(e){UI(c,e);var t,r,n,i,o,a,s=eR(c);function c(e,t){var r;return Hl(this,c),Zd(sI(r=s.call(this)),"uuid",(bz++).toString()),Zd(sI(r),"_peerConnectionId",""),Zd(sI(r),"audioTrack4ff",void 0),Zd(sI(r),"_pc",void 0),Zd(sI(r),"_dc",void 0),Zd(sI(r),"_iceNode",void 0),Zd(sI(r),"_initSctpEvents",!1),Zd(sI(r),"_monitor",void 0),Zd(sI(r),"_offerIce",{}),Zd(sI(r),"_answerIce",{}),Zd(sI(r),"_offerSession",void 0),Zd(sI(r),"_answerSession",void 0),Zd(sI(r),"_offerMlines",[]),Zd(sI(r),"_answerMlines",[]),Zd(sI(r),"_connectReject",void 0),Zd(sI(r),"_logger",void 0),Zd(sI(r),"_peerConfig",void 0),r._ctx=e,r._groupConnectionId=t,r._monitor=qP(e.id),r._logger=new fM("PeerConnection_".concat(r.uuid),4,e.id),r._ctx.enableFallbackHandler&&r._logger.warn("ctor","PeerConnection running in fallback mode"),r._peerConfig=kz(e),r._pc=new RTCPeerConnection(r._peerConfig),r._pc.ontrack=function(e){var t,n,i,o,a=null===(t=e.streams)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.id;r._print("pc.ontrack",Nm(i=Nm(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",Nm(e="".concat(r._pc.connectionState,". ice -> ")).call(e,r._pc.iceConnectionState)),"failed"!==r._pc.iceConnectionState&&"closed"!==r._pc.iceConnectionState&&"failed"!==r._pc.connectionState||r.emit("disconnect","ice failed")},r._pc.oniceconnectionstatechange=function(){var e=r._pc.iceConnectionState;r._report("rtc_pre_ice_state",{message:e,ice_state:e.toUpperCase()}),r.emit("ice_state",e)},r}return jl(c,[{key:"getOriginRTCPeerConnection",value:function(){return this._pc}},{key:"getOriginRTCDataChannel",value:function(){return this._dc}},{key:"getConnectionId",value:function(){return this._peerConnectionId}},{key:"getGroupConnectionId",value:function(){return this._groupConnectionId}},{key:"connect",value:(a=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._ctx.enableStandardHandler){e.next=2;break}return e.abrupt("return",this.startIceConnectStandard(t));case 2:return this._print("connect","invoke. %o",t),this._iceNode=t,(r=this._pc.createDataChannel("signaling",{negotiated:!0,id:100})).binaryType="arraybuffer",this._dc=r,e.next=9,this._genIceInfo(t);case 9:return n=e.sent,i=n.offerIce,o=n.answerIce,this._offerIce=i,this._answerIce=o,DD&&tN<138&&(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 SA(_A.NOT_SUPPORTED,"create offer sdp failed.");case 20:if(s=fV.parse(a.sdp),this._peerConnectionId=o.iceUfrag||"",(c=!i.iceUfrag&&!i.icePwd)&&((h="renomination"===(null===(u=s.media[0])||void 0===u?void 0:u.iceOptions))||(delete i.iceOptions,delete o.iceOptions),delete i.iceUfrag,delete i.icePwd,p=JV({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(d=s.media[0])||void 0===d?void 0:d.icePwd,options:(l={},Zd(l,YV.kICEConfigTypeSrtpDtlsType,!0),Zd(l,YV.kICEConfigTypeRenominationType,h),l)}),v=aI(p,2),f=v[0],_=v[1],this._peerConnectionId=_,o.iceUfrag=f,this._logger.info("use serverUfrag v2",Fm({dtls:!0,renomination:h}))),m=aI(s.media,1),g=m[0],this._offerIce.fingerprint=s.fingerprint||g.fingerprint,!DD&&!this._ctx.enableFallbackHandler){e.next=42;break}if(s.media=Km(y=s.media).call(y,(function(e){var t,r,n=el(el({},e),E._offerIce);return"video"===n.type&&(n.ext=null===(t=n.ext)||void 0===t?void 0:Ks(t).call(t,(function(e){var t;return-1===DE(t=e.uri).call(t,"abs-send-time")})),n.rtcpFb=null===(r=n.rtcpFb)||void 0===r?void 0:Ks(r).call(r,(function(e){return"goog-remb"!==e.type}))),n})),(b=el({},s)).fingerprint=this._answerIce.fingerprint,b.media=Km(S=b.media).call(S,(function(e){return delete(e=el(el({},e),E._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),!this._ctx.enableFallbackHandler){e.next=36;break}return e.next=34,this.setLocalDescription(a.sdp);case 34:e.next=38;break;case 36:return e.next=38,this.setLocalDescription(fV.write(s));case 38:return e.next=40,this.setRemoteDescription(fV.write(b));case 40:e.next=51;break;case 42:delete s.media,this._offerSession=el({},s),this._answerSession=el({},s),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),c&&(this._offerIce.iceUfrag=g.iceUfrag,this._offerIce.icePwd=g.icePwd),this._offerMlines=[el(el(el({},g),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[el(el(el({},g),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription();case 51:return e.next=53,new $_((function(e,t){E._connectReject=t,r.onopen=function(){E._print("connect","dataChannel open"),E._reportRtcInvokeStatus("es.dc.open",""),e(""),delete E._connectReject},r.onerror=function(e){var t,r,n,i;E._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"}),E._reportRtcInvokeStatus("es.dc.error",""),null===(n=E._connectReject)||void 0===n||n.call(E,{message:"dc.onerror, ".concat(null===(i=e.error)||void 0===i?void 0:i.errorDetail),code:0}),E.emit("disconnect","dc onerror"),delete E._connectReject},r.onclose=function(){var e;E._reportRtcInvokeStatus("es.dc.close",""),null===(e=E._connectReject)||void 0===e||e.call(E,{message:"dc.onclose",code:1}),E.emit("disconnect","dc onclose"),delete E._connectReject},E._pc.addEventListener("connectionstatechange",(function(){var e,t;"failed"!==E._pc.iceConnectionState&&"closed"!==E._pc.iceConnectionState&&"failed"!==E._pc.connectionState||(null===(e=E._connectReject)||void 0===e||e.call(E,{message:Nm(t="pc.connectionstatechange -> ".concat(E._pc.connectionState,", ice -> ")).call(t,E._pc.iceConnectionState),code:2}),delete E._connectReject)})),setTimeout((function(){var e;null===(e=E._connectReject)||void 0===e||e.call(E,{code:4,message:"connect timeout"}),delete E._connectReject}),8e3)}));case 53:return this._print("connect","dataChannel establish success"),e.abrupt("return",r);case 55:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"startIceConnectStandard",value:(o=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("connect","standard invoke. %o",t),this._iceNode=t,(i=this._pc.createDataChannel("signaling",{negotiated:!0,id:100})).binaryType="arraybuffer",this._dc=i,e.next=7,this._genIceInfo(t);case 7:return o=e.sent,a=o.offerIce,s=o.answerIce,this._offerIce=a,this._answerIce=s,DD&&tN<138&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=15,this._pc.createOffer();case 15:if(c=e.sent,u=c.sdp){e.next=19;break}throw new SA(_A.NOT_SUPPORTED,"create offer sdp failed.");case 19:if(d=fV.parse(u),this._answerSession=el({},d),l=kE(r=d.media).call(r,(function(e){return"application"===e.type})),this._peerConnectionId=s.iceUfrag||"",!a.iceUfrag&&!a.icePwd&&((p="renomination"===(null==l?void 0:l.iceOptions))||(delete a.iceOptions,delete s.iceOptions),delete a.iceUfrag,delete a.icePwd,v=JV({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null==l?void 0:l.icePwd,options:(h={},Zd(h,YV.kICEConfigTypeSrtpDtlsType,!0),Zd(h,YV.kICEConfigTypeRenominationType,p),h)}),f=aI(v,2),_=f[0],m=f[1],this._peerConnectionId=m,s.iceUfrag=_,this._logger.info("use serverUfrag v2",Fm({dtls:!0,renomination:p}))),this._offerIce.fingerprint=d.fingerprint||(null==l?void 0:l.fingerprint),(g=el({},d)).fingerprint=this._answerIce.fingerprint,g.media=Km(n=g.media).call(n,(function(e){if("application"===(e=el(el({},e),S._answerIce)).type&&(e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}),DD)if(delete e.bundleOnly,e.port=9,"audio"===e.type)e.msid="ff-stream ff-stream-audio",e.direction="sendonly";else if("video"===e.type){var t,r,n,i;oV?(e.ext=null===(t=e.ext)||void 0===t?void 0:Ks(t).call(t,(function(e){var t;return-1===DE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Ks(r).call(r,(function(e){return"goog-remb"!==e.type}))):(e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:Ks(n).call(n,(function(e){return"transport-cc"!==e.type})),e.ext=null===(i=e.ext)||void 0===i?void 0:Ks(i).call(i,(function(e){var t;return-1===DE(t=e.uri).call(t,"transport")}))),e.direction="sendonly"}return e})),"v1"!==this.getIceVersion()){e.next=35;break}return d.media=Km(y=d.media).call(y,(function(e){return e=el(el({},e),S._offerIce)})),e.next=33,this.setLocalDescription(fV.write(d));case 33:e.next=37;break;case 35:return e.next=37,this.setLocalDescription(u);case 37:return e.next=39,this.setRemoteDescription(fV.write(g));case 39:return e.next=41,new $_((function(e,t){S._connectReject=t,i.onopen=function(){S._print("connect","dataChannel open"),S._reportRtcInvokeStatus("es.dc.open",""),e(""),delete S._connectReject},i.onerror=function(e){var t,r,n,i;S._report("rtc_signaling_msg_error",{error_code:null==e||null===(t=e.error)||void 0===t?void 0:t.sdpLineNumber,message:null==e||null===(r=e.error)||void 0===r?void 0:r.errorDetail,reason:"invalid data"}),S._reportRtcInvokeStatus("es.dc.error",""),null===(n=S._connectReject)||void 0===n||n.call(S,{message:"dc.onerror, ".concat(null===(i=e.error)||void 0===i?void 0:i.errorDetail),code:0}),S.emit("disconnect","dc onerror"),delete S._connectReject},i.onclose=function(){var e;S._reportRtcInvokeStatus("es.dc.close",""),null===(e=S._connectReject)||void 0===e||e.call(S,{message:"dc.onclose",code:1}),S.emit("disconnect","dc onclose"),delete S._connectReject},S._pc.addEventListener("connectionstatechange",(function(){var e,t;"failed"!==S._pc.iceConnectionState&&"closed"!==S._pc.iceConnectionState&&"failed"!==S._pc.connectionState||(null===(e=S._connectReject)||void 0===e||e.call(S,{message:Nm(t="pc.connectionstatechange -> ".concat(S._pc.connectionState,", ice -> ")).call(t,S._pc.iceConnectionState),code:2}),delete S._connectReject)})),setTimeout((function(){var e;null===(e=S._connectReject)||void 0===e||e.call(S,{code:4,message:"connect timeout"}),delete S._connectReject}),8e3)}));case 41:return this._print("connect","dataChannel establish success"),e.abrupt("return",i);case 43:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setDescription",value:(i=xm(wm().mark((function e(t){var r,n;return wm().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=tD(),t&&this._report("rtc_begin_create_offer",{direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,pc_session_id:this._peerConnectionId,vendor_mode:0}),t&&this._report("rtc_create_offer",{error_code:0,direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,elapse:tD()-n}),e.next=11,this.setLocalDescription(fV.write(this._offerSession),t);case 11:return e.next=13,this.setRemoteDescription(fV.write(this._answerSession),t);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setLocalDescription",value:(n=xm(wm().mark((function e(t,r){var n,i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=tD(),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:tD()-n},{type:"offer"}),this._initSctpEvents||(this._initSctpEvents=!0,(o=null===(i=this._pc)||void 0===i?void 0:i.sctp)&&(o.onstatechange=function(){a._reportRtcInvokeStatus("sctp","sctp state change TO: ".concat(o.state))},o.transport&&(o.transport.onstatechange=function(){var e;a._reportRtcInvokeStatus("dtls","dtls state change TO: ".concat(null==o||null===(e=o.transport)||void 0===e?void 0:e.state))}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:"",stream_user_id:"",elapse:tD()-n},{type:"offer"});case 12:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(r=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=tD(),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:tD()-n},{type:"answer"}),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(1),console.error("setRemote",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:tD()-n},{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"disconnect",value:function(){var e,t;null===(e=this._connectReject)||void 0===e||e.call(this,{code:3,message:"invoke destroy()"}),delete this._connectReject,this._pc.close(),null===(t=this._dc)||void 0===t||t.close(),this._pc.ontrack=null}},{key:"getIceVersion",value:function(){var e,t;return null!==(e=this._iceNode)&&void 0!==e&&e.iceParams.clientIceUfrag||null!==(t=this._iceNode)&&void 0!==t&&t.iceParams.clientIcePwd?"v1":"v2"}},{key:"createAnswerSdp",value:function(e,t){BG(this._answerSession,"_answerSession should be existed");var r=el({},this._answerSession);return r.media=e,r.groups=t,fV.write(r)}},{key:"destroy",value:function(){this._print("destroy",this._peerConnectionId),NI(DI(c.prototype),"removeAllListeners",this).call(this),this.disconnect()}},{key:"_genIceInfo",value:(t=xm(wm().mark((function e(t){var r,n,i,o;return wm().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,KV(t);case 3:return o=e.sent,e.abrupt("return",{offerIce:i,answerIce:o});case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"_print",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];(t=this._logger).info.apply(t,Nm(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,el(el({},t),{},{connection_id:this._peerConnectionId,group_connection_id:this._groupConnectionId}),el(el({},r),{},{tcp_only:null===(i=this._iceNode)||void 0===i?void 0:i.iceConfig.tcpOnly,ms_addr:Fm((null===(o=this._iceNode)||void 0===o?void 0:Km(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 SA(_A.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 SA(_A.NOT_SUPPORTED,"missing peer.".concat(e," API."))}))}}]),c}($N),kz=function(e){var t=el({},yz);return e.pcKillSwitch.ctor_sdpsemantics_add&&(t.sdpSemantics="unified-plan"),e.pcKillSwitch.ctor_encodedinsetablestream_add&&gz&&(t.encodedInsertableStreams=!0),t};function Tz(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],DE(t).call(t,r)>=0||(i[r]=e[r]);return i}(e,t);if(Ms){var o=Ms(e);for(n=0;n<o.length;n++)r=o[n],DE(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var Iz=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(Iz||{}),Rz=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}(Rz||{}),Az=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}(Az||{}),wz=(Zd(JG={},0,[0,"success"]),Zd(JG,1,[_A.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),Zd(JG,2,[_A.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),Zd(JG,3,[_A.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),Zd(JG,4,[_A.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),Zd(JG,5,[_A.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),Zd(JG,17,[_A.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),Zd(JG,18,[_A.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),Zd(JG,100,[_A.USER_MESSAGE_NOT_JOIN,"not join room"]),Zd(JG,105,[_A.USER_MESSAGE_NOT_LOGIN,"not login."]),Zd(JG,106,[_A.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),Zd(JG,1e3,[_A.USER_MESSAGE_UNKNOWN,"unknown."]),JG),Cz=["msg"],xz=[],Oz=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}(Oz||{}),Pz=function(e){UI(a,e);var t,r,n,i,o=eR(a);function a(e,t){var r;return Hl(this,a),Zd(sI(r=o.call(this)),"_singlingCache",new ib),Zd(sI(r),"_p2pCache",new ib),Zd(sI(r),"_rttIds",{}),Zd(sI(r),"_p2pMessageId",1),Zd(sI(r),"_clearDataChannelListener",void 0),Zd(sI(r),"_monitor",void 0),Zd(sI(r),"logger",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=qP(e),r.logger=new fM("DataChannelSignaling",3,e),r}return jl(a,[{key:"destroy",value:function(){var e=this;this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.forEach((function(t,r){t.error(new SA(_A.OPERATION_CANCEL,"disconnect")),e._singlingCache.delete(r)})),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=1,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n,i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:3e4;return null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:Fm(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new $_((function(n,a){var s,c=i._genHeader(r);c.id=iD();var u=c.id.join("-"),d="customMessage"===e;d&&VP.samplingOne2ManyMsg(i.id,Number(c.id.join("")),t);var l=setTimeout((function(){i._singlingCache.delete(u),a(new SA(_A.TIME_OUT,"".concat(e," message time out"))),d&&VP.updateOne2ManyMsgAck(i.id,t,999)}),o);i._singlingCache.set(u,{signalingType:e,success:function(e){clearTimeout(l),n(e),d&&VP.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(l),a(e),d&&VP.updateOne2ManyMsgAck(i.id,t,e.code)}}),i.logger.info("Signal",Nm(s=">>>>>> [".concat(e,"][")).call(s,u,"]"),t),i._sendMessage(e,c,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=xm(wm().mark((function e(t,r){var n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=Tz(t,Cz),o=n instanceof ArrayBuffer,e.t0=this,e.t1=VP,e.t2=this.id,e.t3=el,e.t4=el({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:Iz.SEND,type:Rz.P2P,err:Az.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,nD.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 aD(e.msg)?this._rttIds[e.id]=e.id:e.dir===Iz.SEND&&this.logger.info("_sendP2PMessage [DC Signaling p2p >>]",Fm(e)),new $_((function(n,i){var o=t._genHeader(el(el({needAck:!0,functionType:1},r),{},{id:iD()}));if(e.dir===Iz.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new SA(_A.USER_MESSAGE_TIMEOUT,"P2P message timeout")),VP.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),VP.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),VP.updateP2PMsgAck(t.id,e,r.err);var o=aI(wz[r.err]||[_A.USER_MESSAGE_UNKNOWN,Nm(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===_A.NOT_CONNECTED_YET&&(s.code=_A.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new SA(_A.NOT_CONNECTED_YET,"DataChannel not open");var i=kN("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=nD.str2ab(Fm([e,r])),c=rD(Uint8Array,Nm(n=[o,a]).call(n,eT(t.id||[])),i||t.zip?EP.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:vz.DC_SEND_ERROR}),d}"p2p"===e?VP.updateP2PMsgReq(this.id,r,c.buffer.byteLength):"customMessage"===e&&VP.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=Zk(Am(t).call(t,2,r))}return{header:o,data:Am(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:Km(n=e.split("-")).call(n,(function(e){return Number(e)}))});bk(xz).call(xz,t)||this.logger.info("Signal",Nm(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d;return wm().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 EP.Inflate).push(o,!0),o=s.result),c=nD.ab2str(o),u=[],e.prev=8,u=JSON.parse(c),e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(8),e.t0 instanceof Error&&(null===(d=this._monitor)||void 0===d||d.report("rtc_signaling_msg_error",{error_code:-1,message:e.t0.message,reason:"message parse failed"})),e.abrupt("return");case 16:e.t1=a.functionType,e.next=0===e.t1?19:1===e.t1?21:2===e.t1?23:25;break;case 19:return this.C2S(a,u,c,n,r),e.abrupt("break",26);case 21:return this.C2C(u,n,r),e.abrupt("break",26);case 23:return this.C2GW(a,u,c),e.abrupt("break",26);case 25:return e.abrupt("break",26);case 26:case"end":return e.stop()}}),e,this,[[8,12]])}))),function(e){return n.apply(this,arguments)})},{key:"C2S",value:(r=xm(wm().mark((function e(t,r,n,i,o){var a,s,c,u,d;return wm().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],bk(xz).call(xz,u)||this.logger.info("Signal","<<<<<< ".concat(u),r,s),this._feedbackSignaling(s,u,u===ez.ON_CUSTOM_MESSAGE?el(el({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,nD.b64str2ab(r.message);case 13:r.message=e.sent;case 14:d=Date.now(),this.emit(u,el({},r)),u===ez.ON_CUSTOM_MESSAGE&&VP.reportOne2ManyMsgRecv(this.id,r,{msg_size:i,recv_msg_ts:o,fwd_msg_ts:d}),null===(c=this._monitor)||void 0===c||c.report("rtc_signaling",{error_code:0,message:n,signaling_event:"on-".concat(u),signaling_type:"Recv",stream_id:r.streamId,stream_user_id:r.clientId,direction:"down"});case 18:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"C2C",value:(t=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_;return wm().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)===Iz.FEEDBACK||aD(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===Iz.SEND?6:e.t0===Iz.FEEDBACK?46:48;break;case 6:if(u=Date.now(),aD(null===(s=t)||void 0===s?void 0:s.msg)){e.next=43;break}if(l=(d=t).binary,h=d.msg,p=d.room,v=d.to,f=d.from,_=""===p?l?ez.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:ez.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:l?ez.USER_BINARY_MESSAGE_RECEIVED:ez.USER_MESSAGE_RECEIVED,v){e.next=27;break}if(e.t1=this,e.t2=ez.ON_CUSTOM_MESSAGE,e.t3=f,e.t4=l,!l){e.next=21;break}return e.next=18,nD.b64str2ab(h);case 18:e.t5=e.sent,e.next=22;break;case 21:e.t5=h;case 22:e.t6=e.t5,e.t7={clientId:e.t3,binary:e.t4,message:e.t6},e.t1.emit.call(e.t1,e.t2,e.t7),e.next=43;break;case 27:if(e.t8=this,e.t9=_,e.t10=el,e.t11=el({},t),e.t12={},!l){e.next=38;break}return e.next=35,nD.b64str2ab(h);case 35:e.t13=e.sent,e.next=39;break;case 38:e.t13=h;case 39:e.t14=e.t13,e.t15={msg:e.t14},e.t16=(0,e.t10)(e.t11,e.t12,e.t15),e.t8.emit.call(e.t8,e.t9,e.t16);case 43:return this._sendP2PMessage(el(el({},t),{},{dir:Iz.FEEDBACK,msg:""})),VP.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=aI(t,2),a=o[0],s=o[1],c=void 0===s?{}:s;if("RXMediaMsg"===a){var u,d=c.type,l=c.data;switch(null===(u=this._monitor)||void 0===u||u.report("rtc_signaling",{error_code:0,message:r,signaling_event:"on-".concat(d),signaling_type:"Recv",stream_id:"",stream_user_id:"",direction:"down"}),d){case"RSCP":try{var h=JSON.parse(l);Array.isArray(h)&&this.emit(d,h)}catch(f){}break;case"RTT":try{var p=JSON.parse(l);p.length&&this.emit(d,p[0])}catch(f){}break;case"SSC":try{var v=JSON.parse(l);v.length&&this.emit(d,v[0])}catch(f){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(t){e.logger.warn("_handleHandler","dataChannel close",t)},r=function(t){e.logger.error("_handleHandler","dataChannel error",t)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){return el({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",Nm(i="<<<<<< [".concat(o.signalingType,"-ack] ")).call(i,e),t));null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:r,signaling_event:null==o?void 0:o.signalingType,signaling_type:"Ack",stream_id:"",stream_user_id:"",direction:"down"})}},{key:"_handleP2PMsgFeedback",value:function(e){var t=this._p2pCache.get(e.id);t&&(this._p2pCache.delete(e.id),e.err===Az.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(JN.EventEmitter),Mz=function(e){UI(o,e);var t,r,n,i=eR(o);function o(e){var t;return Hl(this,o),Zd(sI(t=i.call(this)),"id",void 0),Zd(sI(t),"_monitor",void 0),Zd(sI(t),"logger",void 0),Zd(sI(t),"_getAccessManager",void 0),Zd(sI(t),"_connectionPool",new ib),Zd(sI(t),"_curConnection",void 0),Zd(sI(t),"_hasReportBrowerWarning",!1),Zd(sI(t),"_reconnectTimer",void 0),Zd(sI(t),"_connecting",!1),Zd(sI(t),"_isFirstTimeConnected",!0),Zd(sI(t),"_feedbackNodes",[]),Zd(sI(t),"_preIceStartTime",-1),Zd(sI(t),"_tcpOnlyTimer",void 0),Zd(sI(t),"_destroyed",!1),t._ctx=e,t.id=e.id,t._monitor=qP(t.id),t.logger=new fM("ConnectionManager",3,t.id),t.logger.info("constructor","invoke"),t._getAccessManager=new mz(e),t}return jl(o,[{key:"connect",value:function(){var e=this;this.logger.info("connect","invoke");try{Ez.checkSupported()}catch(t){this.safeEmit("disconnected",t)}this._connecting||(this._onConnectStart("init"),$_.resolve().then((function(){return e.emit("__onGetIceConfigHook")})),this._getAccess())}},{key:"reconnectByNodeChange",value:(n=xm(wm().mark((function e(t){var r,n,i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.info("reconnectByNodeChange","invoke %o",t),o=t.nodes,a=t.reason,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:Fm(t),reason:Fm(a)}),vN.clearAccessNode(this._ctx.appId),s=(null===(n=this._curConnection)||void 0===n||null===(i=n.node.publicIPs[0])||void 0===i?void 0:i.ip)||"",this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart("node change"),Array.isArray(o)&&o.length>0?this._startIceConnect(o):this._getAccess([{feedbackIP:s,feedbackReason:{type:"NODE_CHANGED",reason:a}}]);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"reconnect",value:(r=xm(wm().mark((function e(t){var r,n=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.logger.info("reconnect","invoke. ".concat(r?"ICE over TCP":"")),this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart(t),this._getAccess(void 0,r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){this.logger.info("destroy","invoke"),this._destroyed=!0,this.safeEmit("disconnected",new SA(_A.OPERATION_CANCEL,"destroy")),NI(DI(o.prototype),"removeAllListeners",this).call(this),this._clearReconnectTimer(),this._clearConnectionPool(),this._getAccessManager.destroy(),this._closeCurrentConnection()}},{key:"_getAccess",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._getAccessManager.getICENode(e).then((function(e){t.emit("__onGetIceSuccessHook",e),t._startIceConnect(e,r)})).catch((function(e){t.safeEmit("disconnected",e)})).finally((function(){t._feedbackNodes=[]}))}},{key:"_startIceConnect",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this._destroyed){this.logger.info("_startIceConnect","invoke");var n=yw();this._preIceStartTime=tD();var i=this._ctx.joinRoomConfig.useTcpJoin,o=this._ctx.joinRoomConfig.useTcpJoinDelay,a=function(){var e=xm(wm().mark((function e(i){var o,a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r&&((i=MG(i)).iceConfig.tcpOnly=!0),o={node:i},e.prev=2,a=new Ez(t._ctx,n),o.pc=a,t._connectionPool.set(a.uuid,o),e.next=8,a.connect(i);case 8:return s=e.sent,c=new Pz(t.id,s),o.signaling=c,e.next=13,c.sendPingSignaling();case 13:t._onConnectSuccess({node:i,pc:a,signaling:c,dc:s}),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(2),t._onConnectionFailed(o,e.t0);case 19:case"end":return e.stop()}}),e,null,[[2,16]])})));return function(t){return e.apply(this,arguments)}}();this.emit("__onIceConnectStartHook"),e.forEach(a),i&&!r&&(this.logger.info("_startIceConnect","tcp-only will try after ".concat(o,"ms")),this._tcpOnlyTimer=window.setTimeout((function(){t.emit("connectWidthTcp"),e.forEach((function(e){(e=MG(e)).iceConfig.tcpOnly=!0,a(e)})),delete t._tcpOnlyTimer}),o))}}},{key:"_onConnectSuccess",value:function(e){var t,r,n,i=this;(this.logger.info("connect","peer_%s connect success.",e.pc.uuid),this.emit("__onIceConnectSuccessHook",e),this._curConnection)?(e.pc.destroy(),null===(t=e.signaling)||void 0===t||t.destroy(),this._connectionPool.delete(e.pc.uuid)):(this._curConnection=e,this._addConnectionHandler(e.pc),null===(r=this._monitor)||void 0===r||r.set({connection_id:e.pc.getConnectionId(),rtc_vid:(null===(n=e.node.iceConfig)||void 0===n?void 0:n._abtest_vid)||""}),this._connectionPool.delete(e.pc.uuid),this._feedbackNodes.forEach((function(e){return i._feedbackBySignaling(e)})),this._feedbackNodes=[],this._onConnectEnded(e))}},{key:"_onConnectionFailed",value:function(e,t){var r,n,i=this;(this.logger.info("connect","peer_%s connect failed. %s",(null===(r=e.pc)||void 0===r?void 0:r.uuid)||"",t.message),this.emit("__onIceConnectFailedHook",e),t.code!==Sz.DESTROY&&t.code!==_A.OPERATION_CANCEL)&&(this._curConnection?this._feedbackBySignaling(e.node):this._feedbackNodes.push(e.node),this.logger.info("connect","remove cache node"),vN.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(),tD()-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=xm(wm().mark((function e(t){return wm().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(Km(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:vz.BLACK_BROWSER,message:"failed to establish data-channel, and the current browser is on the browser blacklist."}))}},{key:"_onConnectStart",value:function(e){var t;this.logger.info("_onConnectStart","invoke, reason: ".concat(e)),this._connecting=!0,this.safeEmit(this._isFirstTimeConnected?"connecting":"reconnecting");var r,n=yw();(null===(t=this._monitor)||void 0===t||t.set({connect_session_id:n}),this._isFirstTimeConnected)||(null===(r=this._monitor)||void 0===r||r.report("rtc_reconnect",{error_code:1002,message:"peerconnection reconnecting",reconnect_id:n,reconnect_type:"peerconnection"},{reason:e}))}},{key:"_onConnectEnded",value:function(e){var t;(this.logger.info("_onConnectEnded","invoke"),this._connecting=!1,this._isFirstTimeConnected)||(null===(t=this._monitor)||void 0===t||t.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"}));this._isFirstTimeConnected=!1,this.safeEmit("connected",e),e.node.iceConfig.tcpOnly&&(this.logger.info("_onConnectEnded","use tcp only"),$P(this._ctx.id,"connected_with_tcp_only",Fm(e.node))),this._tcpOnlyTimer&&(window.clearTimeout(this._tcpOnlyTimer),delete this._tcpOnlyTimer),this._clearConnectionPool()}},{key:"_addConnectionHandler",value:function(e){var t=this;e.on("disconnect",(function(e){t._closeCurrentConnection(),t._clearReconnectTimer(),navigator.onLine?t.reconnect(e):t._reconnectTimer=window.setTimeout((function(){return t.reconnect(e)}),3e3)}))}},{key:"_closeCurrentConnection",value:function(){var e,t;null===(e=this._curConnection)||void 0===e||e.pc.destroy(),null===(t=this._curConnection)||void 0===t||t.signaling.destroy(),delete this._curConnection}},{key:"_clearConnectionPool",value:function(){var e=this;this._connectionPool.forEach((function(t,r){var n,i;null===(n=t.pc)||void 0===n||n.destroy(),null===(i=t.signaling)||void 0===i||i.destroy(),e._connectionPool.delete(r)}))}},{key:"_clearReconnectTimer",value:function(){this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer)}}]),o}($N),Dz=cd,Nz=ic,Lz=function(e,t,r,n){for(var i,o=n>1?void 0:n?Nz(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&Dz(t,r,o),o},Uz=3e4,Vz=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(Vz||{}),Fz=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)},Bz=function(e){UI(R,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I=eR(R);function R(e){var t;return Hl(this,R),Zd(sI(t=I.call(this)),"id",void 0),Zd(sI(t),"publicStream",!1),Zd(sI(t),"_token",void 0),Zd(sI(t),"_roomId",void 0),Zd(sI(t),"_roomAttributes",void 0),Zd(sI(t),"_vendorConfig",{enableMultiVendor:!1,vendorCode:0}),Zd(sI(t),"_clientId",void 0),Zd(sI(t),"_businessId",void 0),Zd(sI(t),"_userInfo",void 0),Zd(sI(t),"_authorization",void 0),Zd(sI(t),"_sessionId",""),Zd(sI(t),"_liveControlMessage",void 0),Zd(sI(t),"isReconnecting",!1),Zd(sI(t),"_ontrackCallbackMap",new ib),Zd(sI(t),"_subResolves",{}),Zd(sI(t),"supportConcurrent",!1),Zd(sI(t),"_handler",void 0),Zd(sI(t),"_pubSubLock",void 0),Zd(sI(t),"_joinLeaveLock",void 0),Zd(sI(t),"_state",void 0),Zd(sI(t),"_dataChannelSignal",void 0),Zd(sI(t),"_joinRoomStartTs",void 0),Zd(sI(t),"_monitor",void 0),Zd(sI(t),"logger",void 0),Zd(sI(t),"_roomProfile",Il.communication),Zd(sI(t),"_context",void 0),Zd(sI(t),"_connectionManager",void 0),Zd(sI(t),"_joinRoom5xxTimer",void 0),Zd(sI(t),"_joinResolve",void 0),Zd(sI(t),"_joinReject",void 0),Zd(sI(t),"_pubSubBackOff",{}),t.id=e.id,t._monitor=qP(t.id),t.logger=new fM("MediaServerClient",2,t.id),t.logger.info("constructor","invoke"),t._pubSubLock=new sz("pubSubLock"),t._joinLeaveLock=new sz("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._pubSubBackOff={},t._context=e,t._connectionManager=new Mz(e),t._addConnectHandler(),t}return jl(R,[{key:"_addSignalEventHandler",value:function(){var e,t,r=this;[ez.ON_ADD_STREAM,ez.ON_ADD_STREAM_LIST,ez.ON_REMOVE_STREAM,ez.ON_REMOVE_STREAM_LIST,ez.USER_CONNECTION,ez.USER_CONNECTION_LIST,ez.USER_DISCONNECTION,ez.USER_DISCONNECTION_LIST,ez.ON_UPDATE_STREAM_ATTRIBUTES,ez.ON_UPDATE_ROOM_ATTRIBUTES,ez.ON_PUSH_TRACK,ez.ON_REMOVE_TRACK,ez.ON_CUSTOM_MESSAGE,ez.USER_MESSAGE_RECEIVED,ez.USER_BINARY_MESSAGE_RECEIVED,ez.POST_PROCESSING_MESSAGE,ez.ON_USER_TOKEN_WILL_EXPIRE,ez.STREAM_CONTROL_MESSAGE,ez.ON_UPDATE_USER_ATTRIBUTES,ez.ON_SPEAKER_CHANGE,tz.RSCP,tz.RTT,ez.ON_STREAM_FAILED,ez.ON_NOTIFY_RECONNECT,tz.SSC,ez.ON_FORWARD_DST_ROOM_USER_KICK].forEach((function(e){var t;null===(t=r._dataChannelSignal)||void 0===t||t.on(e,(function(t){r.safeEmit(e,t)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.on(ez.NODE_CHANGE,(function(e){r._connectionManager.reconnectByNodeChange(e)})),null===(t=this._dataChannelSignal)||void 0===t||t.on(ez.ON_NOTIFY_RECONNECT,(function(){r._connectionManager.reconnect("recv notifyReconnect signaling")}))}},{key:"_removeSignalEventHandler",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.removeAllListeners(),null===(t=this._handler)||void 0===t||t.removeAllListeners()}},{key:"connectionState",get:function(){return this._state},set:function(e){this._state!==e&&(this.safeEmit(rz.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"businessId",set:function(e){this._businessId=e}},{key:"setLiveControlMessage",value:function(e){this._liveControlMessage=e}},{key:"connect",value:function(){var e=this;return new $_((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"join",value:(T=xm(wm().mark((function e(t){var r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("join()","info: %o",t),this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._roomProfile=t.roomProfile,this._reportJoinRoomStart(),e.next=10,new $_((function(e,t){n._joinResolve=e,n._joinReject=t,(n._handler?$_.resolve():n.connect()).then((function(){n._callJoinRoom()})).catch((function(e){var t=Array.isArray(e)&&e.length>0?e[0]:e;n._joinRoomFailed(t.message)}))}));case 10:return r=e.sent,e.abrupt("return",r);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"_callJoinRoom",value:(k=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y=this,S=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=S.length>0&&void 0!==S[0]&&S[0],this.logger.info("_callJoinRoom","invoke"),e.t0=nD.token2auth(this._context.appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId,e.t2=Date.now(),e.t3=this._liveControlMessage,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=9,null===(t=this._handler)||void 0===t?void 0:t.getDefaultSdp();case 9:return e.t5=e.sent,e.next=12,KU();case 12:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=bN.VERSION,e.t9=vN.getDeviceId(),e.t10=this._context.appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._context.useCloudProxy,e.t15=lz[this._roomProfile]?"".concat(lz[this._roomProfile][0]):"0",e.t16={supportedCodecs:e.t6,deviceType:"web",userAgent:e.t7,sdkVersion:e.t8,deviceId:e.t9,appId:e.t10,roomId:e.t11,userId:e.t12,businessId:e.t13,enableCloudProxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0,supportMultiVendor:!0},e.t18=Fm({requireICEUfragV2:!0}),i={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17,accessParams:e.t18},kN("SIGNAL_CROP_JOINROOM")&&null!==(r=i.sdpInfo)&&void 0!==r&&r.sdp&&(i.sdpInfo.sdp=ZV(i.sdpInfo.sdp)),$_.resolve().then((function(){return y.emit("onSendingJoinMessageHook")})),e.prev=29,a=n?"reconnected":"joinRoom",e.next=33,this._joinRoomWithRetry(a,i);case 33:s=e.sent,this.logger.success("join","send join message success"),c=s.config||{},u=c.engine_WEB,this.connectionState="connected",this._authorization=i.Authorization,vN.setEngineWebConfig(this._context.appId,this._roomId,u),this._context&&(this._context.serverConfig={videoCodec:(null==u?void 0:u.video_codec)||"H264",audioRed:!(null==u||!u.pub_audio_red),muteReplaceUnsub:!(null===(d=s.config)||void 0===d||!d.mute_replace_unsub),simulcastOnDemand:!(DD||!1===(null===(l=s.config)||void 0===l||null===(h=l.engine_VPM)||void 0===h||null===(p=h.ondemand)||void 0===p?void 0:p.enable)),forceUniHandler:1===(null==s||null===(v=s.config)||void 0===v||null===(f=v.vendor_param)||void 0===f?void 0:f.vendor_stream_sub_mode)},"boolean"==typeof(null==u?void 0:u.av_sync)&&(this._context.avSync=u.av_sync)),s.vendorConfig&&(this._vendorConfig=s.vendorConfig),hB.audioStallConfig=u,null!=s&&null!==(o=s.relayMessage)&&void 0!==o&&o.sdp&&(null===(_=this._handler)||void 0===_||_.createAVMlineAnswerTpl(s.relayMessage.sdp)),this.emit("joinSuccess",{joinRes:s,reconnect:n}),this._joinRoomSuccess(s),e.next=51;break;case 47:e.prev=47,e.t19=e.catch(29),m={461:_A.ROOM_FORBIDDEN,462:_A.USER_FORBIDDEN},(null===e.t19||void 0===e.t19?void 0:e.t19.code)>=700&&(null===e.t19||void 0===e.t19?void 0:e.t19.code)<800?this._joinRoomFailed("token_error",_A.INVALID_TOKEN):m[null===e.t19||void 0===e.t19?void 0:e.t19.code]?this._joinRoomFailed((null===e.t19||void 0===e.t19?void 0:e.t19.message)||m[null===e.t19||void 0===e.t19?void 0:e.t19.code],m[null===e.t19||void 0===e.t19?void 0:e.t19.code]):(null===e.t19||void 0===e.t19?void 0:e.t19.code)===_A.TIME_OUT&&this._context.joinRoomConfig.useTcpAfterJoinTimeout?(g="joinRoom timeout, retry with tcp only",this.logger.error("join",g),this.safeEmit(cz.ON_REJOIN_WITH_TCP),this._connectionManager.reconnect(g,!0)):e.t19.code===_A.OPERATION_CANCEL&&"connecting"===this.connectionState||this._joinRoomFailed((null===e.t19||void 0===e.t19?void 0:e.t19.message)||"signaling_error");case 51:case"end":return e.stop()}}),e,this,[[29,47]])}))),function(){return k.apply(this,arguments)})},{key:"_getVendorPubSdpInfo",value:(E=xm(wm().mark((function e(t){var r,n,i,o=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new Ez(this._context,""),t.vendorHandler=new pz(this._context,r),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),e.next=5,t.vendorHandler.publish(t);case 5:return n=e.sent,(i=t.vendorHandler).on("ice_state",(function(e){o.emit(rz.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:pl.CONNECTION_STATE_CONNECTING,connected:pl.CONNECTION_STATE_CONNECTED,disconnected:pl.CONNECTION_STATE_RECONNECTING}[e],userId:o._clientId})})),i.once("disconnect",xm(wm().mark((function e(){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i.removeAllListeners(),"connected"===(null===(r=o._handler)||void 0===r||null===(n=r.pc)||void 0===n?void 0:n.iceConnectionState)){e.next=4;break}return o.logger.info("vendor ice failed",t.streamId),e.abrupt("return");case 4:return e.next=6,o.unpublish(t);case 6:return e.next=8,o.publish(t);case 8:t.vendorHandler&&t.statsReport.setVar(t.vendorHandler);case 9:case"end":return e.stop()}}),e)})))),e.abrupt("return",[i,n]);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"publish",value:(b=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._publish(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"_publish",value:(S=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,M,D,N,L,U,V=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publish()","localStream: %o",t),g=t.videoTrack,y=t.audioTrack,S=tD(),b="",E="",k=this._handler,"H264"!==(null===(r=this._context)||void 0===r||null===(n=r.serverConfig)||void 0===n?void 0:n.videoCodec)){e.next=13;break}return e.next=10,ZU();case 10:if(e.sent){e.next=13;break}throw new SA(_A.PUBLISH_FAILED,"h264 is not supported");case 13:if(!this._vendorConfig.enableMultiVendor){e.next=22;break}return e.next=16,this._getVendorPubSdpInfo(t);case 16:I=e.sent,R=aI(I,2),k=R[0],T=R[1],e.next=25;break;case 22:return e.next=24,this._handler.publish(t);case 24:T=e.sent;case 25:return null===(i=t.observer)||void 0===i||i.setHandler(k),this.emit("_test_pub_sdpInfo_",T),b=T.audioMid,E=T.videoMid,t.pubAttributes={localaudio:!!y,localvideo:!!g,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(g instanceof RF),extaudio:!!(y instanceof AF)},A={attributes:el({videoDescriptions:T.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:b,videoMid:E,sdpInfo:{msid:t.stream.id,type:T.type,sdp:T.partialSdp,semantics:T.semantics},peerConnectionMode:null===(o=T)||void 0===o?void 0:o.peerConnectionMode,supportMultiVendor:!0},(w=!this._vendorConfig.enableMultiVendor&&t.enableSimulcast&&(null===(a=this._context)||void 0===a||null===(s=a.serverConfig)||void 0===s?void 0:s.simulcastOnDemand)&&(null===(c=T.subVideoDescriptions)||void 0===c?void 0:c.length))&&(A.attributes.subVideoDescriptions=T.subVideoDescriptions),null!==(u=T)&&void 0!==u&&u.peerConnectionId&&(A.peerConnectionId=T.peerConnectionId),e.prev=34,this.emit("_test_pub_body_",A),e.next=38,null===(x=this._dataChannelSignal)||void 0===x?void 0:x.sendSignaling("publish",A);case 38:C=e.sent,e.next=63;break;case 41:return e.prev=41,e.t0=e.catch(34),e.t0 instanceof Error?null===(P=this._monitor)||void 0===P||P.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:S,message:Nm(M="".concat(e.t0.name,": ")).call(M,e.t0.message)}):e.t0 instanceof SA&&(null===(D=this._monitor)||void 0===D||D.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:S,message:Nm(N="".concat(e.t0.code,": ")).call(N,e.t0.message)})),e.next=46,null===(O=k)||void 0===O?void 0:O.rollback({msid:t.stream.id,stream:t,audioMid:b,videoMid:E});case 46:if(!(e.t0.code>=500&&e.t0.code<600)){e.next=62;break}if(this.emit("_test_pub_5xx_"),!((L=this.getPubSubBackOff(t.id)).retryDuration<6e4)){e.next=60;break}return this.logger.info("pubRetry",t.id,L.retryDuration),e.next=53,new $_((function(e){return setTimeout(e,L.interval)}));case 53:return L.retryDuration+=L.interval,L.interval=L.interval>4e3?8e3:2*L.interval,t.resetStream(),this.emit(cz.PUB_RETRY,{screen:t.isScreen}),e.abrupt("return",this._publish(t));case 60:this.logger.info("pubRetry","end"),delete this._pubSubBackOff[t.id];case 62:throw e.t0;case 63:if(null===(d=this._monitor)||void 0===d||d.report("rtc_recv_answer",{error_code:0,answer_type:null===(l=C)||void 0===l?void 0:l.relayMessage.type,sequence_id:(null===(h=C)||void 0===h||null===(p=h.relayMessage)||void 0===p?void 0:p.sequenceId)||0,message:null===(v=C)||void 0===v||null===(f=v.relayMessage)||void 0===f?void 0:f.sdp,direction:"up",stream_id:"",stream_user_id:"",pc_session_id:(null===(_=k)||void 0===_?void 0:_.peerConnectionId)||""}),U=new $_((function(e,r){var n,i,o,a,s,c,u,d;null===(n=k)||void 0===n||n.handleAck({action:bB.publish,streamId:C.streamId,audioMid:b,videoMid:E,audioTransceiverInit:null===(i=T)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=T)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:{sdp:null===(a=C)||void 0===a||null===(s=a.relayMessage)||void 0===s?void 0:s.sdp,sequenceId:null===(c=C)||void 0===c||null===(u=c.relayMessage)||void 0===u?void 0:u.sequenceId},sdp:null===(d=T)||void 0===d?void 0:d.sdp,stream:t,onSuccess:function(){V.logger.info("publish()","publish success"),e(0)},onFail:function(e){V.logger.info("publish()","publish fail"),r(e)}})})),e.t1=!DD,!e.t1){e.next=69;break}return e.next=69,U;case 69:w&&this.emit(tz.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}],!0),t.streamId=C.streamId,t.videoMid=E,t.audioMid=b,t.subVideoDescriptions=T.subVideoDescriptions,null===(m=this._monitor)||void 0===m||m.report("rtc_publish_stat",{result:"success",is_screen:"0",start:S,message:"unknown"});case 75:case"end":return e.stop()}}),e,this,[[34,41]])}))),function(e){return S.apply(this,arguments)})},{key:"updatePubTrack",value:(y=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updatePubTrack()","localStream: %o",t),n=t.videoTrack,i=t.audioTrack,o=t.pubAudio,a=t.pubVideo,s=t.vendorHandler||this.handler,c=null==i?void 0:i.getTrack("preprocessing"),u=null==n?void 0:n.getTrack("preprocessing"),!a||!u){e.next=10;break}return e.next=8,null===(d=t.videoTransceiver)||void 0===d?void 0:d.sender.replaceTrack(u);case 8:e.next=12;break;case 10:return e.next=12,null===(l=t.videoTransceiver)||void 0===l?void 0:l.sender.replaceTrack(null);case 12:if(null==s||s.updateMaxBitrate(t),!o||!c){e.next=20;break}return p=i.mixType,(v=i.mixedAudioTrack)&&p!==Ll.PLAYOUT&&c.enabled&&(c=v),e.next=18,null===(h=t.audioTransceiver)||void 0===h?void 0:h.sender.replaceTrack(c);case 18:e.next=23;break;case 20:return e.next=22,null===(f=t.audioTransceiver)||void 0===f?void 0:f.sender.replaceTrack(null);case 22:$P(this.id,"MediaClient.updatePubTrack(audio)","null");case 23:try{$P(this.id,"MediaClient.updatePubTrack",Fm({audioStreamTrack:Ew(c),videoStreamTrack:Ew(u)}))}catch(BY){}for(m={},g=0,y=CA(_={localaudio:!!i,localvideo:!!n,videostream:a,audiostream:o,extvideo:!!(n instanceof RF),extaudio:!!(i instanceof AF)});g<y.length;g++)S=aI(y[g],2),b=S[0],(E=S[1])!==_I(t.pubAttributes,b)&&cL(m,b,E);if(cn(m).length){e.next=29;break}return e.abrupt("return");case 29:return t.observer&&(k=t.observer,T=m.audiostream,I=m.videostream,R=m.localaudio,A=m.localvideo,w=m.extaudio,C=m.extvideo,void 0!==A?void 0!==C?k.setPushVideo(C):k.setEnableVideo(A):void 0!==I&&k.setUnmuteVideo(I),void 0!==R?void 0!==w?k.setPushAudio(w):k.setEnableAudio(R):void 0!==T&&k.setUnmuteAudio(T)),t.pubAttributes=_,x={roomId:this._roomId,streamId:t.streamId,attributes:m},e.next=34,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateStreamAttributes",x);case 34:if(!DD){e.next=37;break}return e.next=37,null==s?void 0:s.setCurrentDescription();case 37:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"updateToken",value:(g=xm(wm().mark((function e(t){var r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateToken()","newToken: %o",t),this._token=t,this._context.appId&&null!==(r=this._userInfo)&&void 0!==r&&r.userId&&this._roomId){e.next=4;break}return e.abrupt("return");case 4:return i={roomId:this._roomId,userId:null===(n=this._userInfo)||void 0===n?void 0:n.userId,appId:this._context.appId,token:"Bearer ".concat(t)},e.prev=5,e.next=8,null===(o=this._dataChannelSignal)||void 0===o?void 0:o.sendSignaling("updateToken",i);case 8:e.next=13;break;case 10:throw e.prev=10,e.t0=e.catch(5),new SA(_A.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 13:case"end":return e.stop()}}),e,this,[[5,10]])}))),function(e){return g.apply(this,arguments)})},{key:"unpublish",value:(m=xm(wm().mark((function e(t){var r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("unpublish()","localStream: %o",t),n={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",n),i=t.vendorHandler||this._handler,e.next=6,null==i?void 0:i.handleAck({action:bB.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 6:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"_getVendorSubSdpInfo",value:(_=xm(wm().mark((function e(t,r){var n,i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Ez(this._context,""),t.vendorHandler=new pz(this._context,n),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),(i=t.vendorHandler).on("ontrack",r),e.next=7,t.vendorHandler.subscribe(t);case 7:return o=e.sent,i.on("ice_state",(function(e){a.emit(rz.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:pl.CONNECTION_STATE_CONNECTING,connected:pl.CONNECTION_STATE_CONNECTED,disconnected:pl.CONNECTION_STATE_RECONNECTING}[e],userId:t.userId})})),i.once("disconnect",xm(wm().mark((function e(){var r,n,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==i||i.removeAllListeners(),"connected"===(null===(r=a._handler)||void 0===r||null===(n=r.pc)||void 0===n?void 0:n.iceConnectionState)){e.next=4;break}return a.logger.info("vendor ice failed",t.streamId),e.abrupt("return");case 4:return o=t.subMediaType,e.next=7,a.unsubscribe(t);case 7:return e.next=9,a.subscribe(t,o);case 9:t.vendorHandler&&t.statsReport.setVar(t.vendorHandler),a.emit(cz.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 _.apply(this,arguments)})},{key:"subscribe",value:(f=xm(wm().mark((function e(t,r,n){return wm().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 f.apply(this,arguments)})},{key:"_subscribe",value:(v=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,M,D,N,L,U,V,F,B,j,H,G,z,K,X,W,q,Y,J,Q,Z,$,ee,te,re,ne,ie=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("subscribe()","mediaType: %o",r),Fz("subscribe()",t,this.logger),t.streamState=_B.SUB_ING,I=!1,R=!1,gD(r)&&(R=!0),yD(r)&&(I=!0),I||!this.multiChatMode()){e.next=9;break}return t.streamState=_B.INIT,e.abrupt("return");case 9:if(A=tD(),w=t.subVideo,C=[],this._subResolves[t.streamId]||(this._subResolves[t.streamId]=[]),C.push(new $_((function(e,r){ie._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SA(_A.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),Uz);t.on("ontrack",(function r(i){"video"===i.mediaType&&(ie.logger.info("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),this.multiChatMode()||C.push(new $_((function(e,r){ie._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SA(_A.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),Uz);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(ie.logger.info("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),x=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",x),this._ontrackCallbackMap.set(t,x),O=this._handler,null!==(o=this._context.serverConfig)&&void 0!==o&&o.forceUniHandler||!t.enableVendorMode){e.next=28;break}return e.next=22,this._getVendorSubSdpInfo(t,x);case 22:M=e.sent,D=aI(M,2),O=D[0],P=D[1],e.next=31;break;case 28:return e.next=30,this._handler.subscribe(t,{multiChatMode:this.multiChatMode()});case 30:P=e.sent;case 31:if(null===(a=t.observer)||void 0===a||a.setHandler(O),L=(N=P).audioMid,U=N.videoMid,t.subVideo=I,V={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},F={audio:!this.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:U,audioMid:L,sdpInfo:{sdp:null===(s=P)||void 0===s?void 0:s.partialSdp,semantics:null===(c=P)||void 0===c?void 0:c.semantics,type:null===(u=P)||void 0===u?void 0:u.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!this.multiChatMode()||R,video:I},qualityLayer:V},extra:{enableSendRTT:!0},peerConnectionMode:null===(d=P)||void 0===d?void 0:d.peerConnectionMode,supportMultiVendor:!0},null!==(l=P)&&void 0!==l&&l.peerConnectionId&&(F.peerConnectionId=P.peerConnectionId),B=this._context||{},j=B.subscribeFallbackOption,H=B.userPriority,"number"==typeof j&&(F.config.fallbackOption=j),H.has(t.userId)&&(F.config.priority=H.get(t.userId)),null!==(h=P)&&void 0!==h&&h.allSsrc&&(F.extra.subscribeSSRC=P.allSsrc),null===(p=P)||void 0===p||!p.signalingAck){e.next=44;break}return e.next=44,new $_((function(e,r){var n,i,o,a;null===(n=O)||void 0===n||n.handleAck({action:bB.subscribe,streamId:t.streamId,audioMid:L,videoMid:U,audioTransceiverInit:null===(i=P)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=P)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:null===(a=P)||void 0===a?void 0:a.signalingAck,stream:t,sdp:P.sdp,onSuccess:function(){ie.logger.info("ssrc","success"),e(0)},onFail:function(e){ie.logger.info("ssrc","fail",e),r(e)}})}));case 44:return e.prev=44,this.emit("_test_sub_body_",F),e.next=48,null===(z=this._dataChannelSignal)||void 0===z?void 0:z.sendSignaling("subscribe",F);case 48:G=e.sent,e.next=78;break;case 51:if(e.prev=51,e.t0=e.catch(44),t.streamState=_B.INIT,e.t0 instanceof Error&&(null===(W=this._monitor)||void 0===W||W.report("rtc_subscribe_stat",{result:"fail",start:A,message:e.t0.message,stream_user_id:t.userId})),!(e.t0.code>=500&&e.t0.code<600)){e.next=70;break}if(this.emit("_test_sub_5xx_"),!((q=this.getPubSubBackOff(t.streamId)).retryDuration<6e4)){e.next=68;break}return this.logger.info("subRetry",t.streamId,q.retryDuration),e.next=62,new $_((function(e){return setTimeout(e,q.interval)}));case 62:return q.retryDuration+=q.interval,q.interval=q.interval>4e3?8e3:2*q.interval,this.emit(cz.SUB_RETRY,{screen:t.isScreen,userId:t.userId}),e.abrupt("return",this._subscribe(t,r,n));case 68:this.logger.info("subRetry","end",t.streamId),delete this._pubSubBackOff[t.streamId];case 70:return t.subVideo=w,e.next=73,null===(K=O)||void 0===K?void 0:K.rollback({msid:t.streamId,stream:t});case 73:return Y={roomId:this._roomId,streamId:t.streamId,userId:t.userId},e.next=76,null===(X=this._dataChannelSignal)||void 0===X?void 0:X.sendSignaling("unsubscribe",Y).catch((function(){}));case 76:throw t.streamState=_B.INIT,e.t0;case 78:if(G.relayMessage){e.next=81;break}throw null===(J=this._monitor)||void 0===J||J.report("rtc_error",{error_code:-1009,message:"relayMessage is null"}),new SA(_A.UNEXPECTED_ERROR,"unable to subscribe");case 81:if(Q=null===(v=G)||void 0===v?void 0:v.relayMessage,Z=Q.audioMid,$=Q.videoMid,Zd(f={},L,Z),Zd(f,U,$),ee=f,this.logger.info("sub midmap",t.userId,ee),t.videoMid=U,t.audioMid=L,t.subMediaType=r,t.streamState=_B.SUB_ED,t.subLayer=V,null===(_=this._monitor)||void 0===_||_.report("rtc_recv_answer",{error_code:0,answer_type:null===(m=G)||void 0===m||null===(g=m.relayMessage)||void 0===g?void 0:g.type,sequence_id:(null===(y=G)||void 0===y||null===(S=y.relayMessage)||void 0===S?void 0:S.sequenceId)||0,message:null===(b=G)||void 0===b||null===(E=b.relayMessage)||void 0===E?void 0:E.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:(null===(k=O)||void 0===k?void 0:k.peerConnectionId)||""}),e.prev=90,null!==(te=P)&&void 0!==te&&te.signalingAck){e.next=94;break}return e.next=94,new $_((function(e,r){var n,i,o,a,s,c,u;null===(n=O)||void 0===n||n.handleAck({action:bB.subscribe,streamId:t.streamId,audioMid:L,videoMid:U,audioTransceiverInit:null===(i=P)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(o=P)||void 0===o?void 0:o.videoTransceiverInit,signalingAck:{sdp:null===(a=G)||void 0===a||null===(s=a.relayMessage)||void 0===s?void 0:s.sdp,sequenceId:null===(c=G)||void 0===c||null===(u=c.relayMessage)||void 0===u?void 0:u.sequenceId},stream:t,sdp:P.sdp,onSuccess:function(){ie.logger.info("sub ack","success"),e(0)},onFail:function(e){ie.logger.info("sub ack","fail",e),r(e)}})}));case 94:return e.next=96,$_.all(C);case 96:e.next=106;break;case 98:return e.prev=98,e.t1=e.catch(90),e.t1 instanceof Error&&(null===(ne=this._monitor)||void 0===ne||ne.report("rtc_subscribe_stat",{result:"fail",start:A,message:e.t1.message,stream_user_id:t.userId})),Y={roomId:this._roomId,streamId:t.streamId,userId:t.userId},e.next=104,null===(re=this._dataChannelSignal)||void 0===re?void 0:re.sendSignaling("unsubscribe",Y).catch((function(){}));case 104:throw t.streamState=_B.INIT,e.t1;case 106:this.multiChatMode()||(t.subAudio=R),null===(T=this._monitor)||void 0===T||T.report("rtc_subscribe_stat",{result:"success",start:A,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return ie.emit("onRemoteStreamStats",e)}),O);case 109:case"end":return e.stop()}}),e,this,[[44,51],[90,98]])}))),function(e,t,r){return v.apply(this,arguments)})},{key:"controlMessage",value:(p=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"updateUserAttributes",value:(h=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateUserAttributes()","attributes: %o",t),e.next=3,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateUserAttributes",{roomId:this._roomId,sessionId:this._sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(l=xm(wm().mark((function e(t,r){var n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return this.logger.warn("updateSubTrack()","subLayer no change"),e.abrupt("return");case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:return this.emit("___afterUpdateSubscribeSend"),t.subLayer=r,e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"updateSubPriority",value:(d=xm(wm().mark((function e(t,r){var n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return this.logger.warn("updateSubPriority()","priority no change"),e.abrupt("return",t);case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{priority:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:return t.priority=r,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"updateSubMediaType",value:(u=xm(wm().mark((function e(t,r){var n,i,o,a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=!1,a=!1,gD(r)&&(a=!0),yD(r)&&(o=!0),s={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:o,audio:!!this.multiChatMode()||a}}},e.next=6,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",s);case 6:return this.multiChatMode()||(null===(c=t.observer)||void 0===c||c.setUnmuteAudio(a),t.subAudio=a),null===(i=t.observer)||void 0===i||i.setUnmuteVideo(o),t.subVideo=o,t.subMediaType=r,e.abrupt("return",t);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(c=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("subscribe4pushTrack()","streamInfo: %o",r),Fz("subscribe4pushTrack()",t,this.logger),t.subAudio=!0,e.next=5,null===(n=this._handler)||void 0===n?void 0:n.subscribe(t,{multiChatMode:this.multiChatMode()});case 5:if(a=e.sent){e.next=8;break}throw new SA(_A.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 8:return s=a.audioMid,c=a.videoMid,(u=[]).push(new $_((function(e,r){var n=setTimeout((function(){return r(new SA(_A.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),Uz);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(l.logger.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),d=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",d),this._ontrackCallbackMap.set(t,d),e.next=17,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:bB.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,$_.all(u);case 19:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return l.emit("onRemoteStreamStats",e)}),this._handler);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(s=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Fz("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)&ll.AUDIO),d=!!(c&ll.VIDEO),e.next=10,null===(i=this._handler)||void 0===i?void 0:i.handleAck({action:bB.removetrack,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:null===(o=t.observer)||void 0===o||o.setPushTrack(!1),null===(a=t.observer)||void 0===a||a.setUnmuteAudio(!u),t.subAudio=!u,null===(s=t.observer)||void 0===s||s.setUnmuteVideo(!d),t.subVideo=!d,t.subMediaType=t.subMediaType-(t.subMediaType&c),t.virtual&&(t.clean(),t.resetHasSubscribed(),t.statsReport.unsubscribe());case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return s.apply(this,arguments)})},{key:"unsubscribe",value:(a=xm(wm().mark((function e(t){var r,n,i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Fz("unsubscribe()",t,this.logger),o={roomId:this._roomId,streamId:t.streamId,userId:t.userId},a=t.vendorHandler||this.handler,null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unsubscribe",o).catch((function(){})),t.streamState=_B.INIT,t.subVideo=!1,null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(i=t.observer)||void 0===i||i.setSubscribeAudio(!1)),e.next=10,null==a?void 0:a.handleAck({action:bB.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:s=e.sent,this._subResolves[s]&&this._subResolves[s].forEach((function(e){return e(0)})),this.logger.info("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),t.subMediaType=tB.NONE,this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t=this._ontrackCallbackMap.get(e);if(t){var r=e.vendorHandler||this._handler;null==r||r.off("ontrack",t),this._ontrackCallbackMap.delete(e)}}},{key:"handleRemoveStream",value:(o=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Fz("handleRemoveStream()",t,this.logger),t.subVideo=!1,t.streamState!==_B.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"leave",value:(i=xm(wm().mark((function e(){var t,r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("leave()"),this._stopJoinRoom5xxRetry(),this._joinRoomFailed("leave_room"),"connected"!==this.connectionState){e.next=20;break}return t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=7,this._joinLeaveLock.lock();case 7:return r=e.sent,e.prev=8,e.next=11,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 11:r(),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(8),r(),e.t0;case 18:e.next=21;break;case 20:return e.abrupt("return",$_.reject(new SA(_A.NOT_CONNECTED_YET,"server not connected")));case 21:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(){return i.apply(this,arguments)})},{key:"subscribePublicStream",value:(n=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._handler)||void 0===r?void 0:r.subscribe(t,{multiChatMode:!1});case 2:if(s=e.sent){e.next=5;break}throw new SA(_A.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=tD(),u=s.audioMid,d=s.videoMid,e.t0=this._context.appId,e.t1=t.streamId,e.t2=u,e.t3=d,e.t4={sdp:null==s?void 0:s.partialSdp,semantics:null==s?void 0:s.semantics,type:null==s?void 0:s.type},e.next=15,KU();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=bN.VERSION,e.t8=vN.getDeviceId(),e.t9=this._context.appId,e.t10=this._businessId,e.t11=this._context.useCloudProxy,e.t12={supportedCodecs:e.t5,deviceType:"web",userAgent:e.t6,sdkVersion:e.t7,deviceId:e.t8,appId:e.t9,businessId:e.t10,enableCloudProxy:e.t11},e.t13={enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}},l={appId:e.t0,streamId:e.t1,audio:!0,video:!0,data:!0,audioMid:e.t2,videoMid:e.t3,sdpInfo:e.t4,params:e.t12,config:e.t13},e.next=27,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",l);case 27:return h=e.sent,p=[],this._subResolves[t.streamId]=[],p.push(new $_((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SA(_A.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),Uz);t.on("ontrack",(function r(i){"video"===i.mediaType&&(g.logger.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p.push(new $_((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SA(_A.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),Uz);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(g.logger.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",v),this._ontrackCallbackMap.set(t,v),f=null==h?void 0:h.relayMessage,_=f.sequenceId,m=f.sdp,t.videoMid=d,t.audioMid=u,t.sequenceId=_,t.streamState=_B.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:bB.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:m,sequenceId:_},stream:t});case 44:return e.next=46,$_.all(p);case 46:null===(a=this._monitor)||void 0===a||a.report("rtc_subscribe_stat",{result:"success",start:c,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return g.emit("onRemoteStreamStats",e)}),this._handler);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(r=xm(wm().mark((function e(t){var r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Fz("unsubscribePublicStream()",t,this.logger),n={appId:this._context.appId,streamId:t.streamId},e.prev=2,e.next=5,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=_B.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:bB.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),t.subMediaType=tB.NONE,this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;this.logger.info("destroy()"),this._joinRoomFailed("leave_room"),this._token=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId="",this._pubSubBackOff={},this._stopJoinRoom5xxRetry(),null===(e=this._handler)||void 0===e||e.destroy(),this._handler=void 0,null===(t=this._dataChannelSignal)||void 0===t||t.destroy(),this._dataChannelSignal=void 0,this._connectionManager.destroy(),null===(r=this._monitor)||void 0===r||r.set({connection_id:""}),this._removeSignalEventHandler(),this.removeAllListeners(),this.connectionState="disconnected"}},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendP2PMessage({to:e,from:this._userInfo.userId,room:this._roomId,app:this._context.appId,msg:t})}},{key:"sendRoomMessage",value:function(e){var t;return null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("customMessage",e)}},{key:"_joinRoomWithRetry",value:function(e,t,r){var n=this;return new $_((function(i,o){n._dataChannelSignal.sendSignaling(e,t,void 0,1e4).then((function(e){n.emit("onJoinRoomAck",e),i(e)})).catch((function(a){if(r=r||new _z,a.code>=500&&a.code<600&&tD()-r.initTs<6e4){var s,c=r.getRetryDelay();return n.logger.warn("_joinRoomWithRetry",Nm(s="joinRoom failed(code: ".concat(a.code,"), will retry after ")).call(s,c,"ms")),void(n._joinRoom5xxTimer=window.setTimeout((function(){delete n._joinRoom5xxTimer,n._joinRoomWithRetry(e,t,r).then(i).catch(o)}),c))}o(a)}))}))}},{key:"_stopJoinRoom5xxRetry",value:function(){this._joinRoom5xxTimer&&(clearTimeout(this._joinRoom5xxTimer),delete this._joinRoom5xxTimer)}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n,i;e.logger.info("connectStateChange","connected"),e.connectionState="connected",null===(r=e._dataChannelSignal)||void 0===r||r.destroy(),null===(n=e._handler)||void 0===n||n.destroy(),e._handler=QG(e._context,t.pc),e._dataChannelSignal=t.signaling,e.supportConcurrent="chrome"===(null===(i=e._handler)||void 0===i?void 0:i.name),e._addSignalEventHandler(),e.isReconnecting&&(e.publicStream?e.emit("connectSuccess",{reconnect:!0}):(e._reportJoinRoomStart(),e._callJoinRoom(!0)))})),this._connectionManager.on("disconnected",(function(t){e.connectionState="disconnected",e.logger.error("connectStateChange","disconnected. %o",t),e.isReconnecting&&e.safeEmit(cz.RECONNECT_FAILED)})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",e.logger.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.connectionState="disconnected",e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",e.logger.warn("connectStateChange","reconnecting"),e.safeEmit("reconnecting")})),this._connectionManager.on("connectWidthTcp",(function(){e.safeEmit(cz.ON_ICE_CONNECT_WITH_TCP)})),["__onGetIceConfigHook","__onIceConnectSuccessHook"].forEach((function(t){e._connectionManager.on(t,(function(){return e.emit(t)}))}))}},{key:"_reportJoinRoomStart",value:function(){var e;this._joinRoomStartTs=tD(),this.emit("__joinRoomStartReport"),null===(e=this._monitor)||void 0===e||e.report("join_room",{type:"begin",start:this._joinRoomStartTs,result:!1,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC})}},{key:"getPubSubBackOff",value:function(e){return this._pubSubBackOff[e]||(this._pubSubBackOff[e]={interval:1e3,retryDuration:0}),this._pubSubBackOff[e]}},{key:"_joinRoomSuccess",value:function(e){var t,r;(this._joinReject&&this._joinResolve&&(this._joinResolve(e),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomSuccessReport"),null===(t=this._monitor)||void 0===t||t.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!0,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),null===(r=this._monitor)||void 0===r||r.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:tD()-this._joinRoomStartTs}),delete this._joinRoomStartTs)}},{key:"_joinRoomFailed",value:function(e,t){var r;(this._joinReject&&this._joinResolve&&(this._joinReject(new SA(t||_A.JOIN_ROOM_FAILED,e)),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomFailedReport"),null===(r=this._monitor)||void 0===r||r.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!1,reason:e},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),delete this._joinRoomStartTs)}},{key:"multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"sendForwardStreamSignal",value:(t=xm(wm().mark((function e(t,r,n){var i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o={forwardStreamType:t,roomId:r},("start"===t||"update"===t)&&(o.dstRoomInfos=null==n?void 0:Km(n).call(n,(function(e){return{dstRoomId:e.roomId,dstToken:nD.token2auth(a._context.appId,e.roomId,a._clientId,e.token)}}))),e.abrupt("return",null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("forwardStream",o));case 4:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}},{key:"vendorConfig",get:function(){return this._vendorConfig}}]),R}($N);function jz(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var r,i,o,a=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._handler||"connected"!==this._state){e.next=6;break}for(r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=4,n.apply(this,i);case 4:e.next=7;break;case 6:throw new SA(_A.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function Hz(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var t,r,i,o,a=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pubSubLock.lock();case 2:for(t=e.sent,this.supportConcurrent&&t(),e.prev=4,r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=8,n.apply(this,i);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,this.supportConcurrent||t(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[4,,9,12]])}))),r}Lz([function(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var t,r,i,o,a=this,s=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=s.length,r=new Array(t),i=0;i<t;i++)r[i]=s[i];return o=!1,e.abrupt("return",new $_(function(){var e=xm(wm().mark((function e(t,i){var s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new SA(_A.OPERATION_CANCEL,"operation not finish when leave"))})),e.prev=1,e.next=4,n.apply(a,r);case 4:s=e.sent,t(s),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o||i(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)}))),r}],Bz.prototype,"join",1),Lz([Hz,jz],Bz.prototype,"publish",1),Lz([Hz,jz],Bz.prototype,"updatePubTrack",1),Lz([Hz,jz],Bz.prototype,"unpublish",1),Lz([Hz,jz],Bz.prototype,"subscribe",1),Lz([jz],Bz.prototype,"controlMessage",1),Lz([jz],Bz.prototype,"updateUserAttributes",1),Lz([jz],Bz.prototype,"updateSubTrackLayer",1),Lz([jz],Bz.prototype,"updateSubPriority",1),Lz([Hz,jz],Bz.prototype,"subscribe4pushTrack",1),Lz([Hz,jz],Bz.prototype,"unsubscribe4removeTrack",1),Lz([Hz,jz],Bz.prototype,"unsubscribe",1),Lz([jz],Bz.prototype,"handleRemoveStream",1),Lz([Hz],Bz.prototype,"subscribePublicStream",1),Lz([Hz],Bz.prototype,"unsubscribePublicStream",1);var Gz,zz=function(){var e=xm(wm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,f,_,m,g;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getOrgTrack():null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getOrgTrack(),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.receiver:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.receiver,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,hV(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,f=kE(p=v||[]).call(p,(function(e){return"inbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(_=e.sent,m=[],null==_||_.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==(null==v?void 0:v.length)||0===m.length){e.next=22;break}return e.next=21,hV(r.pc);case 21:g=e.sent;case 22:u=Fm({type:t,reports:Km(v).call(v,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==f?void 0:f.bytesReceived,framesReceived:null==f?void 0:f.framesReceived,packetsReceived:null==f?void 0:f.packetsReceived,allReports:g}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Fm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_recv_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),Kz=function(){var e=xm(wm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,f,_,m,g;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack("preprocessing"):null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.sender:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.sender,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,hV(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,f=kE(p=v||[]).call(p,(function(e){return"outbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(_=e.sent,m=[],null==_||_.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==v.length||0===m.length){e.next=22;break}return e.next=21,hV(r.pc);case 21:g=e.sent;case 22:u=Fm({type:t,reports:Km(v).call(v,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==f?void 0:f.bytesSent,framesSent:null==f?void 0:f.framesSent,packetsSent:null==f?void 0:f.packetsSent,allReports:g}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Fm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_send_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),Xz=function(e){UI(a,e);var t,r,n,i,o=eR(a);function a(e,t){var r;return Hl(this,a),Zd(sI(r=o.call(this)),"_audioEventSessionId",oD()),Zd(sI(r),"_videoEventSessionId",oD()),Zd(sI(r),"_handler",void 0),Zd(sI(r),"_stream",void 0),Zd(sI(r),"_firstAudioFrameTimer",void 0),Zd(sI(r),"_firstVideoFrameTimer",void 0),Zd(sI(r),"_transportDelayInterval",void 0),Zd(sI(r),"_transportDelay",void 0),Zd(sI(r),"_firstVideoFrameInterval",void 0),Zd(sI(r),"_firstAudioFrameInterval",void 0),Zd(sI(r),"_isScreen",!1),Zd(sI(r),"_audioFirstFrameState",0),Zd(sI(r),"_videoFirstFrameState",0),Zd(sI(r),"_timeout",1e4),Zd(sI(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),Zd(sI(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),Zd(sI(r),"_login",!1),Zd(sI(r),"_unMuteAudio",!1),Zd(sI(r),"_enableAudio",!1),Zd(sI(r),"_unMuteVideo",!1),Zd(sI(r),"_enableVideo",!1),Zd(sI(r),"_remoteUnmuteAudio",!1),Zd(sI(r),"_remoteUnmuteVideo",!1),Zd(sI(r),"_audioExternal",!1),Zd(sI(r),"_pushAudio",!1),Zd(sI(r),"_videoExternal",!1),Zd(sI(r),"_pushVideo",!1),Zd(sI(r),"_autoSubscribeVideo",!1),Zd(sI(r),"_autoSubscribeAudio",!1),Zd(sI(r),"_autoSubscribe",!1),Zd(sI(r),"_publishVideo",!1),Zd(sI(r),"_publishAudio",!1),Zd(sI(r),"_subscribeAudio",!1),Zd(sI(r),"_subscribeVideo",!1),Zd(sI(r),"_subscribe",!1),Zd(sI(r),"_pushTrack",!1),Zd(sI(r),"_multiChatMode",!1),Zd(sI(r),"_monitor",void 0),Zd(sI(r),"logger",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=qP(e.engineId),r.logger=new fM("RecvFrameObserver",0,e.engineId),r}return jl(a,[{key:"beginRecvFrame",value:(i=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,DE(n=["login","unmute","subscribe","push_track"]).call(n,r)>=0&&(i=0,o=!1),"audio"===t?(o||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},p={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(a=this._stream)||void 0===a||!a.isScreen),start:null===(s=this._currentAudioRecv)||void 0===s?void 0:s.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,transport_delay:i,vendor_mode:(null===(u=this._stream)||void 0===u?void 0:u.vendorCode)||0,pc_session_id:(null===(d=this._stream)||void 0===d?void 0:d.pcSessionId)||(null===(l=this._handler)||void 0===l?void 0:l.peerConnectionId)},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){zz("audio",E._handler,E._stream,E._monitor),E.stopRecvFrame("audio","timeout"),E._firstAudioFrameInterval&&window.clearInterval(E._firstAudioFrameInterval)}),this._timeout),this.logger.info("rtcFirstFrameRecv",Fm(p)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",p),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):"video"===t&&(o||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},b={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(v=this._stream)||void 0===v||!v.isScreen),start:null===(f=this._currentVideoRecv)||void 0===f?void 0:f.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,transport_delay:i,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(g=this._stream)||void 0===g?void 0:g.pcSessionId)||(null===(y=this._handler)||void 0===y?void 0:y.peerConnectionId)},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){zz("video",E._handler,E._stream,E._monitor),E.stopRecvFrame("video","timeout"),E._firstVideoFrameInterval&&window.clearInterval(E._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),this.logger.info("rtcFirstFrameRecv",Fm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u;if(1!==this._audioFirstFrameState)return;var d={event_type:"recv_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioRecv)||void 0===n?void 0:n.startTime,reason:t,result:!1,stream_user_id:null===(i=this._stream)||void 0===i?void 0:i.userId,event_session_id:this._audioEventSessionId,type:null===(o=this._currentAudioRecv)||void 0===o?void 0:o.type,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,this.logger.info("rtcFirstFrameRecv",Fm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._audioFirstFrameState=2}else if("video"===e){var l,h,p,v,f,_,m,g;if(1!==this._videoFirstFrameState)return;var y={event_type:"recv_end",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),start:null===(h=this._currentVideoRecv)||void 0===h?void 0:h.startTime,reason:t,result:!1,stream_user_id:null===(p=this._stream)||void 0===p?void 0:p.userId,event_session_id:this._videoEventSessionId,type:null===(v=this._currentVideoRecv)||void 0===v?void 0:v.type,vendor_mode:(null===(f=this._stream)||void 0===f?void 0:f.vendorCode)||0,pc_session_id:(null===(_=this._stream)||void 0===_?void 0:_.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,this.logger.info("rtcFirstFrameRecv",Fm(y)),null===(g=this._monitor)||void 0===g||g.report("rtc_first_frame",y),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:if(r=this._transportDelay,"audio"!==t){e.next=19;break}if(1===this._audioFirstFrameState){e.next=6;break}return e.abrupt("return");case 6:if(this._currentAudioRecv){e.next=8;break}return e.abrupt("return");case 8:d=this._currentAudioRecv,l=d.type,h=d.startTime,DE(n=["login","unmute","subscribe","push_track"]).call(n,l)>=0&&(r=0),p={event_type:"recv_end",media_type:t,start:h,result:!0,is_screen:!(null===(i=this._stream)||void 0===i||!i.isScreen),stream_user_id:null===(o=this._stream)||void 0===o?void 0:o.userId,event_session_id:this._audioEventSessionId,type:l,transport_delay:r,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this.logger.info("rtcFirstFrameRecv",Fm(p)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",p),this.emit("recvAudioFirstFrame"),this._audioFirstFrameState=3,e.next=33;break;case 19:if("video"!==t){e.next=33;break}if(1===this._videoFirstFrameState){e.next=22;break}return e.abrupt("return");case 22:if(this._currentVideoRecv){e.next=24;break}return e.abrupt("return");case 24:b=this._currentVideoRecv,E=b.type,k=b.startTime,DE(v=["login","unmute","subscribe","push_track"]).call(v,E)>=0&&(r=0),T={event_type:"recv_end",media_type:t,is_screen:!(null===(f=this._stream)||void 0===f||!f.isScreen),start:k,result:!0,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,event_session_id:this._videoEventSessionId,type:E,transport_delay:r,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(g=this._stream)||void 0===g?void 0:g.pcSessionId)||(null===(y=this._handler)||void 0===y?void 0:y.peerConnectionId)},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this.logger.info("rtcFirstFrameRecv",Fm(T)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",T),this.emit("recvVideoFirstFrame"),this._videoFirstFrameState=3;case 33:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLogin",value:function(e){var t,r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};this._login!==e&&(this._login=e,e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&o.audio&&this.beginRecvFrame("audio","login"),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame("video","login"),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame("audio","leave_room"),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame("video","leave_room"))}},{key:"setUnmuteAudio",value:function(e){var t,r,n;if(this._unMuteAudio!==e){this._unMuteAudio=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasAudio);null!==(r=this._stream)&&void 0!==r&&r.audioHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.audioHasPublish&&(this._unMuteAudio&&i?this.beginRecvFrame("audio","unmute"):i&&this.stopRecvFrame("audio","mute"))}}},{key:"setRemoteUnmuteAudio",value:function(e){this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame("audio","remote_unmute"):this.stopRecvFrame("audio","remote_mute"))}},{key:"setEnableAudio",value:function(e){this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame("audio","enable"):this.stopRecvFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t,r,n;if(this._unMuteVideo!==e){this._unMuteVideo=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasVideo);null!==(r=this._stream)&&void 0!==r&&r.videoHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.videoHasPublish&&(this._unMuteVideo&&i?this.beginRecvFrame("video","unmute"):i&&this.stopRecvFrame("video","mute"))}}},{key:"setHandler",value:function(e){this._handler=e}},{key:"setRemoteUnmuteVideo",value:function(e){this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame("video","remote_unmute"):this.stopRecvFrame("video","remote_mute"))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame("video","enable"):this.stopRecvFrame("video","disable"))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal=e}},{key:"setPushAudio",value:function(e){var t;this._audioExternal&&this._pushAudio!==e&&(this._pushAudio=e),this._pushAudio&&this.beginRecvFrame("audio","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","stop_push")}},{key:"setExternalVideoSource",value:function(e){this._videoExternal=e}},{key:"setPushVideo",value:function(e){var t;this._videoExternal&&this._pushVideo!==e&&(this._pushVideo=e),this._pushVideo&&this.beginRecvFrame("video","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","stop_push")}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame("video","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unpublish")}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame("audio","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unpublish")}},{key:"setAutoSubscribe",value:function(e){this._autoSubscribe=e}},{key:"setAutoSubscribeVideo",value:function(e){this._autoSubscribeVideo=e}},{key:"setAutoSubscribeAudio",value:function(e){this._autoSubscribeAudio=e}},{key:"setSubscribeAudio",value:function(e){var t,r;this._autoSubscribeAudio||this._subscribeAudio===e||(this._subscribe=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasAudio&&this.beginRecvFrame("audio","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unsubscribe")}},{key:"setSubscribeVideo",value:function(e){var t,r;this._autoSubscribeVideo||this._subscribeVideo===e||(this._subscribeVideo=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&this.beginRecvFrame("video","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unsubscribe")}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(this._pushTrack=e,e&&!this._isScreen&&this.beginRecvFrame("audio","push_track"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","remove_track"))}},{key:"setMultiChatMode",value:function(e){this._multiChatMode=e}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"_watchForFirstVideoFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(xm(wm().mark((function n(){var i,o,a,s,c,u,d,l;return wm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a||!a.getTrack()){n.next=12;break}return n.next=3,hV(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.videoTrack)||void 0===u?void 0:u.getTrack());case 3:if(d=n.sent,!(l=kE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.framesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.framesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(xm(wm().mark((function n(){var i,o,a,s,c,u,d,l;return wm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a||!a.getOrgTrack()){n.next=12;break}return n.next=3,hV(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.getOrgTrack());case 3:if(d=n.sent,!(l=kE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.totalSamplesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.totalSamplesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"getTransportDelay",value:(r=xm(wm().mark((function e(){var t=this;return wm().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(xm(wm().mark((function e(){return wm().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=xm(wm().mark((function e(){var t,r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc){e.next=7;break}return e.next=3,hV(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=kE(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=kE(n).call(n,(function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==i?void 0:i.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*o.currentRoundTripTime/2));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"setDisconnect",value:function(){this.stopRecvFrame("audio","connection_lost"),this.stopRecvFrame("video","connection_lost"),this.reset()}},{key:"reset",value:function(){this._currentAudioRecv={startTime:0,eventSessionId:0,type:"login"},this._currentVideoRecv={startTime:0,eventSessionId:0,type:"login"},this._login=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._remoteUnmuteAudio=!1,this._remoteUnmuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoSubscribeVideo=!1,this._autoSubscribeAudio=!1,this._autoSubscribe=!1,this._subscribeAudio=!1,this._subscribeVideo=!1,this._subscribe=!1,this._pushTrack=!1,this._multiChatMode=!1,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._transportDelayInterval&&window.clearInterval(this._transportDelayInterval)}},{key:"audioFirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}},{key:"FirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}}]),a}(JN.EventEmitter),Wz=function(){function e(t,r){Hl(this,e),Zd(this,"_audioEventSessionId",oD()),Zd(this,"_videoEventSessionId",oD()),Zd(this,"_pcSessionId",void 0),Zd(this,"_handler",void 0),Zd(this,"_firstAudioFrameTimer",void 0),Zd(this,"_firstVideoFrameTimer",void 0),Zd(this,"_stream",void 0),Zd(this,"_firstVideoFrameInterval",void 0),Zd(this,"_firstAudioFrameInterval",void 0),Zd(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),Zd(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),Zd(this,"_login",!1),Zd(this,"_publisher",!1),Zd(this,"_unMuteAudio",!1),Zd(this,"_enableAudio",!1),Zd(this,"_unMuteVideo",!1),Zd(this,"_enableVideo",!1),Zd(this,"_audioExternal",!1),Zd(this,"_pushAudio",!1),Zd(this,"_videoExternal",!1),Zd(this,"_pushVideo",!1),Zd(this,"_autoPublish",!1),Zd(this,"_publish",!1),Zd(this,"_timeout",1e4),Zd(this,"_audioFirstFrameState",0),Zd(this,"_videoFirstFrameState",0),Zd(this,"_monitor",void 0),Zd(this,"logger",void 0),this._stream=t,this._handler=r,this._monitor=qP(t.engineId),this.logger=new fM("SendFrameObserver",0,t.engineId)}var t,r;return jl(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if("audio"===e){var n,i,o,a,s,c,u;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var d={event_type:"begin_send",media_type:e,is_screen:!(null===(n=this._stream)||void 0===n||!n.isScreen),type:t,start:this._currentAudioSend.startTime,event_session_id:this._audioEventSessionId,vendor_mode:(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,pc_session_id:(null===(o=this._stream)||void 0===o?void 0:o.pcSessionId)||(null===(a=this._handler)||void 0===a?void 0:a.peerConnectionId),capture_session_id:null===(s=this._stream)||void 0===s||null===(c=s.audioTrack)||void 0===c?void 0:c.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){Kz("audio",r._handler,r._stream,r._monitor),r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),this.logger.info("rtcFirstFrameSend",Fm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if("video"===e){var l,h,p,v,f,_,m;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var g={event_type:"begin_send",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),type:t,start:this._currentVideoSend.startTime,event_session_id:this._videoEventSessionId,vendor_mode:(null===(h=this._stream)||void 0===h?void 0:h.vendorCode)||0,pc_session_id:(null===(p=this._stream)||void 0===p?void 0:p.pcSessionId)||(null===(v=this._handler)||void 0===v?void 0:v.peerConnectionId),capture_session_id:null===(f=this._stream)||void 0===f||null===(_=f.videoTrack)||void 0===_?void 0:_.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){Kz("video",r._handler,r._stream,r._monitor),r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),this.logger.info("rtcFirstFrameSend",Fm(g)),null===(m=this._monitor)||void 0===m||m.report("rtc_first_frame",g),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u,d;if(1!==this._audioFirstFrameState)return;var l={event_type:"sent_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioSend)||void 0===i?void 0:i.type,vendor_mode:(null===(o=this._stream)||void 0===o?void 0:o.vendorCode)||0,pc_session_id:(null===(a=this._stream)||void 0===a?void 0:a.pcSessionId)||(null===(s=this._handler)||void 0===s?void 0:s.peerConnectionId),capture_session_id:null===(c=this._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,this.logger.info("rtcFirstFrameSend",Fm(l)),null===(d=this._monitor)||void 0===d||d.report("rtc_first_frame",l),this._audioFirstFrameState=2}else if("video"===e){var h,p,v,f,_,m,g,y,S;if(1!==this._videoFirstFrameState)return;var b={event_type:"sent_end",media_type:e,start:null===(h=this._currentVideoSend)||void 0===h?void 0:h.startTime,is_screen:!(null===(p=this._stream)||void 0===p||!p.isScreen),reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(v=this._currentVideoSend)||void 0===v?void 0:v.type,vendor_mode:(null===(f=this._stream)||void 0===f?void 0:f.vendorCode)||0,pc_session_id:(null===(_=this._stream)||void 0===_?void 0:_.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId),capture_session_id:null===(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",Fm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if("audio"===e){var t,r,n,i,o,a,s;if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var c=this._currentAudioSend,u=c.type,d=c.startTime,l={event_type:"sent_end",media_type:e,is_screen:!(null===(t=this._stream)||void 0===t||!t.isScreen),start:d,result:!0,event_session_id:this._audioEventSessionId,type:u,vendor_mode:(null===(r=this._stream)||void 0===r?void 0:r.vendorCode)||0,pc_session_id:(null===(n=this._stream)||void 0===n?void 0:n.pcSessionId)||(null===(i=this._handler)||void 0===i?void 0:i.peerConnectionId),capture_session_id:null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.captureSessionId};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this.logger.info("rtcFirstFrameSend",Fm(l)),null===(s=this._monitor)||void 0===s||s.report("rtc_first_frame",l),this._audioFirstFrameState=3}else if("video"===e){var h,p,v,f,_,m,g;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var y=this._currentVideoSend,S=y.type,b=y.startTime,E={event_type:"sent_end",media_type:e,is_screen:!(null===(h=this._stream)||void 0===h||!h.isScreen),start:b,result:!0,event_session_id:this._videoEventSessionId,type:S,vendor_mode:(null===(p=this._stream)||void 0===p?void 0:p.vendorCode)||0,pc_session_id:(null===(v=this._stream)||void 0===v?void 0:v.pcSessionId)||(null===(f=this._handler)||void 0===f?void 0:f.peerConnectionId),capture_session_id:null===(_=this._stream)||void 0===_||null===(m=_.videoTrack)||void 0===m?void 0:m.captureSessionId};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this.logger.info("rtcFirstFrameSend",Fm(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.pubVideo&&this._stream.videoTrack&&this.beginSendFrame("video","login"),null!==(r=this._stream)&&void 0!==r&&r.pubAudio&&this._stream.audioTrack&&this.beginSendFrame("audio","login");!e&&this._audioSending&&this.stopSendFrame("audio","leave_room"),!e&&this._videoSending&&this.stopSendFrame("video","leave_room")}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&this._stream.pubVideo&&this.beginSendFrame("video","publish"),(null===(r=this._stream)||void 0===r?void 0:r.audioTrack)&&this._stream.pubAudio&&this.beginSendFrame("audio","publish");!e&&this._audioSending&&this.stopSendFrame("audio","unpublish"),!e&&this._videoSending&&this.stopSendFrame("video","unpublish")}}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&(e&&this.beginSendFrame("audio","unmute"),!e&&this._audioSending&&this.stopSendFrame("audio","mute")))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubAudio&&(this._enableAudio=e,e&&this.beginSendFrame("audio","enable"),!e&&this._audioSending&&this.stopSendFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&(e&&this.beginSendFrame("video","unmute"),!e&&this._videoSending&&this.stopSendFrame("video","mute")))}},{key:"setEnableVideo",value:function(e){var t;this._enableVideo!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubVideo&&(this._enableVideo=e,e&&this.beginSendFrame("video","enable"),!e&&this._videoSending&&this.stopSendFrame("video","disable"))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame("audio","push"),!e&&this._audioSending&&this.stopSendFrame("audio","stop_push"))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame("video","push"),!e&&this._videoSending&&this.stopSendFrame("video","stop_push"))}},{key:"setAutoPublish",value:function(e){this._autoPublish=e}},{key:"setPublisher",value:function(e){this._publisher!==e&&(this._publisher=e,!e&&this._audioSending&&this.stopSendFrame("audio","audience"),!e&&this._videoSending&&this.stopSendFrame("video","audience"))}},{key:"setDisconnect",value:function(){this._audioSending&&this.stopSendFrame("audio","connection_lost"),this._videoSending&&this.stopSendFrame("video","connection_lost"),this.reset()}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"setPCSessionId",value:function(e){this._pcSessionId=e}},{key:"setHandler",value:function(e){this._handler=e}},{key:"_getFirstVideoFrameStats",value:(r=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.videoTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=6;break}return e.next=3,hV(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,c=Ks(s).call(s,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=xm(wm().mark((function e(){var t,r,n,i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.audioTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=5;break}return e.next=3,hV(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,e.abrupt("return",kE(s).call(s,(function(e){return"outbound-rtp"===e.type})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_watchForFirstVideoFrameSend",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(xm(wm().mark((function n(){var i,o,a;return wm().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||Km(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(xm(wm().mark((function r(){var n;return wm().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e._getFirstAudioFrameStats();case 2:if(!((n=r.sent)&&n.packetsSent>t)){r.next=9;break}if(-1!==t){r.next=7;break}return t=n.packetsSent,r.abrupt("return");case 7:e.sendFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 9:case"end":return r.stop()}}),r)}))),100)}},{key:"reset",value:function(){this._login=!1,this._publisher=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoPublish=!1,this._publish=!1,this._audioFirstFrameState=0,this._videoFirstFrameState=0,this._currentAudioSend={startTime:0,eventSessionId:0,type:"login"},this._currentVideoSend={startTime:0,eventSessionId:0,type:"login"},window.clearTimeout(this._firstAudioFrameTimer),window.clearTimeout(this._firstVideoFrameTimer),window.clearInterval(this._firstAudioFrameInterval),window.clearInterval(this._firstVideoFrameInterval)}},{key:"destroy",value:function(){this.reset(),delete this._stream,delete this._handler}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),qz=(Zd(Gz={},"audio",{delay:1200,stallRadio:.3}),Zd(Gz,"video",{delay:1200,stallRadio:.6}),Zd(Gz,"screen_audio",{delay:1600,stallRadio:.8}),Zd(Gz,"screen_video",{delay:1600,stallRadio:.8}),Gz),Yz=function(){function e(){Hl(this,e),Zd(this,"_preUplinkStats",new ib),Zd(this,"_preDownlinkStats",new ib),Zd(this,"_timer",void 0),Zd(this,"_delayTimer",void 0),Zd(this,"_msc",void 0),Zd(this,"reportor",void 0)}return jl(e,[{key:"updateUplinkStats",value:function(e){var t=e.audioStats,r=e.videoStats,n=e.isScreen;if(t.sendKBitrate>0&&t.rtt){var i,o,a=n?"screen_audio":"audio",s=t.rtt,c=t._fractionLost,u=t._retransmittedRate,d=this._getQosLevel(s,c||0,u||0),l=this._preUplinkStats.get(a)||[d];this._preUplinkStats.set(a,Am(i=Nm(o=[]).call(o,eT(l),[d])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var h,p,v=n?"screen_video":"video",f=r._fractionLost,_=r.rtt,m=r._sendBandWidth,g=r._retransmittedRate;0===m&&(f=Math.max(.65,f));var y=this._getQosLevel(_,f||0,g||0),S=this._preUplinkStats.get(v)||[y];this._preUplinkStats.set(v,Am(h=Nm(p=[]).call(p,eT(S),[y])).call(h,-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){var r;if(t){var n,i,o=this._getStreamActiveState(t),a=o.audioActive,s=o.videoActive,c=e.audioStats,u=e.videoStats,d=e.isScreen,l=e.userId,h=!0,p=!0;if(a)if(0===c.receivedKBitrate)h=!1;else{var v=c.rtt,f=c.audioLossRate,_=c.stallDuration,m=c.statsInterval,g=c.e2eDelay,y=_/m,S=d?"screen_audio":"audio",b=this._getQosLevel(v,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 M=Nm(r="".concat(l)).call(r,d?"_screen":"");if(h||p){var D=n&&i?Math.ceil((n+i)/2):n||i;if(D){var N,L,U=this._preDownlinkStats.get(M)||[D];this._preDownlinkStats.set(M,Am(N=Nm(L=[]).call(L,eT(U),[D])).call(N,-2)),this._startNetworkQualityReport()}}else this._preDownlinkStats.delete(M)}}},{key:"setMSC",value:function(e){this._msc=e}},{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._delayTimer&&(window.clearTimeout(this._delayTimer),delete this._delayTimer),this._preUplinkStats.clear(),this._preDownlinkStats.clear()}},{key:"_startNetworkQualityReport",value:function(){var e=this;this._delayTimer||this._timer||(this._preUplinkStats.size>0||this._preDownlinkStats.size>0)&&(this._delayTimer=window.setTimeout((function(){delete e._delayTimer,e._reportNetworkQuality(),e._timer=window.setInterval((function(){e._reportNetworkQuality()}),2e3)}),300))}},{key:"_reportNetworkQuality",value:function(){var e,t,r,n,i,o=this;if(bk(e=["connected","connecting"]).call(e,null===(t=this._msc)||void 0===t||null===(r=t.handler)||void 0===r?void 0:r.getConnectionState())){var a,s,c,u=this._getBetterQualityAndRemoveOldest("audio","up"),d=this._getBetterQualityAndRemoveOldest("video","up");n=u&&d?Math.ceil((u+d)/2):u||d||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||kl.EXCELLENT;var l=Ks(a=Km(s=Zk(dw(c=this._preDownlinkStats).call(c))).call(s,(function(e){return o._getBetterQualityAndRemoveOldest(e,"down")}))).call(a,(function(e){return e}));i=Math.ceil(gb(l).call(l,(function(e,t){return t+e}),0)/l.length)||kl.UNKNOWN}else n=i=kl.DOWN;navigator.onLine||(n=kl.DOWN,i=kl.DOWN),"function"==typeof this.reportor&&this.reportor(n,i)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getQosLevel",value:function(e,t,r){var n;return n=(!e||e<=250)&&t<=.15?1:(!e||e<=500)&&t<=.3?2:(!e||e<=750)&&t<=.45?3:(!e||e<=1e3)&&t<=.6?4:5,r>.5?n=Math.max(n,4):r>.35?n=Math.max(n,3):r>.15&&(n=Math.max(n,2)),n}},{key:"_getUplinkQoE",value:function(e,t){var r=0;switch(e){case"audio":case"video":r=t<.05?1:t<.1?2:3;break;case"screen_video":case"screen_audio":r=t<.04?1:t<.08?2:3}return r}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=qz[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=kl.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=Ks(i).call(i,(function(e){return e}));o.length>0&&(r=Math.min.apply(Math,eT(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&&gD(t)&&r.localaudio&&r.audiostream,videoActive:n&&yD(t)&&r.localvideo&&r.videostream}}}]),e}(),Jz=function(){function e(t){Hl(this,e),Zd(this,"_timer",void 0),Zd(this,"_remoteVideoSizeCache",{}),Zd(this,"_remoteScreenSizeCache",{}),Zd(this,"onchange",void 0),this._room=t,this._start()}return jl(e,[{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._remoteVideoSizeCache={},this._remoteScreenSizeCache={}}},{key:"_start",value:function(){var e=this;this._timer||(this._timer=window.setInterval((function(){var t={},r={};e._room.remoteStreams.forEach((function(n,i){n.forEach((function(n){var o,a=null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack();if(a){var s=n.isScreen?e._remoteScreenSizeCache:e._remoteVideoSizeCache,c=s[i]||{},u=c.width,d=void 0===u?0:u,l=c.height,h=void 0===l?0:l,p=a.getSettings(),v=p.width,f=void 0===v?0:v,_=p.height,m=void 0===_?0:_;h===m&&d===f||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,f,m),delete s[i],(n.isScreen?r:t)[i]={width:f,height:m}}}))})),cn(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),cn(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),Qz=Zk((new TextEncoder).encode("subt")),Zz={1:_A.SUBTITLE_ERR_POSTPROCESS,2:_A.SUBTITLE_ERR_CONNECTION_ERROR,3:_A.SUBTITLE_ERR_PROCESS_ERROR},$z=new fM("SubtitleTool",1),eK=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&DE(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))||"";DE(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=Fm({source_language:o}))}},tK=function(){function e(t){var r,n,i;Hl(this,e),Zd(this,"_taskId",void 0),Zd(this,"_appId",void 0),Zd(this,"_roomId",void 0),Zd(this,"_userId",void 0),Zd(this,"onEvent",void 0),Zd(this,"onMessage",void 0),Zd(this,"_preConfig",void 0),Zd(this,"_timer",void 0),this._room=t,this._appId=null===(r=this._room._roomInfo)||void 0===r?void 0:r.appId,this._roomId=null===(n=this._room._roomInfo)||void 0===n?void 0:n.roomId,this._userId=null===(i=this._room._roomInfo)||void 0===i?void 0:i.userInfo.userId}var t,r,n,i;return jl(e,[{key:"start",value:(i=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if($z.info("start","Invoke config: %o",t),PN(t.mode,"mode",[xl.ASR_ONLY,xl.ASR_AND_TRANSLATION]),t.mode!==xl.ASR_AND_TRANSLATION||-1!==DE(nK).call(nK,t.targetLanguage||"")){e.next=4;break}throw new SA(_A.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new SA(_A.SUBTITLE_ALREADY_ON,"Already turned on subtitle");case 6:return this._preConfig=t,this._taskId=(Date.now().toString()+this._roomId+this._userId).substring(0,20),e.next=10,this._sendSubtitleSignalingWithRetry(t,this._taskId);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"update",value:(n=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(PN(t.mode,"mode",[xl.ASR_ONLY,xl.ASR_AND_TRANSLATION]),t.mode!==xl.ASR_AND_TRANSLATION||-1!==DE(nK).call(nK,t.targetLanguage||"")){e.next=3;break}throw new SA(_A.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new SA(_A.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new SA(_A.SUBTITLE_NOT_TURNED_ON,"Start subtitle first.");case 7:if((null===(r=this._preConfig)||void 0===r?void 0:r.mode)===t.mode&&this._preConfig.targetLanguage===t.targetLanguage){e.next=11;break}return this._preConfig=t,e.next=11,this._room.subtitleControlMessage(this._genSubtitleSignaling("update",t,this._taskId));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"stop",value:function(){var e=this;$z.info("stop","Invoke"),this._taskId&&this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId}).finally((function(){var t;delete e._taskId,null===(t=e.onEvent)||void 0===t||t.call(e,{event:Ol.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(r=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._taskId||!this._preConfig){e.next=5;break}return e.next=3,this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId});case 3:delete this._taskId,this.start(this._preConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getConfig",value:function(){return this._preConfig}},{key:"destroy",value:function(){$z.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 SA(Zz[r]||_A.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:Ol.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:Ol.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]||this._taskId&&this._preConfig){var t=rK(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){i===xl.ASR_ONLY?e.mode===i&&a.push(e):i===xl.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==xl.ASR_ONLY||a.push(e),e.mode===xl.ASR_ONLY&&e.language===o&&a.push(el(el({},e),{},{mode:xl.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=xm(wm().mark((function t(r,n){var i,o=this,a=arguments;return wm().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._room.subtitleControlMessage(this._genSubtitleSignaling("started",r,n));case 3:this._timer=self.setTimeout((function(){var e;2===i?(null===(e=o.onEvent)||void 0===e||e.call(o,{event:Ol.ERROR,errorCode:_A.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,r){return{taskId:r,type:"subtitle",action:e,roomId:this._roomId,appId:this._appId,userId:this._userId,subtitleMeta:{subtitleConfig:{mode:t.mode,usersConfig:[{userId:this._userId,targetLanguages:[t.targetLanguage||""]}]},vendorConfig:{type:0}}}}},{key:"_clearTimer",value:function(){this._timer&&(self.clearTimeout(this._timer),delete this._timer)}}]),e}();Zd(tK,"retryIntervel",3e4);var rK=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(Qz.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=nD.ab2str(Am(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(c){}return!1},nK=["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"],iK=cd,oK=ic,aK=function(e,t,r,n){for(var i,o=n>1?void 0:n?oK(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&&iK(t,r,o),o},sK=function(){function e(t){Hl(this,e),Zd(this,"_forwardDstRooms",new ib),Zd(this,"forwardStreamState","stopped"),Zd(this,"_monitor",void 0),this._room=t,this._monitor=qP(this._room.id)}var t,r,n,i,o,a;return jl(e,[{key:"startForwardStream2Rooms",value:(a=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!==this.forwardStreamState&&"paused"!==this.forwardStreamState){e.next=2;break}throw new SA(_A.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke startForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("start",this._room.roomInfo.roomId,t);case 4:return r=e.sent,this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),this.forwardStreamState="running",e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(o=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new SA(_A.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke updateForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult(t),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("update",this._room._roomInfo.roomId,t);case 6:r=e.sent;case 7:return this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(i=xm(wm().mark((function e(){var t,r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new SA(_A.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke stopForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult([]),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 6:r=e.sent;case 7:if(this._updateDstRooms([],r),!(eT(dw(t=this._forwardDstRooms).call(t)).length>0)){e.next=10;break}throw new SA(_A.UNEXPECTED_ERROR,"stopforwardstream failed: ".concat(Fm(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=xm(wm().mark((function e(){var t,r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("paused"!==this.forwardStreamState&&"stopped"!==this.forwardStreamState){e.next=2;break}throw new SA(_A.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke pauseForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 4:return t=e.sent,r=this._transformForwardStreamResult(t),this.forwardStreamState="paused",e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(r=xm(wm().mark((function e(){var t,r,n,i,o=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o.length>0&&void 0!==o[0]&&o[0]||!bk(t=["running","stopped"]).call(t,this.forwardStreamState)){e.next=3;break}throw new SA(_A.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke resumeForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 3:return r=this._getDstRooms(),e.next=6,this._sendForwardStreamSignaling("start",this._room._roomInfo.roomId,r);case 6:return n=e.sent,this._updateDstRooms(r,n),i=this._transformForwardStreamResult(n),this.forwardStreamState="running",e.abrupt("return",i);case 11:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"resumeFromReconnect",value:function(){var e=this;"running"===this.forwardStreamState&&this.resumeForwardStream2AllRooms(!0).then((function(t){t.forEach((function(t){t.state===Pl.FORWARD_STREAM_STATE_FAILURE&&e._room.safeEmit(cz.ON_FORWARD_STREAM_ERROR,t)}))}))}},{key:"onForwardDstRoomUserKick",value:function(e){var t=[{dstRoomId:e.dstRoomId,code:200,forwardStreamType:"stop"}];this._updateDstRooms([],t),this._room.safeEmit(cz.ON_FORWARD_STREAM_ERROR,{roomId:e.dstRoomId,state:Pl.FORWARD_STREAM_STATE_FAILURE,error:Ml.FORWARD_STREAM_ERROR_REMOTE_KICKED})}},{key:"clear",value:function(){this._forwardDstRooms.clear(),this.forwardStreamState="stopped"}},{key:"_mockForwardStreamResult",value:function(e){var t=this,r=[];return this._forwardDstRooms.forEach((function(e,t){r.push({dstRoomId:t,forwardStreamType:"stop",code:200})})),e.forEach((function(e){var n,i=eA(r).call(r,(function(t){return t.dstRoomId===e.roomId}));-1===i?r.push({dstRoomId:e.roomId,forwardStreamType:"start",code:e.roomId===(null===(n=t._room.roomInfo)||void 0===n?void 0:n.roomId)?400:200}):r[i].forwardStreamType="update"})),r}},{key:"_transformForwardStreamResult",value:function(e){e||(e=[]);var t,r=[],n=oI(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=i.dstRoomId,a=i.code,s={roomId:o,state:Pl.FORWARD_STREAM_STATE_SUCCESS,error:Ml.FORWARD_STREAM_ERROR_OK};200===a||(400===a?(s.state=Pl.FORWARD_STREAM_STATE_FAILURE,s.error=Ml.FORWARD_STREAM_ERROR_REMOTE_KICKED):a>=700&&a<800?(s.state=Pl.FORWARD_STREAM_STATE_FAILURE,s.error=Ml.FORWARD_STREAM_ERROR_INVALID_TOKEN):(s.state=Pl.FORWARD_STREAM_STATE_FAILURE,s.error=Ml.FORWARD_STREAM_ERROR_RESPONSE)),r.push(s)}}catch(c){n.e(c)}finally{n.f()}return r}},{key:"_updateDstRooms",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];0===(null==r?void 0:r.length)&&this._forwardDstRooms.clear(),r.forEach((function(r){var n=r.dstRoomId,i=r.code,o=r.forwardStreamType;if(200===i)if("stop"===o)t._forwardDstRooms.delete(n);else{var a,s=kE(e).call(e,(function(e){return e.roomId===n}));if(!s&&!t._forwardDstRooms.has(n))throw new SA(_A.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=Mb(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=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="".concat(oD()),"stop"!==t&&(a=Km(n).call(n,(function(e){return e.roomId})),null===(o=this._monitor)||void 0===o||o.report("rtc_forward_stream",{type:"begin",dst_rooms:"{ ".concat(Km(a).call(a,(function(e){return'"'.concat(e,'"')})).join(",")," }"),event_session_id:i})),e.next=4,this._room._mediaServerClient.sendForwardStreamSignal(t,r,n);case 4:if(s=e.sent,c=[],200===(null==s?void 0:s.code)){e.next=9;break}throw"stop"!==t&&(null==n||n.forEach((function(e){c.push({dst_room_id:e.roomId,result:"server error ".concat(null==s?void 0:s.code)})})),null===(u=this._monitor)||void 0===u||u.report("rtc_forward_stream",{type:"end",dst_rooms:Fm(c),event_session_id:i})),new SA(_A.UNEXPECTED_ERROR,"server side internal error, error code: ".concat(s));case 9:return"stop"!==t&&(null===(d=s.forwardStreamResults)||void 0===d||d.forEach((function(e){c.push({dst_room_id:e.dstRoomId,result:"dst room lost"})})),null===(l=s.forwardStreamResults)||void 0===l||l.forEach((function(e){var t=kE(c).call(c,(function(t){return t.dst_room_id===e.dstRoomId}));t&&(200===e.code?"update"===e.forwardStreamType?t.result="update":t.result="success":t.result="server error ".concat(e.code))})),null===(h=this._monitor)||void 0===h||h.report("rtc_forward_stream",{type:"end",dst_rooms:Fm(c),event_session_id:i})),e.abrupt("return",s.forwardStreamResults);case 11:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})}]),e}();function cK(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var r,i,o,a,s=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=this._room._roomInfo)||void 0===r||!r.roomId){e.next=7;break}for(i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=4,n.apply(this,o);case 4:return e.abrupt("return",e.sent);case 7:throw new SA(_A.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 8:case"end":return e.stop()}}),e,this)}))),r}aK([cK],sK.prototype,"startForwardStream2Rooms",1),aK([cK],sK.prototype,"updateForwardStream2Rooms",1),aK([cK],sK.prototype,"stopForwardStream2Rooms",1),aK([cK],sK.prototype,"pauseForwardStream2AllRooms",1),aK([cK],sK.prototype,"resumeForwardStream2AllRooms",1);var uK={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},dK=function(e){UI(x,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C=eR(x);function x(e,t){var r;return Hl(this,x),Zd(sI(r=C.call(this)),"id",void 0),Zd(sI(r),"_mediaServerClient",void 0),Zd(sI(r),"_localStream",void 0),Zd(sI(r),"_localScreenStream",void 0),Zd(sI(r),"_remoteUsers",new ib),Zd(sI(r),"_remoteStreams",new ib),Zd(sI(r),"_remoteStreamStreamIdUserIdMap",{}),Zd(sI(r),"_virtualStreams",[]),Zd(sI(r),"_context",void 0),Zd(sI(r),"_sessionId",void 0),Zd(sI(r),"_connectionLostTimer",void 0),Zd(sI(r),"_serverConfig",void 0),Zd(sI(r),"_roomConfig",void 0),Zd(sI(r),"_roomInfo",void 0),Zd(sI(r),"_userDuplicateLoginTimerMap",new ib),Zd(sI(r),"_networkQualityManager",void 0),Zd(sI(r),"_videoSizeObserver",void 0),Zd(sI(r),"_hasPublished",!1),Zd(sI(r),"_subtitleTool",void 0),Zd(sI(r),"_csrcUserIdMap",void 0),Zd(sI(r),"_publishOnDemandItem",void 0),Zd(sI(r),"_onceTriggerBySignal",!1),Zd(sI(r),"_pubTransceiverReady",!1),Zd(sI(r),"_publishOnDemandBusy",!1),Zd(sI(r),"_monitor",void 0),Zd(sI(r),"logger",void 0),Zd(sI(r),"_forwardStreamManager",void 0),r.id=t.id,r.logger=new fM("Room",1,t.id),r.logger.info("constructor","invoke"),r._roomConfig=e,r._mediaServerClient=new Bz(t),r._networkQualityManager=new Yz,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(sI(r)),r._videoSizeObserver=new Jz(sI(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(sI(r)),r._context=t,r._csrcUserIdMap={},r._monitor=qP(r.id),r._forwardStreamManager=new sK(sI(r)),r._addHandlerEventHandler(),r}return jl(x,[{key:"hasScreenPublished",get:function(){var e;return null===(e=this._localScreenStream)||void 0===e?void 0:e.hasPublished}},{key:"hasPublished",get:function(){var e;return null===(e=this._localStream)||void 0===e?void 0:e.hasPublished}},{key:"connectionState",get:function(){return this._mediaServerClient.connectionState}},{key:"remoteUsers",get:function(){return this._remoteUsers}},{key:"remoteStreams",get:function(){return this._remoteStreams}},{key:"localStream",get:function(){return this._localStream}},{key:"localScreenStream",get:function(){return this._localScreenStream}},{key:"roomInfo",get:function(){return this._roomInfo}},{key:"roomConfig",set:function(e){this._roomConfig=e}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,M,D,N=this;null===(e=this._mediaServerClient)||void 0===e||e.on(ez.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(ez.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return N._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(ez.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(ez.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return N._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(ez.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(ez.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return N._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(ez.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(ez.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return N._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(ez.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(ez.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(ez.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(ez.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(ez.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(ez.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(ez.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(ez.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(ez.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(ez.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(ez.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(ez.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(tz.RSCP,(function(e,t){!!kE(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:bk(t).call(t,null===(r=N._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(t?N._pubTransceiverReady=!0:N._onceTriggerBySignal=!0,t&&N._onceTriggerBySignal||(N._publishOnDemandItem=e),N._pubTransceiverReady&&N._onPublishOnDemand())})),null===(b=this._mediaServerClient)||void 0===b||b.on(tz.RTT,this._onRTT.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(tz.SSC,this._onSSC.bind(this)),null===(k=this._mediaServerClient)||void 0===k||k.on(rz.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(rz.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return N.emit(rz.ON_VENDOR_CONNECTION_STATE_CHANGE,e)})),null===(I=this._mediaServerClient)||void 0===I||I.on(ez.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){N._networkQualityManager.updateDownlinkStats(e,N._findRemoteStreamByScreen(e.userId,e.isScreen)),N.emit(cz.ON_REMOTE_STREAM_STATS,SD(e))})),null===(A=this._mediaServerClient)||void 0===A||A.on(cz.RESUBSCRIBE,(function(e){N.emit(cz.RESUBSCRIBE,e)})),null===(w=this._mediaServerClient)||void 0===w||w.on(cz.RECONNECT_FAILED,(function(){N.emit(cz.RECONNECT_FAILED)})),null===(C=this._mediaServerClient)||void 0===C||C.on("joinSuccess",this._onJoinSucc.bind(this)),null===(x=this._mediaServerClient)||void 0===x||x.on(ez.ON_FORWARD_DST_ROOM_USER_KICK,this._forwardStreamManager.onForwardDstRoomUserKick.bind(this._forwardStreamManager)),null===(O=this._mediaServerClient)||void 0===O||O.on(cz.ON_REJOIN_WITH_TCP,(function(){N.emit(cz.ON_REJOIN_WITH_TCP)})),null===(P=this._mediaServerClient)||void 0===P||P.on(cz.ON_ICE_CONNECT_WITH_TCP,(function(){N.emit(cz.ON_ICE_CONNECT_WITH_TCP)})),null===(M=this._mediaServerClient)||void 0===M||M.on(cz.PUB_RETRY,(function(e){N.emit(cz.PUB_RETRY,e)})),null===(D=this._mediaServerClient)||void 0===D||D.on(cz.SUB_RETRY,(function(e){N.emit(cz.SUB_RETRY,e)}))}},{key:"_onLocalStreamStats",value:function(e){this._networkQualityManager.updateUplinkStats(e),this.emit(cz.ON_LOCAL_STREAM_STATS,SD(e))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(w=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setSessionId(),e.next=3,this._mediaServerClient.connect();case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"join",value:(A=xm(wm().mark((function e(t,r,n,i,o){var a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(a=this._monitor)||void 0===a||a.set({rtc_app_id:t,room_id:r,user_id:i.userId}),this.logger.info("join()"),this._mediaServerClient.setLiveControlMessage(o),this._roomInfo={appId:t,roomId:r,token:n,userInfo:i,roomProfile:this._roomConfig.roomProfileType},this.setSessionId(),e.prev=5,e.next=8,this._mediaServerClient.join(this._roomInfo);case 8:return c=e.sent,null!==(s=c.roomAttributes)&&void 0!==s&&s.multiChatMode&&this._handleFFAudioTrack(),this._initSubtitleTool(),e.abrupt("return",{users:c.clients,streams:c.streams});case 14:if(e.prev=14,e.t0=e.catch(5),e.t0.code===_A.OPERATION_CANCEL){e.next=18;break}throw e.t0;case 18:case"end":return e.stop()}}),e,this,[[5,14]])}))),function(e,t,r,n,i){return A.apply(this,arguments)})},{key:"publishScreen",value:(R=xm(wm().mark((function e(t,r,n,i,o){var a,s,c,u,d,l,h,p,v,f,_,m;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishScreen()"),this._localScreenStream||(this._localScreenStream=new mB(this._context),null!==(a=this._mediaServerClient)&&void 0!==a&&null!==(s=a.vendorConfig)&&void 0!==s&&s.enableMultiVendor&&(this._localScreenStream.pcSessionId=yw()),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new Wz(this._localScreenStream,this._mediaServerClient.handler))),c=!1,u=!1,d=!1,l=!1,!this._localScreenStream.videoTrack&&r?(r instanceof RF&&(u=!0),c=!0):this._localScreenStream.videoTrack&&!r&&(c=!1),!this._localScreenStream.audioTrack&&n?(n instanceof AF&&(l=!0),d=!0):this._localScreenStream.audioTrack&&!n&&(d=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(gD(i)&&(this._localScreenStream.pubAudio=o===dz.PUB),yD(i)&&(this._localScreenStream.pubVideo=o===dz.PUB),this.logger.info("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(h=this._localScreenStream)||void 0===h||!h.hasPublished){e.next=17;break}return e.abrupt("return",this.unpublishScreen());case 17:return e.abrupt("return");case 18:if(this._localScreenStream.hasPublished){e.next=24;break}return null===(p=this._localScreenStream.observer)||void 0===p||p.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return u?null===(v=this._localScreenStream.observer)||void 0===v||v.setPushVideo(c):null===(f=this._localScreenStream.observer)||void 0===f||f.setEnableVideo(c),l?null===(_=this._localScreenStream.observer)||void 0===_||_.setPushAudio(d):null===(m=this._localScreenStream.observer)||void 0===m||m.setEnableAudio(d),e.next=28,this.updatePubScreenTrack();case 28:this._localScreenStream.pubAudio||this._localScreenStream.pubVideo?this._mediaServerClient.handler&&this._localScreenStream.startReport(this._onLocalStreamStats.bind(this),this._localScreenStream.vendorHandler||this._mediaServerClient.handler):this._localScreenStream.stopReport("unpublish screen");case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return R.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(I=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updatePubScreenTrack","Invoke updatePubScreenTrack"),!this._localScreenStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return I.apply(this,arguments)})},{key:"unpublishScreen",value:(T=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=8;break}return null===(t=this._localScreenStream.observer)||void 0===t||t.setPublish(!1),e.next=5,this._mediaServerClient.unpublish(this._localScreenStream);case 5:this._localScreenStream.stopReport("unpublish screen"),this._localScreenStream.clean(),this._localScreenStream=void 0;case 8:case"end":return e.stop()}}),e,this)}))),function(){return T.apply(this,arguments)})},{key:"liveControlMessage",value:(k=xm(wm().mark((function e(t){var r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),e.next=4,this._mediaServerClient.controlMessage(t);case 4:this._mediaServerClient.setLiveControlMessage("stopped"===t.action?void 0:t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(E=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._mediaServerClient.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"subtitleControlMessage",value:(b=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.controlMessage(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"updateUserAttributes",value:(S=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateUserAttributes","Invoke updateUserAttributes"),t.role&&this._roomInfo&&(this._roomInfo.userInfo.role=t.role),e.next=4,this._mediaServerClient.updateUserAttributes(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"publish",value:(y=xm(wm().mark((function e(t,r,n,i,o,a){var s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=E.length>6&&void 0!==E[6]&&E[6],this.logger.info("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new mB(this._context),null!==(u=this._mediaServerClient)&&void 0!==u&&null!==(d=u.vendorConfig)&&void 0!==d&&d.enableMultiVendor&&(this._localStream.pcSessionId=yw()),this._mediaServerClient.handler&&(this._localStream.observer=new Wz(this._localStream,this._mediaServerClient.handler)),c=!0,this._localStream.vendorCode=(null===(l=this._mediaServerClient.vendorConfig)||void 0===l?void 0:l.vendorCode)||0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,o&&(gD(o)&&(this._localStream.pubAudio=a===dz.PUB),yD(o)&&(this._localStream.pubVideo=a===dz.PUB),this.logger.info("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=26;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=12;break}return e.abrupt("return");case 12:return e.prev=12,s?null===(h=this._localStream.observer)||void 0===h||h.setLogin(!0):c&&(p=!!this._localStream.videoTrack,v=!!this._localStream.audioTrack,f=this._localStream.videoTrack instanceof RF,_=this._localStream.audioTrack instanceof AF,this._roomConfig.isAutoPublish&&!this._hasPublished?(p&&(f?null===(m=this._localStream.observer)||void 0===m||m.setPushVideo(!0):null===(g=this._localStream.observer)||void 0===g||g.setEnableVideo(!0)),v&&(_?null===(y=this._localStream.observer)||void 0===y||y.setPushAudio(!0):null===(S=this._localStream.observer)||void 0===S||S.setEnableAudio(!0))):null===(b=this._localStream.observer)||void 0===b||b.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(cz.ON_PUBLISH_RESULT,{isScreen:!1,state:sl.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(cz.ON_PUBLISH_RESULT,{isScreen:!1,state:sl.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:this._localStream.pubAudio||this._localStream.pubVideo?this._mediaServerClient.handler&&this._localStream.startReport(this._onLocalStreamStats.bind(this),this._localStream.vendorHandler||this._mediaServerClient.handler):this._localStream.stopReport("unpublish");case 29:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return y.apply(this,arguments)})},{key:"updatePubTrack",value:(g=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updatePubTrack","Invoke updatePubTrack"),!this._localStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"unpublish",value:(m=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("unpublish","Invoke unpublish"),!this._localStream){e.next=7;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.stopReport("unpublish"),this._localStream.clean(),this._localStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"subscribe",value:(_=xm(wm().mark((function e(t,r,n){var i,o,a;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("subscribe","remoteStream %o",t),!t.hasSubscribed){e.next=8;break}if((i=t.subMediaType|r)===t.subMediaType){e.next=7;break}return e.next=6,null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubMediaType(t,i);case 6:return e.abrupt("return",e.sent);case 7:return e.abrupt("return");case 8:return a=void 0,n&&(a=this._getSubLayer(n,t)),e.next=12,this._mediaServerClient.subscribe(t,r,a);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return _.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(f=xm(wm().mark((function e(t,r){var n,i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((a=this._findRemoteStreamByScreen(t,!1))&&a.hasSubscribed&&!((null==a||null===(n=a.attributes)||void 0===n||null===(i=n.videoDescriptions)||void 0===i?void 0:i.length)<=1)){e.next=3;break}return e.abrupt("return");case 3:return s=this._getSubLayer(r,a),a.originalStreamIndex=s.spatialLayer,e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrackLayer(a,s));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,c=s.videoDescriptions,u=s.subVideoDescriptions,d=Array.isArray(u)?u:c,l=-1,h=e.width*e.height,p=0;p<(null==d?void 0:d.length);p++){var v,f;if(h>=(null===(v=d[p])||void 0===v?void 0:v.width)*(null===(f=d[p])||void 0===f?void 0:f.height)){l=p;break}}var _=d[0];if(-1===l)_=d[l=d.length-1];else if(0!==l){var m=d[l-1].width*d[l-1].height,g=(m-h)/(m-d[l].width*d[l].height);_=g<.1?d[l-1]:d[l],l=g<.1?l-1:l}return a=null!==(r=null===(n=_)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=_)||void 0===o?void 0:o.video_index)&&void 0!==i?i:l,spatialSubLayer:a}}},{key:"unsubscribe",value:(v=xm(wm().mark((function e(t,r){var n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("unsubscribe","Invoke unsubscribe"),t.hasSubscribed){e.next=3;break}return e.abrupt("return");case 3:if(o=t.subMediaType-(t.subMediaType&r),null!==(n=this._context.serverConfig)&&void 0!==n&&n.muteReplaceUnsub||!(o===tB.NONE||this.multiChatMode&&o===ll.AUDIO)){e.next=8;break}return e.next=7,this._mediaServerClient.unsubscribe(t);case 7:return e.abrupt("return",e.sent);case 8:return e.next=10,null===(i=this._mediaServerClient)||void 0===i?void 0:i.updateSubMediaType(t,o);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"startSubtitle",value:(p=xm(wm().mark((function e(t){return wm().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 SA(_A.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"stopSubtitle",value:(h=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(t=this._subtitleTool)||void 0===t||t.stop();case 1:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"startForwardStream2Rooms",value:(l=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.startForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(d=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.updateForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(u=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.stopForwardStream2Rooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(c=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.pauseForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(s=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.resumeForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"leave",value:(a=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=h.length>0&&void 0!==h[0]&&h[0],this.logger.info("leave","Invoke leave"),n=tD(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,delete this._sessionId,e.prev=6,s=oI(cR(a=this._remoteStreams).call(a));try{for(s.s();!(c=s.n()).done;)u=c.value,Array.isArray(u)&&u.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(p){s.e(p)}finally{s.f()}return this._localStream&&(null===(d=this._localStream.observer)||void 0===d||d.setLogin(!1)),e.next=12,this._mediaServerClient.leave().catch((function(){}));case 12:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:tD()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=25;break;case 17:if(e.prev=17,e.t0=e.catch(6),!r){e.next=23;break}throw e.t0;case 23:this.destroy();case 24:e.t0 instanceof Error&&(null===(l=this._monitor)||void 0===l||l.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:tD()-n}));case 25:case"end":return e.stop()}}),e,this,[[6,17]])}))),function(){return a.apply(this,arguments)})},{key:"updateRemoteUserPriority",value:function(e){var t,r=this;null===(t=this.remoteStreams.get(e))||void 0===t||t.forEach((function(t){var n=(r._context||{}).userPriority;t.hasSubscribed&&n.has(e)&&r._mediaServerClient.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e;this.logger.info("destroy","Invoke destroy"),$P(this.id,"room_destroy","".concat((new Error).stack)),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._mediaServerClient.destroy(),this._removeHandlerEventHandler(),this._roomInfo=void 0,this._remoteUsers=new ib;var t,r,n,i=oI(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=aI(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.destroy()}))}}catch(a){i.e(a)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new ib,this._localStream)&&(null===(r=this._localStream)||void 0===r||r.clean(),this._localStream=void 0);this._localScreenStream&&(null===(n=this._localScreenStream)||void 0===n||n.clean(),this._localScreenStream=void 0);this._removeHandlerEventHandler(),clearTimeout(this._connectionLostTimer),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={},this._forwardStreamManager.clear()}},{key:"updateToken",value:(o=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateToken","Invoke updateToken"),this._roomInfo&&(this._roomInfo.token=t),e.prev=2,e.next=5,this._mediaServerClient.updateToken(t);case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(2),this.safeEmit(cz.ON_ROOM_ERROR,{errorCode:_A.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return o.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._mediaServerClient)||void 0===r?void 0:r.sendUserMessage(e,t)}},{key:"setSessionId",value:function(){var e;this._sessionId||(this._sessionId=mw(),this._mediaServerClient._sessionId=this._sessionId,null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId}))}},{key:"sendRoomMessage",value:(i=xm(wm().mark((function e(t){var r,n,i,o,a,s=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=s.length>1&&void 0!==s[1]&&s[1],a={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:o,message:"",roomId:null===(n=this._roomInfo)||void 0===n?void 0:n.roomId},!o){e.next=8;break}return e.next=5,nD.ab2b64str(t);case 5:a.message=e.sent,e.next=9;break;case 8:a.message=t;case 9:return e.abrupt("return",null===(i=this._mediaServerClient)||void 0===i?void 0:i.sendRoomMessage(a));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"_onJoinSucc",value:function(e){var t,r,n,i=this,o=e.joinRes,a=e.reconnect;this.logger.info("_onJoinSucc()","invoke. ".concat(a?"[reconnect]":"")),this._serverConfig=o.config,this._mediaServerClient.roomAttributes=o.roomAttributes;var s=[],c=[],u=[],d=[],l=[];null===(t=o.clientsDetail)||void 0===t||t.forEach((function(e){if(e.attributes&&(e.attributes.serverMuteVideo&&i.safeEmit(cz.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&i.safeEmit(cz.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=oI(cR(r=this._remoteUsers).call(r));try{for(p.s();!(h=p.n()).done;){var v=h.value;v._stillExist||c.push({clientId:v.userId}),delete v._stillExist}}catch(g){p.e(g)}finally{p.f()}o.streams.forEach((function(e){var t=i._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,l.push(e)):d.push(e)}));var f,_=oI(cR(n=this._remoteStreams).call(n));try{for(_.s();!(f=_.n()).done;){var m=f.value;Array.isArray(m)&&m.forEach((function(e){e.stillExist?delete e.stillExist:u.push({clientId:e.userId,streamId:e.streamId,message:ZG.clientDisconnected})}))}}catch(g){_.e(g)}finally{_.f()}c.forEach((function(e){return i._onUserDisconnection(e)})),s.forEach((function(e){return i._onUserConnection(e)})),u.forEach((function(e){return i._onRemoveStream(e)})),d.forEach((function(e){return i._onAddStream(e,{fromSignal:!1})})),l.forEach((function(e){return i._onUpdateStreamAttributes(e)})),a&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r,n,i,o=this;this._localStream&&(this._localStream.clean(),this._localStream.vendorCode=(null===(r=this._mediaServerClient.vendorConfig)||void 0===r?void 0:r.vendorCode)||0,null===(n=this._localStream.observer)||void 0===n||n.setLogin(!0),this._mediaServerClient.publish(this._localStream).catch((function(e){})));this._localScreenStream&&(this._localScreenStream.clean(),null===(i=this._localScreenStream.observer)||void 0===i||i.setLogin(!0),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var a,s=oI(cR(t=this._remoteStreams).call(t));try{for(s.s();!(a=s.n()).done;){var c=a.value;Array.isArray(c)&&c.forEach(function(){var e=xm(wm().mark((function e(t){var r,n,i,a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=17;break}return t.resetHasSubscribed(),e.prev=2,o.logger.info(Nm(r="start resubscribe ".concat(t.userId," with ")).call(r,t.subMediaType)),yD(t.subMediaType)&&(null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!0)),gD(t.subMediaType)&&(null===(i=t.observer)||void 0===i||i.setSubscribeAudio(!0)),e.next=8,o._mediaServerClient.subscribe(t,t.subMediaType);case 8:o.logger.info(Nm(a="success resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType)),o.safeEmit(cz.RESUBSCRIBE,{stream:t}),e.next=17;break;case 12:e.prev=12,e.t0=e.catch(2),o.logger.error(Nm(s=Nm(c="failed resubscribe ".concat(t.userId," with ")).call(c,t.subMediaType,", error:")).call(s,e.t0)),t.clean(),null==t||t.resetHasSubscribed();case 17:case"end":return e.stop()}}),e,null,[[2,12]])})));return function(t){return e.apply(this,arguments)}}())}}catch(u){s.e(u)}finally{s.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect(),this._forwardStreamManager.resumeFromReconnect()}},{key:"_handleFFAudioTrack",value:function(){var e,t,r,n,i=null===(e=this._mediaServerClient)||void 0===e||null===(t=e.handler)||void 0===t?void 0:t.audioTrack4ff,o=null===(r=this._mediaServerClient)||void 0===r||null===(n=r.handler)||void 0===n?void 0:n.getTransceivers();if(i&&Array.isArray(o)){var a=kE(o).call(o,(function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===i}));if(a){var s=new gB(this._context,"ff-stream","ff-stream",!1,!1,uK);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=zF(i),this._virtualStreams.push(s),this.safeEmit(cz.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?kE(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)?kE(r).call(r,(function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.needEmit,i=void 0===n||n,o=r.fromSignal,a=void 0===o||o,s=r.virtual,c=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var u=this._roomConfig,d=u.isAutoSubscribeAudio,l=u.isAutoSubscribeVideo,h=this._findRemoteStreamByScreen(e.clientId,e.screen);if(h&&h.streamId!==e.streamId){var p,v=null===(p=this._remoteStreams.get(e.clientId))||void 0===p?void 0:Ks(p).call(p,(function(e){return e.streamId!==h.streamId}));h.clean(),this._remoteStreams.set(e.clientId,v||[])}var f=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,f)f.attributes=e.attributes;else if((f=new gB(this._context,e.clientId,e.streamId,e.screen,!1,e.attributes)).virtual=c,this._initStreamListeners(f),!c){var _=this._remoteStreams.get(e.clientId);_?_.push(f):this._remoteStreams.set(e.clientId,[f])}if(this._mediaServerClient.handler&&(f.observer=new Xz(f,this._mediaServerClient.handler)),!f.isScreen&&l){var m,g,y,S,b,E,k,T;if(a&&f.hasVideo)if(f.attributes.extvideo)null===(m=f.observer)||void 0===m||m.setExternalVideoSource(!0),null===(g=f.observer)||void 0===g||g.setPushVideo(!0);else null===(y=f.observer)||void 0===y||y.setExternalVideoSource(!1),null===(S=f.observer)||void 0===S||S.setPublishVideo(!0);if(a&&f.hasAudio&&d&&!this._mediaServerClient.roomAttributes.multiChatMode)if(f.attributes.extaudio)null===(b=f.observer)||void 0===b||b.setExternalAudioSource(!0),null===(E=f.observer)||void 0===E||E.setPushAudio(!0);else null===(k=f.observer)||void 0===k||k.setExternalAudioSource(!1),null===(T=f.observer)||void 0===T||T.setPublishAudio(!0);if(i&&!a){var I,R=this._roomConfig,A=R.isAutoSubscribeAudio,w=R.isAutoSubscribeVideo;null===(I=f.observer)||void 0===I||I.setLogin(!0,{audio:!!A&&!this.multiChatMode,video:!!w})}}return i&&this.safeEmit(ez.ON_ADD_STREAM,{stream:f}),f}}},{key:"_onUserConnection",value:function(e){var t;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var r=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof r)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(r);var n={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,el({},n)),this.safeEmit(ez.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(cz.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(cz.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code,a=e.forbiddenTime;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var s=null;i===nz.kickedByAdmin?s=_A.KICKED_OUT:i===nz.onUserTokenDidExpire?s=_A.TOKEN_EXPIRED:i===nz.userDuplicateLogin&&(s=_A.DUPLICATE_LOGIN),o===iz.roomDismissByAdmin&&(s=_A.ROOM_DISMISS),s&&this.safeEmit(cz.ON_ROOM_ERROR,{errorCode:s,forbiddenTime:a})}else{var c=nl.DROPPED;i===nz.userLeave?c=nl.QUIT:i===nz.kickedByAdmin?c=nl.KICKED_BY_ADMIN:i===nz.roleChanged&&(c=nl.SWITCH_TO_INVISIBLE);var u=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:ZG.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(cz.ON_USER_LEAVE,{userInfo:{userId:n},reason:c})};if(i===nz.userDuplicateLogin){var d=this._userDuplicateLoginTimerMap.get(n);d&&self.clearTimeout(d);var l=self.setTimeout(u,5e3);this._userDuplicateLoginTimerMap.set(n,l)}else u()}}},{key:"_onRemoveStream",value:function(e){var t,r=this;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var n=this._remoteStreams.get(e.clientId);if(n){var i=kE(n).call(n,(function(t){return t.streamId===e.streamId}));if(i){var o,a,s;if(null===(o=this._mediaServerClient)||void 0===o||o.handleRemoveStream(i).then((function(){var t=r._remoteStreams.get(e.clientId);t&&(t=Ks(t).call(t,(function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),r._remoteStreams.set(e.clientId,t))})).finally((function(){r.safeEmit(ez.ON_REMOVE_STREAM,{stream:i,reason:e.message,callback:function(){return i.destroy()}})})),i.hasVideo)null===(a=i.observer)||void 0===a||a.setPublishVideo(!1);if(i.hasAudio&&!this._mediaServerClient.roomAttributes.multiChatMode)null===(s=i.observer)||void 0===s||s.setPublishAudio(!1)}}}}},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(cz.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(cz.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=el(el({},this._mediaServerClient.roomAttributes),e.roomAttributes)),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this._roomConfig,r=t.isAutoSubscribeAudio,n=t.isAutoSubscribeVideo,i=e.clientId,o=e.streamId,a=e.attributes,s=this._findRemoteStream(i,o);if(s){var c,u,d=s.attributes,l=el(el({},d),a),h=!1,p=l.localaudio!==d.localaudio,v=!1,f=!1,_=l.localvideo!==d.localvideo,m=!1,g=tB.NONE,y=tB.NONE;if(l.audiostream!==d.audiostream&&(h=l.localaudio,v=!!l.audiostream,l.audiostream?g|=ll.AUDIO:y|=ll.AUDIO),l.videostream!==d.videostream&&(f=l.localvideo,m=!!l.videostream,l.videostream?g|=ll.VIDEO:y|=ll.VIDEO),g&&this.safeEmit(cz.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:dz.PUB,remoteStream:s}),y&&this.safeEmit(cz.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:dz.UNPUB,remoteStream:s}),s.attributes=l,l.localaudio!==d.localaudio)if(l.localaudio){var S,b,E,k;if(r&&l.audiostream)if(l.extaudio)null===(S=s.observer)||void 0===S||S.setExternalAudioSource(!0),null===(b=s.observer)||void 0===b||b.setPushAudio(!0);else null===(E=s.observer)||void 0===E||E.setExternalAudioSource(!1),null===(k=s.observer)||void 0===k||k.setEnableAudio(!0);this.safeEmit(cz.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(cz.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(l.localvideo!==d.localvideo)if(l.localvideo){var w,C,x,O;if(n&&l.videostream)if(l.extvideo)null===(w=s.observer)||void 0===w||w.setExternalVideoSource(!0),null===(C=s.observer)||void 0===C||C.setPushVideo(!0);else null===(x=s.observer)||void 0===x||x.setExternalVideoSource(!1),null===(O=s.observer)||void 0===O||O.setEnableVideo(!0);this.safeEmit(cz.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var P,M,D,N;if(l.extvideo)null===(P=s.observer)||void 0===P||P.setExternalVideoSource(!0),null===(M=s.observer)||void 0===M||M.setPushVideo(!1);else null===(D=s.observer)||void 0===D||D.setExternalVideoSource(!1),null===(N=s.observer)||void 0===N||N.setEnableVideo(!1);!s.isScreen&&this.safeEmit(cz.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!p&&r)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(v);if(f&&!_&&n)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteVideo(m)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&fA(t).call(t,"audio_mux")){var n=this._onAddStream(el(el({},e),{},{attributes:uK}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(cz.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){r.logger.error("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:Nm(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:vz.TRACK_ERROR})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message,o=e.trackType;this.logger.info("_onRemoveTrack","remove track: %o",r);var a=this._findRemoteStream(r,n);a&&(a.removeTrack=!0,null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(a,i,o),this.emit(cz.REMOVE_PUSH_TRACK,{stream:a,mediaType:o+1}))}},{key:"_onMeetingSpeakerChange",value:function(e){if(Array.isArray(null==e?void 0:e.speakerCsrcInfo)){var t={};null==e||e.speakerCsrcInfo.forEach((function(e){var r=e.csrc,n=e.userId;e.isScreen||(t[r]=n)})),this._csrcUserIdMap=t}Array.isArray(e.muxStreamInUse)&&this._virtualStreams.forEach((function(t){var r;null!==(r=e.muxStreamInUse)&&void 0!==r&&bk(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=aI(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&&KR(t).call(t,(function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_onReconnecting",value:function(){var e,t,r,n,i,o,a,s=this;if(this._roomInfo){var c,u=oI(cR(a=this._remoteStreams).call(a));try{for(u.s();!(c=u.n()).done;){var d=c.value;Array.isArray(d)&&d.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()}))}}catch(l){u.e(l)}finally{u.f()}this._virtualStreams.forEach((function(e){var t;s.emit(cz.REMOVE_PUSH_TRACK,{stream:e,mediaType:ll.AUDIO}),null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()})),this._virtualStreams=[],null===(e=this.localStream)||void 0===e||null===(t=e.observer)||void 0===t||t.setDisconnect(),null===(r=this.localStream)||void 0===r||r.clean(),null===(n=this.localScreenStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setDisconnect(),null===(o=this.localScreenStream)||void 0===o||o.clean()}}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===Vz.DISCONNECTED)t=pl.CONNECTION_STATE_DISCONNECTED;else if(e.next===Vz.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._mediaServerClient.isReconnecting?pl.CONNECTION_STATE_RECONNECTED:pl.CONNECTION_STATE_CONNECTED;else{if(e.next!==Vz.CONNECTING)return;this._mediaServerClient.isReconnecting?(t=pl.CONNECTION_STATE_RECONNECTING,this._onReconnecting()):t=pl.CONNECTION_STATE_CONNECTING}e.prev===Vz.CONNECTED&&e.next===Vz.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(rz.ON_CONNECTION_STATE_CHANGE,{state:pl.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setMSC(this._mediaServerClient),this.safeEmit(rz.ON_CONNECTION_STATE_CHANGE,{state:t})}},{key:"_initStreamListeners",value:function(e){var t=this;e.on("ontrack",(function(e){e.track})),e.on("onSEIMessage",(function(r){var n;t.emit(cz.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:null===(n=t._roomInfo)||void 0===n?void 0:n.roomId,streamIndex:e.isScreen?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){var t;null!==(t=this._subtitleTool)&&void 0!==t&&t.onMessageRecv(e)||this.safeEmit(ez.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(ez.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(ez.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new tK(this),this._subtitleTool.onEvent=function(t){e.emit(cz.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(cz.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=uz.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=uz.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?uz.START_FAILED:uz.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?uz.STOP_FAILED:uz.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?uz.UPDATE_FAILED:uz.UPDATE_SUCCESS}this.safeEmit(ez.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(ez.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(ez.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(n=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("publish"!==t.type){e.next=11;break}if(s=void 0,(null===(r=this.localStream)||void 0===r?void 0:r.streamId)===t.streamId?s=this.localStream:(null===(n=this.localScreenStream)||void 0===n?void 0:n.streamId)===t.streamId&&(s=this.localScreenStream),s){e.next=5;break}return e.abrupt("return");case 5:return null===(i=s)||void 0===i||i.clean(),e.next=8,null===(o=this._mediaServerClient)||void 0===o?void 0:o.unpublish(s).catch((function(){}));case 8:null===(a=this._mediaServerClient)||void 0===a||a.publish(s).catch((function(){})),e.next=22;break;case 11:if("subscribe"!==t.type){e.next=22;break}if(c=this._remoteStreamStreamIdUserIdMap[t.streamId],!(u=this._findRemoteStream(c,t.streamId))){e.next=22;break}return h=u.subMediaType,p=u.subLayer,e.next=19,null===(d=this._mediaServerClient)||void 0===d?void 0:d.unsubscribe(u);case 19:return e.next=21,null===(l=this._mediaServerClient)||void 0===l?void 0:l.subscribe(u,h,p);case 21:this.safeEmit(cz.RESUBSCRIBE,{stream:u});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===$G.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=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publishOnDemandItem&&!this._publishOnDemandBusy&&!1!==(null===(t=this._serverConfig)||void 0===t||null===(r=t.engine_VPM)||void 0===r||null===(n=r.ondemand)||void 0===n?void 0:n.enable)){e.next=2;break}return e.abrupt("return");case 2:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(o=this._localStream)||void 0===o||!o.videoTransceiver){e.next=16;break}return this._publishOnDemandBusy=!0,u=this._publishOnDemandItem,this._publishOnDemandItem=void 0,d=[],l=null===(s=this._localStream)||void 0===s?void 0:s.stream.id,h=null===(c=this._localStream)||void 0===c?void 0:c.videoTransceiver.sender,p=h.getParameters(),Array.isArray(p.encodings)&&Array.isArray(u)&&(f={},this.logger.info("_onPublishOnDemand exec","usedDescriptions: %o",u),u.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&bk(t).call(t,l)){var r=null==e?void 0:e.Metadata.VideoIndex;f[r]=!0}})),p.encodings=Km(v=p.encodings).call(v,(function(e){if(e.rid){f[e.rid]?e.active=!0:e.active=!1;var t=Number(e.rid);d[t]=e.active}return e})),this._context&&(this._context.activeSimStreams=d)),e.next=13,h.setParameters(p);case 13:this._publishOnDemandBusy=!1,e.next=18;break;case 16:if(null!==(a=this._localStream)&&void 0!==a&&a.videoTransceiver){e.next=18;break}return e.abrupt("return");case 18:this._onPublishOnDemand();case 19:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_onRTT",value:function(e){var t=e.StreamIds,r=e.Metadata;if(t.length&&r){var n,i=t[0];null!==(n=this._context)&&void 0!==n&&n.streamRTT&&(this._context.streamRTT[i]={audio:r.audio_rtt,video:r.video_rtt})}}},{key:"_onSSC",value:function(e){var t=e.StreamIds,r=e.Metadata,n=t[0],i=this._remoteStreamStreamIdUserIdMap[n],o=this._findRemoteStream(i,n),a={userId:i,isScreen:!!o&&o.isScreen,beforeVideoIndex:r.ssc_items[0].prev_layer_id,afterVideoIndex:r.ssc_items[0].cur_layer_id,beforeEnable:0!==r.ssc_items[0].prev_video_open,afterEnable:0!==r.ssc_items[0].cur_video_open,reason:r.ssc_items[0].change_reason};this.emit(cz.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(cz.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(cz.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"multiChatMode",get:function(){var e;return null===(e=this._mediaServerClient)||void 0===e?void 0:e.multiChatMode()}},{key:"setAudioEncodeMaxBitrate",value:(t=xm(wm().mark((function e(t,r){var n,i,o,a;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(n=t===dl.STREAM_INDEX_MAIN?this.localStream:this.localScreenStream)||!n.pubAudio){e.next=7;break}if(null==(o=null===(i=n.audioTransceiver)||void 0===i?void 0:i.sender.getParameters())||!o.encodings.length){e.next=7;break}return o.encodings[0].maxBitrate=1e3*r,e.next=7,null===(a=n.audioTransceiver)||void 0===a?void 0:a.sender.setParameters(o);case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),x}($N),lK=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&&Mb(r.style,t.style),t.attributes&&CA(t.attributes).forEach((function(e){var t=aI(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},hK=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],pK={playsinline:"","webkit-playsinline":""},vK={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},fK=function(e){UI(n,e);var t,r=eR(n);function n(e,t){var i;Hl(this,n),Zd(sI(i=r.call(this)),"_containerDom",void 0),Zd(sI(i),"_videoDom",void 0),Zd(sI(i),"__cumulativeTime",void 0),Zd(sI(i),"userId",void 0),Zd(sI(i),"renderMode",void 0),Zd(sI(i),"mirrorType",vl.MIRROR_TYPE_NONE),Zd(sI(i),"isScreen",void 0),Zd(sI(i),"isLocal",void 0),Zd(sI(i),"played",!1),Zd(sI(i),"_needLoad",!1),Zd(sI(i),"_emitPlayFailed",!1),Zd(sI(i),"_videoContainer",void 0),Zd(sI(i),"_safari15VideoTimer",void 0),Zd(sI(i),"_monitor",void 0),Zd(sI(i),"logger",void 0),Zd(sI(i),"_onLocalTrackMute",void 0),Zd(sI(i),"_onInterruptionEnd",void 0),Zd(sI(i),"_needResume",!1),Zd(sI(i),"_rotate",0),Zd(sI(i),"_rotateDom",void 0),Zd(sI(i),"_resizeObserver",void 0),Zd(sI(i),"_hasManuallyPaused",!1),Zd(sI(i),"emitVideoEvent",(function(e){var t,r,n={type:"video",rawEvent:e,readyState:(null===(t=i._videoDom)||void 0===t?void 0:t.readyState)||0,userId:i.userId,eventName:e.type,currentTime:(null===(r=i._videoDom)||void 0===r?void 0:r.currentTime)||0,isScreen:i.isScreen};switch(i.emit("playback_event",n),e.type){case"canplay":i.refreshRenderSize("the video started playing."),i._internalPlay();break;case"loadeddata":i._internalPlay();break;case"playing":i.logger.info("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"));break;case"pause":i.logger.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element pause")),i._needResume&&(i.logger.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element resume")),i._internalPlay(),i._needResume=!1)}})),Zd(sI(i),"_internalPlay",(function(){var e,t;if($P(i.engineId,"video _internalPlay",{paused:null===(e=i._videoDom)||void 0===e?void 0:e.paused,hasManuallyPaused:i._hasManuallyPaused}),!i._hasManuallyPaused&&null!==(t=i._videoDom)&&void 0!==t&&t.paused){var r=i._videoDom.play();null!=r&&r.then&&r.then((function(){var e;i.isLocal&&UD&&!i._needLoad&&(null===(e=i._videoDom)||void 0===e||e.load(),i._needLoad=!0)})).catch((function(e){var t,r,n,o,a,s;i._emitPlayFailed||("AbortError"!==e.name?(i._emitPlayFailed=!0,null===(t=i._monitor)||void 0===t||t.report("rtc_error",{message:Nm(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:vz.AUTOPLAY_FAILED}),i.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(n=i._videoDom)||void 0===n?void 0:n.readyState)||0,userId:i.userId,eventName:"autoplay-error",currentTime:(null===(o=i._videoDom)||void 0===o?void 0:o.currentTime)||0,isScreen:i.isScreen})):null===(a=i._monitor)||void 0===a||a.report("rtc_error",{message:Nm(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:vz.AUTOPLAY_FAILED}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=qP(e),i.logger=new fM("Player",0,e);var a=t.userId,s=t.isScreen?ul.RENDER_MODE_FIT:ul.RENDER_MODE_HIDDEN;i.renderMode=void 0!==t.renderMode?t.renderMode:s,i._rotate=Number(t.rotation||0);var c="string"==typeof o?document.getElementById(o):o;if(!c)throw new SA(_A.CANT_FIND_DOM,"can't find dom");return i._videoContainer=document.createElement("div"),i._videoContainer.style.width="100%",i._videoContainer.style.height="100%",i._videoContainer.style.position="relative",i._videoContainer.style.overflow="hidden",i._containerDom=c,i.userId=a,i.isLocal=!!t.isLocal,i.isScreen=!!t.isScreen,i._initVideo(),!i.isLocal||15!==(null==nN?void 0:nN[0])&&15!==eN||(i._safari15VideoTimer=window.setTimeout((function(){try{i._videoContainer.style.display="block",setTimeout((function(){i._videoContainer.style.display="flex"}),500)}catch(BY){}}),1e3)),i}return jl(n,[{key:"_initVideo",value:function(){var e,t,r=this;this._videoDom||(this._videoDom=lK("video",{style:{width:"100%",height:"100%"},attributes:vK}),this._videoDom.id=Nm(t="".concat(this.userId,"_")).call(t,eD()),this.setRenderMode(this.renderMode),this.mirror(this.mirrorType===vl.MIRROR_TYPE_RENDER));this._containerDom.appendChild(this._videoContainer),DE(e=[90,270]).call(e,this._rotate)>-1?(this._rotateDom=this._createRotationDiv(),this._rotateDom.appendChild(this._videoDom),this._videoContainer.appendChild(this._rotateDom)):(180===this._rotate&&(this._videoContainer.style.transform="rotate(180deg)"),this._videoContainer.appendChild(this._videoDom)),this._initListeners(),this._onLocalTrackMute=function(){r._needResume=!0},this._onInterruptionEnd=function(){r.logger.warn("resume player after iOS interruption"),r._internalPlay()},cF.on(aF.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),cF.on(aF.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),cF.on(aF.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd)}},{key:"_createRotationDiv",value:function(){var e=this,t=document.createElement("div");return t.style.transform="rotate(".concat(this._rotate,"deg)"),180!==this._rotate&&(t.style.position="absolute",this.refreshRenderSize("init"),window.ResizeObserver&&(this._resizeObserver=new ResizeObserver((function(){e.refreshRenderSize("the container size has changed.")})),this._resizeObserver.observe(this._containerDom))),t}},{key:"refreshRenderSize",value:function(e){if(this._rotateDom){var t,r;this.logger.print("refreshRenderSize","Because ".concat(e));var n=Number(window.getComputedStyle(this._containerDom).width.replace("px","")),i=Number(window.getComputedStyle(this._containerDom).height.replace("px","")),o=null===(t=this._videoDom)||void 0===t?void 0:t.videoWidth,a=null===(r=this._videoDom)||void 0===r?void 0:r.videoHeight;if(n&&i&&a&&o){var s,c;if(this.renderMode===ul.RENDER_MODE_FILL)s=i,c=n;else{var u=this.renderMode===ul.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&&hK.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&&hK.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.removeEventListener(t,e.emitVideoEvent)}))}},{key:"_recordFrame",value:function(e){var t=this,r=e.isScreen?1.5:.55;if(ND){var n;if(null===(n=this._videoDom)||void 0===n||!n.requestVideoFrameCallback)return;this._videoDom.requestVideoFrameCallback((function n(i,o){var a=o.presentationTime;if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t.__cumulativeTime){var s,c=(a-t.__cumulativeTime)%2e3,u=c>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:u,stallCount:u?1:0,stallDuration:c})}t.__cumulativeTime=a,t._videoDom.requestVideoFrameCallback(n)}))}else this.on("playback_event",(function(n){var i;if("timeupdate"===n.eventName){if(0===(null===(i=t._videoDom)||void 0===i?void 0:i.currentTime))return;if(void 0===t.__cumulativeTime)return void(t.__cumulativeTime=t._videoDom.currentTime);if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t._videoDom.currentTime>t.__cumulativeTime){var o=Math.floor(1e3*(t._videoDom.currentTime-t.__cumulativeTime)),a=t._videoDom.currentTime-t.__cumulativeTime>r;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"_recordPause",value:function(e){var t=this;void 0===e.statsReport.isPaused&&this.on("playback_event",(function(r){if("pause"===r.eventName)e.statsReport.isPaused=!0,e.statsReport.pauseStart=tD();else if("timeupdate"===r.eventName){var n;if((null===(n=t._videoDom)||void 0===n||!n.paused)&&e.statsReport.isPaused){e.statsReport.isPaused=!1;var i=tD()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{key:"setRenderMode",value:function(e){this.renderMode=e,this._videoDom&&(this.renderMode===ul.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this.renderMode===ul.RENDER_MODE_FILL?this._videoDom.style.objectFit="fill":this._videoDom.style.objectFit="cover")}},{key:"playVideo",value:(t=xm(wm().mark((function e(t,r){var n,i,o,a,s=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,this.logger.info("playVideo","play video track: ".concat(this.userId)),!(o&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(n=t.getTrack())||void 0===n?void 0:n.id))){e.next=5;break}try{$P(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(BY){}return e.abrupt("return");case 5:o||(this._initVideo(),o=this._videoDom),this.logger.info("playVideo","play video by dom: ".concat(null===(i=o)||void 0===i?void 0:i.id)),(a=new MediaStream).addTrack(t.getTrack("preprocessing")),o.srcObject=a,o&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),o&&!this._videoContainer.contains(o)&&this._videoContainer.appendChild(o),setTimeout((function(){return s._internalPlay()})),r&&bN.VIDEO_STALL&&(this._recordFrame(r),this._recordPause(r),r.statsReport.player=this),this.played=!0;case 15:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"updateSrcObject",value:function(e){var t=e.getTrack();if(t&&this._videoDom){var r=new MediaStream;r.addTrack(t),this._videoDom.srcObject=r}}},{key:"removeTrack",value:function(){var e,t=null===(e=this._videoDom)||void 0===e?void 0:e.srcObject;if(t){var r=t.getVideoTracks();null!=r&&r.length&&r.forEach((function(e){t.removeTrack(e)}))}}},{key:"manuallyPlay",value:function(){if(this.logger.info("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,this._hasManuallyPaused=!1,!this._videoDom)throw new SA(_A.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||KD?this._videoDom.play():$_.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 SA(_A.INVALID_PARAMS,"Player not found");return this._videoDom.pause()}}},{key:"mirror",value:function(e){var t;this.logger.info("mirror",Nm(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?vl.MIRROR_TYPE_RENDER:vl.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e,t,r=this,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=this._containerDom;(this.logger.info("stop","stop video track: ".concat(this.userId)),this._videoDom)&&(n||(this._videoDom.srcObject=null),null!=i&&i.contains(this._videoContainer)&&i.removeChild(this._videoContainer),null===(e=this._videoContainer)||void 0===e||e.childNodes.forEach((function(e){e!==r._videoDom&&e!==r._rotateDom||r._videoContainer.removeChild(e)})),null!==(t=this._rotateDom)&&void 0!==t&&t.contains(this._videoDom)&&this._rotateDom.removeChild(this._videoDom));this.__cumulativeTime=void 0,this._hasManuallyPaused=!1,this.played=!1}},{key:"destroy",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.logger.info("destroy","video player: ".concat(this.userId)),this.stop(t),null===(e=this._resizeObserver)||void 0===e||e.disconnect(),NI(DI(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),cF.off(aF.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),cF.off(aF.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),cF.off(aF.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}(JN.EventEmitter),_K=function(e){UI(i,e);var t,r,n=eR(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(Hl(this,i),Zd(sI(r=n.call(this)),"_containerDom",void 0),Zd(sI(r),"_audioDom",void 0),Zd(sI(r),"_fakeAudioDom",void 0),Zd(sI(r),"userId",void 0),Zd(sI(r),"muted",!1),Zd(sI(r),"_emitPlayFailed",!1),Zd(sI(r),"played",!1),Zd(sI(r),"isScreen",void 0),Zd(sI(r),"_wechatTimer",void 0),Zd(sI(r),"_edgeTimer",void 0),Zd(sI(r),"_monitor",void 0),Zd(sI(r),"logger",void 0),Zd(sI(r),"_pasued",!0),Zd(sI(r),"emitAudioEvent",(function(e){var t,n,i={type:"audio",rawEvent:e,readyState:(null===(t=r._audioDom)||void 0===t?void 0:t.readyState)||0,userId:r.userId,eventName:e.type,currentTime:(null===(n=r._audioDom)||void 0===n?void 0:n.currentTime)||0};"playing"===e.type&&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||r._internalPlay()),qD&&KD&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),XD&&jD&&"error"===e.type&&(clearTimeout(r._edgeTimer),r._edgeTimer=window.setTimeout((function(){var e;0===(null===(e=r._audioDom)||void 0===e?void 0:e.currentTime)&&r._autoPlayError("edge")}),500)),r.emit("playback_event",i)})),Zd(sI(r),"_internalPlay",(function(){var e,t;if($P(r.engineId,"audio _internalPlay",{paused:null===(e=r._audioDom)||void 0===e?void 0:e.paused}),null!==(t=r._audioDom)&&void 0!==t&&t.paused)try{var n,i=r._audioDom.play(),o=hF.getAudioContextInstance();if("suspended"===o.state){var a=o.resume(),s=setTimeout((function(){var e;"suspended"===o.state&&(r._autoPlayError("AudioContext cannot resume"),null===(e=r._monitor)||void 0===e||e.report("rtc_error",{message:"audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - timeout"),error_code:-1e3}));clearTimeout(s)}));a.catch((function(e){var t,n,i;r._autoPlayError("AudioContext cannot resume"),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Nm(n=Nm(i="audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - rejected by: [")).call(i,null==e?void 0:e.name,"]")).call(n,null==e?void 0:e.message),error_code:-1e3})})).finally((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(qD&&XD&&(i=i.then((function(){return new $_((function(e){setTimeout(xm(wm().mark((function t(){var n;return wm().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(){$P(r.engineId,"_internalPlay successfully",{userId:r.userId}),r._pasued=!1})).catch((function(e){var t,n,i;r._autoPlayError(e),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Nm(n=Nm(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:vz.AUTOPLAY_FAILED})})))}catch(l){var c,u,d;r._autoPlayError(l),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:Nm(u=Nm(d="audio autoplay failed, userId: ".concat(r.userId,": ")).call(d,l.message," ")).call(u,l.name),error_code:vz.AUTOPLAY_FAILED})}})),r.engineId=e,a){var u=document.getElementById(a);if(!u)throw new SA(_A.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=qP(e),r.logger=new fM("Player",0,e),r._initAudio(),r}return jl(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=lK("audio",{style:{display:"none"},attributes:pK}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Nm(e="".concat(this.userId,"_")).call(e,eD()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&hK.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&&(hK.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=xm(wm().mark((function e(t){var r,n,i,o,a,s=this;return wm().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.getTrack())||void 0===r?void 0:r.id))){e.next=4;break}return e.abrupt("return");case 4:o||(this._initAudio(),o=this._audioDom),a=new MediaStream,t instanceof eB?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.getOrgTrack()]),a.addTrack(t.getTrack())):a.addTrack(t.getTrack("preprocessing")),qD&&XD&&(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 SA(_A.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 SA(_A.INVALID_PARAMS,"Player not found");if(!this.played)return $_.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=hF.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?$_.all(r):$_.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,iF.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=Km(r).call(r,(function(e){return e.deviceId})),bk(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(),NI(DI(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom),this._edgeTimer&&clearTimeout(this._edgeTimer)}}]),i}(JN.EventEmitter);function mK(e,t,r,n){var i=function(){var e=xm(wm().mark((function e(t,i){var o,a;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null==n?void 0:n.get(i),Array.isArray(o)&&(o=null===(a=o)||void 0===a?void 0:kE(a).call(a,(function(e){return e.isScreen===r}))),!t){e.next=9;break}if(!t.played){e.next=8;break}return e.next=6,t.manuallyPlay();case 6:e.next=9;break;case 8:o&&(t instanceof fK&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof _K&&o.audioTrack&&t.playAudio(o.audioTrack));case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();if(t)return i(e.get(t),t);var o=[];return e.forEach((function(e,t){return o.push(i(e,t))})),$_.all(o)}var gK=a,yK=pt("iterator"),SK=!gK((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),!e.toJSON||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[yK]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==r||"x"!==new URL("http://x",void 0).host})),bK=Zt,EK=T,kK=2147483647,TK=/[^\0-\u007E]/,IK=/[.\u3002\uFF0E\uFF61]/g,RK="Overflow: input needs wider integers to process",AK=RangeError,wK=EK(IK.exec),CK=Math.floor,xK=String.fromCharCode,OK=EK("".charCodeAt),PK=EK([].join),MK=EK([].push),DK=EK("".replace),NK=EK("".split),LK=EK("".toLowerCase),UK=function(e){return e+22+75*(e<26)},VK=function(e,t,r){var n=0;for(e=r?CK(e/700):e>>1,e+=CK(e/t);e>455;)e=CK(e/35),n+=36;return CK(n+36*e/(e+38))},FK=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=OK(e,r++);if(i>=55296&&i<=56319&&r<n){var o=OK(e,r++);56320==(64512&o)?MK(t,((1023&i)<<10)+(1023&o)+65536):(MK(t,i),r--)}else MK(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&&MK(t,xK(n));var c=t.length,u=c;for(c&&MK(t,"-");u<i;){var d=kK;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=u+1;if(d-o>CK((kK-a)/l))throw AK(RK);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>kK)throw AK(RK);if(n==o){for(var h=a,p=36;;){var v=p<=s?1:p>=s+26?26:p-s;if(h<v)break;var f=h-v,_=36-v;MK(t,xK(UK(v+f%_))),h=CK(f/_),p+=36}MK(t,xK(UK(h))),s=VK(a,l,u==c),a=0,u++}}a++,o++}return PK(t,"")},BK=Cr,jK=o,HK=M,GK=T,zK=x,KK=SK,XK=vi,WK=ny,qK=Vi,YK=Uc,JK=eo,QK=bp,ZK=w,$K=Ze,eX=Qt,tX=mn,rX=nr,nX=te,iX=Sn,oX=Xn,aX=B,sX=kh,cX=_h,uX=Pp,dX=vR,lX=pt("iterator"),hX="URLSearchParams",pX=hX+"Iterator",vX=JK.set,fX=JK.getterFor(hX),_X=JK.getterFor(pX),mX=Object.getOwnPropertyDescriptor,gX=function(e){if(!zK)return jK[e];var t=mX(jK,e);return t&&t.value},yX=gX("fetch"),SX=gX("Request"),bX=gX("Headers"),EX=SX&&SX.prototype,kX=bX&&bX.prototype,TX=jK.RegExp,IX=jK.TypeError,RX=jK.decodeURIComponent,AX=jK.encodeURIComponent,wX=GK("".charAt),CX=GK([].join),xX=GK([].push),OX=GK("".replace),PX=GK([].shift),MX=GK([].splice),DX=GK("".split),NX=GK("".slice),LX=/\+/g,UX=Array(4),VX=function(e){return UX[e-1]||(UX[e-1]=TX("((?:%[\\da-f]{2}){"+e+"})","gi"))},FX=function(e){try{return RX(e)}catch(BY){return e}},BX=function(e){var t=OX(e,LX," "),r=4;try{return RX(t)}catch(BY){for(;r;)t=OX(t,VX(r--),FX);return t}},jX=/[!'()~]|%20/g,HX={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},GX=function(e){return HX[e]},zX=function(e){return OX(AX(e),jX,GX)},KX=YK((function(e,t){vX(this,{type:pX,iterator:sX(fX(e).entries),kind:t})}),"Iterator",(function(){var e=_X(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),XX=function(e){this.entries=[],this.url=null,void 0!==e&&(nX(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===wX(e,0)?NX(e,1):e:iX(e)))};XX.prototype={type:hX,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=cX(e);if(c)for(r=(t=sX(e,c)).next;!(n=HK(r,t)).done;){if(o=(i=sX(rX(n.value))).next,(a=HK(o,i)).done||(s=HK(o,i)).done||!HK(o,i).done)throw IX("Expected sequence with length 2");xX(this.entries,{key:iX(a.value),value:iX(s.value)})}else for(var u in e)$K(e,u)&&xX(this.entries,{key:u,value:iX(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=DX(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=DX(t,"="),xX(this.entries,{key:BX(PX(r)),value:BX(CX(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],xX(r,zX(e.key)+"="+zX(e.value));return CX(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var WX=function(){QK(this,qX),vX(this,new XX(arguments.length>0?arguments[0]:void 0))},qX=WX.prototype;if(WK(qX,{append:function(e,t){uX(arguments.length,2);var r=fX(this);xX(r.entries,{key:iX(e),value:iX(t)}),r.updateURL()},delete:function(e){uX(arguments.length,1);for(var t=fX(this),r=t.entries,n=iX(e),i=0;i<r.length;)r[i].key===n?MX(r,i,1):i++;t.updateURL()},get:function(e){uX(arguments.length,1);for(var t=fX(this).entries,r=iX(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){uX(arguments.length,1);for(var t=fX(this).entries,r=iX(e),n=[],i=0;i<t.length;i++)t[i].key===r&&xX(n,t[i].value);return n},has:function(e){uX(arguments.length,1);for(var t=fX(this).entries,r=iX(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){uX(arguments.length,1);for(var r,n=fX(this),i=n.entries,o=!1,a=iX(e),s=iX(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?MX(i,c--,1):(o=!0,r.value=s));o||xX(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=fX(this);dX(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=fX(this).entries,n=eX(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 KX(this,"keys")},values:function(){return new KX(this,"values")},entries:function(){return new KX(this,"entries")}},{enumerable:!0}),XK(qX,lX,qX.entries,{name:"entries"}),XK(qX,"toString",(function(){return fX(this).serialize()}),{enumerable:!0}),qK(WX,hX),BK({global:!0,constructor:!0,forced:!KK},{URLSearchParams:WX}),!KK&&ZK(bX)){var YX=GK(kX.has),JX=GK(kX.set),QX=function(e){if(nX(e)){var t,r=e.body;if(tX(r)===hX)return t=e.headers?new bX(e.headers):new bX,YX(t,"content-type")||JX(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),oX(e,{body:aX(0,iX(r)),headers:aX(0,t)})}return e};if(ZK(yX)&&BK({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return yX(e,arguments.length>1?QX(arguments[1]):{})}}),ZK(SX)){var ZX=function(e){return QK(this,EX),new SX(e,arguments.length>1?QX(arguments[1]):{})};EX.constructor=ZX,ZX.prototype=EX,BK({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:ZX})}}var $X,eW=Cr,tW=x,rW=SK,nW=o,iW=Qt,oW=T,aW=vi,sW=function(e,t,r){return bK.f(e,t,r)},cW=bp,uW=Ze,dW=Ob,lW=Jk,hW=ai,pW=Fd.codeAt,vW=function(e){var t,r,n=[],i=NK(DK(LK(e),IK,"."),".");for(t=0;t<i.length;t++)r=i[t],MK(n,wK(TK,r)?"xn--"+FK(r):r);return PK(n,".")},fW=Sn,_W=Vi,mW=Pp,gW={URLSearchParams:WX,getState:fX},yW=eo,SW=yW.set,bW=yW.getterFor("URL"),EW=gW.URLSearchParams,kW=gW.getState,TW=nW.URL,IW=nW.TypeError,RW=nW.parseInt,AW=Math.floor,wW=Math.pow,CW=oW("".charAt),xW=oW(/./.exec),OW=oW([].join),PW=oW(1..toString),MW=oW([].pop),DW=oW([].push),NW=oW("".replace),LW=oW([].shift),UW=oW("".split),VW=oW("".slice),FW=oW("".toLowerCase),BW=oW([].unshift),jW="Invalid scheme",HW="Invalid host",GW="Invalid port",zW=/[a-z]/i,KW=/[\d+-.a-z]/i,XW=/\d/,WW=/^0x/i,qW=/^[0-7]+$/,YW=/^\d+$/,JW=/^[\da-f]+$/i,QW=/[\0\t\n\r #%/:<>?@[\\\]^|]/,ZW=/[\0\t\n\r #/:<>?@[\\\]^|]/,$W=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,eq=/[\t\n\r]/g,tq=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)BW(t,e%256),e=AW(e/256);return OW(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+=PW(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},rq={},nq=dW({},rq,{" ":1,'"':1,"<":1,">":1,"`":1}),iq=dW({},nq,{"#":1,"?":1,"{":1,"}":1}),oq=dW({},iq,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),aq=function(e,t){var r=pW(e,0);return r>32&&r<127&&!uW(t,e)?e:encodeURIComponent(e)},sq={ftp:21,file:null,http:80,https:443,ws:80,wss:443},cq=function(e,t){var r;return 2==e.length&&xW(zW,CW(e,0))&&(":"==(r=CW(e,1))||!t&&"|"==r)},uq=function(e){var t;return e.length>1&&cq(VW(e,0,2))&&(2==e.length||"/"===(t=CW(e,2))||"\\"===t||"?"===t||"#"===t)},dq=function(e){return"."===e||"%2e"===FW(e)},lq={},hq={},pq={},vq={},fq={},_q={},mq={},gq={},yq={},Sq={},bq={},Eq={},kq={},Tq={},Iq={},Rq={},Aq={},wq={},Cq={},xq={},Oq={},Pq=function(e,t,r){var n,i,o,a=fW(e);if(t){if(i=this.parse(a))throw IW(i);this.searchParams=null}else{if(void 0!==r&&(n=new Pq(r,!0)),i=this.parse(a,null,n))throw IW(i);(o=kW(new EW)).bindURL(this),this.searchParams=o}};Pq.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||lq,d=0,l="",h=!1,p=!1,v=!1;for(e=fW(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=NW(e,$W,"")),e=NW(e,eq,""),n=lW(e);d<=n.length;){switch(i=n[d],u){case lq:if(!i||!xW(zW,i)){if(t)return jW;u=pq;continue}l+=FW(i),u=hq;break;case hq:if(i&&(xW(KW,i)||"+"==i||"-"==i||"."==i))l+=FW(i);else{if(":"!=i){if(t)return jW;l="",u=pq,d=0;continue}if(t&&(c.isSpecial()!=uW(sq,l)||"file"==l&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=l,t)return void(c.isSpecial()&&sq[c.scheme]==c.port&&(c.port=null));l="","file"==c.scheme?u=Tq:c.isSpecial()&&r&&r.scheme==c.scheme?u=vq:c.isSpecial()?u=gq:"/"==n[d+1]?(u=fq,d++):(c.cannotBeABaseURL=!0,DW(c.path,""),u=Cq)}break;case pq:if(!r||r.cannotBeABaseURL&&"#"!=i)return jW;if(r.cannotBeABaseURL&&"#"==i){c.scheme=r.scheme,c.path=hW(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=Oq;break}u="file"==r.scheme?Tq:_q;continue;case vq:if("/"!=i||"/"!=n[d+1]){u=_q;continue}u=yq,d++;break;case fq:if("/"==i){u=Sq;break}u=wq;continue;case _q:if(c.scheme=r.scheme,i==$X)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=hW(r.path),c.query=r.query;else if("/"==i||"\\"==i&&c.isSpecial())u=mq;else if("?"==i)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=hW(r.path),c.query="",u=xq;else{if("#"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=hW(r.path),c.path.length--,u=wq;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=hW(r.path),c.query=r.query,c.fragment="",u=Oq}break;case mq:if(!c.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=wq;continue}u=Sq}else u=yq;break;case gq:if(u=yq,"/"!=i||"/"!=CW(l,d+1))continue;d++;break;case yq:if("/"!=i&&"\\"!=i){u=Sq;continue}break;case Sq:if("@"==i){h&&(l="%40"+l),h=!0,o=lW(l);for(var f=0;f<o.length;f++){var _=o[f];if(":"!=_||v){var m=aq(_,oq);v?c.password+=m:c.username+=m}else v=!0}l=""}else if(i==$X||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(h&&""==l)return"Invalid authority";d-=lW(l).length+1,l="",u=bq}else l+=i;break;case bq:case Eq:if(t&&"file"==c.scheme){u=Rq;continue}if(":"!=i||p){if(i==$X||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(c.isSpecial()&&""==l)return HW;if(t&&""==l&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(l))return a;if(l="",u=Aq,t)return;continue}"["==i?p=!0:"]"==i&&(p=!1),l+=i}else{if(""==l)return HW;if(a=c.parseHost(l))return a;if(l="",u=kq,t==Eq)return}break;case kq:if(!xW(XW,i)){if(i==$X||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()||t){if(""!=l){var g=RW(l,10);if(g>65535)return GW;c.port=c.isSpecial()&&g===sq[c.scheme]?null:g,l=""}if(t)return;u=Aq;continue}return GW}l+=i;break;case Tq:if(c.scheme="file","/"==i||"\\"==i)u=Iq;else{if(!r||"file"!=r.scheme){u=wq;continue}if(i==$X)c.host=r.host,c.path=hW(r.path),c.query=r.query;else if("?"==i)c.host=r.host,c.path=hW(r.path),c.query="",u=xq;else{if("#"!=i){uq(OW(hW(n,d),""))||(c.host=r.host,c.path=hW(r.path),c.shortenPath()),u=wq;continue}c.host=r.host,c.path=hW(r.path),c.query=r.query,c.fragment="",u=Oq}}break;case Iq:if("/"==i||"\\"==i){u=Rq;break}r&&"file"==r.scheme&&!uq(OW(hW(n,d),""))&&(cq(r.path[0],!0)?DW(c.path,r.path[0]):c.host=r.host),u=wq;continue;case Rq:if(i==$X||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&cq(l))u=wq;else if(""==l){if(c.host="",t)return;u=Aq}else{if(a=c.parseHost(l))return a;if("localhost"==c.host&&(c.host=""),t)return;l="",u=Aq}continue}l+=i;break;case Aq:if(c.isSpecial()){if(u=wq,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=$X&&(u=wq,"/"!=i))continue}else c.fragment="",u=Oq;else c.query="",u=xq;break;case wq:if(i==$X||"/"==i||"\\"==i&&c.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=FW(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"==i||"\\"==i&&c.isSpecial()||DW(c.path,"")):dq(l)?"/"==i||"\\"==i&&c.isSpecial()||DW(c.path,""):("file"==c.scheme&&!c.path.length&&cq(l)&&(c.host&&(c.host=""),l=CW(l,0)+":"),DW(c.path,l)),l="","file"==c.scheme&&(i==$X||"?"==i||"#"==i))for(;c.path.length>1&&""===c.path[0];)LW(c.path);"?"==i?(c.query="",u=xq):"#"==i&&(c.fragment="",u=Oq)}else l+=aq(i,iq);break;case Cq:"?"==i?(c.query="",u=xq):"#"==i?(c.fragment="",u=Oq):i!=$X&&(c.path[0]+=aq(i,rq));break;case xq:t||"#"!=i?i!=$X&&("'"==i&&c.isSpecial()?c.query+="%27":c.query+="#"==i?"%23":aq(i,rq)):(c.fragment="",u=Oq);break;case Oq:i!=$X&&(c.fragment+=aq(i,nq))}d++}},parseHost:function(e){var t,r,n;if("["==CW(e,0)){if("]"!=CW(e,e.length-1))return HW;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 CW(e,l)};if(":"==h()){if(":"!=CW(e,1))return;l+=2,d=++u}for(;h();){if(8==u)return;if(":"!=h()){for(t=r=0;r<4&&xW(JW,h());)t=16*t+RW(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(!xW(XW,h()))return;for(;xW(XW,h());){if(o=RW(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}(VW(e,1,-1)),!t)return HW;this.host=t}else if(this.isSpecial()){if(e=vW(e),xW(QW,e))return HW;if(t=function(e){var t,r,n,i,o,a,s,c=UW(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"==CW(i,0)&&(o=xW(WW,i)?16:8,i=VW(i,8==o?1:2)),""===i)a=0;else{if(!xW(10==o?YW:8==o?qW:JW,i))return e;a=RW(i,o)}DW(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=wW(256,5-t))return null}else if(a>255)return null;for(s=MW(r),n=0;n<r.length;n++)s+=r[n]*wW(256,3-n);return s}(e),null===t)return HW;this.host=t}else{if(xW(ZW,e))return HW;for(t="",r=lW(e),n=0;n<r.length;n++)t+=aq(r[n],rq);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return uW(sq,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&cq(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+=tq(i),null!==o&&(u+=":"+o)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+OW(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw IW(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new Mq(e.path[0]).origin}catch(BY){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+tq(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(fW(e)+":",lq)},getUsername:function(){return this.username},setUsername:function(e){var t=lW(fW(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=aq(t[r],oq)}},getPassword:function(){return this.password},setPassword:function(e){var t=lW(fW(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=aq(t[r],oq)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?tq(e):tq(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,bq)},getHostname:function(){var e=this.host;return null===e?"":tq(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Eq)},getPort:function(){var e=this.port;return null===e?"":fW(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=fW(e))?this.port=null:this.parse(e,kq))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+OW(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Aq))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=fW(e))?this.query=null:("?"==CW(e,0)&&(e=VW(e,1)),this.query="",this.parse(e,xq)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=fW(e))?("#"==CW(e,0)&&(e=VW(e,1)),this.fragment="",this.parse(e,Oq)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Mq=function(e){var t=cW(this,Dq),r=mW(arguments.length,1)>1?arguments[1]:void 0,n=SW(t,new Pq(e,!1,r));tW||(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())},Dq=Mq.prototype,Nq=function(e,t){return{get:function(){return bW(this)[e]()},set:t&&function(e){return bW(this)[t](e)},configurable:!0,enumerable:!0}};if(tW&&(sW(Dq,"href",Nq("serialize","setHref")),sW(Dq,"origin",Nq("getOrigin")),sW(Dq,"protocol",Nq("getProtocol","setProtocol")),sW(Dq,"username",Nq("getUsername","setUsername")),sW(Dq,"password",Nq("getPassword","setPassword")),sW(Dq,"host",Nq("getHost","setHost")),sW(Dq,"hostname",Nq("getHostname","setHostname")),sW(Dq,"port",Nq("getPort","setPort")),sW(Dq,"pathname",Nq("getPathname","setPathname")),sW(Dq,"search",Nq("getSearch","setSearch")),sW(Dq,"searchParams",Nq("getSearchParams")),sW(Dq,"hash",Nq("getHash","setHash"))),aW(Dq,"toJSON",(function(){return bW(this).serialize()}),{enumerable:!0}),aW(Dq,"toString",(function(){return bW(this).serialize()}),{enumerable:!0}),TW){var Lq=TW.createObjectURL,Uq=TW.revokeObjectURL;Lq&&aW(Mq,"createObjectURL",iW(Lq,TW)),Uq&&aW(Mq,"revokeObjectURL",iW(Uq,TW))}_W(Mq,"URL"),eW({global:!0,constructor:!0,forced:!rW,sham:!tW},{URL:Mq});var Vq=r(re.URL),Fq=function(){var e=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(Vq.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)}}(),Bq=cd,jq=ic,Hq=function(e,t,r,n){for(var i,o=n>1?void 0:n?jq(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&&Bq(t,r,o),o},Gq=function(){function e(t,r){Hl(this,e),Zd(this,"_sharedAudioContext",new AudioContext),Zd(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),Zd(this,"_localGainNode",this._sharedAudioContext.createGain()),Zd(this,"_bufferGainNode",this._sharedAudioContext.createGain()),Zd(this,"_audioBufferSource",void 0),Zd(this,"_localSource",void 0),Zd(this,"_context",void 0),Zd(this,"_failedAudioList",[]),Zd(this,"_startingIds",new ib),Zd(this,"_revokeURLs",new GU),Zd(this,"mixingMap",new ib),Zd(this,"resourcesCache",new ib),Zd(this,"volumeConfig",new ib),Zd(this,"cachedBuffer",[]),Zd(this,"id","AudioMixingManager"),this.engineId=r,this._context=t,this._localGainNode.gain.value=1}var t,r,n;return jl(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=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m=this;return wm().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,PN(o=n.type,"mixingType",NG(Ll)),a=this._context.getLocalAudioTrack()){e.next=9;break}return e.abrupt("return");case 9:if((s=a.getTrack("preprocessing"))&&this.mixMediaStream(new MediaStream([s])),null!=(c=this.mixingMap.get(t))&&c.audioNode){c.audioNode.pause(),this._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_STOPPED,error:mA.AUDIO_MIXING_ERROR_OK});try{c.gainNode.disconnect(this._audioDestination),c.audioSource.disconnect(c.gainNode)}catch(g){}}if(!(d=this.resourcesCache.get(t))||d.filePath!==r){e.next=18;break}u=d.getAudioNode(),e.next=31;break;case 18:return e.next=20,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw m._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_FAILED,error:mA.AUDIO_MIXING_ERROR_START_FAILED}),new SA(_A.LOAD_RESOURCES_FAILED,e.statusText)}));case 20:return l=e.sent,rE(r).call(r,"mp3")?h={type:"audio/mpeg"}:rE(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=24,Fq(l,h);case 24:if(e.sent){e.next=28;break}throw this._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_FAILED,error:mA.AUDIO_MIXING_ERROR_START_FAILED}),new SA(_A.LOAD_RESOURCES_FAILED,"invalid audio resource");case 28:(u=new Audio).crossOrigin="anonymous",u.src=Vq.createObjectURL(new Blob([l],h));case 31:return i<=0?u.loop=!0:i>0&&(p=i,u.onended=function(){--p>0?u.play():(m.mixingMap.delete(t),m._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_FINISHED,error:mA.AUDIO_MIXING_ERROR_OK}))}),e.prev=32,e.next=35,u.play();case 35:e.next=42;break;case 37:e.prev=37,e.t0=e.catch(32),console.error(e.t0),this._failedAudioList.push(u),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:dl.STREAM_INDEX_MAIN,mediaType:ll.AUDIO});case 42:if(this._startingIds.delete(t),v=this._sharedAudioContext.createMediaElementSource(u),f=this._sharedAudioContext.createGain(),_=this.volumeConfig.get(t),f.gain.value=_?_/100:1,v.connect(f).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:v,audioNode:u,gainNode:f,type:"file"}),o===Ll.PUBLISH)try{f.disconnect(this._sharedAudioContext.destination)}catch(g){}else f.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_PLAYING,error:mA.AUDIO_MIXING_ERROR_OK});case 52:case"end":return e.stop()}}),e,this,[[32,37]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"stopAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&"file"===t.type&&(this.mixingMap.delete(e),t.audioNode.pause(),t.audioSource.disconnect(t.gainNode),t.gainNode.disconnect(this._audioDestination),this._context.emitMessage({mixId:e,state:Ul.AUDIO_MIXING_STATE_STOPPED,error:mA.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Ul.AUDIO_MIXING_STATE_PAUSED,error:mA.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:Ul.AUDIO_MIXING_STATE_PLAYING,error:mA.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=xm(wm().mark((function e(t,r){var n,i,o=this;return wm().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 SA(_A.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_FAILED,error:mA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof SA)throw e;throw new SA(_A.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,rE(r).call(r,"mp3")?i={type:"audio/mpeg"}:rE(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,Fq(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_FAILED,error:mA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new SA(_A.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Ul.AUDIO_MIXING_STATE_PRELOADED,error:mA.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=Vq.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new $_((function(e){var r=Vq.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)),Vq.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){PN(e,"type",NG(Ll));var t=this._context.getLocalAudioTrack();if(t){var r=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([r])),e===Ll.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:Ul.AUDIO_MIXING_STATE_PCM_ENABLED,error:mA.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:Ul.AUDIO_MIXING_STATE_PCM_DISABLED,error:mA.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=xm(wm().mark((function e(){var t,r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=oI(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:dl.STREAM_INDEX_MAIN,mediaType:ll.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 ib,this._revokeURLs.forEach((function(e){Vq.revokeObjectURL(e)}))}}]),e}();Hq([JP("id","filePath","options")],Gq.prototype,"startAudioMixing",1),Hq([JP("id")],Gq.prototype,"stopAudioMixing",1),Hq([JP("id")],Gq.prototype,"pauseAudioMixing",1),Hq([JP("id")],Gq.prototype,"resumeAudioMixing",1),Hq([JP("id")],Gq.prototype,"preloadAudioMixing",1),Hq([JP("id")],Gq.prototype,"unloadAudioMixing",1),Hq([JP("id")],Gq.prototype,"getAudioMixingVolume",1),Hq([JP("id","volume")],Gq.prototype,"setAudioMixingVolume",1),Hq([JP("id")],Gq.prototype,"getAudioMixingDuration",1),Hq([JP("id")],Gq.prototype,"getAudioMixingCurrentPosition",1),Hq([JP("id","position")],Gq.prototype,"setAudioMixingPosition",1),Hq([JP("type")],Gq.prototype,"enableAudioMixingBuffer",1),Hq([JP()],Gq.prototype,"disableAudioMixingBuffer",1),Hq([JP("buffer")],Gq.prototype,"pushAudioMixingBuffer",1);var zq=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(zq||{}),Kq=function(e){UI(c,e);var t,r,n,i,o,a,s=eR(c);function c(e){var t;return Hl(this,c),Zd(sI(t=s.call(this)),"_dataChannelSignal",void 0),Zd(sI(t),"_handler",void 0),Zd(sI(t),"_dataChannelSignalState",Vz.DISCONNECTED),Zd(sI(t),"_loginSessionId",null),Zd(sI(t),"_userId",null),Zd(sI(t),"_token",null),Zd(sI(t),"_loginResolveCallback",void 0),Zd(sI(t),"_loginRejectCallback",void 0),Zd(sI(t),"_wait_login_token",!1),Zd(sI(t),"_serverParamsCache",void 0),Zd(sI(t),"id",void 0),Zd(sI(t),"_connectionManager",void 0),Zd(sI(t),"isReconnecting",!1),Zd(sI(t),"logger",void 0),t._ctx=e,t.id=e.id,t.logger=new fM("RTMClient",1,e.id),t._connectionManager=new Mz(e),t._addConnectHandler(),t}return jl(c,[{key:"login",value:function(e,t){var r=this;return new $_((function(n,i){var o;if(r.logger.info("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new SA(_A.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new SA(_A.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=qP(r.id))||void 0===o||o.set({rtm_user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():r.connect().then((function(){r._login()}))}))}},{key:"logout",value:(a=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SA(_A.NOT_LOGIN,"login first");case 2:return e.next=4,null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId},{functionType:Oz.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=xm(wm().mark((function e(t){var r=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new $_((function(e,t){r._wait_login_token?(r._loginResolveCallback=e,r._loginRejectCallback=t,r._login()):e()})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(i=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SA(_A.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,peerUserId:t},{functionType:Oz.C2RTM});case 5:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(n=xm(wm().mark((function e(t,r){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SA(_A.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"setServerParams",value:(r=xm(wm().mark((function e(t,r){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,ON(t,"signature"),ON(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new SA(_A.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,signature:t,url:r},{functionType:Oz.C2RTM}).catch((function(e){throw new SA(_A.UNEXPECTED_ERROR,e.msg)}));case 8:this._serverParamsCache={signature:t,url:r},this.emit("onServerParamsSetResult"),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(0),this.emit("onServerParamsSetResult",e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,12]])}))),function(e,t){return r.apply(this,arguments)})},{key:"sendServerMessage",value:(t=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SA(_A.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:"",room:"",type:Rz.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e;this.logger.info("destroy","invoke."),NI(DI(c.prototype),"removeAllListeners",this).call(this),this._loginResolveCallback&&this._loginRejectCallback&&(this._loginRejectCallback(new SA(_A.LOGIN_FAILED,"logout")),delete this._loginResolveCallback,delete this._loginRejectCallback),null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),delete this._dataChannelSignal,this._clearState(),this._connectionManager.destroy(),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=eD();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:nD.token2auth(this._ctx.appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:bN.VERSION,deviceId:vN.getDeviceId(),appId:this._ctx.appId,userId:this._userId},accessParams:Fm({requireICEUfragV2:!0})},{functionType:Oz.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,VP.setRtsSessionId(e.id,t),e._wait_login_token=!1,e._serverParamsCache&&e.setServerParams(e._serverParamsCache.signature,e._serverParamsCache.url)})).catch((function(t){var r,n,i=t||{},o=i.code,a=i.message;e._wait_login_token=!1,o>=700&&o<800?708===o?(r=_A.INVALID_PARAMS,n="Invalid userId"):(r=_A.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=_A.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new SA(r,a||n))})).finally((function(){delete e._loginResolveCallback,delete e._loginRejectCallback}))}}},{key:"connect",value:function(){var e=this;return new $_((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==Vz.CONNECTED)throw new SA(_A.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n;e._dataChannelSignalState=Vz.CONNECTED,e.logger.info("connectStateChange","connected"),null===(r=e._handler)||void 0===r||r.destroy(),null===(n=e._dataChannelSignal)||void 0===n||n.destroy(),e._handler=QG(e._ctx,t.pc),e._dataChannelSignal=t.signaling,e._addSignalEventHandler(),e.isReconnecting&&e._login()})),this._connectionManager.on("disconnected",(function(t){e._dataChannelSignalState=Vz.DISCONNECTED,e.logger.warn("connectStateChange","disconnected. %o",t),e.isReconnecting&&(e.emit("onUserDisconnection"),e._clearState())})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=Vz.CONNECTING,e.logger.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=Vz.CONNECTING,e.logger.warn("connectStateChange","reconnecting")}))}},{key:"_addSignalEventHandler",value:function(){var e,t,r,n=this;null===(e=this._dataChannelSignal)||void 0===e||e.on(ez.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(t=this._dataChannelSignal)||void 0===t||t.on(ez.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(r=this._dataChannelSignal)||void 0===r||r.on(ez.USER_DISCONNECTION,(function(){n.emit("onUserDisconnection"),n._clearState()}))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,VP.setRtsSessionId(this.id,"")}}]),c}(JN.EventEmitter),Xq=function(){function e(t){Hl(this,e),Zd(this,"_roomId",void 0),Zd(this,"_constraints",{}),Zd(this,"_profile",void 0),Zd(this,"_customMaxBitrate",0),this._appId=t}return jl(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=vN.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=vN.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=aI(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),Km(e=cn(c)).call(e,(function(e){var t;return Nm(t="".concat(e,"=")).call(t,c[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=el(el({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=el({},this._constraints),t=vN.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;ED(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),ED(null==t?void 0:t.channel)||(e.channelCount=t.channel),ED(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),ED(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),ED(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return ED(e.sampleRate)&&!ED(n)&&(e.sampleRate=n),ED(e.channelCount)&&!ED(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case Rl.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case Rl.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case Rl.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case Rl.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case Rl.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),Wq=function(e){UI(o,e);var t,r,n,i=eR(o);function o(e,t,r){var n,a=r.businessId;return Hl(this,o),Zd(sI(n=i.call(this)),"_mediaServerClient",void 0),Zd(sI(n),"_appId",void 0),Zd(sI(n),"remoteStreams",void 0),Zd(sI(n),"_businessId",void 0),Zd(sI(n),"_ctx",void 0),n.id=e,n._appId=t,n.remoteStreams=new ib,n._businessId=a,n._ctx={id:n.id,appId:n._appId,avSync:!0,audioProfileManager:new Xq(n._appId),useCloudProxy:!1,userPriority:new ib,joinRoomConfig:new _N(n.id),enableFallbackHandler:_Y(t),enableStandardHandler:mY(t),pcKillSwitch:el(el({ctor_sdpsemantics_add:!0,ctor_encodedinsetablestream_add:!0,sld_rtcpfb_rrtr_add:!0,sld_ext_sdesmid_remove:!0,sld_fmtp_sps_add:!0,sld_fmtp_bitrate_add:!0,sld_fmtp_opus_add:!0},kN("PC_KILLSWITCH")),fY(n._appId))},n}return jl(o,[{key:"connect",value:(n=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new Bz(this._ctx),this._mediaServerClient.publicStream=!0,this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=6,this._mediaServerClient.connect();case 6:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=xm(wm().mark((function e(t){var r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new SA(_A.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new gB(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.emit(cz.ON_SEI_MESSAGED_RECEIVED,{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._mediaServerClient.subscribePublicStream(r);case 6:return this.remoteStreams.set(t,r),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopPlayPublicStream",value:function(e){var t=this.remoteStreams.get(e);if(t)return this.remoteStreams.delete(e),this._mediaServerClient.unsubscribePublicStream(t)}},{key:"destroy",value:function(){var e;this.remoteStreams.forEach((function(e){e.clean()})),this.remoteStreams=new ib,null===(e=this._mediaServerClient)||void 0===e||e.destroy(),this.removeAllListeners()}},{key:"_handleReconnected",value:(t=xm(wm().mark((function e(){var t,r,n,i=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=oI(this.remoteStreams);try{for(n=function(){var e=aI(r.value,2),t=e[0],n=e[1];n.clean(),n.statsReport.unsubscribe(),i.remoteStreams.delete(t),i.startPlayPublicStream(t).then((function(){var e=i.remoteStreams.get(t);i.safeEmit(cz.RESUBSCRIBE,{stream:e})}))},t.s();!(r=t.n()).done;)n()}catch(o){t.e(o)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on("connectSuccess",(function(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).reconnect&&r._handleReconnected()})),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}($N),qq=new fM("AudioDeviceManager",1),Yq=function(e){UI(c,e);var t,r,n,i,o,a,s=eR(c);function c(e,t){var r;return Hl(this,c),Zd(sI(r=s.call(this)),"_audioLevelFetcher",void 0),Zd(sI(r),"_playbackDeviceTestTimer",void 0),Zd(sI(r),"_audioElement",void 0),Zd(sI(r),"_audioTrack",void 0),Zd(sI(r),"_mediaRecorder",void 0),Zd(sI(r),"_recoderTimer",void 0),Zd(sI(r),"_isAudioPlaybackDeviceTesting",!1),Zd(sI(r),"_isAudioDeviceRecordTesting",!1),Zd(sI(r),"_audioCaptureAndRecoderResolve",void 0),Zd(sI(r),"_onAutoplayFailed",void 0),Zd(sI(r),"_audioPlaybackDeviceId",void 0),r._ctx=e,r._extensionManager=t,r}return jl(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=xm(wm().mark((function e(t,r){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new SA(_A.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,qq.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),qq.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&&(qq.info("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=xm(wm().mark((function e(t,r,n){var i,o=this,a=arguments;return wm().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 SA(_A.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 3:if(!this._isAudioDeviceRecordTesting&&!this._isAudioPlaybackDeviceTesting){e.next=5;break}throw new SA(_A.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 5:return this._isAudioDeviceRecordTesting=!0,qq.info("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){qq.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(){qq.info("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(qq.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=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(qq.info("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new SA(_A.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,iF.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new SA(_A.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(){qq.info("destroy()","Invoke"),NI(DI(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=xm(wm().mark((function e(t,r){var n,i=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qq.info("_playAudioFile()",Nm(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new $_((function(e,n){var o=lK("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new lF(o),o.onplaying=function(){o.onplaying=null,qq.info("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=xm(wm().mark((function e(t){var r,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:qq.error("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new SA(_A.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;qq.warn("_playAudioFile()","autoplay error",e);var r=Nm(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return $_.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new SA(_A.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&&(qq.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&&(qq.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&&(qq.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=xm(wm().mark((function e(t,r){var n,i=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,VF(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r),n=new MediaStream([this._audioTrack.getTrack("preprocessing")]),qq.info("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new $_((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=kE(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),qq.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=xm(wm().mark((function n(o){var a,c;return wm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return qq.info("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(Vq.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 SA(_A.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},i._audioCaptureAndRecoderResolve=e,i._mediaRecorder.start()})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_stopAudioCaptureAndRecoder",value:function(){var e;this._mediaRecorder&&("recording"===this._mediaRecorder.state&&this._mediaRecorder.stop(),delete this._mediaRecorder),null===(e=this._audioTrack)||void 0===e||e.close(),delete this._audioTrack}},{key:"_setAudioCtxSinkId",value:(t=xm(wm().mark((function e(){var t,r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=hF.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),qq.info("setSinkId","ctx.sinkId=".concat(t))}catch(o){qq.error("setSinkId",Nm(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}(JN.EventEmitter),Jq=new fM("VideoSnapshot",1),Qq=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},Zq=function(){var e=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=document.createElement("canvas"),o=i.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(a=function(e,t,n){return t=t||e.width,n=n||e.height,i.width=t,i.height=n,r?o.setTransform(-1,0,0,1,t,0):o.setTransform(1,0,0,1,0,0),o.drawImage(e,0,0,t,n),o.getImageData(0,0,t,n)},s=Date.now(),!(c=Qq(n))){e.next=16;break}return Jq.info("takeSnapshot","VideoPlayer already set."),e.next=11,a(c,c.videoWidth,c.videoHeight);case 11:return u=e.sent,Jq.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",u);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(d=new window.ImageCapture(t)).track.readyState||!d.track.enabled||d.track.muted){e.next=29;break}return Jq.info("takeSnapshot","use ImageCapture"),e.t0=a,e.next=23,d.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return l=e.sent,Jq.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 29:return Jq.info("takeSnapshot","use temp video"),e.abrupt("return",new $_((function(e,r){var n=new MediaStream([t]),i=document.createElement("video");i.setAttribute("playsinline",""),i.muted=!0,document.body.appendChild(i),i.onplaying=function(){var r=a(i,i.videoWidth,i.videoHeight);Jq.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e(r),n.removeTrack(t),i.srcObject=null,i.load()},i.onerror=r,i.srcObject=n,i.play()})));case 31:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),$q=function(){return{url:"",video:{codec:Cl.H264,width:640,height:360,fps:15,gop:2,kBitRate:eY(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:wl.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function eY(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 tY(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new SA(_A.INVALID_PARAMS,"Invalid rtmp address")}function rY(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new SA(_A.INVALID_PARAMS,"regions should not be empty.");var t,r=oI(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new SA(_A.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new SA(_A.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(i){r.e(i)}finally{r.f()}}function nY(e,t){var r,n,i,o=function(e,r){var n=gb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=gb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),$q());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!!kE(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 bk(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return bk(t=[wl.LC,wl.HEv1,wl.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return bk(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:eY(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:Km(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&&bk(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&bk(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 iY,oY={getDefaultValue:$q,checkStartParams:function(e){var t;tY(e.url),rY(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&tY(e.url),rY(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return nY("started",e)},getUpdateParams:function(e){return nY("layoutChanged",e)}},aY=cd,sY=ic,cY=function(e,t,r,n){for(var i,o=n>1?void 0:n?sY(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&&aY(t,r,o),o},uY=function(e){UI(Ie,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,M,D,N,L,U,V,F,B,j,H,G,z,K,X,W,q,Y,J,Q,Z,$,ee,te,re,ne,ie,oe,ae,se,ce,ue,de,le,he,pe,ve,fe,_e,me,ge,ye,Se,be,Ee,ke,Te=eR(Ie);function Ie(e,t,r){var n;return Hl(this,Ie),Zd(sI(n=Te.call(this)),"monitor",void 0),Zd(sI(n),"logger",void 0),Zd(sI(n),"_room",void 0),Zd(sI(n),"_publicStreamManager",void 0),Zd(sI(n),"_appId",void 0),Zd(sI(n),"_businessId",void 0),Zd(sI(n),"_visibility",!0),Zd(sI(n),"_localVideoTrack",void 0),Zd(sI(n),"_localAudioTrack",void 0),Zd(sI(n),"_localImgVideoTrack",void 0),Zd(sI(n),"_localImgScreenTrack",void 0),Zd(sI(n),"_localScreenVideoTrack",void 0),Zd(sI(n),"_localScreenAudioTrack",void 0),Zd(sI(n),"_tempMixingAudioTrack",void 0),Zd(sI(n),"_localAudioVolume",100),Zd(sI(n),"_localScreenAudioVolume",100),Zd(sI(n),"_remoteAudioVolume",new ib),Zd(sI(n),"_remoteScreenAudioVolume",new ib),Zd(sI(n),"_publicAudioVolume",new ib),Zd(sI(n),"_videoPlayer",void 0),Zd(sI(n),"_screenPlayer",void 0),Zd(sI(n),"_remoteVideoPlayer",new ib),Zd(sI(n),"_remoteScreenPlayer",new ib),Zd(sI(n),"_remoteAudioPlayer",new ib),Zd(sI(n),"_remoteScreenAudioPlayer",new ib),Zd(sI(n),"_publicStreamAudioPlayer",new ib),Zd(sI(n),"_publicStreamVideoPlayer",new ib),Zd(sI(n),"_publicStreamIds",new ib),Zd(sI(n),"_roomConfig",void 0),Zd(sI(n),"_videoStreamConstraints",el({},AN)),Zd(sI(n),"_audioStreamConstraints",{}),Zd(sI(n),"_enableSimulcast",!1),Zd(sI(n),"_videoStreamEncodeConfig",[el({},AN)]),Zd(sI(n),"_screenStreamEncodeConfig",[el({},wN)]),Zd(sI(n),"_dummyMainImage",void 0),Zd(sI(n),"_dummyScreenImage",void 0),Zd(sI(n),"_trackSourceType",void 0),Zd(sI(n),"_liveTranscodeConfig",void 0),Zd(sI(n),"_startCloudProxyTimestamp",void 0),Zd(sI(n),"_localVideoDeviceId",void 0),Zd(sI(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),Zd(sI(n),"_audioVolumeIndicationTimer",void 0),Zd(sI(n),"_dummyMainTimer",void 0),Zd(sI(n),"_dummyScreenTimer",void 0),Zd(sI(n),"_audioPropertiesReportTimer",null),Zd(sI(n),"_mirrorType",vl.MIRROR_TYPE_RENDER),Zd(sI(n),"_audioMixingManager",void 0),Zd(sI(n),"_pubLock",void 0),Zd(sI(n),"_subLocks",void 0),Zd(sI(n),"_audioCaptureLock",void 0),Zd(sI(n),"_videoCaptureLock",void 0),Zd(sI(n),"_screenCaptureLock",void 0),Zd(sI(n),"_subScreenLocks",void 0),Zd(sI(n),"_rtmClient",void 0),Zd(sI(n),"_messageStatisticsObserver",void 0),Zd(sI(n),"_tempRoomInfo",void 0),Zd(sI(n),"_originIceConfigRequestUrls",void 0),Zd(sI(n),"_originConfigServerUrls",void 0),Zd(sI(n),"_originLogServerUrl",void 0),Zd(sI(n),"_extensionManager",void 0),Zd(sI(n),"_audioDeviceManager",void 0),Zd(sI(n),"_remoteVideoConfig",new ib),Zd(sI(n),"_config",void 0),Zd(sI(n),"_needClosePreTrack",!1),Zd(sI(n),"_ctx",void 0),Zd(sI(n),"_updateMixAudioTrack",function(){var e=xm(wm().mark((function e(t){var r,i,o=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:Ll.PLAYOUT_AND_PUBLISH,n.logger.info("_updateMixAudioTrack()"),n._localAudioTrack){e.next=5;break}return t&&(n._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(n._localAudioTrack.mixType=i,n._localAudioTrack.mixedAudioTrack=t):(delete n._localAudioTrack.mixType,delete n._localAudioTrack.mixedAudioTrack),null===(r=n._room)||void 0===r||!r.hasPublished){e.next=9;break}return e.next=9,n._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),Zd(sI(n),"_onAudioMixingMessage",(function(e){n.safeEmit(Fl.onAudioMixingStateChanged,e)})),Zd(sI(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(Fl.onAutoplayFailed,e)})),n.id=t,n._appId=e,n.monitor=qP(t),n._ctx={id:t,appId:e,avSync:!0,streamRTT:{},useCloudProxy:!1,audioProfileManager:new Xq(e),userPriority:new ib,expectedIDC:null==r?void 0:r.expectedIDC,joinRoomConfig:new _N(t),enableFallbackHandler:_Y(e),enableStandardHandler:mY(e),pcKillSwitch:el(el({ctor_sdpsemantics_add:!0,ctor_encodedinsetablestream_add:!0,sld_rtcpfb_rrtr_add:!0,sld_ext_sdesmid_remove:!0,sld_fmtp_sps_add:!0,sld_fmtp_bitrate_add:!0,sld_fmtp_opus_add:!0},kN("PC_KILLSWITCH")),fY(n._appId))},n._pubLock=new sz("pubLock"),n._subLocks=new ib,n._subScreenLocks=new ib,n._audioCaptureLock=new sz("audioCap"),n._videoCaptureLock=new sz("videoCap"),n._screenCaptureLock=new sz("screenCap"),n._addDeviceEventHandler(),n._extensionManager=new vF(t),n._audioDeviceManager=new Yq(n._ctx,n._extensionManager),n._audioMixingManager=new Gq({getLocalAudioTrack:function(){return n._localAudioTrack},updateLocalAudioTrack:n._updateMixAudioTrack,emitMessage:n._onAudioMixingMessage,onAutoPlayFailed:n._onAudioMixingAutoplayFailed},t),window.__rtc_engine__=sI(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=sI(n),n._trackSourceType={video:tl.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:tl.VIDEO_SOURCE_TYPE_INTERNAL,audio:rl.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:rl.AUDIO_SOURCE_TYPE_INTERNAL},n._config=r,n._rtmClient=new Kq(n._ctx),n._handleRTMClient(n._rtmClient),n._handleAudioDeviceManager(),n._messageStatisticsObserver=new FP(t),n.logger=new fM("Engine",0,t),VP.createRTSMsgReportor(n.id),n._getServerConfig(),n}return jl(Ie,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(ke=xm(wm().mark((function e(t){var r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("updateToken()","token: %s",t),ON(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return r=this._tempRoomInfo,n=r.config,i=r.userInfo,o=r.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,o,i,n);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new SA(_A.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,this._room.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return ke.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(Ee=xm(wm().mark((function e(t){var r,n,i,o,a,s=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setVideoCaptureDevice()","deviceId: %s",t),ON(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:if(!KD||!qD){e.next=9;break}if(this._localVideoTrack.getTrack().getSettings().deviceId!==t){e.next=9;break}return e.abrupt("return");case 9:return n=sH({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete n.deviceId,n.facingMode=t):!HD||WD?n.deviceId={exact:t}:delete n.deviceId,qD&&LD&&aN>=85&&aN<=91&&(null===(i=this._videoPlayer)||void 0===i||i.removeTrack()),this._needClosePreTrack=this._needClosePreTrack||sV,this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),this.logger.info("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=17,LF(n,this._extensionManager).catch((function(e){if(s._localVideoTrack&&!s._localVideoTrack.dummy)return s.logger.warn("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),s._removeLocalTrackEvents(s._localVideoTrack),s._localVideoTrack.close(),delete s._localVideoTrack,LF(n,s._extensionManager).then((function(e){return s._needClosePreTrack=!0,e})).catch(xm(wm().mark((function t(){var r;return wm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.logger.error("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,LF(s._videoStreamConstraints,s._extensionManager);case 3:throw r=t.sent,s._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 17:return o=e.sent,this.logger.success("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=n,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null!==(r=this._videoStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&o.setContentHint(null===(a=this._videoStreamEncodeConfig[0])||void 0===a?void 0:a.contentHint),e.next=24,this._switchTrack(o);case 24:case"end":return e.stop()}}),e,this)}))),function(e){return Ee.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(be=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setAudioCaptureDevice()","deviceId: %s",t),ON(t,"deviceId"),this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.next=9,VF(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 be.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){iF.on(Fl.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),iF.on(Fl.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R,A,w,C,x,O,P,M,D,N,L,U=this;null===(e=this._room)||void 0===e||e.on(ez.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(ez.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(ez.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(cz.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(cz.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(cz.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(ez.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(ez.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(ez.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(ez.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(ez.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?U._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?U._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&U._onLiveTranscodingResult(e)})),null===(l=this._room)||void 0===l||l.on(rz.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(rz.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return U.safeEmit(Fl.onVendorConnectionStateChanged,e)})),null===(p=this._room)||void 0===p||p.on(cz.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(v=this._room)||void 0===v||v.on(cz.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(cz.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(_=this._room)||void 0===_||_.on(cz.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=U._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&U.safeEmit(Fl.onAutoPublishResult,e)})),null===(m=this._room)||void 0===m||m.on(cz.ON_REMOTE_STREAM_STATS,(function(e){U.safeEmit(Fl.onRemoteStreamStats,e)})),null===(g=this._room)||void 0===g||g.on(cz.ON_LOCAL_STREAM_STATS,(function(e){U.safeEmit(Fl.onLocalStreamStats,e)})),null===(y=this._room)||void 0===y||y.on(cz.ON_SUBTITLE_STATE_CHANGED,(function(e){U.safeEmit(Fl.onSubtitleStateChanged,e)})),null===(S=this._room)||void 0===S||S.on(cz.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){U.safeEmit(Fl.onSubtitleMessageReceived,e)})),null===(b=this._room)||void 0===b||b.on(cz.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(E=this._room)||void 0===E||E.on(cz.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;U._updateAudioPlayerState(t),U.safeEmit(Fl.onUserStartAudioCapture,{userId:r})})),null===(k=this._room)||void 0===k||k.on(cz.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;U.safeEmit(Fl.onUserStopAudioCapture,{userId:t})})),null===(T=this._room)||void 0===T||T.on(cz.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;U.safeEmit(Fl.onUserStartVideoCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(cz.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;U.safeEmit(Fl.onUserStopVideoCapture,{userId:t})})),null===(R=this._room)||void 0===R||R.on(cz.ON_SEI_MESSAGED_RECEIVED,(function(e){U.safeEmit(Fl.onSEIMessageReceived,e)})),null===(A=this._room)||void 0===A||A.on(cz.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){U.safeEmit(Fl.onRemoteVideoSizeChanged,e,t)})),null===(w=this._room)||void 0===w||w.on(cz.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return U.safeEmit(Fl.onSimulcastSubscribeFallback,e)})),null===(C=this._room)||void 0===C||C.on(cz.RECONNECT_FAILED,(function(){U.safeEmit(Fl.onError,{errorCode:_A.RECONNECT_FAILED})})),null===(x=this._room)||void 0===x||x.on(cz.ON_VIDEO_STREAM_BANNED,(function(e){U.safeEmit(Fl.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(O=this._room)||void 0===O||O.on(cz.ON_AUDIO_STREAM_BANNED,(function(e){U.safeEmit(Fl.onAudioStreamBanned,{uid:e.uid,banned:e.banned})})),null===(P=this._room)||void 0===P||P.on(cz.ON_FORWARD_STREAM_ERROR,(function(e){U.safeEmit(Fl.onForwardStreamError,e)})),null===(M=this._room)||void 0===M||M.on(cz.ON_REJOIN_WITH_TCP,(function(){U.safeEmit(Fl.onRejoinWithTcp)})),null===(D=this._room)||void 0===D||D.on(cz.ON_ICE_CONNECT_WITH_TCP,(function(){U.safeEmit(Fl.onIceConnectWithTcp)})),null===(N=this._room)||void 0===N||N.on(cz.PUB_RETRY,(function(e){U.safeEmit(Fl.onPublishRetry,e)})),null===(L=this._room)||void 0===L||L.on(cz.SUB_RETRY,(function(e){U.safeEmit(Fl.onSubscribeRetry,e)}))}},{key:"safeEmit",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return function(e){var t,r=kN("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!bk(r).call(r,e))||!bk(t=[Fl.onRemoteStreamStats,Fl.onLocalStreamStats,Fl.onAudioVolumeIndication,Fl.onLocalAudioPropertiesReport,Fl.onRemoteAudioPropertiesReport]).call(t,e)}(e)&&ZP(this.id,e,i),(t=NI(DI(Ie.prototype),"safeEmit",this)).call.apply(t,Nm(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(Se=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._room){e.next=2;break}return e.abrupt("return",!1);case 2:return this._room=new dK({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:Il.communication},this._ctx),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return Se.apply(this,arguments)})},{key:"joinRoom",value:(ye=xm(wm().mark((function e(t,r,n,i){var o,a,s,c,u;return wm().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),UN(t)||ON(t,"token"),VN(r),jN(n),HN(i=sH({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:Il.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==Vz.CONNECTED){e.next=8;break}throw new SA(_A.REPEAT_JOIN,"Already joined");case 8:return this.monitor.report("rtc_sdk_api_call",{sdk_api_name:"host",message:location.host,error_code:0}),this._room||(this._room=new dK(i,this._ctx),this._addHandlerEventHandler()),this._room.roomConfig=i,a=this._liveTranscodeConfig&&oY.getStartParams(this._liveTranscodeConfig),s=el(el({},n),{},{businessId:this._businessId,role:this._visibility?zq.NORMAL_USER:zq.SILENT_USER}),e.prev=13,this._ctx.useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),eK(s),e.next=18,this._room.join(this._appId,r,t,s,a);case 18:return c=e.sent,this._roomConfig=i,this._ctx.audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,i.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:ll.AUDIO_AND_VIDEO}):this.safeEmit(Fl.onAutoPublishResult,{isScreen:!1,state:sl.PUBLISH_FAIL})),VP.setRoomId(this.id,r),VP.setUserId(this.id,n.userId),e.abrupt("return",c);case 28:throw e.prev=28,e.t0=e.catch(13),e.t0.code===_A.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:s}),null===(u=this._room)||void 0===u||u.destroy(),delete this._room,e.t0;case 34:case"end":return e.stop()}}),e,this,[[13,28]])}))),function(e,t,r,n){return ye.apply(this,arguments)})},{key:"leaveRoom",value:(ge=xm(wm().mark((function e(){var t,r,n,i=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],this.logger.info("leaveRoom()"),!t){e.next=7;break}return e.next=5,null===(r=this._room)||void 0===r?void 0:r.leave(t);case 5:e.next=8;break;case 7:null===(n=this._room)||void 0===n||n.leave(t).catch();case 8:this._removeHandlerEventHandler(),this._subLocks=new ib,this._subScreenLocks=new ib,this._ctx.audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new ib,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new ib,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new ib,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new ib,this._roomConfig=void 0,this._publicStreamIds=new ib,VP.setRoomId(this.id,""),VP.setUserId(this.id,"");case 26:case"end":return e.stop()}}),e,this)}))),function(){return ge.apply(this,arguments)})},{key:"_destroyLocalTrack",value:function(){this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localScreenVideoTrack=void 0),this._localImgVideoTrack&&(this._localImgVideoTrack.stop(),this._localImgVideoTrack=void 0),this._localImgScreenTrack&&(this._localImgScreenTrack.stop(),this._localImgScreenTrack=void 0)}},{key:"destroy",value:function(){var e,t,r;this.logger.info("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,null===(t=this._videoPlayer)||void 0===t||t.destroy(),this._subLocks=new ib,this._subScreenLocks=new ib,this._audioCaptureLock=new sz("audioCap"),this._videoCaptureLock=new sz("videoCap"),this._screenCaptureLock=new sz("screenCap"),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._videoStreamEncodeConfig=[AN],this._screenStreamEncodeConfig=[wN],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),VP.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._destroyLocalTrack(),cF.on("".concat(this.id,"capture-end"),this._destroyLocalTrack.bind(this)),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new ib,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new ib,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new ib,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new ib,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new ib,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new ib,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new ib,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new ib,this._ctx.userPriority.clear(),this._extensionManager.destroy(),this._ctx.avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(me=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!yD(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,PF(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return me.apply(this,arguments)})},{key:"unpublishStream",value:(_e=xm(wm().mark((function e(t,r){var n;return wm().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:dz.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return _e.apply(this,arguments)})},{key:"publishScreen",value:(fe=xm(wm().mark((function e(t){return wm().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,!yD(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,DF(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:dz.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof SA)){e.next=18;break}throw e.t0;case 18:throw new SA(_A.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return fe.apply(this,arguments)})},{key:"unpublishScreen",value:(ve=xm(wm().mark((function e(t){return wm().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:dz.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return ve.apply(this,arguments)})},{key:"subscribeStream",value:(pe=xm(wm().mark((function e(t,r){return wm().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 pe.apply(this,arguments)})},{key:"_subscribe",value:(he=xm(wm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n!==ll.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=3;break}return this.logger.warn("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 3:if(u=this._room.remoteStreams.get(r),d=null==u?void 0:kE(u).call(u,(function(e){return e.isScreen===t}))){e.next=7;break}throw new SA(_A.STREAM_NOT_EXIST,"stream not exist");case 7:return l=this._pauseAllSubscribeState.audio,h=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&ll.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&ll.VIDEO),this.logger.warn("subscribeStream()","due to pauseAll mediaType: %o",n),p=d.hasSubscribed,v=this._remoteVideoConfig.get(r)||(null===(o=this._roomConfig)||void 0===o?void 0:o.remoteVideoConfig),d.originalMediaType=n,e.next=17,this._room.subscribe(d,n,v);case 17:gD(n)&&this._updateAudioPlayerState(d),yD(n)&&this._updateVideoPlayerState(d),f=0,_=0,l!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?f|=ll.AUDIO:_|=ll.AUDIO),h!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?f|=ll.VIDEO:_|=ll.VIDEO),f&&this.pauseAllSubscribedStream(f),_&&this.resumeAllSubscribedStream(_),this._pauseAllSubscribeState.resumeStreamIds[d.streamId]=d.streamId,!t&&(null!==(a=this._roomConfig)&&void 0!==a&&a.isAutoSubscribeAudio||null!==(s=this._roomConfig)&&void 0!==s&&s.isAutoSubscribeVideo)&&(d.audioTrack||d.videoTrack)&&(m={userId:r,isScreen:!1,state:al.SUBSCRIBE_SUCC},this.safeEmit(Fl.onAutoSubscribeResult,m)),null!==(c=this._room)&&void 0!==c&&c.multiChatMode||p||!gD(n)||!d.hasAudio||null===(g=d.observer)||void 0===g||g.setSubscribeAudio(!0),!p&&yD(n)&&d.hasVideo&&(null===(y=d.observer)||void 0===y||y.setSubscribeVideo(!0));case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return he.apply(this,arguments)})},{key:"unsubscribeStream",value:(le=xm(wm().mark((function e(t,r){return wm().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 le.apply(this,arguments)})},{key:"subscribeScreen",value:(de=xm(wm().mark((function e(t,r){return wm().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 de.apply(this,arguments)})},{key:"unsubscribeScreen",value:(ue=xm(wm().mark((function e(t,r){return wm().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 ue.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(r!==ll.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a,s=this._room.remoteStreams.get(t),c=null==s?void 0:kE(s).call(s,(function(t){return t.isScreen===e}));if(!c)throw new SA(_A.STREAM_NOT_EXIST,"stream not exist");if(qD&&aN&&aN>=85&&aN<=91&&r!==ll.AUDIO)null===(a=e?this._remoteScreenPlayer.get(t):this._remoteVideoPlayer.get(t))||void 0===a||a.stop();return this._room.unsubscribe(c,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[c.streamId]}))}this.logger.warn("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(ce=xm(wm().mark((function e(t,r){var n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),FN(t),KN(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 ce.apply(this,arguments)})},{key:"startVideoCapture",value:(se=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startVideoCapture()","deviceId: %s",t),UN(t)||ON(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==tl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!this._localVideoTrack||this._localVideoTrack.dummy){e.next=8;break}throw new SA(_A.REPEAT_CAPTURE,"Has already capture");case 8:return s=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?(s.facingMode=t,delete s.deviceId):!HD||WD?s.deviceId={exact:t}:delete s.deviceId,this._videoStreamConstraints=s),c={},e.next=13,LF(s,this._extensionManager);case 13:if(u=e.sent,null!==(r=this._videoStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&u.setContentHint(null===(d=this._videoStreamEncodeConfig[0])||void 0===d?void 0:d.contentHint),this._initLocalTrackEvents(u),this._localVideoTrack=u,null===(n=this._videoPlayer)||void 0===n||n.playVideo(u),(l=u.getTrack())&&(c=l.getSettings(),h={width:c.width,height:c.height},this._localVideoTrack.resolution=h,this.autoResetVideoEncoderConfig(c),setTimeout((function(){return v.safeEmit(Fl.onLocalVideoSizeChanged,{streamIndex:dl.STREAM_INDEX_MAIN,info:h})}))),cF.emit("".concat(this.id,"capture-end")),this._room){e.next=23;break}return e.abrupt("return",c);case 23:return p=this._room._roomConfig.isAutoPublish,(null!==(i=this._room.localStream)&&void 0!==i&&i.pubVideo||p)&&(this._visibility?this._updatePublish():this.safeEmit(Fl.onAutoPublishResult,{isScreen:!1,state:sl.PUBLISH_FAIL})),null===(o=this._room.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setEnableVideo(!0),e.abrupt("return",c);case 27:case"end":return e.stop()}}),e,this)}))),function(e){return se.apply(this,arguments)})},{key:"stopVideoCapture",value:(ae=xm(wm().mark((function e(){var t,r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopVideoCapture()"),this._trackSourceType.video!==tl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=3;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 3:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),this._localVideoTrack&&(this._localVideoTrack.dummy||((o=this._extensionManager.getPluginByName(pF.PRE_PROCESSING,"RTCBeautyExtension"))&&o.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(this._localVideoTrack.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=7;break}return e.abrupt("return");case 7:if(null===(r=this._room.localStream)||void 0===r||!r.pubVideo){e.next=10;break}return e.next=10,this._updatePublish();case 10:null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableVideo(!1);case 11:case"end":return e.stop()}}),e,this)}))),function(){return ae.apply(this,arguments)})},{key:"startAudioCapture",value:(oe=xm(wm().mark((function e(t){var r,n,i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startAudioCapture()","deviceId: $o",t),UN(t)||ON(t,"deviceId"),t&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._trackSourceType.audio!==rl.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 5:if(!this._localAudioTrack){e.next=7;break}throw new SA(_A.REPEAT_CAPTURE,"Has already capture");case 7:return o={},e.next=10,VF(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 10:if((a=e.sent).getOrgTrack()&&(o=a.getOrgTrack().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),cF.emit("".concat(this.id,"capture-end")),this._room){e.next=19;break}return e.abrupt("return",o);case 19:return s=this._room._roomConfig.isAutoPublish,(null!==(r=this._room.localStream)&&void 0!==r&&r.pubAudio||s)&&(this._visibility?this._updatePublish():this.safeEmit(Fl.onAutoPublishResult,{isScreen:!1,state:sl.PUBLISH_FAIL})),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 oe.apply(this,arguments)})},{key:"stopAudioCapture",value:(ie=xm(wm().mark((function e(){var t,r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopAudioCapture()"),this._trackSourceType.audio!==rl.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=3;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 3:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._room){e.next=8;break}return e.abrupt("return");case 8:if(null===(t=this._room.localStream)||void 0===t||!t.pubAudio){e.next=11;break}return e.next=11,this._updatePublish();case 11:null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableAudio(!1);case 12:case"end":return e.stop()}}),e,this)}))),function(){return ie.apply(this,arguments)})},{key:"checkAudioAndVideoDeviceId",value:function(e,t){var r;return this.logger.print("startAudioAndVideoCapture","optionsOrAudioDeviceId: $o",e,"videoDeviceId: $o",t),UN(t)||ON(t,"videoDeviceId"),UN(e)||("string"==typeof e?(ON(e,"audioDeviceId"),r=e):(r=null==e?void 0:e.audioDeviceId,t=null==e?void 0:e.videoDeviceId,ON(r,"audioDeviceId"),ON(t,"videoDeviceId"))),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,{audioDeviceId:r,videoDeviceId:t}}},{key:"startAudioAndVideoCapture",value:(ne=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("startAudioAndVideoCapture","optionsOrAudioDeviceId: $o",t,"videoDeviceId: $o",r),l=this.checkAudioAndVideoDeviceId(t,r),h=l.audioDeviceId,p=l.videoDeviceId,r=p,h&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:h}}),this._trackSourceType.video!==tl.VIDEO_SOURCE_TYPE_EXTERNAL&&this._trackSourceType.audio!==rl.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,this._trackSourceType.video===tl.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 SA(_A.REPEAT_CAPTURE,"video has already capture");case 8:if(!this._localAudioTrack){e.next=10;break}throw new SA(_A.REPEAT_CAPTURE,"audio has already capture");case 10:return v=this._videoStreamConstraints,r&&("user"===r||"environment"===r||"left"===r||"right"===r?(v.facingMode=r,delete v.deviceId):!HD||WD?v.deviceId={exact:r}:delete v.deviceId,this._videoStreamConstraints=v),f={},_={},e.next=16,BF(this._ctx.audioProfileManager.getConstraints(),v,this._extensionManager);case 16:if(m=e.sent,g=m.audioTrack,y=m.videoTrack,null!==(n=this._videoStreamEncodeConfig[0])&&void 0!==n&&n.contentHint&&y.setContentHint(null===(S=this._videoStreamEncodeConfig[0])||void 0===S?void 0:S.contentHint),this._initLocalTrackEvents(y),this._localVideoTrack=y,null===(i=this._videoPlayer)||void 0===i||i.playVideo(y),this._initLocalTrackEvents(g),this._localAudioTrack=g,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),b=y.getTrack(),f=b.getSettings(),E={width:f.width||0,height:f.height||0},this._localVideoTrack.resolution=E,this.autoResetVideoEncoderConfig(f),setTimeout((function(){return T.safeEmit(Fl.onLocalVideoSizeChanged,{streamIndex:dl.STREAM_INDEX_MAIN,info:E})})),b=g.getOrgTrack(),_=b.getSettings(),cF.emit("".concat(this.id,"capture-end")),this._room){e.next=38;break}return e.abrupt("return",{audioTrackSettings:_,videoTrackSettings:f});case 38:return k=this._room._roomConfig.isAutoPublish,(null!==(o=this._room.localStream)&&void 0!==o&&o.pubVideo||null!==(a=this._room.localStream)&&void 0!==a&&a.pubAudio||k)&&(this._visibility?this._updatePublish():this.safeEmit(Fl.onAutoPublishResult,{isScreen:!1,state:sl.PUBLISH_FAIL})),null===(s=this._room.localStream)||void 0===s||null===(c=s.observer)||void 0===c||c.setEnableVideo(!0),null===(u=this._room.localStream)||void 0===u||null===(d=u.observer)||void 0===d||d.setEnableAudio(!0),e.abrupt("return",{audioTrackSettings:_,videoTrackSettings:f});case 43:case"end":return e.stop()}}),e,this)}))),function(e,t){return ne.apply(this,arguments)})},{key:"startVideoAndAudioCapture",value:(re=xm(wm().mark((function e(t,r){return wm().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 re.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return this.logger.info("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(te=xm(wm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m=this,g=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=g.length>0&&void 0!==g[0]?g[0]:{},this.logger.info("startScreenCapture()","config: %o",c),u=c.enableAudio,d=void 0!==u&&u,this._trackSourceType.screenVideo!==tl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==rl.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,HF(d,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(l=e.sent,h=aI(l,2),p=h[0],null==(v=h[1])||v.setVolume(this._localScreenAudioVolume),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(t=this._localScreenAudioTrack)||void 0===t||t.close(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=p,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&p.setContentHint(null===(f=this._screenStreamEncodeConfig[0])||void 0===f?void 0:f.contentHint),(_=p.getTrack())&&setTimeout((function(){var e=_.getSettings(),t={width:e.width,height:e.height};p.resolution=t,m.safeEmit(Fl.onLocalVideoSizeChanged,{streamIndex:dl.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),v&&(this._localScreenAudioTrack=v,this._initLocalTrackEvents(v)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),!(null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubAudio||null!==(a=this._room)&&void 0!==a&&null!==(s=a.localScreenStream)&&void 0!==s&&s.pubVideo)){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return te.apply(this,arguments)})},{key:"stopScreenCapture",value:(ee=xm(wm().mark((function e(){var t,r,n,i,o;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localImgScreenTrack&&(this._localScreenVideoTrack.setTrack(this._localImgScreenTrack,this._extensionManager),this._localScreenVideoTrack.dummy=!0))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,!(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localScreenStream)&&void 0!==n&&n.pubAudio||null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubVideo)){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return ee.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(this.logger.info("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),PN(e,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,i,o,a=el(el({userId:this._getUserId()},t),{},{isLocal:!0});if(delete a.rotation,GN(a),e===dl.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new fK(this.id,a),this._initPlayerEvents(this._videoPlayer,!1,e),this._videoPlayer.mirror(!!this._mirrorType),this._localVideoTrack&&!this._localVideoTrack.dummy&&(null===(r=this._config)||void 0===r?void 0:r.autoPlayPolicy)!==Al.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),(null===(n=this._room)||void 0===n?void 0:n.localStream)&&(this._room.localStream.videoDom=this._videoPlayer.domElement),this._videoPlayer.domElement;if(e===dl.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new fK(this.id,el(el({},a),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==Al.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),(null===(o=this._room)||void 0===o?void 0:o.localScreenStream)&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),this._screenPlayer.domElement;if(t&&void 0!==t.renderMode){var s=e===dl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer;null==s||s.setRenderMode(t.renderMode)}}else{var c,u;e===dl.STREAM_INDEX_MAIN?(null===(c=this._videoPlayer)||void 0===c||c.destroy(!0),delete this._videoPlayer):(null===(u=this._screenPlayer)||void 0===u||u.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:($=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("startLiveTranscoding()","transcode: %o",t),oY.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.roomInfo)&&n.roomId.length+n.userInfo.userId.length>126)){e.next=6;break}throw new SA(_A.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(Fl.onStreamMixingEvent,{event:uz.START,error:0,message:""}),!this._room||this._room.connectionState!==Vz.CONNECTED){e.next=11;break}return e.next=11,this._room.liveControlMessage(oY.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof SA)){e.next=19;break}throw e.t0;case 19:throw new SA(_A.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return $.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(Z=xm(wm().mark((function e(t){var r,n,i,o;return wm().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=sH({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,oY.checckUpdateParams(i),this._liveTranscodeConfig=sH(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(Fl.onStreamMixingEvent,{event:uz.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(oY.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof SA)){e.next=21;break}throw e.t0;case 21:throw new SA(_A.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return Z.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(Q=xm(wm().mark((function e(){var t;return wm().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(Fl.onStreamMixingEvent,{event:uz.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 SA)){e.next=16;break}throw e.t0;case 16:throw new SA(_A.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return Q.apply(this,arguments)})},{key:"startSubtitle",value:(J=xm(wm().mark((function e(t){var r;return wm().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 J.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;this.logger.info("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return this.logger.info("setBusinessId()","businessId: %s",e),!function(e){return"string"!=typeof e}(e)&&!this._room&&(this.monitor.set({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(Y=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("setUserVisibility()","enable: %o",t),t=!!t,this._visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._visibility=t,e.abrupt("return");case 7:return this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),t||(this._room.unpublish(),this._room.unpublishScreen()),e.next=12,this._room.updateUserAttributes({role:t?zq.NORMAL_USER:zq.SILENT_USER});case 12:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:ll.AUDIO_AND_VIDEO});case 14:case"end":return e.stop()}}),e,this)}))),function(e){return Y.apply(this,arguments)})},{key:"_initPlayerEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:dl.STREAM_INDEX_MAIN)===dl.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:kE(a).call(a,(function(e){return e.isScreen===n})),u=function(){r?t.safeEmit(Fl.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(Fl.onAudioFirstFrameDecoded,{userId:s,isScreen:n}),t.safeEmit(Fl.onRemoteAudioFirstFrame,{userId:s,isScreen:n})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:n})};c&&c.observer&&!c.observer.audioFirstFrameReceived?c.observer.once("recvAudioFirstFrame",u):u()}else{var d,l,h={userId:e.userId,height:(null===(d=e.domElement)||void 0===d?void 0:d.videoHeight)||0,width:(null===(l=e.domElement)||void 0===l?void 0:l.videoWidth)||0,isScreen:n};r?(h.publicStreamId=h.userId,delete h.userId,delete h.isScreen,t.safeEmit(Fl.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(Fl.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(Fl.onVideoFirstFrameRendered,h),t.safeEmit(Fl.onVideoFirstFrameDecoded,h),t.safeEmit(Fl.onRemoteVideoFirstFrame,h)),t.monitor.report("first_remote_video_render",{stream_id:"",stream_user_id:i.userId||""},{isScreen:n})}break;case"autoplay-error":return r&&(i.publicStreamId=i.userId),$P(t.id,"autoplay-error",e instanceof fK?"video":"audio",0,i.userId||""),void t.safeEmit(Fl.onAutoplayFailed,{userId:i.userId,kind:e instanceof fK?"video":"audio",mediaType:e instanceof fK?ll.VIDEO:ll.AUDIO,streamIndex:e.isScreen?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN})}t.safeEmit(Fl.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=xm(wm().mark((function e(n){var i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.monitor.report("rtc_error",{message:Nm(i="track-".concat(r," mediaType: ")).call(i,n.getTrack().kind),error_code:vz.TRACK_ERROR,capture_session_id:n.captureSessionId,media_type:r,reason:r}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),a=n.getTrack(),s=a.kind,t.safeEmit({"track-ended":Fl.onTrackEnded,"track-mute":Fl.onTrackMute,"track-unmute":Fl.onTrackUnmute}[r],{kind:s,isScreen:o}),!WD&&!GD){e.next=13;break}if("track-mute"!==r){e.next=12;break}if(cF.emit(aF.ON_IOS_LOCAL_TRACK_MUTE,s),"audio"!==s){e.next=12;break}return e.next=11,t.stopAudioCapture();case 11:t.startAudioCapture();case 12:"track-unmute"===r&&cF.emit(aF.ON_IOS_LOCAL_TRACK_UNMUTE,s);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),e.on("resolution-change",(function(e){t._extensionManager.getPluginsByType(pF.PRE_PROCESSING).forEach((function(t){var n;null==t||null===(n=t.applyConstraints)||void 0===n||n.call(t,r?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN,e)})),t.safeEmit(Fl.onLocalVideoSizeChanged,{streamIndex:r?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN,info:e})}))}},{key:"_removeLocalTrackEvents",value:function(e){e.removeAllListeners("track-ended"),e.removeAllListeners("track-mute"),e.removeAllListeners("track-unmute"),e.removeAllListeners("resolution-change")}},{key:"setRemoteVideoPlayer",value:function(e,t){this.logger.info("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),PN(e,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),GN(t);var r,n,i,o=t.userId;if(e===dl.STREAM_INDEX_MAIN){var a,s,c;if(null===(a=this._remoteVideoPlayer.get(o))||void 0===a||a.destroy(),!t.renderDom)return;var u=new fK(this.id,t);this._initPlayerEvents(u,!1,e),this._remoteVideoPlayer.set(o,u);var d=null===(s=this._room)||void 0===s||null===(c=s.remoteStreams.get(o))||void 0===c?void 0:kE(c).call(c,(function(e){return!e.isScreen}));return d&&(this._updateVideoPlayerState(d),d.videoDom=u.domElement),u.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var l=new fK(this.id,el(el({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(o,l),this._initPlayerEvents(l,!1,e);var h=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(o))||void 0===i?void 0:kE(i).call(i,(function(e){return e.isScreen}));return h&&(this._updateVideoPlayerState(h),h.videoDom=l.domElement),l.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){this.logger.info("setLocalVideoMirrorType()","mirrorType: %o",e),PN(e,"mirrorType",[vl.MIRROR_TYPE_NONE,vl.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(q=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("setAudioPlaybackDevice()","deviceId: %s",t),ON(t,"deviceId"),e.next=4,this._audioDeviceManager.setSinkId(t);case 4:r=e.sent,this._remoteAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._remoteScreenAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this.safeEmit(Fl.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:Fm(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return q.apply(this,arguments)})},{key:"play",value:(W=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=m.length>1&&void 0!==m[1]?m[1]:ll.AUDIO_AND_VIDEO,o=m.length>2?m[2]:void 0,this.logger.info("play()","userId: %s, mediaType: %s, streamIndex: %s",t,i,o),a=!t||t===this._getUserId()||"local_user"===t,s=void 0===o||o===dl.STREAM_INDEX_MAIN,c=void 0===o||o===dl.STREAM_INDEX_SCREEN,u=i!==ll.VIDEO,d=i!==ll.AUDIO,l=[],a&&d&&(s&&this._localVideoTrack&&(null===(h=this._videoPlayer)||void 0===h||h.mirror(!!this._mirrorType),l.push(null===(p=this._videoPlayer)||void 0===p?void 0:p.manuallyPlay())),c&&this._localScreenVideoTrack&&l.push(null===(v=this._screenPlayer)||void 0===v?void 0:v.manuallyPlay())),t===this._audioMixingManager.id&&l.push(this._audioMixingManager.resumeLocalPlay()),f=null===(r=this._room)||void 0===r?void 0:r.remoteStreams,d&&s&&l.push(mK(this._remoteVideoPlayer,t,!1,f)),d&&c&&l.push(mK(this._remoteScreenPlayer,t,!0,f)),u&&s&&l.push(mK(this._remoteAudioPlayer,t,!1,f)),d&&c&&l.push(mK(this._remoteScreenAudioPlayer,t,!0,f)),_=null===(n=this._publicStreamManager)||void 0===n?void 0:n.remoteStreams,u&&l.push(mK(this._publicStreamVideoPlayer,t,!1,_)),d&&l.push(mK(this._publicStreamAudioPlayer,t,!1,_)),e.abrupt("return",$_.all(l).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return W.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(X=xm(wm().mark((function e(t){var r,n,i,o,a,s=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),gD(t)&&(s._pauseAllSubscribeState.audio=!0),yD(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",$_.resolve());case 6:n=[],i=oI(cR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(e.hasSubscribed){s._pauseAllSubscribeState.resumeStreamIds[e.streamId]=e.streamId;var r=s._unsubscribe(e.isScreen,e.userId,t,!0);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",$_.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return X.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(K=xm(wm().mark((function e(t){var r,n,i,o,a,s=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.info("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),gD(t)&&(s._pauseAllSubscribeState.audio=!1),yD(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",$_.resolve());case 6:n=[],i=oI(cR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(s._pauseAllSubscribeState.resumeStreamIds[e.streamId]){delete s._pauseAllSubscribeState.resumeStreamIds[e.streamId];var r=s._subscribe(e.isScreen,e.userId,t);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",$_.all(n).then((function(){var e;null===(e=s._room)||void 0===e||e.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){s._updateAudioPlayerState(e),s._updateVideoPlayerState(e)}))}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return K.apply(this,arguments)})},{key:"sendUserMessage",value:(z=xm(wm().mark((function e(t,r){var n,i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FN(t),zN(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!1,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!1,o,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return z.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(G=xm(wm().mark((function e(t,r){var n,i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FN(t),NN(r,"message"),zN(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!0,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!0,o,e),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return G.apply(this,arguments)})},{key:"sendRoomMessage",value:(H=xm(wm().mark((function e(t){var r,n,i,o=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return zN(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return H.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(j=xm(wm().mark((function e(t){var r,n,i,o=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return zN(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t,!0))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return j.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(B=xm(wm().mark((function e(){var t,r=arguments;return wm().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,LN(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._ctx.audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return B.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(F=xm(wm().mark((function e(){var t,r=arguments;return wm().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 F.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(V=xm(wm().mark((function e(){var t,r,n,i=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,LN(r),n=el(el({},r),{},{deviceId:this._videoStreamConstraints.deviceId}),!this._localVideoTrack){e.next=7;break}return e.next=7,this._localVideoTrack.updateVideoCaptureConfig(n);case 7:return this._videoStreamConstraints=n,e.abrupt("return",(null===(t=this._localVideoTrack)||void 0===t?void 0:t.getTrack().getSettings())||{});case 9:case"end":return e.stop()}}),e,this)}))),function(){return V.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return this.logger.info("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==nN[0]&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&TD("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(U=xm(wm().mark((function e(t){var r,n,i,o,a;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(this.logger.info("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),WN(t=Ks(t).call(t,(function(e){return!!e}))),t.length>3&&(TD("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=Am(t).call(t,0,3)),n=1;n<t.length;n++)i=ID(t[0].width)/ID(t[n].width)||1,Math.floor(i)!==i&&TD("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");KR(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),this._setVideoCaptureConfig(el({},t[0])),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(dl.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 12:case"end":return e.stop()}}),e,this)}))),function(e){return U.apply(this,arguments)})},{key:"setVideoEncoderAutoConfigList",value:function(e){if(Array.isArray(e))return KR(e).call(e,(function(e,t){return e.maxKbps-t.maxKbps})),RN(e)}},{key:"autoResetVideoEncoderConfig",value:function(e){var t,r=IN;if(r.length){this._videoStreamEncodeConfig.length||(this._videoStreamEncodeConfig=[AN]);var n=this._videoStreamEncodeConfig[0],i=e.width||ID(n.width),o=e.height||ID(n.height),a=i*o;if(!(ID(n.width)*ID(n.height)<=a)){var s,c,u=r[0];r.forEach((function(e){var t=ID(e.width)*ID(e.height);s||(a<t?s=e:u=e)})),c=s&&ID(s.width)*ID(s.height)-a<a-ID(u.width)*ID(u.height)?Mb({},s):Mb({},u),this._videoStreamEncodeConfig=Ks(t=this._videoStreamEncodeConfig).call(t,(function(e){return!(c&&ID(e.width)*ID(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",Fm(this._videoStreamEncodeConfig)),$P(this.id,"autoResetVideoEncoderConfig",Fm(this._videoStreamEncodeConfig))}}}},{key:"setScreenEncoderConfig",value:(L=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.info("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&("16.1"!==rN&&this._localScreenVideoTrack.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(dl.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(this.logger.info("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!rV())throw new SA(_A.NOT_SUPPORTED,"Browser does not support sending SEI");PN(e,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),xN(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(nD.str2ab(t)):t;if(t.length){var i;if(e===dl.STREAM_INDEX_MAIN){var o,a;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=this._room.localStream}else{var s,c;if(null===(s=this._room)||void 0===s||null===(c=s.localScreenStream)||void 0===c||!c.hasPublished)return;i=this._room.localScreenStream}if(n.byteLength>4096)this.logger.warn("sei size must not bigger than 4KB");else{var u=eD();i.seiList.push({content:n,uuid:u,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=eA(e=i.seiList).call(e,(function(e){return e.uuid===u}));if(r>=0)ak(t=i.seiList).call(t,r,1)}}),2e3)}}else this.logger.warn("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;this.logger.info("setAudioVolumeIndicationInterval()","interval %o: ",e),("number"!=typeof e||e<200)&&(e=200);var r=[];this._audioVolumeIndicationTimer&&clearInterval(this._audioVolumeIndicationTimer),this._audioVolumeIndicationTimer=setInterval((function(){var e,n;r=[],null===(e=t._room)||void 0===e||e.remoteStreams.forEach((function(e,t){var n;if(0!==e.length){var i=kE(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(Fl.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=gb(t).call(t,(function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=n?i?n.audioPropertiesInfo.nonlinearVolume>i.audioPropertiesInfo.nonlinearVolume?n:i:n:i)&&r.audioPropertiesInfo.nonlinearVolume>-35){var o,a;if(r.streamKey)o=this._room.remoteUsers.get(r.streamKey.userId);else o=null===(a=this._room._roomInfo)||void 0===a?void 0:a.userInfo;o&&this.safeEmit(Fl.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger.info("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.localMainReportMode,o=void 0===i?fl.NORMAL:i,a=t.audioReportMode,s=void 0===a?_l.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=mD(d),h={streamIndex:dl.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:d,nonlinearVolume:l}};if(c||u)t.push(h);else switch(o){case fl.DISCONNECT:break;case fl.RESET:h.audioPropertiesInfo.linearVolume=0,h.audioPropertiesInfo.nonlinearVolume=-127,t.push(h);break;case fl.NORMAL:t.push(h);break;default:throw new SA(_A.INVALID_PARAMS,"invalid localMainReportMode: ".concat(o," in config"))}}if(e._localScreenAudioTrack){var p=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:dl.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:p,nonlinearVolume:mD(p)}})}if(e.safeEmit(Fl.onLocalAudioPropertiesReport,t),e._room){var v=[];if(e._room.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i,o=255*t.audioLevel;v.push({streamKey:{userId:t.userId,streamIndex:dl.STREAM_INDEX_MAIN,roomId:null!==(r=null===(n=e._room)||void 0===n||null===(i=n._roomInfo)||void 0===i?void 0:i.roomId)&&void 0!==r?r:""},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:mD(o)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o,a=t.audioTrack.getAudioLevel();v.push({streamKey:{userId:r,streamIndex:t.isScreen?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN,roomId:null!==(n=null===(i=e._room)||void 0===i||null===(o=i.roomInfo)||void 0===o?void 0:o.roomId)&&void 0!==n?n:""},audioPropertiesInfo:{linearVolume:a,nonlinearVolume:mD(a)}})}}))}));e.safeEmit(Fl.onRemoteAudioPropertiesReport,v),e._sendActiveSpeaker(t,Ks(v).call(v,(function(e){return e.streamKey.streamIndex!==dl.STREAM_INDEX_SCREEN})))}}}),u))}},{key:"setVideoSourceType",value:(N=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T,I,R,A;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),PN(t,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),PN(r,"VideoSourceType",[tl.VIDEO_SOURCE_TYPE_EXTERNAL,tl.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===dl.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,this.logger.print("setVideoSourceType",Nm(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==dl.STREAM_INDEX_MAIN){e.next=17;break}if(u=!1,r===tl.VIDEO_SOURCE_TYPE_EXTERNAL&&(u=!0,(d=this._extensionManager.getPluginByName(pF.PRE_PROCESSING,"RTCBeautyExtension"))&&d.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(o=this._videoPlayer)||void 0===o||o.stop(),this._localVideoTrack=void 0,l=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,u?null===(h=this._room)||void 0===h||null===(p=h.localStream)||void 0===p||null===(v=p.observer)||void 0===v||v.setEnableVideo(!1):null===(f=this._room)||void 0===f||null===(_=f.localStream)||void 0===_||null===(m=_.observer)||void 0===m||m.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubVideo||l)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==dl.STREAM_INDEX_SCREEN){e.next=26;break}if(b=!1,r===tl.VIDEO_SOURCE_TYPE_EXTERNAL&&(b=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(g=this._screenPlayer)||void 0===g||g.stop(),this._localScreenVideoTrack=void 0,b?null===(E=this._room)||void 0===E||null===(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 N.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(D=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setExternalVideoTrack()","index: %o, track: %o",t,r),PN(t,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),MN(r),t!==dl.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.video===tl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,KF(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,!r.contentHint&&null!==(n=this._videoStreamEncodeConfig[0])&&void 0!==n&&n.contentHint&&this._localVideoTrack.setContentHint(null===(c=this._videoStreamEncodeConfig[0])||void 0===c?void 0:c.contentHint),this._initLocalTrackEvents(this._localVideoTrack),null===(i=this._videoPlayer)||void 0===i||i.playVideo(this._localVideoTrack),u=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubVideo||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==dl.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenVideo===tl.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 19:return e.next=21,YF(r,this._extensionManager);case 21:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(d=this._screenPlayer)||void 0===d||d.playVideo(this._localScreenVideoTrack),null===(l=this._room)||void 0===l||null===(h=l.localScreenStream)||void 0===h||null===(p=h.observer)||void 0===p||p.setPushVideo(!0),null===(v=this._room)||void 0===v||null===(f=v.localScreenStream)||void 0===f||!f.pubVideo){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return D.apply(this,arguments)})},{key:"setAudioSourceType",value:(M=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,g,y,S,b,E,k,T;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),PN(t,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),PN(r,"audioSourceType",[rl.AUDIO_SOURCE_TYPE_EXTERNAL,rl.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===dl.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,this.logger.print("setVideoSourceType",Nm(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==dl.STREAM_INDEX_MAIN){e.next=16;break}if(c=!1,this._trackSourceType.audio===rl.AUDIO_SOURCE_TYPE_EXTERNAL&&(c=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,u=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,c?null===(d=this._room)||void 0===d||null===(l=d.localStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setEnableAudio(!1):null===(p=this._room)||void 0===p||null===(v=p.localStream)||void 0===v||null===(f=v.observer)||void 0===f||f.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==dl.STREAM_INDEX_SCREEN){e.next=24;break}if(g=!1,this._trackSourceType.audio===rl.AUDIO_SOURCE_TYPE_EXTERNAL&&(g=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,g?null===(y=this._room)||void 0===y||null===(S=y.localScreenStream)||void 0===S||null===(b=S.observer)||void 0===b||b.setEnableAudio(!1):null===(E=this._room)||void 0===E||null===(k=E.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setPushAudio(!1),null===(_=this._room)||void 0===_||null===(m=_.localScreenStream)||void 0===m||!m.pubAudio){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return M.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(P=xm(wm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setExternalAudioTrack()","index: %o, track: %o",t,r),PN(t,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),MN(r),t!==dl.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===rl.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,WF(r,this._extensionManager);case 8:if(this._localAudioTrack=e.sent,this._localAudioTrack.setVolume(this._localAudioVolume),this._initLocalTrackEvents(this._localAudioTrack),u=null===(n=this._room)||void 0===n?void 0:n._roomConfig.isAutoPublish,null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setPushAudio(!0),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==dl.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===rl.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new SA(_A.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,QF(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(d=this._room)||void 0===d||null===(l=d.localScreenStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setPushAudio(!0),null===(p=this._room)||void 0===p||null===(v=p.localScreenStream)||void 0===v||!v.pubAudio){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return P.apply(this,arguments)})},{key:"login",value:(O=xm(wm().mark((function e(t,r){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("login()","token: %o, userInfo: %o",t,r),UN(t)||ON(t,"token"),FN(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return O.apply(this,arguments)})},{key:"logout",value:(x=xm(wm().mark((function e(){return wm().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 x.apply(this,arguments)})},{key:"updateLoginToken",value:(C=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("updateLoginToken()","token: %o",t),UN(t)||ON(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(w=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.info("getPeerOnlineStatus()","userId: %o",t),FN(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(A=xm(wm().mark((function e(t,r){var n,i=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FN(t),zN(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!1,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return A.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(R=xm(wm().mark((function e(t,r){var n,i=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FN(t),NN(r,"message"),zN(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!0,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"setServerParams",value:(I=xm(wm().mark((function e(t,r){return wm().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 I.apply(this,arguments)})},{key:"sendServerMessage",value:(T=xm(wm().mark((function e(t){var r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ON(t,"message"),zN(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!1,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(k=xm(wm().mark((function e(t){var r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return NN(t,"message"),zN(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!0,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new SA(_A.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");this.logger.info("startCloudProxy()",e),ON(e.logProxy,"logProxy"),ON(e.accessProxy,"accessProxy"),ON(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=kN("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=kN("LOG_SERVER_URL"),this._originConfigServerUrls=kN("CONFIG_REQUEST_DOMAINS"),EN("ICE_CONFIG_REQUEST_URLS",e.accessProxy),EN("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)),EN("CONFIG_REQUEST_DOMAINS",[e.configProxy]),vN.clearAccessNode(this._appId),vN.clearAccessUrls(),this._ctx.useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){var e,t,r;if(this._room)throw new SA(_A.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:Km(e).call(e,(function(e){return e.replace("https://","").replace("/dispatch/v1/AccessInfo?Action=GetAccessInfo","")}));EN("ICE_CONFIG_REQUEST_URLS",null!=n?n:[]),EN("LOG_SERVER_URL",null!==(t=this._originLogServerUrl)&&void 0!==t?t:""),EN("CONFIG_REQUEST_DOMAINS",null!==(r=this._originConfigServerUrls)&&void 0!==r?r:[]),vN.clearAccessNode(this._appId),vN.clearAccessUrls(),this._ctx.useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(E=xm(wm().mark((function e(t,r){var n,i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),BN(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new SA(_A.REPEAT_PUSH,"repeat push public media stream");case 5:return o=TN(t,"started",r),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.publicStreamControlMessage(o))||void 0===i?void 0:i.then((function(){a._publicStreamIds.set(t,t)})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return E.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(b=xm(wm().mark((function e(t,r){var n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),BN(t),this._assertNotInRoom(),i=TN(t,"layoutChanged",r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.publicStreamControlMessage(i));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"stopPushPublicStream",value:(S=xm(wm().mark((function e(t){var r,n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startPushPublicStream()","publicStreamId: %o",t),BN(t),this._assertNotInRoom(),e.abrupt("return",null===(r=this._room)||void 0===r?void 0:r.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){n._publicStreamIds.delete(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"startPlayPublicStream",value:(y=xm(wm().mark((function e(t){var r,n,i,o,a=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BN(t),this._publicStreamManager){e.next=8;break}return this._publicStreamManager=new Wq(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.on(cz.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=a._publicStreamAudioPlayer.get(t.streamId);n&&t.audioTrack&&(n.stop(),n.playAudio(null===(r=e.stream)||void 0===r?void 0:r.audioTrack));var i,o=a._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),this._publicStreamManager.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,a.safeEmit(Fl.onPublicStreamStats,e)})),this._publicStreamManager.on(cz.ON_SEI_MESSAGED_RECEIVED,(function(e){a.safeEmit(Fl.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._publicStreamManager.connect();case 8:return e.next=10,this._publicStreamManager.startPlayPublicStream(t);case 10:r=e.sent,(n=this._publicStreamVideoPlayer.get(t))&&r.videoTrack&&n.playVideo(r.videoTrack,r),!(i=this._publicStreamAudioPlayer.get(t))&&r.audioTrack&&(i=new _K(this.id,t,{muted:(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)===Al.VIDEO_ONLY,isScreen:!1}),this._initPlayerEvents(i,!0),i.playAudio(r.audioTrack),this._publicStreamAudioPlayer.set(t,i));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(g=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publicStreamManager){e.next=2;break}return e.abrupt("return");case 2:this._publicStreamManager.stopPlayPublicStream(t),(r=this._publicStreamAudioPlayer.get(t))&&(r.destroy(),this._publicStreamAudioPlayer.delete(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"setAudioProfile",value:(m=xm(wm().mark((function e(t){return wm().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 m.apply(this,arguments)})},{key:"setAudioEncodeMaxBitrate",value:(_=xm(wm().mark((function e(t){var r,n,i,o,a,s;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("setAudioEncodeMaxBitrate()",t),xN(t,"maxBitrate",6,256),this._ctx.audioProfileManager.setCustomMaxBitrate(t),!this._ctx.audioProfileManager.customMaxBitrate){e.next=10;break}if(!DD||!(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 SA(_A.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(dl.STREAM_INDEX_MAIN,t);case 8:return e.next=10,null===(s=this._room)||void 0===s?void 0:s.setAudioEncodeMaxBitrate(dl.STREAM_INDEX_SCREEN,t);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i;this.logger.print("setPublicStreamVideoPlayer()","publicStreamId: %o, videoPlayerOption: %o",e,t);var o=this._publicStreamVideoPlayer.get(e);if(null===(r=o)||void 0===r||r.destroy(),t.renderDom){o=new fK(this.id,el(el({},t),{},{userId:e})),this._initPlayerEvents(o,!0),this._publicStreamVideoPlayer.set(e,o);var a=null===(n=this._publicStreamManager)||void 0===n?void 0:n.remoteStreams.get(e);null!=a&&a.videoTrack&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==Al.PLAY_MANUALLY&&o.playVideo(a.videoTrack,a)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(f=xm(wm().mark((function e(t,r){var n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new $_((function(e,i){ON(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===dl.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new SA(_A.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new SA(_A.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return f.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===dl.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=ID(r.width),c=ID(r.height);if(!a)throw new SA(_A.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===dl.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===dl.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=xm(wm().mark((function e(r,n){var i,o,a;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=17;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.prev=2,e.next=5,t._localVideoTrack.generatePreProcessingTrack(t._extensionManager);case 5:e.next=10;break;case 7:e.prev=7,e.t0=e.catch(2),n(e.t0);case 10:if(t._initLocalTrackEvents(t._localVideoTrack),null!==(i=t._videoPlayer)&&void 0!==i&&i.played&&(t._videoPlayer.stop(),t._videoPlayer.playVideo(t._localVideoTrack),t._videoPlayer.mirror(!!t._mirrorType)),t.safeEmit(Fl.onLocalStreamTrackChangedByExtension,{streamIndex:dl.STREAM_INDEX_MAIN,type:"video"}),r(),null===(o=t._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.pubVideo){e.next=17;break}return e.next=17,t._updatePublish();case 17:r();case 18:case"end":return e.stop()}}),e,null,[[2,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"registerExtension",value:(v=xm(wm().mark((function e(t){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.monitor=this.monitor,e.prev=1,e.next=4,t.isSupported();case 4:if(e.sent){e.next=7;break}throw new Error("This extension is not supported.");case 7:e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(1),new Error("This extension is not supported.");case 12:return e.next=14,t.init({videoCaptureConfig:this._videoStreamConstraints});case 14:this._extensionManager.register(t),this._addListenExtensionEvent(t);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return v.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(Fm(oY.getDefaultValue()))}},{key:"_updatePublish",value:(p=xm(wm().mark((function e(){var t,r,n,i=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},this.logger.info("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:dz.PUB},t=el(el({},r),t),this._visibility){e.next=6;break}throw new SA(_A.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===Vz.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 15:this._videoPlayer&&this._room.localStream&&(this._room.localStream.videoDom=this._videoPlayer.domElement),e.next=25;break;case 18:if(e.prev=18,e.t0=e.catch(12),!(e.t0 instanceof SA)){e.next=24;break}throw e.t0;case 24:throw new SA(_A.UNEXPECTED_ERROR,"unexpected error",e.t0);case 25:return e.prev=25,n(),e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[12,18,25,28]])}))),function(){return p.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(h=xm(wm().mark((function e(t,r){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),ON(t,"filePath"),xN(r,"indicationInterval"),e.next=5,this._audioDeviceManager.startAudioPlaybackDeviceTest(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this.logger.info("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(l=xm(wm().mark((function e(t,r){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),xN(t,"indicationInterval"),e.next=4,this._audioDeviceManager.startAudioDeviceRecordTest(t,r,this._localAudioVolume);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){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{FN(e),PN(t,"priority",[El.HIGH,El.MEDIUM,El.LOW])}catch(n){return console.warn(n),!1}return this._ctx.userPriority.set(e,t),null===(r=this._room)||void 0===r||r.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(d=xm(wm().mark((function e(t){var r,n;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("takeLocalSnapshot()","streamIndex: %o",t),PN(t,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),r=t===dl.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new SA(_A.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===dl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",Zq(r.getTrack("preprocessing"),(null==n?void 0:n.mirrorType)===vl.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(u=xm(wm().mark((function e(t,r){var n,i,o,a,s,c;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logger.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),ON(t,"id"),PN(r,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),c=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=kE(i).call(i,(function(e){return e.isScreen===(r===dl.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._publicStreamManager)||void 0===a||null===(s=a.remoteStreams.get(t))||void 0===s?void 0:s.videoTrack)){e.next=6;break}throw new SA(_A.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",Zq(c.getTrack(),!1,r===dl.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){this.logger.info("setSubscribeFallbackOption()","option: %o",e);try{PN(e,"option",[bl.DISABLE,bl.VIDEO_STREAM_LOW,bl.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===dl.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 $F&&r.mixedAudioTrack?r.mixedAudioTrack:r.getTrack("preprocessing");if(o){var a=n();return this._reportMsTrackEvent(o,(null==a?void 0:a.stream.id)||"local"),o}}}},{key:"getRemoteStreamTrack",value:function(e,t,r){var n,i,o=(null===(n=this._room)||void 0===n?void 0:n.remoteStreams.get(e))||[];if(o&&o.length){var a,s,c,u,d;if(t===dl.STREAM_INDEX_MAIN)a=kE(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=kE(o).call(o,(function(e){return e.isScreen})),i="video"===r?null===(u=a)||void 0===u?void 0:u.videoTrack:null===(d=a)||void 0===d?void 0:d.audioTrack;if(i){var l=i.getTrack();if(l&&a){var h=a.streamId;return this._reportMsTrackEvent(l,h),l}}}}},{key:"getPublicStreamTrack",value:function(e,t){if(this._publicStreamManager&&this._publicStreamManager.remoteStreams){var r=this._publicStreamManager.remoteStreams.get(e);if(r){var n="video"===t?r.videoTrack:r.audioTrack;if(n){var i=n.getTrack();if(i){var o=r.streamId;return this._reportMsTrackEvent(i,o),i}}}}}},{key:"setRemoteStreamRenderSync",value:function(e){return!this._room&&(this._ctx.avSync=!!e,!0)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i;(PN(e,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),t=qN(t,"volume",0,400),e===dl.STREAM_INDEX_SCREEN)?(null===(r=this._localScreenAudioTrack)||void 0===r||r.setVolume(t),this._localScreenAudioVolume=t):(null===(n=this._localAudioTrack)||void 0===n||n.setVolume(t),null===(i=this._audioDeviceManager.audioTrack)||void 0===i||i.setVolume(t),this._localAudioVolume=t)}},{key:"setPlaybackVolume",value:function(e,t,r){var n,i,o;if(FN(e),PN(t,"streamIndex",[dl.STREAM_INDEX_MAIN,dl.STREAM_INDEX_SCREEN]),r=qN(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)TD("setPlaybackVolume is not supported in Conference mode");else{var a=t===dl.STREAM_INDEX_SCREEN;a?this._remoteScreenAudioVolume.set(e,r):this._remoteAudioVolume.set(e,r),null===(i=this._room)||void 0===i||null===(o=i.remoteStreams.get(e))||void 0===o||o.forEach((function(e){var t;e.isScreen===a&&(null===(t=e.audioTrack)||void 0===t||t.setVolume(r))}))}}},{key:"setPublicStreamVolume",value:function(e,t){var r,n,i;ON(e,"publicStreamId"),t=qN(t,"volume",0,400),this._publicAudioVolume.set(e,t),null===(r=this._publicStreamManager)||void 0===r||null===(n=r.remoteStreams.get(e))||void 0===n||null===(i=n.audioTrack)||void 0===i||i.setVolume(t)}},{key:"startForwardStreamToRooms",value:(c=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){VN(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.startForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"updateForwardStreamToRooms",value:(s=xm(wm().mark((function e(t){var r;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){VN(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.updateForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"stopForwardStreamToRooms",value:(a=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.stopForwardStream2Rooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"pauseForwardStreamToAllRooms",value:(o=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.pauseForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"resumeForwardStreamToAllRooms",value:(i=xm(wm().mark((function e(){var t;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.resumeForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_reportMsTrackEvent",value:function(e,t){var r=this;if(!e.hookStop){e.hookStop=!0;var n=e.stop;e.stop=function(){$P(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=xm(wm().mark((function e(){var t,r,n,i=arguments;return wm().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:dz.PUB},t=el(el({},r),t),this._visibility){e.next=6;break}throw new SA(_A.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===Vz.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 15:this._screenPlayer&&this._room.localScreenStream&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),e.next=25;break;case 18:if(e.prev=18,e.t0=e.catch(12),!(e.t0 instanceof SA)){e.next=24;break}throw e.t0;case 24:throw new SA(_A.UNEXPECTED_ERROR,"unexpected error",e.t0);case 25:return e.prev=25,n(),e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[12,18,25,28]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){this.logger.info("_updateAudioPlayerState()");var t,r=e.userId,n=e.isScreen,i=n?this._remoteScreenAudioPlayer:this._remoteAudioPlayer,o=i.get(r);if(e.audioTrack&&e.attributes.audiostream&&e.subAudio){var a,s,c,u=n?null!==(a=this._remoteScreenAudioVolume.get(r))&&void 0!==a?a:100:null!==(s=this._remoteAudioVolume.get(r))&&void 0!==s?s:100;if(e.audioTrack.setVolume(u),!o){var d;o=new _K(this.id,r,{muted:(null===(d=this._config)||void 0===d?void 0:d.autoPlayPolicy)===Al.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?dl.STREAM_INDEX_SCREEN:dl.STREAM_INDEX_MAIN),i.set(r,o);var l=this._audioDeviceManager.getSinkId();l&&o.setPlaybackDevice(l)}(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)!==Al.PLAY_MANUALLY&&o.playAudio(e.audioTrack),ND&&GD&&(t=this._remoteAudioPlayer,iY&&clearTimeout(iY),iY=setTimeout((function(){var e,r=oI(t);try{for(r.s();!(e=r.n()).done;){var n=aI(e.value,2),i=n[0],o=n[1];null!=i&&fA(i).call(i,"mux")&&o.pause()}}catch(l){r.e(l)}finally{r.f()}var a,s=oI(t);try{for(s.s();!(a=s.n()).done;){var c=aI(a.value,2),u=c[0],d=c[1];null!=u&&fA(u).call(u,"mux")&&d.manuallyPlay()}}catch(l){s.e(l)}finally{s.f()}}),2e3))}else{var h;null===(h=o)||void 0===h||h.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;this.logger.info("_updateVideoPlayerState()");var r,n,i=e.userId;if(r=e.isScreen?this._remoteScreenPlayer.get(i):this._remoteVideoPlayer.get(i),e.videoTrack)r&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==Al.PLAY_MANUALLY&&r.playVideo(e.videoTrack,e);else if(null!==(t=r)&&void 0!==t&&t.played){var o;null===(o=r)||void 0===o||o.stop()}}},{key:"_onAddStream",value:(r=xm(wm().mark((function e(t){var r,n,i,o,a,s,c,u;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.stream).videoDom=null===(r=this._remoteVideoPlayer.get(n.userId))||void 0===r?void 0:r.domElement,i=n.attributes,o=i.localaudio,a=i.audiostream,s=i.localvideo,c=i.videostream,u=tB.NONE,a&&(u|=ll.AUDIO),c&&(u|=ll.VIDEO),!u){e.next=12;break}return e.next=9,new $_((function(e){return setTimeout(e)}));case 9:n.isScreen?this.safeEmit(Fl.onUserPublishScreen,{userId:n.userId,mediaType:u}):(this.safeEmit(Fl.onUserPublishStream,{userId:n.userId,mediaType:u,videoStreamDescriptions:n.attributes.videoDescriptions}),this._handleAutoSubscribe(n,!0)),this.safeEmit("onAddStream",{userId:n.userId,mediaType:u,isScreen:!!n.isScreen}),n.isScreen||(o&&this.safeEmit(Fl.onUserStartAudioCapture,{userId:n.userId}),s&&this.safeEmit(Fl.onUserStartVideoCapture,{userId:n.userId}));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=tB.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=ll.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=ll.VIDEO),i){var o,a;if(t&&gD(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&yD(i))null===(a=e.observer)||void 0===a||a.setAutoSubscribeVideo(!0);this._subscribe(!1,e.userId,i)}}},{key:"_onRemoveStream",value:function(e){var t,r=this,n=e.stream,i=null!==(t=dY[e.reason])&&void 0!==t?t:hl.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?Fl.onUserUnpublishScreen:Fl.onUserUnpublishStream,a=tB.NONE;n.attributes.audiostream&&(a|=ll.AUDIO),n.attributes.videostream&&(a|=ll.VIDEO),a!==tB.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),"function"==typeof e.callback&&e.callback(),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){n.isScreen?(r._remoteScreenPlayer.delete(n.userId),r._remoteScreenAudioPlayer.delete(n.userId)):(r._remoteAudioPlayer.delete(n.userId),r._remoteVideoPlayer.delete(n.userId)),null==e||e.destroy()}))}},{key:"_onUserConnection",value:function(e){var t=this;setTimeout((function(){return t.safeEmit(Fl.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){var t=this,r=e.userInfo;this._getRemotePlayer(r.userId,!0).forEach((function(e){t._remoteScreenAudioPlayer.delete(r.userId),t._remoteScreenPlayer.delete(r.userId),null==e||e.destroy()})),this._getRemotePlayer(r.userId,!1).forEach((function(e){t._remoteAudioPlayer.delete(r.userId),t._remoteVideoPlayer.delete(r.userId),null==e||e.destroy()})),this.safeEmit(Fl.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(Fl.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,Nm(e=[Fl.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._ctx.useCloudProxy&&e.state===pl.CONNECTION_STATE_CONNECTED&&this.safeEmit(Fl.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(Fl.onConnectionStateChanged,e),e.state===pl.CONNECTION_STATE_RECONNECTING){var t,r=oI(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=aI(t.value,2),i=n[0],o=n[1];fA(i).call(i,"mux")&&o.stop()}}catch(a){r.e(a)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ll.AUDIO_AND_VIDEO,n=(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),i=(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e),o=[];return r&ll.AUDIO&&o.push(n),r&ll.VIDEO&&o.push(i),o}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){e.stream&&(this._getRemotePlayer(e.stream.userId,e.stream.isScreen).forEach((function(e){return null==e?void 0:e.stop()})),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){var t=this;if(e.stream){this._updateAudioPlayerState(e.stream);var r=e.stream;this._getRemotePlayer(r.userId,r.isScreen,e.mediaType).forEach((function(n){e.mediaType&ll.AUDIO&&(r.isScreen?t._remoteScreenAudioPlayer.delete(r.userId):t._remoteAudioPlayer.delete(r.userId)),r.isScreen?e.mediaType&ll.VIDEO&&t._remoteScreenPlayer.delete(r.userId):e.mediaType&ll.VIDEO&&t._remoteVideoPlayer.delete(r.userId),null==n||n.destroy()}))}}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(Fl.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(Fl.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&ll.AUDIO&&setTimeout((function(){t._updateAudioPlayerState(a)})),n?o===dz.PUB?this.safeEmit(Fl.onUserPublishScreen,s):this.safeEmit(Fl.onUserUnpublishScreen,el(el({},s),{},{reason:hl.STREAM_REMOVE_REASON_UNPUBLISH})):o===dz.PUB?(s.videoStreamDescriptions=a.attributes.videoDescriptions,this.safeEmit(Fl.onUserPublishStream,s),this._handleAutoSubscribe(a,!0)):this.safeEmit(Fl.onUserUnpublishStream,el(el({},s),{},{reason:hl.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(Fl.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(Fl.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Fl.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Fl.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(Fl.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(Fl.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Fl.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(Fl.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Fl.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Fl.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(Fl.onError,{errorCode:_A.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(Fl.onError,{errorCode:_A.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(Fl.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"waitForNewToken",get:function(){return!!this._tempRoomInfo}},{key:"getSubLock",value:function(e,t){var r,n=e?this._subScreenLocks:this._subLocks,i=n.get(t);i||(i=new sz(Nm(r="sub_".concat(e?1:0,"_")).call(r,t)),n.set(t,i));return i}},{key:"localAudioTrack",get:function(){return this._localAudioTrack}},{key:"localVideoTrack",get:function(){return this._localVideoTrack}},{key:"localScreenAudioTrack",get:function(){return this._localScreenAudioTrack}},{key:"localScreenVideoTrack",get:function(){return this._localScreenVideoTrack}},{key:"remoteStreams",get:function(){var e,t=[];return null!==(e=this._room)&&void 0!==e&&e.remoteStreams&&this._room.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){t.push({userId:e.userId,isScreen:e.isScreen,hasVideo:e.hasVideo,hasAudio:e.hasAudio,videoStreamDescriptions:e.attributes.videoDescriptions})}))})),t}},{key:"iceState",get:function(){var e,t,r;return null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient.handler)||void 0===t||null===(r=t._peerConnection)||void 0===r?void 0:r.iceConnectionState}},{key:"remoteUsers",get:function(){var e,t=[];return null!==(e=this._room)&&void 0!==e&&e.remoteUsers&&this._room.remoteUsers.forEach((function(e){t.push({userId:e.userId})})),t}},{key:"multiChatMode",get:function(){var e;return!(null===(e=this._room)||void 0===e||!e._mediaServerClient.roomAttributes.multiChatMode)}},{key:"checkMediaType",get:function(){return this._checkMediaType}},{key:"assertNotInRoom",get:function(){return this._assertNotInRoom}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(Fl.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==Vz.CONNECTED)throw new SA(_A.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){PN(e,"mediaType",[ll.AUDIO,ll.VIDEO,ll.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e,t;return(null===(e=this._room)||void 0===e||null===(t=e.roomInfo)||void 0===t?void 0:t.userInfo.userId)||"local_user"}},{key:"_switchTrack",value:(t=xm(wm().mark((function e(t){var r,n,i;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,null!==(r=this._videoPlayer)&&void 0!==r&&r.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(t),this._videoPlayer.mirror(!!this._mirrorType)),null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||!i.pubVideo){e.next=6;break}return e.next=6,this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_shouldUpdateAudioConf",value:function(e){var t,r,n,i=(null===(t=this._room)||void 0===t?void 0:t.hasPublished)||(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n?void 0:n.pubAudio)||this._localAudioTrack&&this._localAudioTrack.sourceType===fF.INTERNAL;if(i){var o="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: ".concat(o)),$P(this.id,e,o)}return!i}},{key:"_getServerConfig",value:function(){var e=this,t=vN.getServerConfig(this.appId);t.rts_report&&VP.setConfig(t.rts_report),this._ctx.joinRoomConfig.setServerConfig(t.web_join_room),this._getServerConfigExecutor(t),_M({engineId:this.id,appId:this.appId,sdkVersion:kN("VERSION"),requestDomains:kN("CONFIG_REQUEST_DOMAINS"),keys:["rts_report","web_join_room","web_rtc_config"],deviceId:kN("DEVICE_ID")}).then((function(t){vN.setServerConfig(e.appId,t),e.safeEmit("__onGetServerConfigFinishHook")}))}},{key:"_getServerConfigExecutor",value:function(e){var t,r,n,i;Bw.setParameter("UPLOAD_CONSOLE_ON",!(null==e||null===(t=e.web_rtc_config)||void 0===t||!t.upload_console_on)),Bw.setParameter("UPLOAD_CONSOLE_LENGTH_CUT",null==e||null===(r=e.web_rtc_config)||void 0===r?void 0:r.upload_console_length_cut),Bw.setParameter("UPLOAD_REPORT_LIMIT",null==e||null===(n=e.web_rtc_config)||void 0===n?void 0:n.upload_report_limit),Bw.setParameter("ENABLE_REPORT_IDB_BUFFER",!(null==e||null===(i=e.web_rtc_config)||void 0===i||!i.enable_report_idb_buffer))}}]),Ie}($N);cY([JP()],uY.prototype,"updateToken",1),cY([JP(),pY("video")],uY.prototype,"setVideoCaptureDevice",1),cY([JP(),pY("audio")],uY.prototype,"setAudioCaptureDevice",1),cY([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=qP(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)}}},JP()],uY.prototype,"connect",1),cY([JP()],uY.prototype,"joinRoom",1),cY([JP()],uY.prototype,"leaveRoom",1),cY([JP()],uY.prototype,"destroy",1),cY([JP()],uY.prototype,"publishStream",1),cY([JP()],uY.prototype,"unpublishStream",1),cY([JP()],uY.prototype,"publishScreen",1),cY([JP()],uY.prototype,"unpublishScreen",1),cY([JP()],uY.prototype,"subscribeStream",1),cY([lY],uY.prototype,"_subscribe",1),cY([JP()],uY.prototype,"unsubscribeStream",1),cY([JP()],uY.prototype,"subscribeScreen",1),cY([JP()],uY.prototype,"unsubscribeScreen",1),cY([lY],uY.prototype,"_unsubscribe",1),cY([JP(),hY],uY.prototype,"setRemoteVideoConfig",1),cY([JP(),pY("video")],uY.prototype,"startVideoCapture",1),cY([JP(),pY("video")],uY.prototype,"stopVideoCapture",1),cY([JP(),pY("audio")],uY.prototype,"startAudioCapture",1),cY([JP(),pY("audio")],uY.prototype,"stopAudioCapture",1),cY([JP(),pY("all")],uY.prototype,"startAudioAndVideoCapture",1),cY([JP()],uY.prototype,"startVideoAndAudioCapture",1),cY([JP()],uY.prototype,"getAudioMixingManager",1),cY([JP(),vY],uY.prototype,"startScreenCapture",1),cY([JP(),vY],uY.prototype,"stopScreenCapture",1),cY([JP()],uY.prototype,"setLocalVideoPlayer",1),cY([JP()],uY.prototype,"startLiveTranscoding",1),cY([JP()],uY.prototype,"updateLiveTranscoding",1),cY([JP()],uY.prototype,"stopLiveTranscoding",1),cY([JP()],uY.prototype,"startSubtitle",1),cY([JP()],uY.prototype,"stopSubtitle",1),cY([JP()],uY.prototype,"setBusinessId",1),cY([JP()],uY.prototype,"setUserVisibility",1),cY([JP()],uY.prototype,"setRemoteVideoPlayer",1),cY([JP()],uY.prototype,"setLocalVideoMirrorType",1),cY([JP()],uY.prototype,"setAudioPlaybackDevice",1),cY([JP()],uY.prototype,"play",1),cY([JP()],uY.prototype,"pauseAllSubscribedStream",1),cY([JP()],uY.prototype,"resumeAllSubscribedStream",1),cY([JP()],uY.prototype,"sendUserMessage",1),cY([JP()],uY.prototype,"sendUserBinaryMessage",1),cY([JP()],uY.prototype,"sendRoomMessage",1),cY([JP()],uY.prototype,"sendRoomBinaryMessage",1),cY([JP()],uY.prototype,"setAudioCaptureConfig",1),cY([kD("4.51"),JP()],uY.prototype,"setVideoCaptureConfig",1),cY([JP()],uY.prototype,"enableSimulcastMode",1),cY([JP()],uY.prototype,"setVideoEncoderConfig",1),cY([JP()],uY.prototype,"setScreenEncoderConfig",1),cY([JP()],uY.prototype,"sendSEIMessage",1),cY([kD("4.42"),JP()],uY.prototype,"setAudioVolumeIndicationInterval",1),cY([JP()],uY.prototype,"enableAudioPropertiesReport",1),cY([JP()],uY.prototype,"setVideoSourceType",1),cY([JP()],uY.prototype,"setExternalVideoTrack",1),cY([JP()],uY.prototype,"setAudioSourceType",1),cY([JP()],uY.prototype,"setExternalAudioTrack",1),cY([JP()],uY.prototype,"login",1),cY([JP()],uY.prototype,"logout",1),cY([JP()],uY.prototype,"updateLoginToken",1),cY([JP()],uY.prototype,"getPeerOnlineStatus",1),cY([JP()],uY.prototype,"sendUserMessageOutsideRoom",1),cY([JP()],uY.prototype,"sendUserBinaryMessageOutsideRoom",1),cY([JP()],uY.prototype,"setServerParams",1),cY([JP()],uY.prototype,"sendServerMessage",1),cY([JP()],uY.prototype,"sendServerBinaryMessage",1),cY([JP()],uY.prototype,"startCloudProxy",1),cY([JP()],uY.prototype,"stopCloudProxy",1),cY([JP()],uY.prototype,"startPushPublicStream",1),cY([JP()],uY.prototype,"updatePublicStreamParam",1),cY([JP()],uY.prototype,"stopPushPublicStream",1),cY([JP("streamId")],uY.prototype,"startPlayPublicStream",1),cY([JP("streamId")],uY.prototype,"stopPlayPublicStream",1),cY([JP()],uY.prototype,"setAudioProfile",1),cY([JP()],uY.prototype,"setAudioEncodeMaxBitrate",1),cY([JP()],uY.prototype,"setPublicStreamVideoPlayer",1),cY([JP()],uY.prototype,"setDummyCaptureImagePath",1),cY([JP()],uY.prototype,"registerExtension",1),cY([JP()],uY.prototype,"startAudioPlaybackDeviceTest",1),cY([JP()],uY.prototype,"stopAudioPlaybackDeviceTest",1),cY([JP()],uY.prototype,"startAudioDeviceRecordTest",1),cY([JP()],uY.prototype,"stopAudioDeviceRecordAndPlayTest",1),cY([JP()],uY.prototype,"stopAudioDevicePlayTest",1),cY([JP(),hY],uY.prototype,"setRemoteUserPriority",1),cY([JP()],uY.prototype,"takeLocalSnapshot",1),cY([JP()],uY.prototype,"takeRemoteSnapshot",1),cY([JP()],uY.prototype,"setSubscribeFallbackOption",1),cY([JP()],uY.prototype,"getLocalStreamTrack",1),cY([JP()],uY.prototype,"getRemoteStreamTrack",1),cY([JP()],uY.prototype,"getPublicStreamTrack",1),cY([JP()],uY.prototype,"setRemoteStreamRenderSync",1),cY([JP()],uY.prototype,"startForwardStreamToRooms",1),cY([JP()],uY.prototype,"updateForwardStreamToRooms",1),cY([JP()],uY.prototype,"stopForwardStreamToRooms",1),cY([JP()],uY.prototype,"pauseForwardStreamToAllRooms",1),cY([JP()],uY.prototype,"resumeForwardStreamToAllRooms",1);var dY={"client unpublished":hl.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":hl.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":hl.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":hl.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":hl.STREAM_REMOVE_REASON_REPUBLISH};function lY(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var t,r,i,o,a,s,c,u=arguments;return wm().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 hY(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var t,r,i,o,a,s=arguments;return wm().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 pY(e){return function(t,r,n){var i=n.value;return n.value=xm(wm().mark((function t(){var r,n,o,a,s,c=arguments;return wm().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,$_.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 vY(e,t,r){var n=r.value;return r.value=xm(wm().mark((function e(){var t,r,i,o,a=arguments;return wm().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}function fY(e){var t=vN.getServerConfig(e).web_rtc_config;return null!=t&&t.web_pc_killswitch?null==t?void 0:t.web_pc_killswitch:{}}function _Y(e){var t=vN.getServerConfig(e).web_rtc_config;return"boolean"==typeof(null==t?void 0:t.fallback)?!1!==t.fallback&&(!!Array.isArray(null==t?void 0:t.fallback_ua_reg)&&t.fallback_ua_reg.every((function(e){return"string"==typeof e&&new RegExp(e).test(navigator.userAgent)}))):!!kN("ENABLE_FALLBACK_HANDLER")}function mY(e){var t=vN.getServerConfig(e).web_rtc_config;return"boolean"==typeof(null==t?void 0:t.standard)?!1!==t.standard&&(!!Array.isArray(null==t?void 0:t.standard_ua_reg)&&t.standard_ua_reg.every((function(e){return"string"==typeof e&&new RegExp(e).test(navigator.userAgent)}))):!!kN("ENABLE_STANDARD_HANDLER")}var gY,yY=cd,SY=ic,bY=function(e,t,r,n){for(var i,o=n>1?void 0:n?SY(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&&yY(t,r,o),o},EY=function(e){UI(i,e);var t,r,n=eR(i);function i(e,t,r){var o;return Hl(this,i),Zd(sI(o=n.call(this,e,t,r)),"singleStreamRenderMode",!1),o.id=t,o.logger=new fM("BLWEngine",0,t),RN([{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 jl(i,[{key:"subscribeStream",value:(r=xm(wm().mark((function e(t,r){var n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("subscribeStream()","userId: %o, mediaType: %o",t,r),this.singleStreamRenderMode&&yD(r)&&NI(DI(i.prototype),"subscribeScreen",this).call(this,t,ll.VIDEO).catch((function(e){n.logger.error("singleStreamRenderMode subscribeScreen()",e)})),e.abrupt("return",NI(DI(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=xm(wm().mark((function e(t,r){var n=this;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.logger.print("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this.singleStreamRenderMode&&yD(r)&&NI(DI(i.prototype),"unsubscribeScreen",this).call(this,t,ll.VIDEO).catch((function(e){n.logger.error("singleStreamRenderMode unsubscribeScreen()",e)})),e.abrupt("return",NI(DI(i.prototype),"unsubscribeStream",this).call(this,t,r));case 3:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"setRemoteScreenVideoStreamIndex",value:function(e){var t;return this.logger.print("setRemoteScreenVideoStreamIndex()","streamIndex: %o",e),(null===(t=this._room)||void 0===t?void 0:t.connectionState)!==Vz.CONNECTED&&(this.singleStreamRenderMode=e===dl.STREAM_INDEX_MAIN,!0)}},{key:"setRemoteVideoPlayer",value:function(e,t){if(this.logger.print("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),!this.singleStreamRenderMode||e!==dl.STREAM_INDEX_SCREEN)return NI(DI(i.prototype),"setRemoteVideoPlayer",this).call(this,e,t)}},{key:"destroy",value:function(){this.singleStreamRenderMode=!1,NI(DI(i.prototype),"destroy",this).call(this)}},{key:"_updateVideoPlayerState",value:function(e){var t,r;if(!this.singleStreamRenderMode)return NI(DI(i.prototype),"_updateVideoPlayerState",this).call(this,e);var n,o=e.userId,a=null===(t=this._room)||void 0===t?void 0:t.remoteStreams.get(o);Array.isArray(a)&&a.forEach((function(e){e.isScreen&&(n=e)}));var s=this._remoteVideoPlayer.get(o);if(s){if(!e.isScreen&&null!==(r=n)&&void 0!==r&&r.videoTrack)return this.logger.print("_updateVideoPlayerState","prevent play main stream"),void s.playVideo(n.videoTrack,n);var c;if(e.videoTrack)(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)!==Al.PLAY_MANUALLY&&s.playVideo(e.videoTrack,e);else s.played&&s.stop()}}},{key:"_handleEngineEvents",value:function(){var e=this;this.on(Fl.onUserPublishScreen,(function(t){if(e.singleStreamRenderMode&&yD(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:kE(i).call(i,(function(e){return!e.isScreen})),a=null==i?void 0:kE(i).call(i,(function(e){return e.isScreen}));null!=a&&a.hasSubscribed?(e.logger.info("onUserPublishScreen","singleStreamRenderMode screen hasSubscribed"),e._updateVideoPlayerState(a)):(null!==(n=e._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo||null!=o&&o.hasSubscribed&&yD(o.subMediaType))&&(e.logger.info("onUserPublishScreen","singleStreamRenderMode subscribeScreen"),e.subscribeScreen(t.userId,ll.VIDEO))}})),this.on(Fl.onUserUnpublishScreen,(function(t){if(e.singleStreamRenderMode&&yD(t.mediaType)){var r,n=e._remoteVideoPlayer.get(t.userId),i=null===(r=e._room)||void 0===r?void 0:r.remoteStreams.get(t.userId),o=null==i?void 0:kE(i).call(i,(function(e){return!e.isScreen}));if(null==o||!o.videoTrack||!n)return;n.playVideo(o.videoTrack)}}))}}]),i}(uY);bY([JP()],EY.prototype,"subscribeStream",1),bY([JP()],EY.prototype,"unsubscribeStream",1),bY([JP()],EY.prototype,"setRemoteScreenVideoStreamIndex",1),bY([JP()],EY.prototype,"setRemoteVideoPlayer",1),bY([JP()],EY.prototype,"destroy",1);var kY=new fM("VERTC",0);xw.storeKey=Nm(gY="".concat(Date.now(),"-")).call(gY,vN.getDeviceId()),BP({rtc_sdk_version:bN.VERSION,device_id:vN.getDeviceId(),log_cache_key:xw.storeKey}),jP(bN.LOG_SERVER_URL);var TY=1,IY=function(e,t){kY.info("createEngine","Invoke VERTC.createEngine"),ON(e,"appId");var r=(TY++).toString();return YP(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new uY(e,r,t)},RY=function(e,t){kY.print("createBLWEngine","Invoke VERTC.createBLWEngine"),ON(e,"appId");var r=(TY++).toString();return YP(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new EY(e,r,t)},AY=function(e){if(kY.info("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof uY))throw new SA(_A.INVALID_ENGINE,"Invalid engine object");var t;e.destroy(),(t=e.monitor).report("sdk_init_engine",{start:Date.now(),type:"end"}),WP.delete(t.id)},wY=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",iF.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),CY=function(){var e=xm(wm().mark((function e(){var t,r,n,i,o,a,s=arguments;return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=(t=s.length>0&&void 0!==s[0]?s[0]:{video:!0,audio:!0}).video,n=t.audio,i={video:!1,audio:!1},!r){e.next=14;break}return e.prev=4,e.next=7,iF.getPermissions({video:!0,force:!0});case 7:o=e.sent,i.video=o.video,o.video||(i.videoExceptionError=o.reason),e.next=14;break;case 12:e.prev=12,e.t0=e.catch(4);case 14:if(!n){e.next=25;break}return e.prev=15,e.next=18,iF.getPermissions({audio:!0,force:!0});case 18:a=e.sent,i.audio=a.audio,a.audio||(i.audioExceptionError=a.reason),e.next=25;break;case 23:e.prev=23,e.t1=e.catch(15);case 25:return e.abrupt("return",i);case 26:case"end":return e.stop()}}),e,null,[[4,12],[15,23]])})));return function(){return e.apply(this,arguments)}}(),xY=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",iF.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),OY=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",iF.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),PY=function(){var e=xm(wm().mark((function e(){return wm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",iF.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),MY=function(){return bN.VERSION},DY=function(){return GP("isSupported",0,""),zU()},NY=function(){return GP("getSupportedCodecs",0,""),XU()},LY=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(xw.logLevel=t),r&&(xw.LogfileSize=r)},UY=function(e){xw.download(e)};function VY(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Fm(Km(t).call(t,(function(e){return e instanceof uY?"[ENGINE]":e})))}function FY(e,t){return function(){GP(t,0,VY.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 zP(t,0,VY(e)),e})).catch((function(e){throw zP(t,e.code,e.message),e})):(zP(t,0,VY(r)),r)}}return el(el(el(el({},new(jl((function e(){Hl(this,e),Zd(this,"getSdkVersion",FY(MY,"getSdkVersion")),Zd(this,"createEngine",FY(IY,"createEngine")),Zd(this,"createBLWEngine",FY(RY,"createBLWEngine")),Zd(this,"destroyEngine",FY(AY,"destroyEngine")),Zd(this,"enumerateDevices",FY(wY,"enumerateDevices")),Zd(this,"enableDevices",FY(CY,"enableDevices")),Zd(this,"enumerateAudioCaptureDevices",FY(xY,"enumerateAudioCaptureDevices")),Zd(this,"enumerateVideoCaptureDevices",FY(OY,"enumerateVideoCaptureDevices")),Zd(this,"enumerateAudioPlaybackDevices",FY(PY,"enumerateAudioPlaybackDevices")),Zd(this,"getParameter",kN),Zd(this,"setParameter",EN),Zd(this,"isSupported",FY(DY,"isSupported")),Zd(this,"getSupportedCodecs",FY(NY,"getSupportedCodecs")),Zd(this,"events",Fl),Zd(this,"ErrorCode",_A),Zd(this,"platform","BytePlus"),Zd(this,"commitInfo","release_456<b034e23*>"),Zd(this,"downloadLog",FY(UY,"downloadLog")),Zd(this,"setLogConfig",FY(LY,"setLogConfig"))})))),Dl),Vl),{},{events:Fl})}));